

var errormsg="";
function clearError()//goi ham` nay truoc
{
   errormsg="";
}
function checkEmail(email)
{
   var at1      =  email.indexOf("@");
   var at2      =  email.lastIndexOf("@");
   var dot     =  email.indexOf(".");
   var space   =  email.indexOf(" ");
   if((at1!=-1)&&
      (at1!=0)&&
      (at2==at1)&&
      (dot!=-1)&&
      (dot>at1+1)&&
      (dot<email.length-1)&&
      (space==-1))
   {
      return true;
   }
   else
   {
      errormsg=errormsg+"- Email không tồn tại! Bạn cần điền thông tin đầy đủ \n";
      return false;
   }
}
function checkDate(dd,mm,yyyy,name)
{
   result=true;
   if(!isNaN(mm)&&(mm!="")&&(parseInt(mm)<12)){
   		result=false
   }
   if(!isNaN(dd)&&(dd!="")&&(parseInt(dd)<31)){
   		result=false
   }
   if(!isNaN(yyyy)&&(yyyy!="")&&(yyyy<10000))	
   {
      if( (mm=="02") && ((dd=="30")||(dd=="31")) )
         result=false;
      if( (mm=="02") && (dd=="29") && (yyyy%4>0) )
         result=false;
      if( ((mm=="04")||(mm=="06")||(mm=="09")||(mm=="11")) && (dd=="31") )
         result=false;
   }
   else
   {
      result=false;
   }
   if(result==false)
      errormsg=errormsg+"- "+name+"  Invalid .\n"	
   return result;
}
function checkInterval(dstart,mstart,ystart,names,dend,mend,yend,namee)
{
   var re=true;
   re=checkDate(dstart,mstart,ystart,names)&&checkDate(dend,mend,yend,namee);   
   if(re)
   {
      var yyyy=yend-ystart;
      if(yyyy>0)
	 re=true;
      else if(yyyy==0)
      {
         var mm=mend-mstart;
         if(mm>0)
            re=true;
         else if(mm==0)
         {
            var dd=dend-dstart;
	    if(dd>=0)
	       re=true;
            else
               re=false; 		 
         }
         else
	    re=false; 
      }
      else
         re=false; 	
   }
   if(re==false)
      errormsg=errormsg+"- Time  Invalid .\n";
   
   return re; 
}
function checkTextField(str,name)
{
	if(str=="")
		errormsg=errormsg+"- "+name+"  không tồn tại ! Bạn cần điền thông tin đầy đủ .\n";
}
function checkTextField2(str,name)
{
	if(str=="")
		errormsg=errormsg+"- "+name+" .\n";
}

function checkRadio(val,name)
{
	var legal=false;
	for(var i=0;i<val.length;i++)
	{
		if(val[i].checked==true)
		{
			legal=true;
		}
	}
	if(legal==false)
		errormsg=errormsg+"- "+name+" can phai chon mot.\n";
}
function checkChoice(val,name)
{
	if(val<0)
		errormsg=errormsg+"- "+name+" can phai chon mot .\n"; 
}
function checkChoiceText(val,name)
{
	if(val=="")
		errormsg=errormsg+"- "+name+" can phai chon mot .\n"; 
}
function checkIsNum(val,name)
{
	if((val!="")&&(!isNaN(val)))
		return true;
	else
	{	
		errormsg=errormsg+"- "+name+"  Invalid . \n";
	}

}
function checkAll()
{
	if(errormsg!="")
	{
		alert("Error!     \n\n"+errormsg);
		return false;
	}
	else
		return true;
}
/*-------------------------------------------------------------------------*/

function xmlhttpPost(strURL,resudiv,formm) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,resudiv);
        }
    }
    self.xmlHttpReq.send(getquerystring(formm));
}

//   The following function obtains two variables from your form (email and message) 
//   and builds a string that gets sent to your PHP script.  Change this function to
//   obtain whatever fields you want from your form.

function getquerystring(formm) {
   var form = document.forms[formm];
   var submit_reply = form.submit_reply.value;
   var total_year = form.total_year.value;
   var job_title = form.job_title.value;
   var job_level = form.job_level.value;
   var category = form.category.value;
   var company_name = form.company_name.value;
   var start_month = form.start_month.value;
   var start_year = form.start_year.value;
   var end_month = form.end_month.value;
   var end_year = form.end_year.value;
   var intro = form.intro.value;
   qstr = 'total_year=' + total_year + '&submit_reply=' + submit_reply + '&job_title=' + job_title + '&job_level=' + job_level + '&category=' + category + '&company_name=' + company_name + '&start_month=' + start_month + '&start_year=' + start_year + '&end_month=' + end_month + '&end_year=' + end_year + '&intro=' + intro; 
   return qstr;
}

