﻿var xmlHttp; 
 //申明一个XMLHttpRequest对象
function CreateXMLHTTP()
{
     if(window.XMLHttpRequest)
    {
        xmlHttp=new XMLHttpRequest();//mozilla浏览器
    }
    else if(window.ActiveXObject)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");//IE老版本
        }
        catch(e)
        {}
        try
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");//IE新版本
        }
        catch(e)
        {}
        if(!xmlHttp)
        {
            window.alert("不能创建XMLHttpRequest对象实例！");
            return false;
        }
    }

}


var numkey = Math.random(999);
numkey = Math.round(numkey*10000);
function ReSet()
{
	numkey = Math.random(999);
	numkey = Math.round(numkey*10000);
	checkcode.innerHTML = "<img src='../checkImage.aspx?k="+numkey+"' onclick='ReSet();'>";
}
 
 
 function get_send()
{
	CreateXMLHTTP();
	var key = getHost();
	var url = "logoDeal.aspx?action=getlogo&key="+escape(key);
	xmlHttp.open("POST",url,true);
	xmlHttp.onreadystatechange = s_send;
	xmlHttp.send(null);

}
 
 function s_send()
{
	
	if(xmlHttp.readyState == 4)
    {
		
        if(xmlHttp.status == 200)
        {
			var sw = xmlHttp.responseText.split("@")[0];
			
			
			if(sw == "0")
            {
				//alert(xmlHttp.responseText.split("@")[1]);
				
            }
            if(sw == "1")
            {
				if(xmlHttp.responseText.split("@")[1] != "")
				{
					document.getElementById("mylogo").src = xmlHttp.responseText.split("@")[1];
				}
				
            }
			  if(sw == "2")
            {
				
				alert("加载失败！");
            }
        }
    }
}
 function getHost(url) 
{
	var host = "null";
	if(typeof url == "undefined"|| null == url)
	{ 
   	url = window.location.href;
   	}   
	var regex = /.*\:\/\/([^\/]*).*/; 
	var match = url.match(regex); 

	if(typeof match != "undefined" && null != match)
	{
   		host = match[1];
	}
	return host;
}

			

function Login()
{
	if(loginFormForm.username.value == "")
	{
		alert("用户名不能为空!");
		loginFormForm.username.focus();
		return false;
	}
	
	if(loginFormForm.password.value == "")
	{
		alert("密码不能为空!");
		loginFormForm.password.focus();
		return false;
	}
	if(loginFormForm.code.value != numkey)
	{
		alert("验证码不正确!");
		loginFormForm.code.focus();
		return false;
	}
	loginFormForm.submit();
	return true;
}