﻿function isie()
{
    if (window.ActiveXObject) {
        return true;
    }
}

function getGet(argname)
{
var url = document.location.href;
var arrStr = url.substring(url.indexOf("?")+1).split("&");
for(var i =0;i<arrStr.length;i++)
{
   var loc = arrStr[i].indexOf(argname+"=");

   if(loc!=-1)
   {
    return arrStr[i].replace(argname+"=","").replace("?","");
    break;
   }
  
}
return "";
}

function fanhui(){history.back();}

function zhuan(shu)
{
    var num=""+shu;
    var pos=num.indexOf(".");
    if(pos!=-1)
    {
        var d3=parseInt(num.substr(pos+3,3));
        if(d3 && d3!=0)//如果有第3位数开始后面有数就加1分
        {
            var aww=shu+0.01;
            num=""+aww;
            return parseFloat(num.substr(0,pos+2+1))}
        else
        {
            return parseFloat(num.substr(0,pos+2+1));
        }
    }
    else
        return num;
} 

function qu2(shu)
{
    var num=""+shu;
    var pos=num.indexOf(".");
    if(pos!=-1)
        return parseFloat(num.substr(0,pos+2+1));
    else
        return num;
} 

var $=function(Id){
    return document.getElementById(Id);
};
var $N=function(Name){
    return document.getElementsByName(Name);
};
//获取select的值
var $S=function(Id){
    return $(Id).options[$(Id).selectedIndex].value;
}
//获取radio的值
var $R=function(name){
    var radio = $N(name);
    var getresult = 0;
    for (var i=0;i<radio.length;i++){
        if(radio[i].checked)
            getresult = radio[i].value;
    }
    return getresult;
};
//调用$S("select的id名")

function setCookie(name,value) 
{ 

expires = new Date(); 
expires.setTime(expires.getTime() + (1000 * 86400 * 365)); 
var dd=expires.toGMTString();
//escape(value)
document.cookie = name + "=" + value + "; expires=" + expires.toGMTString() + "; path=/"; 
} 

function getCookie(name) 
{ 

cookie_name = name + "="; 
cookie_length = document.cookie.length; 
cookie_begin = 0; 
while (cookie_begin < cookie_length) 
{ 

value_begin = cookie_begin + cookie_name.length; 
if (document.cookie.substring(cookie_begin, value_begin) == cookie_name) 
{ 
var value_end = document.cookie.indexOf ( ";", value_begin); 
if (value_end == -1) 
{ 
value_end = cookie_length; 
}
return document.cookie.substring(value_begin, value_end);
//return unescape(document.cookie.substring(value_begin, value_end)); 
//return decodeURI(document.cookie.substring(value_begin, value_end)); 
} 
cookie_begin = document.cookie.indexOf ( " ", cookie_begin) + 1; 
if (cookie_begin == 0) 
{ 
break; 
} 
} 
return null; 
} 

function delCookie(name) 
{ 
var expireNow = new Date(); 
document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/"; 
} 

function GWCBianCookie(zuiduo) 
{
var sp=getCookie("_G");
var cooks=sp.split(',');
for (i = 0,s=0; i < cooks.length && i<zuiduo; i++)
{
    if (s == 0)
        z = cooks[i];
    else
        z = z + "," + cooks[i];
    s++;
}
setCookie("_G",z);
}

function createHTTP(divc)
{
    try{
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e)
    {
        try{
        return new XMLHttpRequest();
        }
        catch(e)
        {
            try{
                return new ActiveXObject('Msxml2.XMLHTTP')
            }
            catch(e)
            {
                divc.innerText="浏览器不支持";
                return false;
            }
        }
    }
}
//var _Name=unescape(getCookie("_Name"));
function GetUserZT()
{
    var divob=$("userinfo");
    var xmlhttp=createHTTP(divob);
    
    var DQF = function () { GetUserZT();}
    var SJDQ=function timedaoqi(divob)
            {xmlhttp.abort();
            $("userinfo").innerHTML="读取超时";}
    var DuQuShiJian=setTimeout(SJDQ,20000);
    if(divob && xmlhttp)
    {
        var HuoQuFa=function getUserXinXi()
                {
                    if(xmlhttp.readyState==4)
                    {
                        clearTimeout(DuQuShiJian);
                        if(xmlhttp.status==200)
                        {
                            var dd=qZYKG(xmlhttp.responseText);
                            divob.innerHTML=dd;
                            var na=getCookie("_Name");
                            if(na)
                                $('usernnn').innerHTML=decodeURI(na);
                        }
                        else if (xmlhttp.status==304) {
                            
                        }
                        else if (xmlhttp.status >= 400 && xmlhttp.status < 500) {

                        }
                        else if (xmlhttp.status >= 500 && xmlhttp.status < 600) {
                            setTimeout(DQF, 5000);
                        }
                        else {
                            divob.innerHTML="失败";
                        }

                    }
                }
        caretAjax(xmlhttp,divob,"/default/__UserInfo.aspx?"+Math.random(),HuoQuFa);
    }
}

