
function killerr()
{
return true;
}
window.onerror = killerr;
var oPopup = window.createPopup();    
var popTop=50; 
var ifShowNext=true;
function newXMLHttpRequest() {
var http_request = false;
　//开始初始化XMLHttpRequest对象
		if(window.XMLHttpRequest) { //Mozilla 浏览器
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {//设置MiME类别
				http_request.overrideMimeType('text/xml');
			}
		}
		else if (window.ActiveXObject) { // IE浏览器
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) { // 异常，创建对象实例失败
			window.alert("不能创建XMLHttpRequest对象实例.");
			return false;
		}
　return http_request;
}

function send_reqssss(url,obj)
{　

        var http_request = newXMLHttpRequest();
       //http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		//loadingdStr(obj);
		http_request.onreadystatechange = processRequest;		
		http_request.open("GET", url, true);
		http_request.send(null);		
		
// 处理返回信息的函数
    function processRequest() {
        if (http_request.readyState == 4) { // 判断对象状态		
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息  
		       document.getElementById(obj).innerHTML=http_request.responseText;  
            } else { //页面不正常
                alert("您所请求的页面有异常。");
            } 
		}
    }

}


function send_load(url,obj)
{　
        var http_request = newXMLHttpRequest();
       //http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		loads(obj);
		http_request.onreadystatechange = processRequest;		
		http_request.open("GET", url, true);
		http_request.send(null);		
		
// 处理返回信息的函数
    function processRequest() {
        if (http_request.readyState == 4) { // 判断对象状态		
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息 
		       document.getElementById(obj).innerHTML=http_request.responseText;
            } else { //页面不正常
                alert("您所请求的页面有异常。");
            } 
		}
    }

}
//新增，隐藏图片
function send_url2(url,obj,func,p_id)
{　		

        var http_request = newXMLHttpRequest();
       //http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	
	   var ifhide;
       if(obj.checked){ifhide=true;url+='1';}else {ifhide=false;url+='0';}

		http_request.onreadystatechange = processRequest2;

		http_request.open("GET", url, true);
		http_request.send(null);		

// 处理返回信息的函数
    function processRequest2() {

        if (http_request.readyState == 4) { // 判断对象状态
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息 
			   var r=http_request.responseText;
			   if(r){
				   if(func=='hidden_p'){
					   hidden_p(ifhide,p_id);
				   }
			   }
            } else { //页面不正常
                alert("您所请求的页面有异常。");
            } 
		}
    }

}



function send_url(url,obj)
{　

        var http_request = newXMLHttpRequest();
       //http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		loadingdStr(obj);
		http_request.onreadystatechange = processRequest;		
		http_request.open("GET", url, true);
		http_request.send(null);		
		
// 处理返回信息的函数
    function processRequest() {
        if (http_request.readyState == 4) { // 判断对象状态
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息 
	
		       document.getElementById(obj).innerHTML=http_request.responseText;
            } else { //页面不正常
                alert("您所请求的页面有异常。");
            } 
		}
    }

}


function chkpassword(ms,ojb){
 if (ms.length>18 || ms.length<6 || !ifstrE(ms)){
 document.getElementById(ojb).innerHTML="<font color='red'>密码格式错误</font>";
 }else{
 document.getElementById(ojb).innerHTML="";
 }
}

function VerifyData(form)
	{
		var valid = 1;		
			
		document.getElementById("nick_name_error").innerHTML="";
		document.getElementById("real_name_error").innerHTML="";
		document.getElementById("password_error").innerHTML="";
		document.getElementById("surePassword_error").innerHTML="";		
		document.getElementById("email_error").innerHTML="";		
		document.getElementById("country_error").innerHTML="";		
		document.getElementById("Birthdate_error").innerHTML="";		
		document.getElementById("occupation_error").innerHTML="";		
		
		if (form.nick_name.value.length <2)
		{
			document.getElementById("nick_name_error").innerHTML="<font color='red'>请输入正确的昵称</font>";
			form.nick_name.focus();
			valid = 0;
		}
		
       if (form.real_name.value.length <2)
		{
			document.getElementById("real_name_error").innerHTML="<font color='red'>请输入正确的真实姓名</font>";
			form.real_name.focus();
			valid = 0;
		}
		
		if (form.password.value.length <6 || form.password.value.length >18)
		{
			document.getElementById("password_error").innerHTML="<font color='red'>密码必须6-18位</font>";
			form.password.focus();
			valid = 0;
		}else{
			if (!ifstrE(form.password.value))
			{
			document.getElementById("password_error").innerHTML="<font color='red'>密码只能为数字或英文</font>"
			form.password.focus();
			valid = 0;
		  }
		}

		if (form.surePassword.value!=form.password.value)
		{
			document.getElementById("surePassword_error").innerHTML="<font color='red'>两次输入的密码不同</font>";
			form.surePassword.focus();
			valid = 0;
		}		

		if (form.country.value=="" || form.province.value=="" || form.city.value=="")
		{
			document.getElementById("country_error").innerHTML="<font color='red'>出生地不能为空</font>";
			form.surePassword.focus();
			valid = 0;
		}		

				
		if (checkbd(form.year.value,form.month.value,form.day.value)==false){
			document.getElementById("Birthdate_error").innerHTML="<font color='red'>请输入正确的生日,必须年满18岁以上</font>";	
			valid = 0;
			}
			
		if (checkEmail(form.email.value)==false){
			document.getElementById("email_error").innerHTML="<font color='red'>请输入正确的邮件地址</font>";
			form.email.focus();			
			valid = 0;
			}
		
			
		if (form.occupation.value=='0'){
			document.getElementById("occupation_error").innerHTML="<font color='red'>请选择职业</font>";
			valid = 0;
			}
		
		if (valid==0)
			return false;	
	}
	
