/**
 * 检查用户名是否可用
 */
function checkUsername(username,divId){
    var haveCheckedUsername=false;    
	if (username.value == "") {		  
		setPromptText("请输入用户名！", true,divId);			
		return false;
	}
	if (username.value.length<3) {	
     
		setPromptText("用户名应大于3字符！", true,divId);		
		return false;
	}
	if (username.value.length>18) {	
		setPromptText("用户名应少于18字符！", true,divId);		
		return false;
	}	
	if((/>|<|,|\[|\]|\{|\}|\?|\/|\+|=|\||\'|\\|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i).test(username.value)){	 
	   setPromptText("填写用户名时请勿使用特殊字符!", true,divId);
	   return false;
	}
	
	var pat = /^[a-zA-Z0-9]+$/;
	if(pat.test(username.value)){
	  return true;
	}else{
	  setPromptText("用户名只能是数字和英文字母组成!", true,divId);
	  return false;
	}
	if(username.value.slice(username.value.length-1)=="_"){	
		setPromptText("填写用户名时下划线不能在最后!", true,divId);
		return false
	}
	haveCheckedUsername=true;
	setElementTextDisabled(divId);
	return true;
}

  function checkRealname(realname,divId){
	    var haveCheckedRealname=false;    
		if (realname.value == "") {		  
			setPromptText("请您认真填写输入真实姓名！", true,divId);			
			return false;
		}
		if(!isAllChinese(realname.value)){
		   	setPromptText("真实姓名必须全是汉字！", true,divId);			
			return false;
		}
		haveCheckedRealname=true;
		setElementTextDisabled(divId);
		return true;
  }
  
   /**
    *验证字符串是否全是汉字
    */
	function isAllChinese(inputStr){
	   iLength=inputStr.length;
	   for(i=0;i<iLength;i++)
		if(inputStr.charCodeAt(i)<256)
			return false;
	    return true;
	}
/**
 * 检查电子邮件是否可用
 */
function isValidEmail(inEmail)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(inEmail)) return true;
	else return false;
}
/**
 * 检查用户密码是否可用
 */
function isValidPassword(inPassword)
{
	var filter = /^([a-zA-Z0-9]{6,20})$/;
	if (filter.test(inPassword)) return true;
	else return false;
}

function checkEmail(EMail,divId)
{
	var email =EMail.value;	
	var haveCheckedEmail=false;
	if (email != "") {
		userFinalEmail = email;
		if (!isValidEmail(email)) {
			setPromptText("您填写的电子邮件地址, 可能不是一个有效的邮件地址，请检查后重新提交。", true,divId);
			haveCheckedEmail = false;
			return false;
		}
		else if (email.length > 100) {
			setPromptText("您输入的电子邮件地址长度超过允许范围，请检查后重新提交。", true,divId);
			haveCheckedEmail = false;
			return false;
		}else {
		   haveCheckedEmail=true;
		   setElementTextDisabled(divId);
		   return true;
		}
	}else{
	     setPromptText("请您填写电子邮件地址！", true,divId);
	     haveCheckedEmail = false;
	     return false;
	}	
}
function checkPassword(Password,divId)
{
	var password = Password.value;
	var haveCheckedPassword=false;	
	if (password != "") {
		userFinalPassword = password;
		if (!isValidPassword(password)) {
			setPromptText("请确认密码符合基本规则：由英文字母(A-Z)，阿拉伯数字组成(0-9)，不能有特殊字符，并且密码长度不能少于6个字符。", true,divId);
			haveCheckedPassword = false;
			return false;
		} else{
		   haveCheckedPassword=true;
		   setElementTextDisabled(divId);
		   return true;		   
		}
	}else{
	     userFinalPassword="";
	     setPromptText("请您认真填写密码！密码必须由英文字母(A-Z)，阿拉伯数字组成(0-9)，并且密码长度不能少于6个字符。", true,divId);
	     haveCheckedPassword = false;
	     return false;
	}
	
}

