function GetObj(id){return document.getElementById(id);}
function SubmitKeyClick(keyEvent,ControlId){if(keyEvent.keyCode == 13){keyEvent.returnValue = false;GetObj(ControlId).click();}}
function checkKey()
{
	GetObj("sKey").value = escape(GetObj("tKey").value);
	return true;
}
function AddToShuoJia(xsid)
{
	var uid = get_cookie("uid");
	if(uid==null || uid=="")
	{
		if(confirm('书架功能需要登录才能使用，现在去登录吗？'))
		{
			window.location = 'http://www.duzhe123.com/login.aspx?furl='+escape(window.location.toString());
		}
		else
		{
			return;
		}
	}
	var datas = "xsid=" + xsid;
	jQuery.ajax({
	url: '/AjaxServer/AddToShuoJia.aspx', 
	data: datas, 
	type: 'POST',
	beforeSend: function() {
		
	},
	error: function(request) {
		alert('放入书架失败！');
	},
	success: function(data) {
		if(data == "" || data == null)
		{
			if(confirm('成功放入您的首席书架，您也可以方便地移动到其他书架，现在要去书架看看吗？'))
			{
				window.location = 'http://www.duzhe123.com/bookcase.aspx';
			}
		}
		else
		{
			var strs = data.split('$');
			if(confirm(strs[1]+"现在要去书架看看吗？"))
			{
				window.location = 'http://www.duzhe123.com/bookcase.aspx?bid='+strs[0];
			}
		}
	}
	});
}

function vote(xsid)
{
	
}

function jubao(xsid)
{
	
}

function login()
{
	if(GetObj("username") && GetObj("password") && GetObj("savetype"))
	{
		var email = GetObj("username").value;
		var pwd = GetObj("password").value;
		var savetype = GetObj("savetype").value;
		var datas = "email=" + escape(email);
		datas = datas + "&" + "pwd=" + escape(pwd);
		datas = datas + "&" + "savetype=" + savetype;
		jQuery.ajax({
		url: '/AjaxServer/login.aspx', 
		data: datas, 
		type: 'POST',
		beforeSend: function() {
			GetObj("lableTs").innerHTML ="&nbsp;<img src=\"http://www.duzhe123.com/image/loading.gif\" />";
		},
		error: function(request) {
			GetObj("lableTs").innerHTML = "失败,<a href=\"http://www.duzhe123.com/GetPassWord.aspx\">忘记密码了?</a>";
		},
		success: function(data) {
			var uid = get_cookie("uid");
			var uname = get_cookie("uname");
			if(uid == "" || uname =="")
			{
				document.getElementById("spLoginKuan").style.display="";	
			}
			else
			{
				document.getElementById("spLoginKuan").style.display="none";
				GetObj("lableTs").innerHTML = "";
				
				document.getElementById("spUserKuan").style.display="";
				var content = "欢迎书友：<a href=\"http://www.duzhe123.com/panel.aspx\">"+uname+"</a>，您可以进入：<a href=\"http://www.duzhe123.com/panel.aspx\">用户面板</a> | <a href=\"http://www.duzhe123.com/bookcase.aspx\">我的书架</a> | <a href=\"http://www.duzhe123.com/logout.aspx\">退出登录</a>";
				document.getElementById("spUserKuan").innerHTML = content;
			}
		}
		});
	}
	
}

function getTop(e) {
	var offset = e.offsetTop;
	if (e.offsetParent != null){ offset += getTop(e.offsetParent);}
	return offset;
}

function getLeft(e) {
	var offset = e.offsetLeft;
	if (e.offsetParent != null) offset += getLeft(e.offsetParent);
	return offset;
}

function ShowPanel(objE,panelID,msg,width)
{
	GetObj(panelID).innerHTML = msg;	
	GetObj(panelID).style.top = (getTop(objE)+objE.offsetHeight) + "px";
	GetObj(panelID).style.left = (getLeft(objE)+objE.offsetWidth) + "px";
	GetObj(panelID).style.display = "block";
	GetObj(panelID).style.width = width + "px";
}

function HiddenPanel(panelID)
{
	GetObj(panelID).innerHTML = "";
	GetObj(panelID).style.display = "none";
}

<!--cookie access begin-->
function SetCookie(name,value)
{
	var argv=SetCookie.arguments;
    var argc=SetCookie.arguments.length;
    var expires=(2<argc)?argv[2]:null;
    var path=(3<argc)?argv[3]:null;
    var domain=(4<argc)?argv[4]:null;
    var secure=(5<argc)?argv[5]:false;
    document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}