var userinfo;
function caretAjax(xmlhttp,Div,Url,HuoQuFa)
{
    xmlhttp.onreadystatechange=HuoQuFa;
    xmlhttp.open("GET",Url,true);
    //xmlhttp.setRequestHeader("If-Modified-Since","0"); 
    xmlhttp.send(null);
}

function qZYKG(s)  
{  
  return  s.replace(/(^\s*)|(\s*$)/g,  "");  
}  
//删除字符串左端的空格
function qZKG(s)  
{  
return  s.replace(/(^\s*)/g,  "");  
}  
  //删除字符串右端的空格
function qYKG(s)  
  {  
  return  s.replace(/(\s*$)/g,  "");  
}

function getChangDu(s)   
{
  var j=0; 
  if(!s)return 0;  
  if(/[^\x00-\xff]/g.test(s))
      for(var i=0;i<s.length;i++)   
      {   
          if (s.charCodeAt(i)>255) j=j+2;   
          else j++   
      }
  else
    j=s.length;
  return j;  
}

function sousuo(s)
{
    var str=$(s);
    var zd=getChangDu(str.value);
    if(zd>20)
    {
        alert("您输入的查询关键字太长了不能超过10个汉字或20个英文。请精简以得到更好的效果。");
        return false;
    }
    else if(zd<2 || str.value=="开始全新搜索")
    {
        alert("您输入的查询关键字太短了不能低于2个字。");
        return false;
    }
    return true;
}


function GetYinHang()
{
    var divob=$("YinHang");
    divob.innerHTML="正在读取银行信息..请稍等...";
    var xmlhttp=createHTTP(divob);
    var xiaoxi="请点这里<a href='/sc/yinhang.htm' target='_blank'>查看银行帐号</a> 或 <a href='/GuanYu/LianXi.aspx' target='_blank'>联系我们</a>获取银行信息";
    var DQF = function () { GetUserZT();}
    var SJDQ=function timedaoqi(divob,nr)
            {xmlhttp.abort();
            divob.innerHTML="读取超时,"+xiaoxi;}
    var DuQuShiJian=setTimeout(SJDQ,10000);
    if(divob && xmlhttp)
    {
        var HuoQuFa=function getUserXinXi()
                {
                    if(xmlhttp.readyState==4)
                    {
                        clearTimeout(DuQuShiJian);
                        if(xmlhttp.status==200)
                        {
                            divob.innerHTML=xmlhttp.responseText;
                        }
                        else if (xmlhttp.status >= 500 && xmlhttp.status < 600) {
                            setTimeout(DQF, 5000);
                            divob.innerHTML=xiaoxi;
                        }
                        else {
                            divob.innerHTML=xiaoxi;
                        }

                    }
                }
        caretAjax(xmlhttp,divob,"/SC/YinHang.htm?"+Math.random(),HuoQuFa);
    }
}


function newWindows(isNo)
{
    if(isNo==1)
    {
        $("aspnetForm").target="_blank";
    }
    else
        $("aspnetForm").target="_self";
}

function gwcsl()
{
var sl=$("gwcsl");
if(sl)
{
var yqsp = getCookie("_G");
if(yqsp&&yqsp!="")
    {
var ysqpzu = yqsp.split(',');
sl.innerHTML=ysqpzu.length;
}
}
}

function gwcJiaUrl(a)
{
var url=document.location.href.toLowerCase();
    if(url.indexOf("gwc.aspx")>=0){
        a.href=url;a.target="_self";
    }
    else
        a.href="/User/GWC.aspx?qurl="+document.location.href.replace("?","`");
}


function xsTU(dd)
{    
     var x1 = event.clientX+document.documentElement.scrollLeft;
     var y1 = event.clientY+document.documentElement.scrollTop ;

     if($("qqcontact"))
     {                
         var div1 = $("qqcontact");
         document.body.removeChild(div1);
     }            
     var newNode = document.createElement("div");
     newNode.setAttribute("id", "qqcontact");

     var result1= document.createElement("img");
     result1.setAttribute("src",dd.src.replace("zxiao/",""));
     newNode.appendChild(result1);
	 document.body.appendChild(newNode);
	 newNode.style.position = "absolute";
newNode.style.left = x1 + 15 + "px";
newNode.style.top = y1 -40 + "px";
}
function gbTU()
{
	var div = $("qqcontact");
	if(div)
    	document.body.removeChild(div);
}
function xssmGO(dd)
{         
     var x1 = event.clientX+document.documentElement.scrollLeft;
     var y1 = event.clientY+document.documentElement.scrollTop ;

     if($("beizhu1"))
     {                
         var div1 = $("beizhu1");
         document.body.removeChild(div1);
     }            
     var newNode = document.createElement("div");
     newNode.setAttribute("id", "beizhu1");

     var result1= document.createElement("span");
     result1.innerHTML = dd;
     newNode.appendChild(result1);
	 document.body.appendChild(newNode);
	 newNode.style.position = "absolute";
newNode.style.left = x1 + 15 + "px";
newNode.style.top = y1 - 15 + "px";
}
function gbsm()
{
	var div = $("beizhu1");
	if(div)
    	document.body.removeChild(div);
}
