﻿function loginbox()
    {
        var ly = document.getElementById("ly");
        var Layer1 = document.getElementById("Layer_login");
    	
        Layer1.innerHTML = '<table width="340" border="0" cellpadding="0" cellspacing="0" style="border: 0   solid   #e7e3e7;border-collapse: collapse"><tr><td style="background:url(../images/button_bg.gif); color: #3399CC; padding-left: 4px; font-weight:bold; font-size: 12px;" height="27" valign="middle" align="left">&nbsp;用户登录&nbsp;</td></tr><tr><td height="70" align="center" style="color:#FF6600; font-size:20px; font-weight: bold;"><iframe frameBorder="0" id="login_panel" name="login_panel" scrolling="no" src="http://bank.comicfans.net/inc/login_panel.asp" style="HEIGHT: 120px; VISIBILITY: inherit; WIDTH: 320px; Z-INDEX: 1"></iframe></td></tr></table>';
    	
        ly.style.display="block";
        ly.style.width=document.body.scrollWidth;     
        ly.style.height=document.body.scrollHeight; 
        Layer1.style.top=document.body.scrollTop+(window.screen.height-370)/2;
        document.getElementById("Layer_login_bd").style.display='block';
        Layer1.style.display='block';
    }
    
    function regbox()
    {
        var ly = document.getElementById("ly");
        var Layer1 = document.getElementById("Layer_reg");
    	
        Layer1.innerHTML = '<table width="634" border="0" cellpadding="0" cellspacing="0" style="border: 0   solid   #e7e3e7;border-collapse: collapse"><tr><td style="background:url(../images/button_bg.gif); color: #3399CC; padding-left: 4px; font-weight:bold; font-size: 12px;" height="27" valign="middle" align="left">&nbsp;用户注册&nbsp;</td></tr><tr><td height="664" align="center" style="color:#FF6600; font-size:20px; font-weight: bold;"><iframe frameBorder="0" id="login_panel" name="login_panel" scrolling="no" src="http://bank.comicfans.net/inc/regist.asp" style="HEIGHT: 664px; VISIBILITY: inherit; WIDTH: 630px; Z-INDEX: 1"></iframe></td></tr></table>';
    	
        ly.style.display="block";
        ly.style.width=document.body.scrollWidth;     
        ly.style.height=document.body.scrollHeight; 
        //Layer1.style.top=document.body.scrollTop+(window.screen.height-370)/2;
        document.getElementById("Layer_reg_bd").style.display='block';
        Layer1.style.display='block';
    }
    