function checkPassword2(Confirmpwd,Password,divId)
{  
    var password=Password.value;
	var password2 = Confirmpwd.value;
	var haveCheckedConfirmpwd=false;
	if (password2 != "") {
		if (!isValidPassword(password)) return false;
		if (password2 == password) {			
			haveCheckedConfirmpwd = true;
			setElementTextDisabled(divId);
			return true;
		} else {
			setPromptText("您输入两次的密码不同，请再次检查。", true,divId);
			haveCheckedConfirmpwd = false;
			return false;
		}
	}else{
	     setPromptText("请确认您刚填写的密码！", true,divId);
	     haveCheckedConfirmpwd = false;
	     return false;
	}
	
}
function setPromptText(inText,errorFlag,divId)
{
	var msgText =inText;		
	setElementText(divId, msgText);
}


function setElementText(elementId,inText)
{
	document.getElementById(elementId).innerHTML=inText;
	document.getElementById(elementId).style.display="";
}

function setElementTextDisabled(elementId){
    document.getElementById(elementId).style.display="none";
}


function foundSpecialChars(str)
{
	var chars = "!@#$%^&*()+=|\/?<>,.:;'\"`[]{}";
	for (var i=0; i<chars.length; i++)
	{
		if ( str.indexOf(chars.substring(i, i+1)) != -1 )
		{
			return true;
		}
	}
	return false;
}


function isRefuse(name)
{
	var refuseString = '123|111|222|333|444|aaa|ddd|sdf|sss|asd|---|——|……|...|admin|administrator|guest|user|keyword|keyname|系统|游客|会员|用户|关键字|版主|斑竹|管理员|毛泽东|周恩来|邓小平|江泽民|毛主席|周总理';
	if (refuseString.indexOf('|') == -1)
	{
		return false;
	}
	var refuseString = refuseString.split('|');
	for(i=0; i<=refuseString.length; i++)
	{
		if (name.toLowerCase().indexOf(refuseString[i]) != -1)
		{
			return true;
		}
	}
	return false;
}

function isBadWord(name)
{
	var badwords = '妈的|你妈|妈b|妈比|fuck|shit|我日|法轮|我操|我靠|狗屎';
	if (badwords.indexOf('|') != -1)
	{
		return false;
	}
	var badword = badwords.split('|');
	for(i=0; i<=badword.length; i++)
	{
		if (name.toLowerCase().indexOf(badword[i]) != -1)
		{
			return true;
		}
	}
	return false;
}

function displayToggle(chkbox)
{
	if (chkbox.checked)
	{
		document.getElementById('optionInputs').style.display='';
		//document.getElementById('toggletext').innerText='隐藏以下选填内容';
	}
	else
	{
		document.getElementById('optionInputs').style.display='none';
		//document.getElementById('toggletext').innerText='显示更多选填内容';
	}
}

