function systemMsg( msg ){
	alert(msg);
}
function validateNull(value,field,msg){
  		if ( value == "" ){
  			//field.style.cssText = "border: 1px solid red;";
  			field.focus();
  			systemMsg( msg + "不能为空");
  			return false;
  		} else {
  			field.style.cssText = "";
  			return true;
  		}
}
function validateIsNaN(value,field,msg){
  		if ( isNaN(value) ){
  			//field.style.cssText = "border: 1px solid red;";
  			field.focus();
  			systemMsg( msg + "格式错误");
  			return false;
  		} else {
  			field.style.cssText = "";
  			return true;
  		}
}
function validatePlus(value,field,msg){
  		if ( value <= 0 ){
  			//field.style.cssText = "border: 1px solid red;";
  			field.focus();
  			systemMsg( msg + "必须大于0");
  			return false;
  		} else {
  			field.style.cssText = "";
  			return true;
  		}
}
function validateLength(value,field,msg,length){
	 if ( value.length < length  ){
  			//field.style.cssText = "border: 1px solid red;";
  			field.focus();
  			systemMsg( msg + "长度不够");
  			return false;
  		} else {
  			field.style.cssText = "";
  			return true;
  		}
}
function validateEmail(value,field,msg){
				var p_end=value.length-1, p_at=value.indexOf('@'), p_dot=value.lastIndexOf('.');
				if (p_end==-1 || (p_at>0 && p_dot>(p_at+1) && p_dot<p_end)){
					field.style.cssText = "";
					return true
				} else {
					//field.style.cssText = "border: 1px solid red;";
					field.focus();
  					systemMsg( msg + "邮件地址格式错误！");
  					return false;
				}	
	
}
function validateEquals(value1,value2,field1,field2,msg){
	if ( value1 != value2 ){
			field1.style.cssText = "border: 1px solid red;";
			field2.style.cssText = "border: 1px solid red;";
  			field1.focus();
  			systemMsg( msg + "不相同！");
  			return false;
	} else {
			field1.style.cssText = "";
			field2.style.cssText = "";
  			return true;
	}
}
function efocus(event) {
            var elem = Event.element(event);
            elem.style.border = '1 solid #9ecc00';
        }
     function eblur(event) {
            var elem = Event.element(event);
            elem.style.border = '1px solid #cccccc';
        }
/************************************************/
function show_hide( showId,arrowId ){
  			if ( $(showId).style.display == "none" ){
  				Effect.BlindDown( $(showId),{duration:0.25} );
  				$(arrowId).src = approot + "/images/admin/ico_down.gif";
  			} else {
  				Effect.BlindUp( $(showId),{duration:0.25} );
  				$(arrowId).src = approot + "/images/admin/ico_up.gif";
  			}
}        
        
function checkIdcard(idcard){
	if ( idcard == ""){
		return true;
	}
	var Errors=new Array(
	"验证通过!",
	"身份证号码位数不对!",
	"身份证号码出生日期超出范围或含有非法字符!",
	"身份证号码校验错误!",
	"身份证地区非法!"
	);
	var area={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"} 
	
	var idcard,Y,JYM;
	var S,M;
	var idcard_array = new Array();
	idcard_array = idcard.split("");
	/*地区检验*/
	if(area[parseInt(idcard.substr(0,2))]==null) 
	{
	   alert(Errors[4]); 
	   return false;
	}
	
	/*身份号码位数及格式检验*/
	switch(idcard.length){
	   case 15:
	   if ( (parseInt(idcard.substr(6,2))+1900) % 4 == 0 || ((parseInt(idcard.substr(6,2))+1900) % 100 == 0 && (parseInt(idcard.substr(6,2))+1900) % 4 == 0 )){
	    ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//测试出生日期的合法性
	   } else {
	    ereg=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//测试出生日期的合法性
	   }
	   if(ereg.test(idcard)){
	     return true;
	    }
	   else {
	     alert(Errors[2]);
	      return false;
	     }
	   break;
	  
	   case 18:
	   //18位身份号码检测
	   //出生日期的合法性检查 
	   //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
	   //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
	   if ( parseInt(idcard.substr(6,4)) % 4 == 0 || (parseInt(idcard.substr(6,4)) % 100 == 0 && parseInt(idcard.substr(6,4))%4 == 0 )){
	   ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;//闰年出生日期的合法性正则表达式
	   } else {
	   ereg=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;//平年出生日期的合法性正则表达式
	   }
	   if(ereg.test(idcard)){//测试出生日期的合法性
	    //计算校验位
	    S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7
	    + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
	    + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10
	    + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
	    + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8
	    + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
	    + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2
	    + parseInt(idcard_array[7]) * 1 
	    + parseInt(idcard_array[8]) * 6
	    + parseInt(idcard_array[9]) * 3 ;
	    Y = S % 11;
	    M = "F";
	    JYM = "10X98765432";
	    M = JYM.substr(Y,1);/*判断校验位*/
	    if(M == idcard_array[17]){
	     return true; /*检测ID的校验位*/
	    }
	    else {
	     alert(Errors[3]); 
	     return false;
	    }
	   }
	   else {
	    alert(Errors[2]); 
	    return false;
	   }
	   break;
	  
	   default:
	    alert(Errors[1]); 
	    return false;
	}       
} 
function validatemobile(mobile,field)
    {
        if(mobile.length==0)
        {
           //alert('请输入手机号码！');
           //document.form1.mobile.focus();
           return true;
        }    
        if(mobile.length!=11)
        {
            alert('请输入有效的手机号码！');
            field.focus();
            return false;
        }
        
        var myreg = /^(((13[0-9]{1})|159|153)+\d{8})$/;
        if(!myreg.test(mobile))
        {
            alert('请输入有效的手机号码！');
            field.focus();
            return false;
        }
        return true;
    }
 function validateqq(qq,field){
 	if(qq.length==0){
 		return true;
    }
 	var myreq = /^[1-9]\d{4,8}$/;
 	if (!myreq.test(qq)){
 		alert('qq号码输入错误');
 		field.focus();
 		return false;
 	}
 	return true;
 }   
  function clearDate(date){
			date.value = "";
}         