function checknull(theField,theAlert)
{
	if (theField.value=="" || theField.value=="undefined"){
		alert(theAlert); 
		theField.focus();
		return false;
	}else{
		tmp=theField.value;
		while(tmp.charAt(0)==" ")
			tmp=tmp.substring(1);
		if (tmp==""){
			alert(theAlert);
			theField.focus();
			return false;
		}
	}
	return true;
}

function checkUseridValid(theField,theAlert)
{ 
  var patrn=/^([a-zA-Z0-9]){4,20}$/;
  if (!patrn.exec(theField.value)) {
    alert(theAlert);
	theField.focus();
	return false;
  } else {
    return true;
  }
} 

function checkbox(theField,theAlert){
   if (theField.value){
		if (!theField.checked){
				alert(theAlert); 
			return false;
			}
   }else{
		len=theField.length;
		flag=false;
		for (i=0;i<len;i++)
		{
			if ( theField[i].checked)
				flag=true;
		}
		if (!flag){
			alert(theAlert);
			return false;
		}
   } 
   return true;
 }

function checksize(theField,theNum,theAlert)
{
	if (theField.value.length>=theNum){
		alert(theAlert);
		return false;
	}
	return true;
}

function checkemail(theField,theAlert)
{
	temp=theField.value
	if ((temp == null) || (temp.length == 0)){
	    window.alert(theAlert);	
		theField.focus();
		return false;
	}		
	len = temp.length;
	if(len>0)
	{
	  if (len > 100)
	  {
		window.alert(theAlert);
		theField.focus();
		return false;
	  }
	  pos1 = temp.indexOf("@");
	  pos2 = temp.indexOf(".");
	  pos3 = temp.lastIndexOf("@");
	  pos4 = temp.lastIndexOf(".");
	  if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))
	  {
		window.alert(theAlert);
		theField.focus();
		return false;
	  }
	  else
	  {
		if( (pos1 == pos2 - 1)||(pos1 == pos2 + 1)||( pos1 != pos3 )||( pos4 < pos3 ) )
		{
			window.alert(theAlert);
		    theField.focus();
		    return false;
		}
	  }		
	}
	return true;
}

function checkmultiemail(theField,theAlert)
{
	temp = theField.value.split(";");
	for(i=0;i<temp.length;i++)
	{
	    if ((temp[i] == null) || (temp[i].length == 0)){
			window.alert(theAlert);	
			theField.focus();
			return false;
		}		
		len = temp[i].length;
		if(len>0)
		{
			if (len > 100)
			{
				window.alert(theAlert);
				theField.focus();
				return false;
			}
			pos1 = temp[i].indexOf("@");
			pos2 = temp[i].indexOf(".");
			pos3 = temp[i].lastIndexOf("@");
			pos4 = temp[i].lastIndexOf(".");
			if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))
			{
				window.alert(theAlert);
				theField.focus();
				return false;
			}
			else
			{
				if( (pos1 == pos2 - 1)||(pos1 == pos2 + 1)||( pos1 != pos3 )||( pos4 < pos3 ) )
				{
					window.alert(theAlert);
					theField.focus();
					return false;
				}
			}		
		}
	}
	return true;
}

function load(Object)
{ 
	if (Object.selectedIndex > 0) 
		location = Object.options[Object.selectedIndex].value;
}

function load1(Object)
{ 
	if (Object.selectedIndex >= 0) 
		location = Object.options[Object.selectedIndex].value;
}

function showPic()
{
 	return window.showModalDialog("../uploadfile/selectfile.php");
}

function OpenUpload(theField)
{
	if(showPic) {
		var str=null;
		str=showPic();
		if (str!=null)	
			theField.value=str;
	}	
	else
		alert("该功能在此处无效！")
}

function OpenIndex(theIndex){
	if(showIndex) {
		var str=null;
		var strindex=null;
		str=showIndex();
		if (str!=null){
			strindex=str;			
			theIndex.value=strindex;
		}
	}	
	else
		alert("该功能在此处无效！")
}

