﻿var xmlhttp=null;
function createXmlHttp()
{
    try
    {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e)
		{}
	}
	return xmlhttp;
}
function SoohawAjaxRequest(url,Param,fName)
{
    if(url=="")
    {
//        url=window.location.protocol+"//"+window.location.host+"/Zonvan.Soohaw.Web/WebService.asmx";
        url=window.location.protocol+"//"+window.location.host+"/WebService.asmx";
    }
    var pUrl="";
    xmlhttp = createXmlHttp();
    xmlhttp.Open("POST", url, false);
    xmlhttp.setRequestHeader("Content-type", "text/xml; charset=utf-8"); 
    xmlhttp.onreadystatechange = GetResult;
    var soapString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
    soapString+="<soap:Envelope ";
    soapString+="xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" ";
    soapString+="xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
    soapString+="xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
    soapString+="<soap:Body>";
    soapString+="<"+fName+" xmlns=\"http://tempuri.org/\">";
    soapString+=Param;
    soapString+="</"+fName+">";
    soapString+= "</soap:Body>";
    soapString+="</soap:Envelope>";
  
    xmlhttp.Send(soapString);
   
    return GetResult(xmlhttp.responseText);
}
function GetResult(result)
{
    try
    {
        return xmlhttp.responseXml.childNodes[1].childNodes[0].childNodes[0].childNodes[0].text;
    }
    catch(e)
    {
        return "";
    }
}

//电子邮件输入验证
function verifyEmail(email) 
{ 
    var email = email.value; 
    if(email==null || email=="" || email=="请输入您的Email!")
        document.getElementById("imgflag3").src="/Images/Inc/Text_Right.jpg";
    else
    {
        var pattern =/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
        flag = pattern.test(email); 
        if(flag) 
        { 
　        document.getElementById("imgflag3").src="/Images/Inc/Text_Right.jpg";
        } 
        else 
　        { 
　　        document.getElementById("imgflag3").src="/Images/Inc/Text_Wrong.jpg";
　        } 
　  }
} 
//获取Cookies
function GetCookie(sName)   
{     
      var aCookie   =   document.cookie.split("; "); 
      for (var i=0;   i < aCookie.length;i++)   
      {      
          var aCrumb = aCookie[i].split("="); 

          if (sName==aCrumb[0])     
              return unescape(aCrumb[1]);   
      }       
      return null;  
 }  
//添加Cookies
function addCookie(objName,objValue,objHours)
{
    var str = objName + "=" + escape(objValue);
    if(objHours > 0)
    {//为0时不设定过期时间，浏览器关闭时cookie自动消失
	    var date = new Date();
	    var ms = objHours*3600*1000;
	    date.setTime(date.getTime() + ms);
	    str += "; expires=" + date.toGMTString();
    }
    document.cookie = str;
}
//为了删除指定名称的cookie，可以将其过期时间设定为一个过去的时间
function delCookie(name)
{
	var date = new Date();
	date.setTime(date.getTime() - 10000);
	document.cookie = name + "=a; expires=" + date.toGMTString();
}
//读取所有保存的cookie字符串	
function allCookie()
{
	var str = document.cookie;
	if(str == "")
	{
		str = "没有保存任何cookie";
	}
	alert(str);
}
//鼠标经过事件
function mouseover(obj)
{
    obj.style.color="#1C71C4";
    obj.style.textDecorationUnderline=true;
    obj.style.lineHeight="33px";
}
//鼠示离开事件
function mouseout(obj)
{
    obj.style.color="#FF6600";
    obj.style.textDecorationUnderline=false;
    obj.style.lineHeight="33px";
}
//设置图片属性
function setImgSize(img,width,height)
{
    var MaxWidth=width;//设置图片宽度界限
    var MaxHeight=height;//设置图片高度界限
    var HeightWidth=img.offsetHeight/img.offsetWidth;//设置高宽比
    var WidthHeight=img.offsetWidth/img.offsetHeight;//设置宽高比
    if(img.offsetWidth>MaxWidth)
    {
        img.width=MaxWidth;
        img.height=MaxWidth*HeightWidth;
    }
    if(img.offsetHeight>MaxHeight)
    {
        img.height=MaxHeight;
        img.width=MaxHeight*WidthHeight;
    }
}