function _hide(e) {
	e.style.display = "none";
}

function _show(e) {
	e.style.display = "";
}
function showDiv(idx){
     
    ct0.style.display ="none";
    ct1.style.display ="none";
    ct2.style.display ="none";
    ct3.style.display ="none";
   	idx.style.display  = ""; 
   		
    return false;
}
function _clearSpace(input_string) {
	var checkvalue = input_string;
	var i;
	var arr_checkvalue = checkvalue.split(" ");
	for(i=1;i<arr_checkvalue.length;i++)
		checkvalue = checkvalue.replace(" ","");
	return(checkvalue);
}

function _isNull(input_string) {
	var checkvalue = _clearSpace(input_string);
    if(checkvalue.length == 0)
    	return true;
	return false;
}

function _isNumber(inputnumber) {
	var checkvalue = inputnumber;
	if(isNaN(checkvalue))
		return false;
	return true;
}

function _isDate(inputdate) {
	var checkvalue = _clearSpace(inputdate);
	//var checkvalue = inputdate;
	if((checkvalue.length>0)&&(checkvalue.length<11)) {
		arrcheckvalue = checkvalue.split("/");
		if(arrcheckvalue.length != 3)
			return false;
		else {
			partdate = arrcheckvalue[0];
			partmonth = arrcheckvalue[1];
			partyear = arrcheckvalue[2];
			if(isNaN(partdate)||isNaN(partmonth)||isNaN(partyear)||(partdate.length>2)||(partdate.length<=0)||(partmonth.length>2)||(partmonth.length<=0)||(partyear.length!=4))
				return false;
			 else
				if((partdate>31)||(partdate<=0)||(partmonth>12)||(partmonth<=0))
					return false;
		}	
	}else
		return false;
	return true;	
}

function acceptDate(selectedDate) {
	var now = new Date();
	var currentYear = now.getFullYear();  
	var currentMonth = now.getMonth()+1;
	var currentDay = now.getDate();										
										
	var arrselectedDate = selectedDate.split("/");
	var selectedDay=arrselectedDate[0];
	var selectedMonth=arrselectedDate[1];
	var selectedYear=arrselectedDate[2];
	//alert(currentDay+"--"+selectedDay);

	if (selectedYear<currentYear) return false;
	if((selectedYear==currentYear)&&(selectedMonth<currentMonth)) return false;
	if((selectedYear==currentYear)&&(selectedMonth==currentMonth)&&(selectedDay<currentDay)) return false;
										
	return true;
}

function _onlyDate()
{
	if (event.keyCode < 47 || event.keyCode >58)
		        event.keyCode=0 ;
}

function _onlyNumber()
{
	if (event.keyCode < 48 || event.keyCode >58)
		        event.keyCode=0 ;
}

function _edititem(e) {
	e.readOnly=false;
	e.focus();
	e.style.borderColor="#C0C0C0";
	e.style.backgroundColor="#FFFFFF";
	e.style.fontWeight="bold";
}

function _updateitem(formname,e) {
	if(event.keyCode==13) {
		event.keyCode=0;
		e.style.borderColor="#E5E6E6";
		e.style.backgroundColor="#E5E6E6";
		e.style.fontWeight="normal";
		e.readOnly=true;
		item_id = e.id;
		item_name = e.value;
		formname.iditem.value=item_id;
		//alert(formname.iditem.value);
		formname.submit();
	}
}

function _openuploadfiles() {
	var uURL = "uploadfile.asp";
	window.open(uURL,"","height=180,width=500,center=yes,status=no,toolbar=no,menubar=no,location=no");
}

function _openaddressbook() {
	var adURL = "addressbook.asp";
	window.open(adURL,"","height=400,width=420,scrollbars=yes,center=yes,status=no,toolbar=yes,menubar=no,location=no");
}

function _openleaderbook() {
	var adURL = "leaderbook.asp";
	window.open(adURL,"","height=400,width=400,center=yes,status=no,toolbar=yes,menubar=no,location=no");
}

