/*if (top.location == self.location){
window.opener=null
window.close();

}
*/
/**
function InitAjax()
{
　var ajax=false; 
　try { 
　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　} catch (e) { 
　　try { 
　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch (E) { 
　　　ajax = false; 
　　} 
　}
　if (!ajax && typeof XMLHttpRequest!='undefined') { 
　　ajax = new XMLHttpRequest(); 
　} 
　return ajax;
} 
*/

function InitAjax(){
    var HttpRequest=false;
	var MSXML = ['MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
	//检查浏览器类型
	if(window.XMLHttpRequest){
		//Mozilla 浏览器
		HttpRequest=new XMLHttpRequest;
		if(HttpRequest.OverrideMimeType){
			HttpRequest.overrideMimeType('text/xml');
			}
	}else if(window.ActiveXObject){//IE浏览器
        for(var i=0;i<MSXML.length;n++){	
				try{
					HttpRequest=new ActiveXObject(MSXML[i]);
					break;
				}catch(e){
						}
			}
	}
	if(!HttpRequest){
		window.alert('Can not create HttpRequest Object!');
		return false;
		}
	return HttpRequest;	
}

function ajax_get(url,obj)
{　
        var http_request = InitAjax();		
		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 ajax_post(url,obj)
{　
        var http_request = InitAjax();		
		http_request.onreadystatechange = processRequest;		
		http_request.open("POST", url, true);
		http_request.send(null);
		loads(obj);
    function processRequest() {
        if (http_request.readyState == 4) { 	
            if (http_request.status == 200) {   
		       document.getElementById(obj).innerHTML=http_request.responseText;
            } else { 
                alert("请求页面出错！");
            } 
		}
    }

}

function loads(obj){
	document.getElementById(obj).innerHTML='<img src="/img/load.gif" border="0" width="16" height="16">wait...';
	}
function Ajaxpost(url,obj,posts)
{　     loads(obj);
        var http_request = InitAjax();     
		http_request.onreadystatechange = processRequest;		
		http_request.open("POST", url, true);        
		http_request.setRequestHeader("Content-Length",posts.length);
        http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		http_request.send(posts);				
    function processRequest() {
        if (http_request.readyState == 4) { // 判断对象状态		
            if (http_request.status == 200) { // 信息已经成功返回，开始处理信息  
		       document.getElementById(obj).innerHTML=http_request.responseText;
            } else { //页面不正常
                alert("您所请求的页面有异常。");
            } 
		}
    }

}



function get_city(pro,obj){
	var url='include/get.php?ac=get_city&pro='+pro;
	ajax_post(url,obj);
}
function get_tcity(pro,obj){
	var url='include/get.php?ac=get_tcity&pro='+pro;
	ajax_post(url,obj);
	}
function get_age(agefrom,obj){
	var url='include/get.php?ac=get_age&agef='+agefrom;
	ajax_post(url,obj);
	}	
function get_h(hf,obj){
	var url='include/get.php?ac=get_height&hf='+hf;
	ajax_post(url,obj);
	}	
	
function loads(obj){
	document.getElementById(obj).innerHTML='<img src="/img/load.gif" border="0" width="16" height="16">wait...'
	}
function hidden(flag,obj){
	var div=document.getElementById(obj);
		if(flag==true){
		div.style.display='block';
   }else{
	    div.style.display='none';
	   }
	
	}


function tryCollectGarbage(){
    return Try.these(
        function() {return CollectGarbage();},
        function() {return false;}
        );
}

function get_ajax_rs(obj){
	 if (ajax.readyState < 4) {
                loads('ajax_rs');
        }else if (ajax.readyState == 4) {
                if (ajax.status == 200){
                var result = ajax.responseText;
				if(obj=="ok"){
                        document.getElementById('ajax_rs').innerHTML = result;
                        }
        }
                else {
                        alert("无法创建XMLHTTP对象！");
                        delete ajax;
                        tryCollectGarbage();
                }
        }
	
	}

function sendRequest(url,posts,func){
        ajax = InitAjax();
        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);        
}

function sendq(t,c){ 
		var posts ="title="+t+"&content="+c;
        var url = "action/ucaction.php?ac=qadd";
        function func(){
            get_ajax_rs('ok');
        };
        sendRequest(url,posts,func);
}

function check_null(v) 
{ 
var i=v.length;
var j = 0; 
var k = 0; 
var flag = true;
   while (k<i){ 
     if (v.charAt(k)!= " ") 
     j = j+1; 
     k = k+1; 
   } 
  if (j==0){ 
     flag = false;
  } 
   return flag; 
}
function getdays(year,month,day,offset){
var yvalue=year.value;
var mday='';
var ol=day.options.length;
var t=1;
var x=1;
var d=new Date();
var td=d.getDate()-offset;
switch (month){
     case '1':
	 case '3':	
	 case '5':	
	 case '7':	
	 case '8':	
	 case '10':	
	 case '12':	
	  mday=31;
	  break;
	 case '4':	
	 case '6':	
	 case '9':	
	 case '11':	
	   mday=30;
	   break;
     case '2': 
     if(yvalue%4==0 && yvalue%100!=0 || yvalue%100==0 && yvalue%400==0){
         mday=29;
     }else{
         mday=28;
     }break;
}
for(t=1;t<=ol;t++){
day.remove(t.t);
}
for(x=1;x<=mday;x++){
day.options.add(new Option(x,x));
}
day.options[td].selected=true;
}

function trim(stringToTrim) //去除字符串两边空格
  {	
     return stringToTrim.replace(/^\s+|\s+$/g,"");
  }

function saveUserInfo(value,url,moth,div)
{
　//获取接受返回信息层
//　var user = document.getElementById("user").value;

　//获取表单对象和用户信息值
 // var pass = document.getElementById("pass").value;
   
　//接收表单的URL地址
 var this_value=value;
 if(this_value=="")
 {
	// eval(div).innerHTML = "<img src='../images/reg/other.gif' /><font color='#FF8400'> 系统未检测到你的输入</font>"; 
	 document.getElementById(div).innerHTML = "<img src='../images/reg/other.gif' /><font color='#FF8400'> 系统未检测到你的输入</font>"; 
	 
	 return true;
	 }
 
else if(this_value.length<2)
 {
	 //eval(div).innerHTML = "<font color='#FF0000'><img src='../images/reg/err.gif' />输入不符合规范</font>"; 
	 document.getElementById(div).innerHTML = "<font color='#FF0000'><img src='../images/reg/err.gif' />输入不符合规范</font>"; 
	 return true;
	 }
 //　var this_url = url;
 　//需要POST的值，把每个变量都通过&来联接
//　var postStr = "user="+user+"&pass="+pass;
   var poststr="key="+value;
 
　//实例化Ajax
　var ajax = InitAjax();
　if(moth=="POST"){
　//通过Post方式打开连接
　ajax.open("POST", url, true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
　ajax.send(postStr);
 }else{
　var this_url = url+"?key="+this_value;
  ajax.open("GET", this_url, true);
  ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
　ajax.send(null);
 
 }
 
 　ajax.onreadystatechange = function(){oa_inserthtml(div);};

function oa_inserthtml(a) 
  { 
		//如果执行状态成功，那么就把返回信息写到指定的层里
　　	if (ajax.readyState == 4 && ajax.status == 200)
		{ 
		 
		 
　　　		 //eval(a).innerHTML = ajax.responseText; 
             document.getElementById(a).innerHTML = ajax.responseText; 
　　	} 
  }
} 