var BookMarker;
var postReturnUrl;
var postReturnLink;
BookMarker=location.hash;

//生成随机数
function GetRandomNum(Min,Max){
	var Range = Max - Min;
	var Rand = Math.random();
	return(Min + Math.round(Rand * Range));
}


function createXmlHttp() {
	xmlHttp = false;

	//开始初始化XMLHttpRequest对象
	if(window.XMLHttpRequest) { //Mozilla 浏览器
		xmlHttp = new XMLHttpRequest();
		if (xmlHttp.overrideMimeType) {//设置MiME类别
			xmlHttp.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject) { // IE浏览器
		try {
			xmlHttp = new XMLHttpRequest();
		} catch(e)	{
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	}
	if (!xmlHttp) { // 异常，创建对象实例失败
		window.alert("不能创建XMLHttpRequest对象实例.");
		return false;
	}
}

function startPostRequest(postUrl,postData,returnUrl,returnLink)
{
	createXmlHttp();
	postReturnUrl=returnUrl;
	postReturnLink=returnLink;
	xmlHttp.onreadystatechange=handlePost;
	xmlHttp.open('POST',postUrl,true);
//	xmlHttp.setrequestheader("cache-control","no-cache"); 
	xmlHttp.setRequestHeader("Accept-Encoding","gb2312");
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttp.send(postData);
}

function handlePost()
{	
	try{
		if(xmlHttp.readystate=='4'||xmlHttp.status=='200')
		{	
			var moveStr=xmlHttp.responseText;
			if(left(moveStr,5)=='false')
			{
				moveStr=moveStr.split('|');
				alert(moveStr[1]);
				clearFrom()
				return false
			}
			else
			{
				alert('您已经登录成功');
				document.getElementById('CententData').innerHTML=moveStr;
			}
		}
	}
	catch(e){}
}

function handlePost11()
{
	try{
		if(xmlHttp.readystate=="4" || xmlHttp.status=="200") 
		{	
			var moveStr=xmlHttp.responseText;
			if(moveStr!='')
			{
				if(moveStr=='系统提示|　　信息已保存！')
				{
					var errStr=moveStr.split('|');
					Ealert(errStr[0],errStr[1]);
					
					window.location.href=postReturnLink;
					startRequest(postReturnUrl+'&num='+GetRandomNum(0,9999));
				}
				else
				{
					var errStr=moveStr.split('|');
					Ealert(errStr[0],errStr[1],2);
					document.getElementById('img_code').src='/inc/img_code.asp'
				}
			}
		}
	}
	catch(e){}
}

	function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
	}
function left(mainStr,lngLen) { 
if (lngLen>0) {return mainStr.substring(0,lngLen)} 
else{return null} 
} 
function clearFrom()
{
	document.loginform.loginName.value='';
	document.loginform.password.value='';
	document.loginform.yzm.value='';
	document.getElementById('TitleLoginCheckCode').src='/inc/img_code.asp';
}