function adduploadfiletolist(filename) {
	//alert("called");
	frow = fTable.insertRow(fTable.rows.length);
	frow.id = "files";
	frow.className = "mediumTahoma";
	for(var i=0;i<=2;i++) {
		fcell = frow.insertCell(i);
		switch(i) {
			case 0:
				fcell.innerHTML=(fTable.rows.length-1)+".";
				fcell.className="stt";
				fcell.align = "center";
				break;
			case 1:
				fcell.innerHTML=filename;
				fcell.align = "left";
				break;
			case 2:
				fcell.id="remove";
				fcell.className="menutitle_span";
				fcell.innerHTML="[Remove]";
				fcell.align = "center";
				break;
			}	
		fcell.height = "18";
	}
}

var objfile = "";

function removefilefromlist(filename) {
	var dURL = "aspcode/deletefile.asp?filename="+filename;
	window.open(dURL,"","height=1,width=1,top=1,left=1000");
}

function btnCancel() {
	history.go(-1);
}

function entersubmit(formname) {
	if(event.keyCode==13) {
		event.keyCode=0;
		formname.submit();
	}
}

function _opentaskcorrectinfor(tasktype,id) {
	var sURL = "taskcorrectinfor.asp?tasktype="+tasktype+"&idtask="+id;
	//alert(sURL);
	window.open(sURL,"","height=150,width=400,center=yes,status=no,toolbar=no,menubar=no,location=no");
}

function _thongtincanhan(id) {
	var sURL = "thongtincanhan.asp?idtask="+id;
	//alert(sURL);
	window.open(sURL,"","height=330,width=450,center=yes,status=no,toolbar=no,menubar=no,location=no");
}
function _opendelattachfiles(strfiles) {
	if(strfiles!="") {
		var dURL = "deleteattachfiles.asp?strfiles="+strfiles;
		//alert(dURL);
		window.open(dURL,"","height=1,width=1,top=1000,left=1000");
	}	
}
function _opendeluploadfiles(m_sent,strfiles) {
	//alert(m_sent+","+strfiles);
	if(m_sent!=1)
	if(strfiles!="") {
		var dURL = "deleteuploadfiles.asp?strfiles="+strfiles;
		//alert(dURL);
		window.open(dURL,"","height=1,width=1,top=1000,left=1000");
	}	
}
function _openscheduleinfor(id) {
	var sURL = "lichngay.asp?idschedule=" + id;
	//alert(sURL);
	window.open(sURL,"","height=300,width=616,center=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}

function _openscheduleyouthinfor(id) {
	var sURL = "lichngaydoan.asp?idschedule=" + id;
	//alert(sURL);
	window.open(sURL,"","height=300,width=616,center=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}
function _openscheduledepartmentinfor(id) {
	var sURL = "lichngayphong.asp?idschedule=" + id;
	//alert(sURL);
	window.open(sURL,"","height=300,width=616,center=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}
function _opendanhba() {
	var sURL = "db.asp";
	//alert(sURL);
	window.open(sURL,"","height=300,width=600,center=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
}						
function _openreplypage(page,id) {
	if(id!="") {
		var dURL;
		switch (page) {
			case "mail":
				dURL="compose-mail-reply.asp?id="+id;
				break;
			case "instruct":
				dURL="compose-instruct-reply.asp?id="+id;
				break;
			case "propose":
				dURL="compose-propose-reply.asp?id="+id;
				break;
		}
		//alert(dURL);
		window.location=dURL;
	}	
}

function _openalert(id) {
	var aURL = "alert.asp?id="+id;
	//alert(aURL);
	window.showModalDialog(aURL,"","center:yes; scroll:no; status:no; dialogHeight:170px; dialogWidth:250px;");
}
function valid(form) { 
  
  var field = document.forms(form).Email; 

  var str = field.value; 
  if (window.RegExp) { 
      var reg1str = "(@.*@)|(\ \ .\ \ .)|(@\ \ .)|(\ \ .@)|(^\ \ .)"; 
//    var reg2str = "^.+\ \ @(\ \ [?[a-zA-Z0-9\ \ -\ \ .])+\ \ .([a-zA-Z]{2,3}|[0-9]{1,3})(\ \ ]?)"; 
    var reg2str = "^.+@[a-zA-Z0-9]+.([a-zA-Z]{2,3}|[0-9]{1,3})"; 
    var reg1 = new RegExp(reg1str); 
    var reg2 = new RegExp(reg2str); 
    if (!reg1.test(str) && reg2.test(str)) { 
      return true; 
      
    } 
    return false; 
  } else { 
    if(str.indexOf("@") >= 0)
    return true; 
    return false; 
  } 
}