var boxCon1 = "<table width=\"369\" height=\"299\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" background=\"\/c\/a\/logBox_bg.gif\" style=\"background-repeat: no-repeat;\"><tr><td height=\"118\" colspan=\"2\"><\/td><\/tr><tr align=\"left\" valign=\"top\"><td width=\"86\"><\/td><td id=\"mainCon\">";

var boxCon2 = "<form name=\"ulogT\" method=\"post\" action=\"\"><table width=\"230\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr align=\"center\" valign=\"top\"><td id=\"showMsg\" height=\"28\" colspan=\"2\" class=\"fRed\"><\/td><\/tr><tr align=\"left\"><td width=\"78\">&nbsp;用户名：<\/td><td width=\"152\"><input name=\"uname\" maxlength=\"16\" class=\"input1\" onKeyUp=\"value=value.replace(\/[\\W]\/g,\'\')\" onbeforepaste=\"clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(\/[^\\d]\/g,\'\'))\"><\/td><\/tr><tr><td height=\"10\" colspan=\"2\"><\/td><\/tr><tr align=\"left\"><td>&nbsp;密&nbsp;&nbsp;码：<\/td><td><input type=\"password\" name=\"upass\" maxlength=\"16\" class=\"input1\" onKeyUp=\"value=value.replace(\/[\\W]\/g,\'\')\" onbeforepaste=\"clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(\/[^\\d]\/g,\'\'))\"><\/td><\/tr><tr><td height=\"10\" colspan=\"2\"><\/td><\/tr><tr align=\"left\"><td><\/td><td><input type=\"button\" class=\"sub1\" value=\"登 录\" onClick=\"return checLog_T()\">&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" class=\"sub1\" value=\"取 消\" onClick=\"javascript:CloseLogbox();\"><\/td><\/tr><tr><td height=\"20\" colspan=\"2\"><\/td><\/tr><tr align=\"center\"><td colspan=\"2\">您还没有注册？&nbsp;&nbsp;<a href=\"\/u\/Reg\/\" target=\"_blank\" style=\"text-decoration:underline; color:#006600;\">马上注册<\/a><\/td><\/tr><\/table><\/form>";

var boxCon3 = "<\/td><\/tr><\/table>";

function gotoB()
{
mainCon.innerHTML = boxCon2;
}

/*---------------------------------------------------------------------------------------------------*/

function setCookie(){
var Then = new Date()
Then.setTime(Then.getTime() + 60*1000 ) //60秒
document.cookie = "Cookie1=molo_1;expires="+ Then.toGMTString()
}

function getCookie(){
var cookieString = new String(document.cookie)
var cookieHeader = "baobaoUnam="
var beginPosition = cookieString.indexOf(cookieHeader)
if (beginPosition != -1){
	var cookie_uname = cookieString.substring(beginPosition + cookieHeader.length)
	//document.all.Textbox.value = cookieString.substring(beginPosition + cookieHeader.length)
	document.getElementById('showU_top').innerHTML = "<span class=aLine>欢迎您，<font color=#FF0033>"+ cookie_uname +"</font>&nbsp;&nbsp;<a href=\"\/u\/\" target=\"_blank\">用户中心<\/a>&nbsp;&nbsp;<a href=\"javascript:liveIt()\">退出登录<\/a></span>";
}
else
	document.getElementById('showU_top').innerHTML = "<span class=aLine><a href=\"\/u\/Log\/Logout\/\">退出登录<\/a></span>";
}

/*---------------------------------------------------------------------------------------------------*/

function getElement(aID)
{
  return (document.getElementById) ? document.getElementById(aID): document.all[aID];
}

function makeRequest(url){
  http_request=false;
  if(window.XMLHttpRequest){//Mozilla,Safari,...
     http_request=new XMLHttpRequest();
     if(http_request.overrideMimeType){
     http_request.overrideMimeType('text/xml');
   }
 }else if(window.ActiveXObject){//IE
   try{
   http_request=new ActiveXObject("Msxml2.XMLHTTP");
   }catch(e){
   try{
 		http_request=new ActiveXObject("Microsoft.XMLHTTP");
 	}catch(e){}
 	}
 }
 if(!http_request){
 	alert('Giving up:(Cannot create an XMLHTTP instance)');
 	return false;
 }
 return http_request;
}

function flower(sUname,sUpass){
    var url = "http://baobao.ly169.cn/u/Log/chklogT?a="+sUname+"&b="+sUpass;
	var xhttp=makeRequest();
	xhttp.onreadystatechange=function(){
		if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
		{		
				   var getCon = xhttp.responseText;
				   if(getCon == "OK"){
				   mainCon.innerHTML = "<div id=showLogInfo2>登录成功！<br><br><a href=javascript:CloseLogbox(); style=color:#ff0033;text-decoration:underline;>确定</a></div>";
				   getCookie();
				   CloseLogbox();
				   }
				   else
				   {
					 mainCon.innerHTML = "<div id=showLogInfo2>"+ getCon +"<br><br><a href=javascript:gotoB(); style=color:#ff0033;text-decoration:underline;>返回</a></div>";
					  }

}
	}
	xhttp.open("GET",url,true);
	xhttp.send(null);
}