function CheckEmployerUserName()
{
	var user_id = document.create_account.user_id.value;
	if (!checknull(document.create_account.user_id,"Please fill Username")) {
      return false;
    }
    if (document.create_account.user_id.value.length < 4 || document.create_account.user_id.value.length > 20) {
      window.alert("Content of field User Name is too short, should be between 4 and 20 characters.");
	  return false;
    }
	if (!checkUseridValid(document.create_account.user_id,"Letters and/or numbers only and Please do not include spaces in your username.")) {
      return false;
    }
	return window.showModalDialog("checkusername.php?user_id="+user_id,"","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
}

function CheckEmployerEmail()
{
	var unit_email = document.create_account.unit_email.value;
	if (!checkemail(document.create_account.unit_email,"Please check the Email Address given. It is an invalid one.")) {
      return false;
    }
	return window.showModalDialog("checkemail.php?user_email="+unit_email,"","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
}

function CheckEmployeeUserName()
{
	var user_id = document.create_account.user_id.value;
	if (!checknull(document.create_account.user_id,"Please fill Username")) {
      return false;
    }
    if (document.create_account.user_id.value.length < 4 || document.create_account.user_id.value.length > 20) {
      window.alert("Content of field User Name is too short, should be between 4 and 20 characters.");
	  return false;
    }
	if (!checkUseridValid(document.create_account.user_id,"Letters and/or numbers only and Please do not include spaces in your username.")) {
      return false;
    }
	return window.showModalDialog("checkusername.php?user_id="+user_id,"","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
}

function CheckEmployeeEmail()
{
	var person_email = document.create_account.person_email.value;
	if (!checkemail(document.create_account.person_email,"Please check the Email Address given. It is an invalid one.")) {
      return false;
    }
	return window.showModalDialog("checkemail.php?user_email="+person_email,"","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
}

function showCity()
{
	return window.showModalDialog("selectprov.php","","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
	//return window.open("selectprov.php","","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
}

function OpenCities(theProv,theProvId,theCity,theCityId){
	if(showCity) {
		var str=null;
		var strprov=null;
		var strcity=null;
		var strprovarr=null;
		var strprovname=null;
		var strprovid=null;
		var strcityname=null;
		var strcityename=null;
		var strcityid=null;
		str=showCity();
		if (str!=null){
			strprov=str.substring(0,str.indexOf("|"));
			strcity=str.substring(str.indexOf("|")+1,str.lastIndexOf("|"));

            strprovarr = strprov.split("&");

            strprovname=strprovarr[0];
            strprovid=strprovarr[1];
            strprovename=strprovarr[2];
			//strprovname=strprov.substring(0,strprov.indexOf("&"));
			//strprovid=strprov.substring(strprov.indexOf("&")+1,strprov.lastIndexOf("&"));

			strcityname=strcity.substring(0,strcity.indexOf("&"));
			strcityid=strcity.substring(strcity.indexOf("&")+1,strcity.lastIndexOf("&"));


			theProv.value=strprovename;
			theProvId.value=strprovid;
			theCity.value=strcityname;
			theCityId.value=strcityid;
		}
	}	
	else
		alert("该功能在此处无效！")
}

function showPos()
{
	return window.showModalDialog("selectjob.php","","status:no;resizable:no;dialogHeight:180px;dialogWidth:500px;unadorne:yes");
}

function OpenJobs(theJob,theJobId,thePos,thePosId){
	if(showPos) {
		var str=null;
		var strJob=null;
		var strPos=null;
		var strJobname=null;
		var strJobid=null;
		var strPosname=null;
		var strPosid=null;
		str=showPos();
		if (str!=null){
			strJob=str.substring(0,str.indexOf("|"));
			strPos=str.substring(str.indexOf("|")+1,str.lastIndexOf("|"));
			strJobname=strJob.substring(0,strJob.indexOf("&"));
			strJobid=strJob.substring(strJob.indexOf("&")+1,strJob.lastIndexOf("&"));
			strPosname=strPos.substring(0,strPos.indexOf("&"));
			strPosid=strPos.substring(strPos.indexOf("&")+1,strPos.lastIndexOf("&"));		
			theJob.value=strJobname;
			theJobId.value=strJobid;
			thePos.value=strPosname;
			thePosId.value=strPosid;
		}
	}	
	else
		alert("该功能在此处无效！")
}

function checkdel(theField)
{
	if (!checkvalue(theField))
		return false;
    if (confirm("删除记录可能造成不确定后果，确认删除吗？"))
		return true;
		else
		return false;
}

function checkoperate(theField)
{
	if (!checkvalue(theField))
		return false;
    if (confirm("确认操作吗？"))
		return true;
		else
		return false;
}

function checkvalue(theField)
{
   if (theField.value){
		if (!theField.checked){
				alert("请选择记录！"); 
			return false;
			}
   }else{
		len=theField.length;
		flag=false;
		for (i=0;i<len;i++)
		{
			if ( theField[i].checked)
				flag=true;
		}
		if (!flag){
			alert("请选择记录！");
			return false;
		}
   } 
   return true;
 }

function cfmdel()
{
    if (confirm("删除记录可能造成不确定后果，确认删除吗？"))
		return true;
		else
		return false;
}

function cfmupdate()
{
    if (confirm("更新已选中的职位吗？"))
		return true;
		else
		return false;
}

function cfmupdate1()
{
    if (confirm("更新搜索到的所有职位吗？"))
		return true;
		else
		return false;
}

function cfmclick(theAlert)
{
    if (confirm(theAlert))
		return true;
		else
		return false;
}

function cfmreset()
{
    if (confirm("确认清空表单吗？"))
		return true;
		else
		return false;
}

function openWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}

function IsPositiveInt(value) {
  if (/^[1-9]\d*$/.test(value)) return true
  else return false;
}

function swap_status() {
  if (document.swap_form.elements['swap'].checked == true) {
    for(i = 0; i < document.swap_form.elements('selid[]').length; i++) {
      document.swap_form.elements['selid[]'][i].checked = true;
    }
  } else {
    for(i = 0; i < document.swap_form.elements('selid[]').length; i++) {
      document.swap_form.elements['selid[]'][i].checked = false;
    }
  }
}

function check_swap_form()	{
  if (!check_swap_value()) return false;
  return cfmupdate();
}

function check_swap_value() {
  temp = document.swap_form.elements['selid[]'];
  if (temp.value) {
    if (!temp.checked) {
      window.alert("至少选择一条记录！"); 
      return false;
    }
  } else {
    len  = temp.length;
    flag = false;
    for (i = 0; i < len; i++) {
      if (temp[i].checked) flag = true;
    }
	if (!flag) {
      window.alert("至少选择一条记录！");
      return false;
    }
  } 
  return true;
}

function emailResume() {
	//return window.showModalDialog("emailresume.php","","top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=450");
	return window.open("emailresume.php","","top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=450");
}

function showPollResult() {
	return window.open("pollresult.php","","top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=450");
}

function change_faq_catalog(para) {
	if (para == "") return false;
	else location.href = "http://www.foreignhr.com/faq/list.php?news_cata2="+para;
}
	
function change_education_catalog(para) {
	if (para == "") return false;
	else location.href = "http://www.foreignhr.com/education/list.php?news_cata2="+para;
}

/*function showBeijingJobs() {
  beijingjobs.style.display="";
  shanghaijobs.style.display="none";
  guangdongjobs.style.display="none";
  beijingimage.src="/images/home_bjjobs_01.jpg";
  shanghaiimage.src="/images/home_shjobs_01.jpg";
  guangdongimage.src="/images/home_gdjobs_01.jpg";
}

function showShanghaiJobs() {
  beijingjobs.style.display="none";
  shanghaijobs.style.display="";
  guangdongjobs.style.display="none";
  beijingimage.src="/images/home_bjjobs_02.jpg";
  shanghaiimage.src="/images/home_shjobs_02.jpg";
  guangdongimage.src="/images/home_gdjobs_01.jpg";
}

function showGuangdongJobs() {
  beijingjobs.style.display="none";
  shanghaijobs.style.display="none";
  guangdongjobs.style.display="";
  beijingimage.src="/images/home_bjjobs_02.jpg";
  shanghaiimage.src="/images/home_shjobs_01.jpg";
  guangdongimage.src="/images/home_gdjobs_02.jpg";
}*/

// Flash table Extension for Dreamwever ,by dio(diopex@sina.com)
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta) {
  if (!document.all)
  return
  if (object != "[object]") {  //do this so I can take a string too
    setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
    return;
  }
  clearTimeout(nereidFadeTimers[object.sourceIndex]);
  diff = destOp-object.filters.alpha.opacity;
  direction = 1;
  if (object.filters.alpha.opacity > destOp) {
    direction = -1;
  }
  delta = Math.min(direction*diff,delta);
  object.filters.alpha.opacity+=direction*delta;
  if (object.filters.alpha.opacity != destOp) {
    nereidFadeObjects[object.sourceIndex]=object;
	nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
  }
}

function showBeijingJobs() {
  beijingjobs.style.display="";
  shanghaijobs.style.display="none";
  guangdongjobs.style.display="none";
  otherjobs.style.display="none";
  nereidFade(beijingjobslabel,100,10,5);
  nereidFade(shanghaijobslabel,50,10,5);
  nereidFade(guangdongjobslabel,50,10,5);
  nereidFade(otherjobslabel,50,10,5);
}

function showShanghaiJobs() {
  beijingjobs.style.display="none";
  shanghaijobs.style.display="";
  guangdongjobs.style.display="none";
  otherjobs.style.display="none";
  nereidFade(beijingjobslabel,50,10,5);
  nereidFade(shanghaijobslabel,100,10,5);
  nereidFade(guangdongjobslabel,50,10,5);
  nereidFade(otherjobslabel,50,10,5);
}

function showGuangdongJobs() {
  beijingjobs.style.display="none";
  shanghaijobs.style.display="none";
  guangdongjobs.style.display="";
  otherjobs.style.display="none";
  nereidFade(beijingjobslabel,50,10,5);
  nereidFade(shanghaijobslabel,50,10,5);
  nereidFade(guangdongjobslabel,100,10,5);
  nereidFade(otherjobslabel,50,10,5);
}

function showOtherJobs() {
  beijingjobs.style.display="none";
  shanghaijobs.style.display="none";
  guangdongjobs.style.display="none";
  otherjobs.style.display="";
  nereidFade(beijingjobslabel,50,10,5);
  nereidFade(shanghaijobslabel,50,10,5);
  nereidFade(guangdongjobslabel,50,10,5);
  nereidFade(otherjobslabel,100,10,5);
}

function showEducationJobs() {
  educationjobs.style.display="";
  professionaljobs.style.display="none";
  highsalaryjobs.style.display="none";
  alljobs.style.display="none";
  nereidFade(educationjobslabel,100,10,5);
  nereidFade(professionaljobslabel,50,10,5);
  nereidFade(highsalaryjobslabel,50,10,5);
  nereidFade(alljobslabel,50,10,5);
}

function showProfessionalJobs() {
  educationjobs.style.display="none";
  professionaljobs.style.display="";
  highsalaryjobs.style.display="none";
  alljobs.style.display="none";
  nereidFade(educationjobslabel,50,10,5);
  nereidFade(professionaljobslabel,100,10,5);
  nereidFade(highsalaryjobslabel,50,10,5);
  nereidFade(alljobslabel,50,10,5);
}

function showHighSalaryJobs() {
  highsalaryjobs.style.display="";
  educationjobs.style.display="none";
  professionaljobs.style.display="none";
  alljobs.style.display="none";
  nereidFade(educationjobslabel,50,10,5);
  nereidFade(professionaljobslabel,50,10,5);
  nereidFade(highsalaryjobslabel,100,10,5);
  nereidFade(alljobslabel,50,10,5);
}

function showAllJobs() {
  highsalaryjobs.style.display="none";
  educationjobs.style.display="none";
  professionaljobs.style.display="none";
  alljobs.style.display="";
  nereidFade(highsalaryjobslabel,50,10,5);
  nereidFade(educationjobslabel,50,10,5);
  nereidFade(professionaljobslabel,50,10,5);
  nereidFade(alljobslabel,100,10,5);
}

/*function showNewJobs1() {
  beijingjobs.style.display="none";
  shanghaijobs.style.display="none";
  newjobs1.style.display="";
  newjobs2.style.display="none";
  nereidFade(beijingjobslabel,50,10,5);
  nereidFade(shanghaijobslabel,50,10,5);
  nereidFade(newjobslabel1,100,10,5);
  nereidFade(newjobslabel2,50,10,5);
}

function showNewJobs2() {
  beijingjobs.style.display="none";
  shanghaijobs.style.display="none";
  newjobs1.style.display="none";
  newjobs2.style.display="";
  nereidFade(beijingjobslabel,50,10,5);
  nereidFade(shanghaijobslabel,50,10,5);
  nereidFade(newjobslabel1,50,10,5);
  nereidFade(newjobslabel2,100,10,5);
}*/

function ContentSize(size,lineheight)
{
    var obj=document.all.BodyLabel;
    document.getElementById("Content").style.fontSize = size + "px";
    document.getElementById("Content").style.lineHeight = lineheight + "px";
}