//检测字符串为空
function check_null(string) 
{ 
   var i=string.length;
var j = 0; 
var k = 0; 
var flag = true;
while (k<i)
{ 
if (string.charAt(k)!= " ") 
j = j+1; 
k = k+1; 
} 
if (j==0) 
{ 
flag = false;
} 
return flag; 
}

//判断数字	
function is_number(str){
  exp=/[^0-9]/g;
  if(str.search(exp)!=-1){
    return false;
  }else{
    return true;
  }
}
  //判断无效字符	
function ifstr(str){
  exp=/[^\u4E00-\u9FA5a-zA-Z]/g;
  if(str.search(exp)!=-1){
    return false;
  }else{
    return true;
  }
} 


  //判断无效字符，只能出现数字或字母
function ifstrE(str){
  var re=/^[0-9a-z][\w-.]*[0-9a-z]$/i;
	if(re.test(str))
		return true;
	else
		return false;
} 

  //判断无效字符，只能出现汉字或字母
function Enstr(str){
  var re=/[^\u4E00-\u9FA5a-zA-Z]/g;
	if(re.test(str))
		return true;
	else
		return false;
} 


function checkbd(byear,bmon,bday){		
           var Digital=new Date();
		   var yes=Digital.getFullYear();
			if (byear==""||bmon==""||bday==""
				||byear <=0 || bday<=0
			){
				return false;
			}
			switch(bmon){
				case '1':
				case '3':	
				case '5':	
				case '7':	
				case '8':	
				case '10':	
				case '12':	
					if (bday>31){
						return false;
					}
					break;
				case '4':	
				case '6':	
				case '9':	
				case '11':	
					if (bday>30){
						return false;
					}
					break;
				case '2':
					var mday=28;
					var yy = Math.floor(byear/4);
					if (yy*4 == byear){
						mday=29
						if (Math.floor(byear/100)*100 == byear){
							mday = 28;
						}
						if (Math.floor(byear/400)*400 == byear){
							mday = 29;
						}
					}
					if (bday>mday){
						return false;
					}
			}
			if (yes-byear<18 || yes-byear>70){
			return false;
			}
			return true;
		}

function checkEmail(emailStr) {  
			   if (emailStr.length == 0) {                  
                   return false;
               }   
               var emailPat=/^(.+)@(.+)$/;
               var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
               var validChars="\[^\\s" + specialChars + "\]";
               var quotedUser="(\"[^\"]*\")";
               var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
               var atom=validChars + '+';
               var word="(" + atom + "|" + quotedUser + ")";
               var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
               var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
               var matchArray=emailStr.match(emailPat);
               if (matchArray == null) {                   
                   return false;
               }
               var user=matchArray[1];
               var domain=matchArray[2];
               if (user.match(userPat) == null) {                  
                  return false;
               }
               var IPArray = domain.match(ipDomainPat);
               if (IPArray != null) {
                   for (var i = 1; i <= 4; i++) {
                      if (IPArray[i] > 255) {                        
                         return false;
                      }
                   }
                   return true;
               }
               var domainArray=domain.match(domainPat);
               if (domainArray == null) {
                     return false;
               }
               var atomPat=new RegExp(atom,"g");
               var domArr=domain.match(atomPat);
               var len=domArr.length;
               if ((domArr[domArr.length-1].length < 2) ||
                   (domArr[domArr.length-1].length > 3)) {                  
                   return false;
               }
               if (len < 2) {                  
                  return false;
               }
               return true;
            }