function xmlhttpPost2(strURL,resudiv,formm) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,resudiv);
        }
    }
    self.xmlHttpReq.send(getquerystring2(formm));
}

//   The following function obtains two variables from your form (email and message) 
//   and builds a string that gets sent to your PHP script.  Change this function to
//   obtain whatever fields you want from your form.

function getquerystring2(formm) {
   var form = document.forms[formm];
   var submit_reply = form.submit_reply.value;
   var degree_level = form.degree_level.value;
   var school_program = form.school_program.value;
   var major = form.major.value;
   var country = form.country.value;
   var start_month = form.start_month.value;
   var start_year = form.start_year.value;
   var end_month = form.end_month.value;
   var end_year = form.end_year.value;
   qstr = 'degree_level=' + degree_level + '&submit_reply=' + submit_reply + '&school_program=' + school_program + '&major=' + major + '&country=' + country + '&start_month=' + start_month + '&start_year=' + start_year + '&end_month=' + end_month + '&end_year=' + end_year; 
   return qstr;
}

function xmlhttpPost3(strURL,resudiv,formm) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,resudiv);
        }
    }
    self.xmlHttpReq.send(getquerystring3(formm));
}

//   The following function obtains two variables from your form (email and message) 
//   and builds a string that gets sent to your PHP script.  Change this function to
//   obtain whatever fields you want from your form.

function getquerystring3(formm) {
   var form = document.forms[formm];
   var submit_reply = form.submit_reply.value;
   var skill_group = form.skill_group.value;
   var skill = form.skill.value;
   var proficiency = form.proficiency.value;
   var year_use = form.year_use.value;
   qstr = 'skill_group=' + skill_group + '&submit_reply=' + submit_reply + '&skill=' + skill + '&proficiency=' + proficiency + '&year_use=' + year_use; 
   return qstr;
}

function xmlhttpPost4(strURL,resudiv,formm) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,resudiv);
        }
    }
    self.xmlHttpReq.send(getquerystring4(formm));
}

//   The following function obtains two variables from your form (email and message) 
//   and builds a string that gets sent to your PHP script.  Change this function to
//   obtain whatever fields you want from your form.

function getquerystring4(formm) {
   var form = document.forms[formm];
   var non_submit_reply = form.non_submit_reply.value;
   var non_skill = form.non_skill.value;
   var non_proficiency = form.non_proficiency.value;
   var non_year_use = form.non_year_use.value;
   qstr = 'non_skill=' + non_skill + '&non_submit_reply=' + non_submit_reply + '&non_proficiency=' + non_proficiency + '&non_year_use=' + non_year_use; 
   return qstr;
}

function xmlhttpPost5(strURL,resudiv,formm) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,resudiv);
        }
    }
    self.xmlHttpReq.send(getquerystring5(formm));
}

//   The following function obtains two variables from your form (email and message) 
//   and builds a string that gets sent to your PHP script.  Change this function to
//   obtain whatever fields you want from your form.

function getquerystring5(formm) {
   var form = document.forms[formm];
   var submit_reply_reference = form.submit_reply_reference.value;
   var name = form.name.value;
   var title = form.title.value;
   var phone = form.phone.value;
   var email = form.email.value;
   var information = form.information.value;
   qstr = 'name=' + name + '&submit_reply_reference=' + submit_reply_reference + '&title=' + title + '&phone=' + phone + '&email=' + email + '&information=' + information; 
   return qstr;
}

function xmlhttpPost6(strURL,resudiv,formm) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,resudiv);
        }
    }
    self.xmlHttpReq.send(getquerystring6(formm));
}

//   The following function obtains two variables from your form (email and message) 
//   and builds a string that gets sent to your PHP script.  Change this function to
//   obtain whatever fields you want from your form.

function getquerystring6(formm) {
   var form = document.forms[formm];
   var submit_reply = form.submit_reply.value;
   var email = form.email.value;
   qstr = 'email=' + email + '&submit_reply=' + submit_reply; 
   return qstr;
}

function updatepage(str,resudiv){
    document.getElementById(resudiv).innerHTML = str;
}


/*-------------------------------------------------------------------------*/