function chkUrl(str)
{
	if (str.search(/^(http|https):\/\/[A-Za-z0-9%\-_@]+\.[A-Za-z0-9%\-_@]{2,}[A-Za-z0-9\.\/=\?%\-&_~`@[\]:+!;]*$/gi) >= 0)
	{
		return true;
	}
	return false;
}

function checkMobilephone(phone,divId)
{ 
	 var len=phone.length;
	 var reg0=/^13\d{5,9}$/;
	 var reg1=/^153\d{4,8}$/;
	 var reg2=/^159\d{4,8}$/;
	 var hascheckphone=false;
	 if (reg0.test(phone)){
	   hascheckphone=true;
	 }
	 if (reg1.test(phone)){
	   hascheckphone=true;
	 }
	 
	 if (reg2.test(phone)){
	   hascheckphone=true;
	 }
	 if (!hascheckphone){	
		setPromptText("请您输入正确的手机号码,以方便我们与您联系!", true,divId);
		return false;
	 }else {
	   return true; 
	 }	

}

/**
 *改变Css
 */
function changeRegStyle(elementID,toStyle,secondID) {
  document.getElementById(elementID).className=toStyle;
  document.getElementById(elementID).style.display='';
  setElementTextDisabled(secondID); 
}

/**
 *改变验证码
 */
 function changeAuthimage(bashpath){        
    location.reload();
 }
 
 function showWindowLoading(divid){   
	    
	    var locdiv=document.getElementById(divid);   
	    locdiv.style.top = document.body.scrollTop + "px";
	    locdiv.style.left = (document.body.offsetWidth - 135 - (document.all?20:0)) + "px";
	    locdiv.style.display = "block";    
 }
 
 function hideLocSelect(itemName){	 
	document.getElementById(itemName).style.display="none";
 }
 
 
  /**
   *显示操作成功信息
   */		
   function showUpdatefinashMsg(desc)
	{
	   var finashmsg=document.getElementById("finshMsg");  
	    if(finashmsg!=null){
		  finashmsg.style.top = document.body.scrollTop+100 + "px";
		  finashmsg.style.left = (document.body.offsetWidth -790 - (document.all?20:0)) + "px";					 
		  var divShim=document.getElementById("DivShim");
		  window.document.all.finshText.innerHTML = desc+"<IMG alt='载入状态' src='../../images/executeok.gif'>";
		  finashmsg.style.display = "block";  
		  divShim.style.top = document.body.scrollTop+100 + "px";
		  divShim.style.left = (document.body.offsetWidth -790 - (document.all?20:0)) + "px";  
		  divShim.style.width = finashmsg.offsetWidth;
		  divShim.style.height = finashmsg.offsetHeight;
		  divShim.style.zIndex = finashmsg.style.zIndex;
		  divShim.style.display = "block";				
	   }
	}
   /**
    *根据不同的错误信息提示错误
    */	 	
   function showUpdateErrorMsg(desc)
   {
	   	 var finashmsg=document.getElementById("finshMsg");  
		 if(finashmsg!=null){
			 finashmsg.style.top = document.body.scrollTop+100 + "px";
			 finashmsg.style.left = (document.body.offsetWidth -790 - (document.all?20:0)) + "px";
		     var divShim=document.getElementById("DivShim");
		     window.document.all.finshText.innerHTML = desc+"<IMG alt='载入状态' src='../../images/executeerror.gif'>";
		     finashmsg.style.display = "block";  
		     divShim.style.top = document.body.scrollTop+100 + "px";
			 divShim.style.left = (document.body.offsetWidth -790 - (document.all?20:0)) + "px";     
			 divShim.style.width = finashmsg.offsetWidth;
			 divShim.style.height = finashmsg.offsetHeight;
			 divShim.style.zIndex = finashmsg.style.zIndex;
			 divShim.style.display = "block";				
		 }  
	         	
   }
  /**
   * 关闭层
   */	
  function closeLayer(){
	   var layer=document.getElementById("finshMsg");
	   if(layer!=null){
	      var divShim=document.getElementById("DivShim");
	      divShim.style.display = "none";
	      layer.style.display="none";
	   
	   }
	}	

 /**
  * 判断CheckBox是否为空!
  */	
 function validSelectedCheckBox(){
 	var finashmsg=document.getElementById("finshMsg");  
	if(finashmsg!=null){
		 finashmsg.style.top = document.body.scrollTop+100 + "px";
		 finashmsg.style.left = (document.body.offsetWidth -790 - (document.all?20:0)) + "px";
	     var divShim=document.getElementById("DivShim");
	     window.document.all.finshText.innerHTML = "请选中您要编辑的选项! <IMG alt='载入状态' src='/images/empty.gif'>";
		 finashmsg.style.display = "block"; 
		 divShim.style.top = document.body.scrollTop+100 + "px";
		 divShim.style.left = (document.body.offsetWidth -790 - (document.all?20:0)) + "px";      
		 divShim.style.width = finashmsg.offsetWidth;
		 divShim.style.height = finashmsg.offsetHeight;
		 divShim.style.zIndex = finashmsg.style.zIndex;
		 divShim.style.display = "block";				
	}
 }	
 
 function mm(){  
   var b = document.getElementById("checkbox");
   var a = document.getElementsByTagName("input");
   if(b.checked==true){
      for (var i=0; i<a.length; i++){
        a[i].checked = true;
      }
   }else{
     for (var i=0; i<a.length; i++){
       a[i].checked = false;
     }
   }
}

 function cc(tt,id){          
	   var  daps    =  document.all.pop.style;     
	   var  ttop    =  tt.offsetTop;          //TT控件的定位点高  
	   var  thei    =  tt.clientHeight;    //TT控件本身的高  
	   var  whei    =  tt.offsetWidth;
	   var  tleft  =  tt.offsetLeft+whei;        //TT控件的定位点宽  
	   var  ttyp    =  tt.type;                   //TT控件的类型  			  	 
	   document.getElementById("viewimage").innerHTML=document.getElementById(id).innerHTML;
	   while  (tt  =  tt.offsetParent){ttop+=tt.offsetTop;  tleft+=tt.offsetLeft;}  
	   daps.top    =  (ttyp=="image")?  ttop+thei  :  ttop+thei+6;  //层的  Y  坐标  
	   daps.left  =  tleft  +  1;    //层的  X  坐标  
	   daps.display  =  "";    //层显示  
 }  
 
 function getResponseJsonMsgsCodeid(responseText) {
  var jsonObj = eval('(' + responseText + ')');
  return jsonObj.codeid;
}

var JsonMsgObj = function(responseText) {
  this.json = eval('(' + responseText + ')');
}

JsonMsgObj.prototype.getCodeid = function() {
  return this.json.codeid;
}

JsonMsgObj.prototype.getMessage = function() {
  return this.json.message;
}

JsonMsgObj.prototype.getText = function() {
  return this.json.text;
}

String.prototype.format = function() {
    var str = this;
    for(var i=0;i<arguments.length;i++) {
        var re = new RegExp('\\{' + (i) + '\\}','gm');
        str = str.replace(re, arguments[i]);
    }
    return str;
}

function selectedcity(url,obj,mobj,sobj){	
   if(obj.value!="" && obj.value!=-1){
        var param="";        
        param=param+"provinceid="+obj.value;          
        ajax_selectedcity=new Ajax(url);
    	ajax_selectedcity.OnReading 
		{	            
		  showWindowLoading('window_loading');
		}
		ajax_selectedcity.OnSucceed
		(	        
		    function(result)
		    {	
		       var city = document.getElementById(mobj);
			   while(city.childNodes.length>0){
				city.removeChild(city.childNodes[0]);
			   }      		       
		       opvalue = result.getElementsByTagName("opvalue");
		       optext = result.getElementsByTagName("optext");	

		     
		         for(var i=0;i<opvalue.length;i++){  
		            var t = new Option();
		            t.value=opvalue[i].firstChild.data;
				    t.appendChild(document.createTextNode(decodeURIComponent(optext[i].firstChild.data)));
				    city.appendChild(t);
		          }			      	
	
		       var area = document.getElementById(sobj);
			   while(area.childNodes.length>0){
				area.removeChild(area.childNodes[0]);
			   }   
			   apvalue = result.getElementsByTagName("apvalue");
		       aptext = result.getElementsByTagName("aptext");	  
		       for(var i=0;i<apvalue.length;i++){  
		            var a = new Option();
		            a.value=apvalue[i].firstChild.data;
				    a.appendChild(document.createTextNode(decodeURIComponent(aptext[i].firstChild.data)));
				    area.appendChild(a);
		          }			       
               hideLocSelect('window_loading');         
			}
		  );	         
	
		 ajax_selectedcity.OnTimeout
		  (
				 function()
			     {
			        hideLocSelect('window_loading');
					alert("网络连接超时！");
					location.reload();
			  	   }
		   );   
		 ajax_selectedcity.invokeServerXml(param,'POST');  
     }

}


function selectedarea(url,obj,sobj){		 
     if(obj.value!="" && obj.value!=-1){
        var param="";
        param=param+"cityid="+obj.value;       
        ajax_selectedarea=new Ajax(url);
    	ajax_selectedarea.OnReading 
		{	            
		  showWindowLoading('window_loading');
		}
		ajax_selectedarea.OnSucceed
		(	        
		    function(result)
		    {		     	      	
		       var area = document.getElementById(sobj);
			   while(area.childNodes.length>0){
				area.removeChild(area.childNodes[0]);
			   }   
			   apvalue = result.getElementsByTagName("apvalue");
		       aptext = result.getElementsByTagName("aptext");	  
		       for(var i=0;i<apvalue.length;i++){  
		            var a = new Option();
		            a.value=apvalue[i].firstChild.data;
				    a.appendChild(document.createTextNode(decodeURIComponent(aptext[i].firstChild.data)));
				    area.appendChild(a);
		          }			       
               hideLocSelect('window_loading');         
			}
		  );	         
	
		 ajax_selectedarea.OnTimeout
		  (
				 function()
			     {
			        hideLocSelect('window_loading');
					alert("网络连接超时！");
					location.reload();
			  	   }
		   );   
		 ajax_selectedarea.invokeServerXml(param,'POST');  
     }
}

 function showDiv(divid){	
	     if(document.getElementById(divid).style.display==""){
	         document.getElementById(divid).style.display="none";
	     }else{
	        document.getElementById(divid).style.display="";
	     }  
	     
  }
 
function cc(tt,id){    
    
   var  daps    =  document.all.pop.style;     
   var  ttop    =  tt.offsetTop;          //TT控件的定位点高  
   var  thei    =  tt.clientHeight;    //TT控件本身的高  
   var  whei    =  tt.offsetWidth;
   var  tleft  =  tt.offsetLeft+whei;        //TT控件的定位点宽  
   var  ttyp    =  tt.type;                   //TT控件的类型  			  	 
   document.getElementById("pcontent").innerHTML=document.getElementById(id).innerHTML;
   while  (tt  =  tt.offsetParent){ttop+=tt.offsetTop;  tleft+=tt.offsetLeft;}  
   daps.top  =  (ttyp=="image")?  ttop+thei  :  ttop+thei+6;  //层的  Y  坐标  
   daps.left  =  tleft  +  1;    //层的  X  坐标  
   daps.display  =  "";    //层显示  
 }  
 
  function showNode(nodeid){	
	     if(document.getElementById("Node"+nodeid).style.display==""){
	         document.getElementById("Node"+nodeid).style.display="none";
	     }else{
	        document.getElementById("Node"+nodeid).style.display="";
	     }  
	     
  }  
  
  function changeStyle(menu,meau){      
		document.getElementById(menu).className='change_a_hover';
//		document.getElementById(meau).className='top_bg2d';
  }
  
  function checkIdcard(idcard){
			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) return Errors[4];
			//身份号码位数及格式检验
			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 Errors[0];
			else return Errors[2];
			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 return false;
			}
			else return false;
			break;
			default:
			return false;
			break;
			}
	
	}
	
	
	/**
	 *验证top.jsp查询信息是否为空	 
	 */
	 
//	function topsearch(){
//	  var main=document.main1;
//	  var city=document.getElementById("city");
//	  var area=document.getElementById("area");
//	  var province=document.getElementById("province");
//	  if(main.hotkey.value=="" && province.value==""
//	     && city.value=="" && area.value==""){
//             alert("请输入查询条件!");
//	     return false;
//	  }
//	  return true;
//	}

function changeUnitspec(obj){
  var unit=obj.value;
  if(unit==3){
     document.getElementById("spec").style.display="";
  }else{
     document.getElementById("spec").style.display="none";
  }
}

function changeStoreUnit(obj){
  var unit=obj.value;
  if(unit==3){
     document.getElementById("storespec").style.display="";
  }else{
     document.getElementById("storespec").style.display="none";
  }
} 
  

//通过控件名字得到object
function MM_findObj_(n, d){
	var p,i,x;

	if(!d)
		d=document;

	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if( !(x=d[n]) && d.all )
		x=d.all[n];

	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];

	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj_(n,d.layers[i].document);

	return x;
}
function setValue(name,value)
{
    object = MM_findObj_(name);
    if(object){
      object.value=value;
    }
}


function getValue(name)
{
    object = MM_findObj_(name);
    if(object){
      return object.value;
    }
}

function changecheck(obj,checkname){
    var unit=obj.value;
    var objs = document.getElementsByName(checkname);
    if(unit==-1){
        for(var i=0;i<objs.length;i++) {
           if(objs[i].value!=-1) objs[i].checked=false;
        }
    }else{
        for(var i=0;i<objs.length;i++) {
           if(objs[i].value==-1) objs[i].checked=false;
        }
    }
}

function changeUnit(obj,unitname,specname){
    var indexId;
    var unitId = document.getElementsByName(unitname);
    for(var i=0;i<unitId.length;i++) {
        if(unitId[i]==obj) {indexId=i;break;}
    }
    var unit=obj.value;

    var specId = document.getElementsByName(specname);
    if(specId.length==null){
        if(unit==3){
           specId.style.display="";
        } else {
           specId.style.display="none";
           specId.options[0].selected=true;
        }
    } else {
        if(unit==3){
           specId[indexId].style.display="";
        } else {
           specId[indexId].style.display="none";
           specId[indexId].options[0].selected=true;
        }
    }
}


var line_num=1;
function addacreage(trId, delName, prefixName)
{
    var newLine = document.getElementById(trId).cloneNode(true);
    newLine.id = prefixName + line_num;
    newLine.style.display = "";
    document.getElementById(trId).parentNode.appendChild(newLine);
    var text = "<span style=\"cursor:hand;\" class=\"pink_txt\" onclick=\"" + delName + "(\'" + prefixName + line_num + "\');\">-删除</span>";
    var delac = document.getElementsByTagName("label");
    if (delac.length != null) {
        delac[delac.length - 1].innerHTML = text;
    } else {
        delac.innerHTML = text;
    }
    line_num++;
}
var line_num1=1;
function addpic(trId, delName, prefixName)
{
    var newLine = document.getElementById(trId).cloneNode(true);
    newLine.id = prefixName + line_num1;
    newLine.style.display = "";
    document.getElementById(trId).parentNode.appendChild(newLine);
    var text = "<span style=\"cursor:hand;\" class=\"pink_txt\" onclick=\"" + delName + "(\'" + prefixName + line_num1 + "\');\">-删除</span>";
    var delac = document.getElementsByTagName("label");
    if (delac.length != null) {
      //  delac[delac.length - 1].innerHTML = text;
    } else {
       // delac.innerHTML = text;
    }
    line_num1++;
}
var line_num2=1;
function addlocation(trId, delName, prefixName)
{
    var newLine = document.getElementById(trId).cloneNode(true);
    newLine.id = prefixName + line_num2;
    newLine.style.display = "";
    document.getElementById(trId).parentNode.appendChild(newLine);
    var text = "<b style=\"cursor:hand;\" class=\"pink_txt\" onclick=\"" + delName + "(\'" + prefixName + line_num2 + "\');\">-删除</b>";
    var delac = document.getElementsByTagName("label");
    if (delac.length != null) {
        delac[delac.length - 1].innerHTML = text;
    } else {
        delac.innerHTML = text;
    }
    line_num2++;
}
function delRow(indexId) {
    document.getElementById(indexId).parentNode.removeChild(document.getElementById(indexId));
	//indexId.parentNode.removeChild(indexId);
}

var line_num2=1;
function addacreage2(trId, delName, prefixName)
{
    var newLine = document.getElementById(trId).cloneNode(true);
    newLine.id = prefixName + line_num2;
    newLine.style.display = "";
    document.getElementById(trId).parentNode.appendChild(newLine);
    var text = "<span style=\"cursor:hand;\" class=\"pink_txt\" onclick=\"" + delName + "(\'" + prefixName + line_num2 + "\');\">-删除</span>";
	var delac2 = document.getElementsByTagName("label");
    if (delac2.length != null) {
        delac2[delac2.length - 1].innerHTML = text;
    } else {
        delac2.innerHTML = text;
    }
    line_num2++;
}

function changeUnit2(obj){
  var unit=obj.value;
  if(unit==3){
     document.getElementById("spectem").style.display="";
  }else{
     document.getElementById("spectem").style.display="none";
  }
}



 function isNumber(oNum)
  {
	if(!oNum) return false;
	var strP=/^\d+(\.\d+)?$/;
	if(!strP.test(oNum)) return false;
	try{
	if(parseFloat(oNum)!=oNum) return false;
	}
	catch(ex)
	{
	  return false;
	}
	return true;
  }
function IsInteger(string ,sign) 
{  
var integer; 
if ((sign!=null) && (sign!='-') && (sign!='+')) 
{ 
alert('IsInter(string,sign)的参数出错：\nsign为null或"-"或"+"'); 
return false; 
} 
integer = parseInt(string); 
if (isNaN(integer)) 
{ 
return false; 
} 
else if (integer.toString().length==string.length) 
{  
if ((sign==null) || (sign=='-' && integer<0) || (sign=='+' && integer>0)) 
{ 
return true; 
} 
else 
return false;  
} 
else 
return false; 
} 



function checkMail(str) 
{ 
var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/; 
if ( ! sReg.test(str) ) 
{ 
	return false; 
} 

return true; 

} 

function filterusername(str)
{
	if (str.length==11 && IsInteger(str))
	{		
	}else{
		if (checkMail(str))
		{
			
		}else{
			if (foundSpecialChars(str))
			{
				return false;
			}
		}
	}
	return true;
}
function getRadioValue(name)
{
    object = MM_findObj_(name);
	if(object==null)
		return "";
	for(var i=0;i<object.length;i++){
		if(object[i].checked)
		 return object[i].value;
	}
	return "";
}

function qqkf() {
    if(confirm("请确认您是否安装QQ？如没有，请选择MSN或SKYPE进行客服通讯！")) {
        window.open('tencent://message/?uin=378414169&Site=www.51cangku.com&Menu=yes','','');
    }
}
function msnkf() {
    if(confirm("请确认您是否安装MSN？如没有，请选择QQ或SKYPE进行客服通讯！")) {
        window.open('msnim:chat?contact=yuanying1227happy@msn.com','','');
    }
}
function skypekf() {
    if(confirm("请确认您是否安装SKYPE？如没有，请选择MSN或QQ进行客服通讯！")) {
        window.open('skype:shinring?call','','');
    }
}




function qqs(qq) {
    if(confirm("请确认您是否安装QQ？如没有，请选择MSN或SKYPE进行客服通讯！")) {
        window.open('tencent://message/?uin='+qq+'&Site=www.51cangku.com&Menu=yes','','');
    }
}
function msns(msn) {
    if(confirm("请确认您是否安装MSN？如没有，请选择QQ或SKYPE进行客服通讯！")) {
        window.open('msnim:chat?contact='+msn,'','');
    }
}
function skypes(skype) {
    if(confirm("请确认您是否安装SKYPE？如没有，请选择MSN或QQ进行客服通讯！")) {
        window.open('skype:'+skype+'?call','','');
    }
}

function getCheckValue11(name)
{
    object = MM_findObj_(name);
	
	if(object==null)
		return false;
	
	if(object.length!=null) {
	for(var i=0;i<object.length;i++){		
		if(object[i].checked){
		 return true;
		}
	}
	}else{		
		if(object.checked){		
		 return true;
		}
	}
	return false;
}

function getCheckValue(name)
{
    object = MM_findObj_(name);
	
	if(object==null)
		return false;
	
	if(object.length!=null) {
	var val="";
	for(var i=0;i<object.length;i++){		
		if(object[i].checked){
		 if (val=="")
		 {
			 val=object[i].value;
		 }else{
			 val=val+","+object[i].value;
		 }

		}
	}
	return val;
	}else{		
		if(object.checked){		
		 return object.value;
		}
	}
	return "";
}

function showModeWindow(url,width,height){
	window.open(url,'',"height="+height+"px,left="+width+"px,scrollbars=yes,resizable=yes");
}

function selectAddOption(obj,index,displname,value){
			var oOption = document.createElement("OPTION");
			obj.options.add(oOption,index);
			oOption.innerText = displname;
			oOption.value = value;

}

function excel() 
 { 

	
  var oXL = new ActiveXObject("Excel.Application"); 
  var oWB = oXL.Workbooks.Add(); 
  var oSheet = oWB.ActiveSheet;  
  var sel=document.body.createTextRange();

  sel.moveToElementText(tablePrint);

  sel.select();
  sel.execCommand("Copy");
  oSheet.Paste();
  oXL.Visible = true;
 }
 