function loadingdStr(obj){
document.getElementById(obj).innerHTML="<center><img src='/js/indicator.gif' width='16' height='16'></center>";
} 

function loads(obj){
document.getElementById(obj).innerHTML="<table width='274' height='51'  border='0' align='center' cellpadding='0' cellspacing='0'><tr><td align='center' bgcolor='#999999'><table width='100%'  border='0' cellspacing='1' cellpadding='1'><tr><td height='51' align='center' bgcolor='#FFFFFF'><img src='/js/progressbar_microsoft.gif' width='100' height='9'></td></tr></table></td></tr></table>";
} 

function GetResult(str,classid)
{
/*
*--------------- GetResult(str,classid) -----------------
* GetResult(str) 
* 功能:通过XMLHTTP发送请求,返回结果.
* 参数:str,字符串,发送条件;classid,数字,菜单级别
* 实例:GetResult(document.all.userid.value,1);
*--------------- GetResult(str,classid) -----------------
*/
//定义菜单级数，菜单ID数组，菜单对应字段数组




if (window.XMLHttpRequest) { // Mozilla, Safari, ...
    http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
}


var linkurl="/inc/city.php?classid="+classid+"&sel="+str;
http_request.open("GET",linkurl,false);
http_request.send(null);

//服务器端处理返回的是经过escape编码的字符串.
//在页面显示服务器查询结果

var returntxt=unescape(http_request.responseText)

var kkk
for(kkk=classid+2;kkk<=MenuClass;kkk++)
	{	

	submenu=document.getElementById(MenuIdArr[kkk]);
	//submenu.options[0].selected=true;
	submenu.options.length=0;
	submenu.options.add(new Option("select","")); 
	}


BuildSel(returntxt,document.getElementById(MenuIdArr[classid+1]))

//============更改下下级以下菜单为空==============

}
function GetResult1(str,classid)
{
/*
*--------------- GetResult(str,classid) -----------------
* GetResult(str) 
* 功能:通过XMLHTTP发送请求,返回结果.
* 参数:str,字符串,发送条件;classid,数字,菜单级别
* 实例:GetResult(document.all.userid.value,1);
*--------------- GetResult(str,classid) -----------------
*/
//定义菜单级数，菜单ID数组，菜单对应字段数组




if (window.XMLHttpRequest) { // Mozilla, Safari, ...
    http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
}


var linkurl="/inc/city.php?classid="+classid+"&sel="+str;
http_request.open("GET",linkurl,false);
http_request.send(null);

//服务器端处理返回的是经过escape编码的字符串.
//在页面显示服务器查询结果

var returntxt=unescape(http_request.responseText)

var kkk
for(kkk=classid+2;kkk<=MenuClass;kkk++)
	{		
	submenu=document.getElementById(MenuIdArr1[kkk]);
	//submenu.options[0].selected=true;
	submenu.options.length=0;
	submenu.options.add(new Option("select","")); 
	}


BuildSel(returntxt,document.getElementById(MenuIdArr1[classid+1]))

//============更改下下级以下菜单为空==============

}
function BuildSel(str,sel)
{
/*
*--------------- BuildSel(str,sel) -----------------
* BuildSel(str,sel) 
* 功能:通过str构建Select.
* 参数:str,字符串,由服务端返回的.有特定结构"字符串1|,字符串2,字符串3"
*          也可为"字符串1序号|字符串1文本,字符串2序号|字符串2文本,字符串3序号|字符串3文本",如本例
* 参数:sel,要构建的Select
* 实例:BuildSel(unescape(oBao.responseText),document.all.sel2)
*--------------- BuildSel(str,sel) -----------------
*/
//先清空原来的数据.
sel.options.length=0;
var arrstr = new Array();
arrstr = str.split(",");
//开始构建新的Select.
sel.options.add(new Option( "select",""));  
if(str.length>0)   
{
for(var i=0;i<arrstr.length-1;i++)
{
//分割字符串
var subarrstr=new Array
subarrstr=arrstr[i].split("|")
//生成下级菜单
sel.options.add(new Option(subarrstr[1],subarrstr[0])); 
}
sel.options[0].selected=true
}

}