function hc(sUname,sUpass){
mainCon.innerHTML = "<div id=showLogInfo><img src=/c/a/loading.gif width=24 height=24></div>";
flower(sUname,sUpass);
}

function liveIt(){
    var url_2 = "http://baobao.ly169.cn/u/Log/LogoutT";
	var xhttp_2=makeRequest();
	xhttp_2.onreadystatechange=function(){
		if(xhttp_2.readyState == 4 && (xhttp_2.status==200 || window.location.href.indexOf("http")==-1))
		{		
				   var getCon_2 = xhttp_2.responseText;
				   if(getCon_2 == "OK"){
				   document.getElementById('showU_top').innerHTML = "<span class=aLine><a href=javascript:dispLogbox()>登录</a></span>";
				   }

}
	}
	xhttp_2.open("GET",url_2,true);
	xhttp_2.send(null);
}

/*--------------------------------------------------------------------------------------------------------*/

function checLog_T()
{
	if (document.ulogT.uname.value =="")
	{
		showMsg.innerHTML = "<span class=\"msgBg\">请输入您的用户名...</span>";
		document.ulogT.uname.focus();
		return false;
	}
	else
	if (document.ulogT.uname.value.length < 4)
	{
		showMsg.innerHTML = "<span class=\"msgBg\">请正确输入您的用户名...</span>";
		document.ulogT.uname.focus();
		return false;
	}
	else
	if (document.ulogT.uname.value.length > 16)
	{
		showMsg.innerHTML = "<span class=\"msgBg\">请正确输入您的用户名...</span>";
		document.ulogT.uname.focus();
		return false;
	}
	else
	if (document.ulogT.upass.value =="")
	{
		showMsg.innerHTML = "<span class=\"msgBg\">请输入密码...</span>";
		document.ulogT.upass.focus();
		return false;
	}
	else
	if (document.ulogT.upass.value.length < 6)
	{
		showMsg.innerHTML = "<span class=\"msgBg\">请正确输入您的密码...</span>";
		document.ulogT.upass.focus();
		return false;
	}
	else
	if (document.ulogT.upass.value.length > 16)
	{
		showMsg.innerHTML = "<span class=\"msgBg\">请正确输入您的密码...</span>";
		document.ulogT.upass.focus();
		return false;
	}
	else
	//return true;
	
	var sUname = document.ulogT.uname.value;
	var sUpass = document.ulogT.upass.value;
	hc(sUname,sUpass);
}

//---------------------------------------- LogBox -------------------------------------------//

var width=369;
var height=299;
var bgcolor="#99CC00";
var trans=30;
var body = document.body;
var bodyWidth = parseInt((body.scrollWidth<body.clientWidth)?body.clientWidth:body.scrollWidth);
var bodyHeight = body.clientWidth; parseInt((body.scrollHeight<body.clientHeight)?body.clientHeight:body.scrollHeight);
var clientWidth=body.clientWidth;
var clientHeight=body.clientHeight;
//开始创建DivTop 最上信息层
var DivTop        = document.createElement("div");
with(DivTop.style)
{
        display = "none";
        zIndex = 3;
        position = "absolute";
        border = "0px";        
}
DivTop.id = "tLogBox";

body.appendChild(DivTop);

var boxCon = boxCon1 + boxCon2 + boxCon3;
DivTop.innerHTML = boxCon;
//document.getElementById("tLogBox").innerHTML=boxCon;

//开始创建DivMid 中间半透明层
var DivMid        = document.createElement("div");
with(DivMid.style)
{
        display = "none";
        zIndex = 2;
        position = "absolute";
        height = "100%";
        width = "100%";
        top = 0;
        left = 0;
        border = "0px";
        backgroundColor = bgcolor;
}
DivMid.id = "LogBoxBg";
body.appendChild(DivMid);

function $(Id) { return document.getElementById(Id); }
function isIE()
{
        return (document.all && window.ActiveXObject && !window.opera) ? true : false;
}

function center(win)//将主窗口置于网页正中
{
        var s = parseInt(body.scrollTop + clientHeight/2 - height/2);
        win.style.top = (s<body.scrollHeight-height)?s:body.scrollHeight;
        var s = parseInt(body.scrollLeft + clientWidth/2 - width/2);
        win.style.left = (s<body.scrollWidth-width)?s:body.scrollWidth;
}

function dispLogbox(){

        with(body.style)//完全锁定背景层
        {
                width = clientWidth;
                height = clientHeight;
                overflow = "hidden";
        }
        with($('LogBoxBg').style)
        {
                width = bodyWidth;
                height = bodyHeight;
                overflow = "hidden";
                display = "";
                if (isIE()){
                        filter = " Alpha(Opacity="+trans+")";
                }else{
                        opacity = trans/100;
                }
                        
        }
        with($('tLogBox').style)
        {
                display = "";                
        }
        center($('tLogBox'));
        
}

function CloseLogbox(){
        with(body.style)
        {
                width = bodyWidth;
                height = bodyHeight;
                overflow = "auto";
        }
        with($('LogBoxBg').style)
        {
                display = "none";
        }
        with($('tLogBox').style)
        {
                display = "none";                        
        }
        
}