
function bookmark(){
	if (document.all){//检查浏览器是否为IE，如果是，则执行下面的语句
		window.external.AddFavorite('http://gdzs.em.gov.cn', "中山市劳动力市场");
		//调用AddFavorite() 函数，把网站加入到收藏夹里
	}
}

function chang_load(str){
  URL="member.php?op=load&type="+str;
  loc_y="250";
	window.showModalDialog(URL,self,"edge:raised;scroll:0;status:0;help:0;resizable:1;dialogWidth:380px;dialogHeight:280px;dialogTop:"+loc_y+"px;dialogLeft:280px");
}
function register(){
   var url="";
   var d=document.login;
   switch(d.c_flag.value){
	   case "1":
           url="index.php?op=join&t=person";
	       break;  
       case "2":
           url="index.php?op=join&t=company";
		   break;
	   default:
	       alert("温磬提示: 请选择会员类型!");
		   d.flag[0].focus();
	       break;
   }
	  
   if(url!=""){
		window.location=url;
   }
}

function display_join(t){
   if(t=="1"){  
      join_1.style.display='block';
      join_2.style.display='block';

   }else{
      join_1.style.display='none';
      join_2.style.display='none';
	  window.location="./index.php";
   }
}

function checklogin(){
	
   var d=document.login;
   if(d.c_flag.value==""){
   	   alert("温磬提示: 请选择会员类型!");
	   d.flag[0].focus();
	   return false;
   }else{
	   
	  if(!check_letter(d.account,"用户名","4")){
		  return false;
	  }

	 if(jtrim(d.passwd.value).length<6){
	      alert("提示: 密码长度不能小于6 位!");
		  d.passwd.focus();
		  return false;
	 }
      return true;
   }

}
function logout(){
    if (confirm("确认退出吗?")){
		window.location.href="index.php?op=memberlogout";
	}
}

var reg=false;
function checkreg(){
  if (!reg){
	 d=document.join;
	 if(!check_letter(d.account,"用户名","4")){
		  return false;
	 }
	 if(jtrim(d.password.value)==""){
	      alert(" 密码不能为空!");
		  d.password.focus();
		  return false;
	 }
	 if(jtrim(d.password.value).length<6){
	      alert("提示: 密码长度不能小于6 位!");
		  d.password.focus();
		  return false;
	 }
	 if(d.password.value==d.account.value){
	      alert("提示: 为了提高安全性,密码不能与用户名相同!");
		  d.password.focus();
		  return false;
	 }
	 if(d.password.value!=d.password2.value){
	      alert("提示: 两次输入的密码应该相同!");
		  d.password2.focus();
		  return false;
	 }

	 if(jtrim(d.email.value)==""){
	      alert("提示: 电子邮件地址不能为空!");
		  d.email.focus();
		  return false;
	 }
	 
	 if (!chkemail(d.email.value)) {
		  d.email.focus();
		  return false;
	 }

	 if (d.t.value=="company"){

		if (jtrim(d.name.value)==""){
	      alert("提示: 请填写 企业名称!");
		  d.name.focus();
		  return false;
		}

		if (jtrim(d.linkman.value)==""){
	      alert("提示: 请填写 联系人!");
		  d.linkman.focus();
		  return false;
		}

		if (jtrim(d.telephone.value)==""){
	      alert("提示: 请填写 联系电话!");
		  d.telephone.focus();
		  return false;
		}

	 }
	 if (!confirm("确认所填的信息吗?")){
		 return false;
	 }
	 reg=true;
     d.Submit3.value="提交数据中...";
     d.Submit3.disabled=true;
	 return true;
  }else{
       alert("正在提交中,请稍候!若长时间无反应,请刷新本页面.");
	   return false;
  }
}

//检测用户名是否已经注册
function checkusername(username,t){
	if(check_letter(username,"用户名","4")){
    	getvalue=window.showModalDialog("./index.php?op=checkusername&t="+t+"&account="+username.value,"check","center:yes;help:no;resizable:no;status:no;dialogHeight:5;dialogWidth:15")
	}
}


//动态检测字符是否为数字字母,长度..
function check_letter(name,str,len){
	var i,j,strTemp;
	strTemp="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; 
 
	if(jtrim(name.value) == ""){
		alert("请填写您的"+str+"!");
		name.focus();
		return false;
	}
	if(name.value.length < len){
		alert(str+"必须大于"+len+"而且只能为数字,字母或下划线！");
		name.focus();
		return false;
	}
	for (i=0;i<name.value.length;i++)     { 
		j = strTemp.indexOf(name.value.charAt(i)); 
		if (j==-1){ 
			alert("请输入合法的"+str+"!"); 
			name.focus();  
			return false;     
		}   
	}	
	return true;
}