function VerifyChangData(form)
	{
		var valid = 1;				

		document.getElementById("nick_name_error").innerHTML="";
		document.getElementById("country_error").innerHTML="";		
		document.getElementById("Birthdate_error").innerHTML="";		
		document.getElementById("occupation_error").innerHTML="";		
	
		if (form.nick_name.value.length <2)
		{
			document.getElementById("nick_name_error").innerHTML="<font color='red'>请输入正确的昵称</font>";
			form.nick_name.focus();
			valid = 0;
		}

		if (form.country.value=="" || form.province.value=="" || form.city.value=="")
		{
			document.getElementById("country_error").innerHTML="<font color='red'>出生地不能为空</font>";
			form.surePassword.focus();
			valid = 0;
		}		

				
		if (checkbd(form.year.value,form.month.value,form.day.value)==false){
			document.getElementById("Birthdate_error").innerHTML="<font color='red'>请输入正确的生日,必须年满18岁以上</font>";	
			valid = 0;
			}
		
			
		if (form.occupation.value=='0'){
			document.getElementById("occupation_error").innerHTML="<font color='red'>请选择职业</font>";
			valid = 0;
			}
		
		if (valid==0)
			return false;	
	}
	
function checkbox_selectAll(idname){
	
	var f=document.getElementsByName(idname);
var obj = event.srcElement?event.srcElement:event.target;
alert('d');
alert(obj.type);
for(i=0;i<f.length;i++){

if(f(i).type=="checkbox" && f(i)!=obj){

f(i).checked=event.srcElement.checked;
		}
	}
}



