function CreateXMLHTTP()
{
	//早期的IE版本是Msxm12.XMLHTTP
	//IE5+是Microsoft.XMLHTTP
	//非IE，支持的是XMLHttpRequest
	try
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			//alert("IE5--");
			xmlhttp = new ActiveXObject("Msxm12.XMLHTTP");
		}
		catch(E)
		{
			xmlhttp = false;
		}
	}
                    	
	if(!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
		//alert("none IE");
		xmlhttp = new XMLHttpRequest();
	}
	else
	{
		//alert("IE5++");
	}

	return xmlhttp;
}

function chklogin(url,type)
{ 
	var xmlhttp = CreateXMLHTTP();
	try 
	{
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4){
				if (xmlhttp.status == 200){
					var result = xmlhttp.responseText;
					if(result.substring(0,4) != "200 "){
						window.alert("你还没有登录或者登录已经失效,请重新登录");
						window.location="/";
					}
					return false;
				}
			}
		} 

		xmlhttp.open("POST",url, true);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send("type="+type);
	}
	catch(e)
	{
		window.alert("网络错误，请稍后再试");
	}
	return false;
}

//文本框得到焦点和失去焦点的状态说明
//[em]元素id，[msg]默认文本框的说明字串
//By CWQ
//2007-6-24
function txton(em,msg){
	var tag_em = document.getElementById(em);
	var tag_value = tag_em.value;
	tag_em.className = "txt_on";
	if (tag_value == msg){
		tag_em.value = "";
		tag_em.select();
	}else{
		tag_em.value = tag_value;
		tag_em.select();
	}
 }
 
function txtout(em,msg){
 	var tag_em = document.getElementById(em);
	tag_em.className = "txt_out";
	if (tag_em.value == ""){
		tag_em.value = msg;
	}
}

//页面加载数据前的loading效果
//div的样式名称为[loading_div], 在公共的样式表 [public.css]
document.write("<div id='loading_div' style='display:none'><table width='100%' border='0' cellpadding='3' cellspacing='1' class='loading_tb'><tr><td class='input_text'>&nbsp;</td></tr><tr><td align='center'><img src='/images/loading.gif' width='189' height='38' /></td></tr><tr><td align='center'>正在加载数据，请等待...</td></tr></table></div>");
//显示loading层	
function show_loading(){
	document.getElementById("loading_div").style.display="block";
}
//隐藏loading层	
function hide_loading(){
	document.getElementById("loading_div").style.display="none";
}