﻿//ajax类   method(ajax方法"get","post")   url(处理地址)   content(如果是Post方法  content必填如"text" 如果是get方法   content为null)    calback 为回调函数
var xmlhttpreq = null;
function newajax(method,url,content,callback)
{
    if(window.XMLHttpRequest)//除ie5和ie6的实例化
    {
        xmlhttpreq = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        xmlhttpreq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(xmlhttpreq!=null)
    {
        if(method.toLowerCase()=="get")
        {
            xmlhttpreq.open(method,url,true);
    		xmlhttpreq.setRequestHeader("If-Modified-Since", "0");
    		xmlhttpreq.onreadystatechange=callback;
    		content =null;
        }
        else if(method.toLowerCase()=="post")
        {
            xmlhttpreq.open(method,url,true);
		    xmlhttpreq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		    xmlhttpreq.onreadystatechange=callback;
        }
        xmlhttpreq.send(content);
    }
}
function showhuifu(itemname,showid,totalnum)
{
    for(i=0;i<totalnum;i++)
    {
        if(document.getElementById(itemname+i)!=null)
        {
            document.getElementById(itemname+i).style.display="none";
        }
        if(showid==i)
        {
            if(document.getElementById(itemname+i)!=null)
			{
                document.getElementById(itemname+showid).style.display = "block";
            }
        }
    }
}
function showlogin(itemname,showid,totalnum)
{
        container.style.visibility = "hidden";
       login.style.display = "block";
       login.style.top="800";
       forbid.style.width = document.body.clientWidth;
	   forbid.style.height = document.body.clientHeight;
	   forbid.style.visibility = "visible";
}
function companylogin()
{
    var name = document.getElementById("loginname").value;
    var pwd  = document.getElementById("loginpwd").value;
	var url='../Handler.ashx?comname='+name+'&compwd='+pwd+'&type=check';
	if(name!=""&&pwd!="")
	{
		newajax("get",url,"text",RequestCallBack);
		container.style.visibility = 'Visible';
        showall();
	}
	else
	{
		alert('用户名密码不能为空！');
	}
}