function set_cookie(name,value,expireday)
{
	var expdate=new Date();
	expdate.setTime(expdate.getTime()+(24*60*60*1000*expireday));
	SetCookie(name,value,expdate,"/");
}

function get_cookie(cookie_name){
	var cookie_pos = document.cookie.indexOf(cookie_name); 
	// 如果找到了索引，就代表cookie存在，反之，就说明不存在。 
	if (cookie_pos != -1)
	{ 
		// 把cookie_pos放在值的开始，只要给值加1即可。 
		cookie_pos += cookie_name.length + 1; 
		var cookie_end = document.cookie.indexOf(";", cookie_pos); 
		if (cookie_end == -1)
		{ 
			cookie_end = document.cookie.length; 
		} 

		return decodeURIComponent(document.cookie.substring(cookie_pos,cookie_end)); 
	} 
	return ""; 
}  
<!--cookie access end -->

function SetHome(obj,vrl)
{
    try
    {
        obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
    }
    catch(e)
    {
        if(window.netscape)
        {
            try
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e)
            {
                alert("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage',vrl);
        }
    }
}

function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
		try
		{
			window.sidebar.addPanel(sTitle, sURL, ""); 
		}
		catch (e)
		{
			alert("加入收藏夹失败，请您按快捷键CTRL + D来添加。");
		}
    }
}

function postcomment(obj,xsid)
{
	var uid = get_cookie("uid");
	if(uid==null || uid=="")
	{
		if(confirm('只有登录以后才能发表书评，现在去登录吗？'))
		{
			window.location = 'http://www.duzhe123.com/login.aspx?furl='+escape(window.location.toString());
			return;
		}
		else
		{
			return;
		}
	}
	var data = "<table width=\"450\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>  <td width=\"60\" height=\"35\" align=\"right\">标题：</td>  <td align=\"left\"><input type=\"text\" name=\"shupingName\" id=\"shupingName\" style=\"width:350px; line-height:20px; font-size:12px;\" /></td></tr><tr>  <td height=\"110\" align=\"right\">内容：</td>  <td align=\"left\"><textarea name=\"shupingContent\" id=\"shupingContent\" style=\"width:350px; line-height:20px; height:100px; font-size:12px;\"></textarea></td></tr><tr>  <td height=\"25\" align=\"right\">&nbsp;</td>  <td align=\"left\"><a href=\"http://www.duzhe123.com/shuping/all.aspx?xid="+xsid+"\" target=\"_blank\">查看其他网友对小说的评论</a> <span id=\"postshupingts\"></span></td></tr></table>";
	ShowAllFeaturePoP(obj,'发表书评',data,'发表书评','RealPostComment('+xsid+')','取 消','PoPCancel()',500);
}

function RealPostComment(xsid)
{
	var title = GetObj("shupingName").value;
	var content = GetObj("shupingContent").value;
	if(title == "" || title ==null)
	{
		alert("标题不能为空！");
		return;
	}
	if(content == "" || content ==null)
	{
		alert("内容不能为空！");
		return;
	}
	var datas = "xsid="+xsid;
	datas+="&sptitle=" + escape(title);
	datas+="&spcontent=" + escape(content);
	jQuery.ajax({
	url: '/AjaxServer/PostShuPin.aspx', 
	data: datas, 
	type: 'POST',
	beforeSend: function() {
		GetObj("postshupingts").innerHTML = "<img src=\"/image/loading.gif\" /> 正在提交书评...";
	},
	error: function(request) {
		ShowTsPoP("发表书评","对不起发表书评失败。",2000,500);
	},
	success: function(data) {
		GetObj("postshupingts").innerHTML = "";
		if(data == "notlogin")
		{
			if(confirm('只有登录以后才能发表书评，现在去登录吗？'))
			{
				var url = escape(window.location);
				window.location = "http://www.duzhe123.com/login.aspx?furl=" + url;
				return;
			}
		}
		if(confirm('恭喜，评论成功！要查看该小说所有的评论吗？'))
		{
			window.location = "http://www.duzhe123.com/shuping/all.aspx?xid="+data;
		}
		else
		{
			PoPCancel();
		}
	}
	});
	
}
function gosearch()
{
	var stype = GetObj("stype").value;
	var skey = GetObj("skey").value;
	skey = skey.replace(/^\s+|\s+$/g,"");
	if(skey == "")
	{
		alert("请输入搜索的关键字！");
		return;
	}
	//skey = escape(skey);
	window.location = "/ebook/"+stype+"/"+skey+"/";
}