//漫豆卡充值完成
function recharge_card_box_complete(message)
{
    var ly = document.getElementById("ly");
    var Layer1 = document.getElementById("Layer1");
	
    Layer1.innerHTML = '<table width="540" border="0" cellpadding="0" cellspacing="0" style="border: 0   solid   #e7e3e7;border-collapse: collapse"><tr><td style="background:url(../images/button_bg.gif); color: #3399CC; padding-left: 4px; font-weight:bold; font-size: 12px;" height="27" valign="middle" align="left">&nbsp;温馨提示&nbsp;</td></tr><tr><td height="70" align="center" style="color:#FF6600; font-size:20px; font-weight: bold;">'+message+'</td></tr><tr><td height="50" align="center" valign="top"><input type="button" value="确  定" onClick="iframereload()" Class="button"></td></tr></table>';
	
    ly.style.display="block";
    ly.style.width=parent.document.body.scrollWidth     
    ly.style.height=parent.document.body.scrollHeight; 
    Layer1.style.top=parent.document.body.scrollTop+(window.screen.height-370)/2;
    parent.document.getElementById("Layer1_bd").style.display='block';
    Layer1.style.display='block';
}
    
    function GetXmlHttpObject(handler)
    { 
	    var objXmlHttp=null
	    if (navigator.userAgent.indexOf("Opera")>=0)
	    {
		    alert("This example doesnt work in Opera");
		    return; 
	    }
	    if (navigator.userAgent.indexOf("MSIE")>=0)
	    { 
		    var strName="Msxml2.XMLHTTP";
		    if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		    {
			    strName="Microsoft.XMLHTTP";
		    } 
		    try
		    { 
			    objXmlHttp=new ActiveXObject(strName);
			    objXmlHttp.onreadystatechange=handler;
			    return objXmlHttp;
		    } 
		    catch(e)
		    { 
			    alert("Error. Scripting for ActiveX might be disabled"); 
			    return;
		    } 
	    } 
	    if (navigator.userAgent.indexOf("Mozilla")>=0)
	    {
		    objXmlHttp=new XMLHttpRequest();
		    objXmlHttp.onload=handler;
		    objXmlHttp.onerror=handler; 
		    return objXmlHttp;
	    }
    }
    
    function getUserInfo()
    {
	    var url="../inc/Ajax.asp?action=getuserinfo";
	    xmlHttp=GetXmlHttpObject(getResult);
	    xmlHttp.open("POST", url , false);
	    xmlHttp.send(null);
    }
    
    function getalbumcount()
    {
        var url="../inc/Ajax.asp?action=getalbumcnt";
	    xmlHttp=GetXmlHttpObject(getResult);
	    xmlHttp.open("POST", url , false);
	    xmlHttp.send(null);
    }
    
    function logout()
    {
        var url="../inc/Ajax.asp?action=logout";
	    xmlHttp=GetXmlHttpObject(getResult);
	    xmlHttp.open("POST", url , false);
	    xmlHttp.send(null);
    }
    
    function checklogin(flag)
    {
        var url="../inc/Ajax.asp?action=checklogin"+flag;
	    xmlHttp=GetXmlHttpObject(getResult);
	    xmlHttp.open("POST", url , false);
	    xmlHttp.send(null);
    }
    
    function rechargebycard(id)
    {
        var url="../inc/Ajax.asp?action=rechgcardbycard&id="+id;
        xmlHttp=GetXmlHttpObject(getResult);
        xmlHttp.open("POST", url , false);
        xmlHttp.send(null);
    }
    
    function getResult() 
    { 
	    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	    { 
		    var result = xmlHttp.responseText;
		    var resultarray=result.split("|||");　
		    var resultstr=resultarray[0];
		    var username=resultarray[1];
		    if(resultstr=="getuserinfocomplete"){			
			    document.getElementById("userinfo_span").innerHTML = "<a href='#' onclick='logout();return false;'>退 出</a>&nbsp;&nbsp;|&nbsp;&nbsp;<font color='#FF0000'>"+username+"</font>";
			}else if(resultstr=="getalbumcountcomplete"){
			    document.getElementById("count_span").innerHTML = username;
			}else if(resultstr=="usernotlogin"){
			    document.getElementById("userinfo_span").innerHTML = "<a href='#' onclick='loginbox();return false;'>登 录</a>&nbsp;&nbsp;<a href='#' onclick='regbox();return false;'>注 册</a>";
//			    document.getElementById("userinfo_span").innerHTML = "<a href='#' onclick='loginbox();return false;'>登 录</a>";
			}else if(resultstr=="logoutcomplete"){
			    window.location.href="http://bank.comicfans.net";
			}else if(resultstr=="checklogin_mybank_complete"){
			    window.location.href="http://bank.comicfans.net/mybank/";
			}else if(resultstr=="checklogin_mandou_complete"){
			    window.location.href="http://bank.comicfans.net/mybank/?p=EBD39778D4C3724F71C17074C4C9E33F";
			}else if(resultstr=="checklogin_upload_complete"){
			    window.location.href="http://bank.comicfans.net/mybank/?p=0877C5E733446D8A2930E6B6264A45334A68D9D3C155EE1C";
			}else if(resultstr=="checklogin_fail"){
			    loginbox();
			}else if(resultstr=="alreadymark"){
			    alert("你今天已经评过了！");
			}else if(resultstr=="markcomplete"){
			    alert("评分成功！");
			}else if(resultstr=="alreadycollection"){
			    alert("你已经收藏过了！");
			}else if(resultstr=="collectioncomplete"){
			    alert("已成功收藏！");
			}else if(resultstr=="currentpwdpass"){
			    showcheckdiv('currentpwdcheckdiv',true,'密码正确！');
                document.getElementById("submitbtn").disabled = true;
            }else if(resultstr=="currentpwdnotpass"){
			    showcheckdiv('currentpwdcheckdiv',true,'当前密码错误！');
                document.getElementById("submitbtn").disabled = false;
            }else if(resultstr=="rechargebycardcomplete"){
		        recharge_card_box_complete(username);
		    }else{
			    alert("出错！\n"+result);
			    return false;
		    }
	    } 
    }