function getajax(){
        var xmlhttp = false;
        if(window.ActiveXObject){
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if(window.XMLHttpRequest){
                xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
        }
function sendRequest(url,posts,func){
        ajax = getajax();

        ajax.onreadystatechange = func;
        ajax.open('POST', url, true);
        ajax.setRequestHeader("Content-Length",posts.length);
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        ajax.send(posts);        
}
/*------------Try-------------*/
var Try = {
  these: function() {
    var returnValue;
    for (var i = 0; i < arguments.length; i++) {
      var lambda = arguments;
      try {
        returnValue = lambda();
        break;
      } catch (e) {}
    }
    return returnValue;
  }
}

function tryCollectGarbage(){
    return Try.these(
        function() {return CollectGarbage();},
        function() {return false;}
        );
}
function getResult_list(adDiv,num){
        if (ajax.readyState < 4) {
                loads('index_td');
        }
        else if (ajax.readyState == 4) {
                if (ajax.status == 200){
                var result = ajax.responseText;
                if(adDiv=="dopages"){
                        document.getElementById('index_td').innerHTML = result;
                        }
        }
                else {
                        alert("Examples can create XMLHttpRequest object.");
                        delete ajax;
                        tryCollectGarbage();//垃圾回收
                }
        }
}
function popmsg(msgstr){    
	var winstr="<table width=\"240\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#DE659B\">";    
	winstr+="<tr><td width=\"200\" height=\"18\">&nbsp;<span class=\"white\" style=\"font-size:13px;\">通知消息</span></td><td width=\"40\"><div align=\"center\" class=\"white\" style=\"font-size:12px;\"><a href='#' onclick=\"parent.oPopup.hide();\">关闭</a></div></td></tr><tr><td align=\"center\" bgcolor=\"#FDF9FB\" colspan=\"2\"><table width=\"230\" height=\"87\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FDF9FB\">";    
	winstr+="<tr><td valign=\"top\" style=\"font-size:12px;\"><br>"+msgstr+"</td></tr></table></td></tr></table>";    
	if(popTop>220 && popTop<1620){
		popTop=50;
		clearTimeout(mytime);    
		oPopup.hide();  
	}
	oPopup.document.body.innerHTML = winstr;
	popshow();    
}  
function popshow(){    
		//window.status=popTop;    
		if(popTop>1620){   
		clearTimeout(mytime);    
		oPopup.hide();  
		return;    
		}else if(popTop>1400&&popTop<1620){    
		oPopup.show(screen.width-260,screen.height,240,1620-59-popTop);    
		}
		//本注释代码中的如果使用，则会显示上下抖两次。
		//else if(popTop>1400&&popTop<1520){    
		//oPopup.show(screen.width-260,screen.height,240,100);    
		//}
		else if(popTop<160){    
		oPopup.show(screen.width-260,screen.height,240,popTop-47);    
		}
		else if(popTop<220){    
		oPopup.show(screen.width-260,screen.height-popTop+43,240,100+12);    
		}  
		popTop+=10; 
		var mytime=setTimeout("popshow()",80);  
	}


function recive_msg(url)
{　

        var http_request = newXMLHttpRequest();
       //http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		
		http_request.onreadystatechange = processRequest;		
		http_request.open("GET", url, true);
		http_request.send(null);		
		
		
		
// 处理返回信息的函数
    function processRequest() {

        if (http_request.readyState == 4) { // 判断对象状态		
            if (http_request.status == 200 || http_request.status == 0) { // 信息已经成功返回，开始处理信息
		       if(http_request.responseText){getMsg(http_request.responseText,true);}		       
            } else if(http_request.status == 12029) { //常出这个错误，所以使其不做任何反应
               return;
			}else{//页面不正常
			   return;
               //alert("您所请求的页面有异常。错误编号："+http_request.status);
            } 
		}
    }
}
function send_123(url)
{
        var http_request = newXMLHttpRequest();
       //http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		//loadingdStr(obj);
		http_request.open("GET", url, false);
		http_request.send(null);		
}

function send_json(url,obj)
{
        var http_request = newXMLHttpRequest();
		http_request.open("GET", url, false);
		http_request.send(null);	//alert(http_request.responseText);
		var Text=http_request.responseText;
		var json = JSON.parse(Text);
		var sel=document.getElementById(obj);
		sel.options.length=0;
		for (prop in json){
			sel.options.add(new Option(json[prop][1],json[prop][0])); 
		}

}


/*
*右侧弹出框
*/
//window.onload=getMsg('',false);
window.onresize = resizeDiv;
window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0,j=0;
function getMsg(content,ifFromAjax)
{
	try
	{
		divTop = parseInt(document.getElementById("hint_win").style.top,10);
		divLeft = parseInt(document.getElementById("hint_win").style.left,10);
		divHeight = parseInt(document.getElementById("hint_win").offsetHeight,10);
		divWidth = parseInt(document.getElementById("hint_win").offsetWidth,10);
		docWidth = document.body.clientWidth;
		docHeight = document.body.clientHeight;
		document.getElementById("hint_win").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
		document.getElementById("hint_win").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;
		if(ifFromAjax){document.getElementById("content_show_div").innerHTML=content;}
		//隐藏原来的窗口
		if(document.getElementById("hint_win_min").style.visibility=='visible')document.getElementById("hint_win_min").style.visibility=='hidden';
		if(document.getElementById("hint_win").style.visibility=='visible')document.getElementById("hint_win").style.visibility=='hidden';
		//再次显示
		document.getElementById("hint_win").style.visibility="visible";
		objTimer = window.setInterval("moveDiv()",10);
	}
	catch(e){}
}
//初始化位置
function resizeDiv()
{

	i+=1;
	//if(i>300) closeDiv() //想不用自动消失由用户来自己关闭所以屏蔽这句
	try
	{
		divHeight = parseInt(document.getElementById("hint_win").offsetHeight,10);
		divWidth = parseInt(document.getElementById("hint_win").offsetWidth,10);
		docWidth = document.body.clientWidth;
		docHeight = document.body.clientHeight;
		document.getElementById("hint_win").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);
		document.getElementById("hint_win").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);
	}
	catch(e){}
}
//最小化
function minsizeDiv()
{
	i+=1
	//if(i>300) closeDiv() //想不用自动消失由用户来自己关闭所以屏蔽这句
	try
	{
		divHeight = parseInt(document.getElementById("hint_win_min").offsetHeight,10);
		divWidth = parseInt(document.getElementById("hint_win_min").offsetWidth,10);
		docWidth = document.body.clientWidth;
		docHeight = document.body.clientHeight;
		document.getElementById("hint_win_min").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);
		document.getElementById("hint_win_min").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);
	}
	catch(e){}
}
//移动
function moveDiv()
{
	try
	{
		if(parseInt(document.getElementById("hint_win").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
		{
			window.clearInterval(objTimer);
			objTimer = window.setInterval("resizeDiv()",1);
		}
		divTop = parseInt(document.getElementById("hint_win").style.top,10);
		document.getElementById("hint_win").style.top = divTop -1;
	}
	catch(e){}
}
function minDiv()
{
	closeDiv();
	document.getElementById('hint_win_min').style.visibility='visible';
    objTimer = window.setInterval("minsizeDiv()",1);
}
function maxDiv()
{
	document.getElementById('hint_win_min').style.visibility='hidden';
	objTimer = window.setInterval("resizeDiv()",1);
	document.getElementById('hint_win').style.visibility='visible';
	//resizeDiv()
	getMsg('',false);
}
function closeDiv()
{
	document.getElementById('hint_win').style.visibility='hidden';
	document.getElementById('hint_win_min').style.visibility='hidden';
	if(objTimer) window.clearInterval(objTimer);
}