function jtrim(str){
	while (str.charAt(0)==" ")
          {str=str.substr(1);}      
     while (str.charAt(str.length-1)==" ")
         {str=str.substr(0,str.length-1);}
     return(str);
}



//函数名：chkemail
//功能介绍：检查是否为Email Address
//参数说明：要检查的字符串
//返回值：0：不是  1：是
function chkemail(a)
{
    var i=a.length;
    if(i==0) return 1;

    if ((illegalChar(a)==0))
    {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }

    if (a.charAt(0) == ".") {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }

    var temp = a.indexOf('@');
    if (temp < 1) {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }
    if (a.charAt(temp-1) == ".") {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }
    var substr = a.substring(temp+1);
    if (substr.length < 2) {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }
    if (substr.charAt(0) == ".") {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }
    if (substr.charAt(substr.length-1) == ".") {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }
    if (substr.indexOf(".") == -1) {
        alert ("请填写正确的e-mail地址!");
        return 0;
    }
    return 1;
}
//函数名：illegalChar
//功能介绍：检查是否含有不合法字符
//参数说明：要检查的字符串
//返回值：0：是  1：不是
function illegalChar(str) {
    var legalChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.@-_"; //email地址中的合法字符
    for (var i = 0; i < str.length; i ++) {
        if (legalChars.indexOf(str.charAt(i)) == -1) {
            return 0;
        }
    }
    return 1;
}

function getdate(){
	var todayx=new Date();
	yearx=todayx.getYear();
	monthx=todayx.getMonth()+1;
	dayx=todayx.getDate();

	Hoursx=todayx.getHours();
	Minutesx=todayx.getMinutes();
	Secondsx=todayx.getSeconds();

	datex=Secondsx+""+yearx+""+monthx+""+dayx+""+Hoursx+""+Minutesx;
	return datex;
}

function getFileExtension(filePath) { //v1.0
  fileName = ((filePath.indexOf('/') > -1) ? filePath.substring(filePath.lastIndexOf('/')+1,filePath.length) : filePath.substring(filePath.lastIndexOf('\\')+1,filePath.length));
  new_fileName=fileName.substring(fileName.lastIndexOf('.')+1,fileName.length);
  return new_fileName.toLowerCase();
}

function ask(str,url) {
  if (confirm(str)){
		window.location.href=url;
	}
}


function CA(form){
	for(var i=0;i<form.elements.length;i++){ 
		var e=form.elements[i]; 
		if(e.name!='allbox'&&e.type=="checkbox"){ 
			e.checked=form.allbox.checked; 
		} 
	} 
}

function zp_go(form,t){ 

	var j = 0; 
   	for(var i=0;i<form.elements.length;i++){ 
		var e=form.elements[i]; 
		if((form.elements[i].checked == true)&&e.name!='allbox'&&e.type=="checkbox"){ 
			j = j + 1; 
		} 
	}
	if (j == 0) { 
		alert("请选择最少一个职位！") 
		return false;
	}

    switch(t){
	   case 1:
		    if (confirm("确认[暂停]所选中的职位吗?")){
				form.action="member.php?op=company_zp&t=1";
				form.submit();
		    }
 		   break;
	   case 2:
		    if (confirm("确认[恢复]所选中的职位吗?")){
				form.action="member.php?op=company_zp&t=2";
				form.submit();
		    } 
		   break;
	   case 3:
		    if (confirm("确认更新所选职位的发布日期吗?")){
				form.action="member.php?op=company_zp&t=3";
				form.submit();
		    } 
		   break;
	   case 4:
		    if (confirm("确认[删除]所选中的职位吗?")){
				form.action="member.php?op=company_zp&t=4";
				form.submit();
		    }
 		   break;
	}
}

function openNewWindow(mypage, myname, w, h) { 
	var winl = (screen.width - w) / 2; 
	var wint = (screen.height - h) / 2 -20; 
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,resizable=no,toolbar=no' 
	win = window.open(mypage, myname, winprops) 
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 
}

function centerPopup(mypage, myname, w, h, scroll) { 
	var winl = (screen.width - w) / 2; 
	var wint = (screen.height - h) / 2 -20; 
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,toolbar=no' 
	win = window.open(mypage, myname, winprops) 
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 
}

function chat(fileName,windowName,theWidth,theHeight,par){
	uniqueName = new Date();
	windowName = uniqueName.getTime();
	cc=window.open(fileName,windowName,par+",width="+theWidth+",height="+theHeight)
	cc.focus();
}
function edit_fb(t){
	openNewWindow("member.php?op=company_fb&id="+t,"fb",650,450);
}
function high_search(form){
	if(form.flag[0].checked==true){
	     window.location="index.php?op=search&t=1";
	}else{
	     window.location="index.php?op=search&t=2";
	}
    
}