	var gotourl;
	var gototarget;
	function showLogin(tourl, totarget)// showLogin Box method
	{ 
		if(readCookie() && tourl != ''){ 
			if (tourl == "#") {
				return;
			}
			if (totarget == "blank") {
				//window.open(tourl);
				//window.force(tourl);
				openWindow(tourl);
				//window.alert(tourl);
			}
			else {
				window.location = tourl;
			}
			//window.location = tourl;
		}
		else {
			if (!readCookie()) {
				gotourl = tourl;
				gototarget = totarget;
				screenDark();		
				$('menu-div').style.display = "block";
				var x =(document.body.clientWidth-$('menu-div').offsetWidth)/2;		
				var y =(document.body.clientHeight-$('menu-div').offsetHeight)/2+document.body.scrollTop;
				$('menu-div').style.position = "absolute";
				$('menu-div').style.left = x;
				$('menu-div').style.top = y;	
				$('menu-div').style.zIndex = "1000";
				change_style('select', 'hidden');
				if (tourl != '') {
					$('loginInfo').style.display = "block";
					$('loginInfo').innerHTML = "<font color=red><b>您还没有登录，请先登录</b></font>";
				}
				$('username').focus();
			}
			else {
				if (tourl == "#" || tourl == "") {
					return;
				}
				else {
					if (totarget == "blank") {
						//window.open(tourl);
						//window.force(tourl);
						openWindow(tourl);
						//window.alert(tourl);
					}
					else {
						window.location = tourl;
					}
				}
			}
		}
	}
	
function screenDark()
{
	if ($('screen')) {
		var screen = $('screen');
	}
	if (!screen) {
		var screen = document.createElement("div");
		document.body.appendChild(screen);
	}
		//screen.style.position="relative";
		screen.id = "screen";
		screen.style.cssText = "position:absolute;top:0px;left:0px;background:#000;";
		screen.style.width = document.body.offsetWidth +"px";
		//screen.style.height = document.body.offsetHeight +"px";
		screen.style.height = document.body.scrollHeight;
		screen.style.zIndex = "100";
		if(document.all){
			screen.style.filter='Alpha(Opacity=45)';
		}else{
			screen.style.MozOpacity='0.45'
		}
}

function closeLog(box)
{
		if ($('loginInfo')) {
			$('loginInfo').style.display = "none";
		}
		if ($('passwd')) {
			$('passwd').value = '';
		}
		$(box).style.display='none';	
		change_style('select', 'visible');
}

var gTimer;
var gTimes = 0;

function checkLogonForm(frm) 
{
	if(frm.username.value.length <= 0){
		alert("请填写用户名");
		frm.username.focus();
		return false;
	}
	if (frm.passwd.value.length <= 0) 	{
		alert("请填写密码");
		frm.passwd.focus();
		return false;
	}
	frm.loginid.value = frm.username.value + frm.maildomain.value;
	gTimer = window.setInterval("getLoginResult()", 500);
	if ($('loginInfo')) {
		$('loginInfo').style.display = "none";
	}
	if ($('notice')) {
		$('notice').style.visibility = "visible";
	}
	if ($('loginForm')) {
  	$('loginForm').style.display = "none";
  }
	//getLoginResult();
	return true;
}

function checkLogonFormHeader(frm)
{
	if(frm.username.value.length <= 0){
		alert("请填写用户名");
		frm.username.focus();
		return false;
	}
	if (frm.passwd.value.length <= 0) 	{
		alert("请填写密码");
		frm.passwd.focus();
		return false;
	}
	frm.loginid.value = frm.username.value + frm.maildomain.value;
	
	gTimer = window.setInterval("getLoginResultHeader()", 500);
	$('loginForm').style.display = "none";
	$('loginInfo').style.display = "block";
	$('notice').innerHTML = "<b><font color=\"#008000\">正在为您登录......</font></b>";
  return true;
	//getLoginResult();
}


function dGetCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function getLoginResult()
{
	gTimes++;
	//超时处理
  if (gTimes >= 10) {
  	if (gTimer) {
  		window.clearInterval(gTimer);
  	}
  	showLoginError("网络超时，请稍后再试");
  	return;
  }
  var loginResult = dGetCookie('loginResult');
  if (loginResult != "") {
  	//dSsetCookie("loginResult", "", -1);
  	if (gTimer) {
  		window.clearInterval(gTimer);
  	}
  	if (loginResult == "ok") {
  			//登录成功
  		showSuccessInfo();
  	}
  	else if (loginResult == 1) {
  		showLoginError("用户名不存在");
  	}
  	else if (loginResult == 2) {
  		showLoginError("用户名或密码错误");
  	}
  	else if (loginResult == 3) {
  		showLoginError("您还没有激活，请先<a href='http://club.sohu.com/reg_step1_auth.php?back="+window.location.href+"' target=_top>激活您的社区账户</a>");
  	}
  	else if (loginResult == 4) {
  		showLoginError("您已经被网管禁止登陆");
  	}
  	else {
  		showLoginError("系统忙，请稍后再试");
  	}
  }
}

function getLoginResultHeader()
{
	gTimes++;
	//超时处理
  if (gTimes >= 10) {
  	if (gTimer) {
  		window.clearInterval(gTimer);
  	}
  	showLoginErrorHeader("网络超时，请稍后再试");
  	return;
  }
  var loginResult = dGetCookie('loginResult');
  if (loginResult != "") {
  	//dSsetCookie("loginResult", "", -1);
  	if (gTimer) {
  		window.clearInterval(gTimer);
  	}
  	if (loginResult == "ok") {
  			//登录成功
  		showSuccessInfoHeader();
  	}
  	else if (loginResult == 1) {
  		showLoginErrorHeader("用户名不存在");
  	}
  	else if (loginResult == 2) {
  		showLoginErrorHeader("用户名或密码错误");
  	}
  	else {
  		showLoginErrorHeader("系统忙，请稍后再试");
  	}
  }
  //else window.alert('space');
  //window.alert('space');
}

function showLoginError(str)
{
	//window.alert(str);
	$('notice').style.visibility = "hidden";
  $('loginForm').style.display = "block";
  $('loginInfo').style.display = "block";
  $('loginInfo').innerHTML = "<font color=red><b>"+str+"</b></font>";
}

function showLoginErrorHeader(str)
{
	//window.alert(str);
  $('loginForm').style.display = "block";
  $('loginInfo').style.display = "block";
  $('notice').innerHTML = "<font color=red><b>"+str+"</b></font>";
}

function showSuccessInfo()
{
	$('notice').style.visibility = "hidden";
  $('loginInfo').style.display = "block";
  $('loginInfo').innerHTML = "<font color=green><b>登录成功</b></font>";
  window.setTimeout('closedialog()', 1000);
  change_button();
  if (gotourl != "" && gotourl != "huitie") {
  	if (gototarget == "blank") {
  		//window.open(gotourl);
  		//window.location.reload();
  		//window.force(tourl);
  		openWindow(gotourl);
  	}
  	else {
  		window.location = gotourl;
  	}
  }
  else if (gotourl == "huitie") {
  	document.data_form.submit();
  }
}

function showSuccessInfoHeader()
{
	var unick = c.getClubCookie('Unick');
	var logouturl = "http://passport.sohu.com/logout.jsp?ru=http://club.sohu.com/logout.php?go="+window.location.href;
	$('welcomeinfo').innerHTML = unick+' 你好&nbsp;<a href="'+logouturl+'">[退出]</a>';
  $('loginInfo').style.display = "block";
  $('notice').innerHTML = "<font color=green><b>登录成功</b></font>";
  $('menu-div').style.display = "none";
  
  //window.setTimeout('closedialog()', 1000);
  //change_button();
}

function change_style(c_tagname, c_property)
{
	var obj = document.getElementsByTagName(c_tagname);
	for (var i=0; i<obj.length; i++)
	{
		if (obj[i].id != 'maildomain') {
			obj[i].style.visibility = c_property;
		}
	}
}

function closedialog()
{
	closeLog('menu-div');
  closeLog('screen');
}

function change_button()
{
	//$('larea').style.display = "block";
	//$('ularea').style.display = "none";
	if($('ularea')) {
		$('ularea').innerHTML = larea;
	}
	if ($('ularea1')) {
		$('ularea1').innerHTML = larea;
	}
}


function openWindow(openurl)
{
	if ($('tmpform')) {
		removeElement($('tmpform'));
	}
	if(!$('tmpform')) {
		var tmpform = document.createElement("form");
		document.body.appendChild(tmpform);
		tmpform.id = "tmpform";
		tmpform.method = "post";
		tmpform.target = "_blank";
		//openurl = openurl.replace("@", "%40");
		tmpform.action = openurl;
		tmpform.submit();
	}
}

function removeElement(el)
{   
 	var p = el.parentNode;   
  p.removeChild(el);   
}