
// JScript 文件
//Tab菜单转换
function Show_YKTab(tabname,divname,tabid,n)
{   
   var whichEl =document.getElementById(divname +tabid);
   if (whichEl.style.display == "none")
    {	
         for(var i=1;i<=n;i++)
        {
            if(i!=tabid)
            {
                document.getElementById(divname + i).style.display="none";
                document.getElementById(tabname + i).style.background="url(../images/you.jpg)";
             }
         }
         whichEl.style.display="block";
         document.getElementById(tabname + tabid).style.background="url(../images/jia.jpg)";
     }
} 


//返回cookie值 
function getCookie(c_name)
{
    if(document.cookie.length>0)
    {
    c_start=document.cookie.indexOf(c_name + "=")
    if(c_start!=-1)
    { 
       c_start=c_start + c_name.length+1 
       c_end=document.cookie.indexOf(";",c_start)
       if(c_end==-1) c_end=document.cookie.length
       return unescape(document.cookie.substring(c_start,c_end))
    }
    }
    return "";
}
/*设置Cookie值*/




function setCookie(c_name,value,expiredays)
{
   var exdate=new Date()
   exdate.setDate(exdate.getDate()+expiredays)
   document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}4

/*检查Cookie，如果没有，则提示设置，如果有了，则弹其Cookie值*/
function checkCookie()
{
  username=getCookie('username')
  if (username!=null && username!="")
  {
      alert('Welcome again '+username+'!')
  }
  else
  {
      alert("请登陆，您还没有登陆"); 
  }
}





//调用方法如 AsynchHttp("chuli.aspx",display,"GET") 返回的Text
function AsynchHttpText(url,callback,data) 
{   
  var http_request;
  if (window.XMLHttpRequest) //Mozila//非IE浏览器，用xmlhttprequest对象创建
  {
      http_request = new XMLHttpRequest();
      if (http_request.overrideMimeType)
      {
          http_request.overrideMimeType("text/xml");
      }
   } 
   else if (window.ActiveXObject) //IE//IE浏览器用activexobject对象创建
   {
     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;
    }
    
    
    
    
    if(typeof(data)=="undefined")
    {
         var data=null;
    }
    var method=data?"POST":"GET";
    if(http_request)
    {
       try
       {
           http_request.open("GET",url,true);
　　　     if(method=="POST")
　　　     {
　　　        http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
　　　     }
　　　     http_request.setRequestHeader("If-Modified-Since","0");
　　　     http_request.send(data); //发送请求
       }
       catch(e)
       {
          alert(e);
       }
    }
    http_request.onreadystatechange=function()
    {
         if(http_request.readyState==4) //请求状态为4表示成功
　　　　　{
　　　　　　　　if(http_request.status==200) //http状态200表示OK
　　　　　　　　{
　　　　　　　　　　callback(http_request.responseText);
　　　　　　　　}
　　　　　　　　else //http返回状态失败
　　　　　　　　{
　　　　　　　　　　callback("error");
　　　　　　　　}
　　　　　}
　　　　　else
　　　　　{
　　　　　    //数据正在加载中..........
　　　　　}
    }    
}


