if (top.location !== self.location) {
 top.location=self.location;
}
try{
    tophref=top.location.href.toLowerCase();
    thishref=this.location.href.toLowerCase();
}catch(e){};
if(this != top && tophref!=null && tophref.indexOf("localhost") < 0 || thishref!=null && thishref.indexOf("localhost") < 0){
    try{    if(this != top && top.location.href.toLowerCase().indexOf("txsm.com") < 0 && top.location.href.toLowerCase().indexOf("txnsg.com") < 0 && top.location.href.toLowerCase().indexOf("fbook.net") < 0) top.location.href="http://www.fbook.net";}catch(e){};
    if (this.location.href.toLowerCase().indexOf("txsm.com") < 0 && top.location.href.toLowerCase().indexOf("fbook.net") < 0 && top.location.href.toLowerCase().indexOf("txnsg.com") < 0) {  
top.location.href = "http://www.fbook.net"
 }
}

function copyToClipboard(txt) {
　　if(window.clipboardData) {
　　window.clipboardData.clearData();
　　window.clipboardData.setData("Text", txt);
	alert('恭喜您！复制成功，您的推荐信息已经存入剪帖板，\n快使用鼠标的右键“粘帖”或键盘的ctrl+v将地址发送给好友吧！');
　　} else if(navigator.userAgent.indexOf("Opera") != -1) {
　　window.location = txt;
　　} else if (window.netscape) {
　　try {
　　netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
　　} catch (e) {
　　alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
　　}
　　var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
　　if (!clip)
　　return;
　　var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
　　if (!trans)
　　return;
　　trans.addDataFlavor('text/unicode');
　　var str = new Object();
　　var len = new Object();
　　var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
　　var copytext = txt;
　　str.data = copytext;
　　trans.setTransferData("text/unicode",str,copytext.length*2);
　　var clipid = Components.interfaces.nsIClipboard;
　　if (!clip)
　　return false;
　　clip.setData(trans,null,clipid.kGlobalClipboard);
　　}
}


function fucCheckNUM(NUM){
	var i,j,strTemp; 
	strTemp="0123456789"; 
	if(NUM.length==0) 
	return 0 
	for(i=0;i<NUM.length;i++){ 
		j=strTemp.indexOf(NUM.charAt(i)); 
		if(j==-1){
			return 0; 
		}
	} 
	return 1; 
}

function onlogin_bg(id){
	document.getElementById(id).className="login_FormFocus";
	document.getElementById(id).style.background="";
}

function setCookie(cookieName,cookieValue){
  var today = new Date();
  var expire = new Date();
  expire.setTime(today.getTime() + 3600000 * 356 * 24);
  document.cookie = cookieName+'='+escape(cookieValue)+ ";path= / ;"; 
}
function setCookies(cookieName,cookieValue){
  var today = new Date();
  var expire = new Date();
  expire.setTime(today.getTime() + 3600000 * 356 * 24);
  document.cookie = cookieName+'='+escape(cookieValue)+ ';expires = '+expire.toGMTString() + ";path= / ;"; 
}

function getCookie(cookieName){
	var theCookie=''+document.cookie;
	var ind=theCookie.indexOf(cookieName);
	if (ind==-1 || cookieName=='') return ''; 
	var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length;
	return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function arouseFocus(varname){
	document.getElementById(varname).focus();  
}
function requestURL(string){
	var url = decodeURI(location.href);
	var url = url.toLowerCase();
	string = string.toLowerCase();
	if(url.indexOf(string)<1) return false;
	var urlA = url.split(string + "=");
	if(urlA[1].indexOf("&") >= 0){
		var urlB = urlA[1].split("&");
		return urlB[0];
	}else{
		var urlB = urlA[1];
		return urlB;
	}
}
function bookFavorites(x,y){
	if(x.length>0){
		x = "http://www.fbook.net/bookintro/"+x+".htm";
		var title = bookname + " - 天下书盟,小说阅读,玄幻小说,网游小说,武侠小说,言情小说,小说下载";
	}else if(x==""){
		x = location.href;
		var title = "天下书盟,小说阅读,玄幻小说,网游小说,武侠小说,言情小说,小说下载";
	}
	switch(y){
		case "favorites":
			window.external.AddFavorite(x,title)
			break;
		case "default":
			document.body.style.behavior='url(#default#homepage)';
			document.body.setHomePage(x);
		break;
	}
}
function readNode(bookid,articleid){
	if(bookid!="" && articleid!=""){
		window.open("/vip/vipRead.asp?articleid="+articleid+"&bookid="+bookid);
	}
}
function readvip_baoyue(bookid){
	if(bookid!=""){
		window.open("/baoyue_vip/vipRead.asp?bookid="+bookid);
	}
}
function addRack(){
	window.open("/shareadd.asp?bookid="+bookid)	
}
function readAll(){
	window.open("http://readall.fbook.net/"+bookid+".htm")	
}
var menuTimer =null;
function showmenu(state){
	
	var obj1 = "downbookBut"
	var obj2 = "downbookMenu"
	var location = "bottom";
	
    var btn=document.getElementById(obj1);
    var obj=document.getElementById(obj2);
    var h=btn.offsetHeight;
    var w=btn.offsetWidth;
    var x=btn.offsetLeft;
    var y=btn.offsetTop;
    obj.onmouseover =function(){
        showmenu(obj1,obj2,'show',location);
    }
    obj.onmouseout =function(){
        showmenu(obj1,obj2,'hide',location);
    }
    while(btn=btn.offsetParent){y+=btn.offsetTop;x+=btn.offsetLeft;}
    var hh=obj.offsetHeight;
    var ww=obj.offsetWidth;
    var xx=obj.offsetLeft;//style.left;
    var yy=obj.offsetTop;//style.top;
    var obj2state=state.toLowerCase();
    var obj2location=location.toLowerCase();
    var showx,showy;
    if(obj2location=="left" || obj2location=="l" || obj2location=="top" || obj2location=="t" || obj2location=="u" || obj2location=="b" || obj2location=="r" || obj2location=="up" || obj2location=="right" || obj2location=="bottom"){
        if(obj2location=="left" || obj2location=="l"){showx=x-ww;showy=y;}
        if(obj2location=="top" || obj2location=="t" || obj2location=="u"){showx=x;showy=y-hh;}
        if(obj2location=="right" || obj2location=="r"){showx=x+w;showy=y;}
        if(obj2location=="bottom" || obj2location=="b"){showx=x;showy=y+h;}
    }else{ 
        showx=xx;showy=yy;
    }
    obj.style.left=showx+"px";
    obj.style.top=showy+1+"px";
    if(state =="hide"){
		//hiddenmenu()
        menuTimer =setTimeout("hiddenmenu()", 500);
    }else{
        clearTimeout(menuTimer);
        obj.style.visibility ="visible";
    }
}
function hiddenmenu(){
    document.getElementById("downbookMenu").style.visibility ="hidden";
}
function downBook(){}
function readChapter(bookid,chapterid){
	window.open("/read/readChapter.asp?bookid="+bookid+"&chapterid="+chapterid);
}
//ajax处理
function fbook_ajax() {
	this.init = function() {
		this.handler = null;
		this.method = "POST";
  		this.queryStringSeparator = "?";
		this.argumentSeparator = "&";
		this.URLString = "";
		this.encodeURIString = true;
  		this.execute = false;
		this.requestFile = null;
		this.vars = new Object();
		this.responseStatus = new Array(2);
		this.failed = false;
		this.response = "";
		this.asynchronous = true;

		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onComplete = function() { };
  		this.onError = function() { };
		this.onFail = function() { };

		try {
			this.handler = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.handler = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				this.handler = null;
			}
		}

		if (! this.handler) {
			if (typeof XMLHttpRequest != "undefined") {
				this.handler = new XMLHttpRequest();
			} else {
				this.failed = true;
			}
		}
  	};
	this.setVar = function(name, value, encoded){
		this.vars[name] = Array(value, encoded);
	};
	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	};
	this.processURLString = function(string, encode) {
		//regexp = new RegExp(this.argumentSeparator + "|" + encodeURIComponent(this.argumentSeparator));
		regexp = new RegExp(this.argumentSeparator);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1], false);
			} else {
				this.setVar(urlVars[0], urlVars[1], true);
			}
		}
	};
	this.createURLString = function(urlstring) {
		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}
		this.setVar("ajax_request", new Date().getTime(), false);
		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}
			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	};
	this.runResponse = function() {
		eval(this.response);
	};
	this.runAJAX = function(urlstring) {
		if (this.failed) {
			this.onFail();
		} else {
			if(this.requestFile.indexOf(this.queryStringSeparator) > 0){
				var spoint = this.requestFile.indexOf(this.queryStringSeparator);
				this.processURLString(this.requestFile.substr(spoint + this.queryStringSeparator.length), false);
				this.requestFile = this.requestFile.substr(0, spoint);
			}
			this.createURLString(urlstring);
			if (this.handler) {
				var self = this;
				
				if (this.method == "GET") {
					totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
					this.handler.open(this.method, totalurlstring, this.asynchronous);
				} else {
					this.handler.open(this.method, this.requestFile, this.asynchronous);
					try {
						this.handler.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					} catch (e) { }
				}

				this.handler.onreadystatechange = function() {
					switch (self.handler.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							self.response = self.handler.responseText;
							self.responseXML = self.handler.responseXML;
							self.responseStatus[0] = self.handler.status;
							self.responseStatus[1] = self.handler.statusText;

							if (self.execute) {
								self.runResponse();
							}

							if (self.responseStatus[0] == "200") {
								self.onComplete();
							} else {
								self.onError();
							}

							self.URLString = "";
							break;
					}
				}
				this.handler.send(this.method == "GET" ? null : this.URLString);
			}
		}
	};
	this.submitForm = function(form) {
		if(this.requestFile == null) this.requestFile = $(form).attributes["action"].value;
		this.runAJAX(Form.serialize(form));
	};
	this.init();
}

		
		var Ajax = {
	Request	: function(vname, vars){
		var ajax = new fbook_ajax();
		var param = {method:"",parameters:"",asynchronous:true,onLoading:function(){},onLoaded:function(){},onInteractive:function(){},onComplete:function(){},onError:function(){},onFail:function(){}};
		for (var key in vars) param[key] = vars[key];
		if(param["parameters"] != "") ajax.processURLString(param["parameters"], false);
		ajax.asynchronous = param["asynchronous"];
		ajax.onLoading = param["onLoading"];
		ajax.onLoaded = param["onLoaded"];
		ajax.onInteractive = param["onInteractive"];
		ajax.onError = param["onError"];
		ajax.onFail = param["onFail"];
		ajax.onComplete = param["onComplete"];
		if($(vname) != null && $(vname).tagName.toLowerCase() == "form"){
			ajax.method = param["method"]=="" ? "POST" : param["method"];
			ajax.submitForm(vname);
		}else{
			ajax.method = param["method"]=="" ? "GET" : param["method"];
			ajax.requestFile = vname;
			ajax.runAJAX();
		}
	},
	Update : function(vname, vars){
		var param = {outid:"",tipid:"",onLoading:"", outhide:0, cursor:"wait", parameters:""};
		for (var key in vars) param[key] = vars[key];

		var isform = ($(vname) != null && $(vname).tagName.toLowerCase() == "form") ? true : false;

		if(typeof param["onLoading"] == 'function'){
			var doLoading = param["onLoading"];
		}else{
			var doLoading = function(){
				if(param["cursor"] != "") document.body.style.cursor=param["cursor"];
				if(param["tipid"] != "") {$(param["tipid"]).setValue(param["onLoading"]);$(param["tipid"]).show();}
				if(isform) Form.disable(vname);
			}
		}
		var doComplete = function(){
			if(param["cursor"] != "") document.body.style.cursor="auto";
			if(param["tipid"] != "") {$(param["tipid"]).setValue("");$(param["tipid"]).hide();}
			if(param["outid"] != "") {$(param["outid"]).setValue(this.response);$(param["outid"]).show();}
			if(param["outhide"] != "") {setTimeout(function(){$(param["outid"]).hide()},param["outhide"]);}
			if(isform) Form.enable(vname);
		}
		var doError = function(){
			if(param["outid"] != "")  $(param["outid"]).setValue("ERROR:"+this.responseStatus[1]+"("+this.responseStatus[0]+")");
			if(isform) Form.enable(vname);
		}
		var doFail = function() {
			alert("Your browser does not support AJAX!");
			if(isform) Form.enable(vname);
		}
		
		Ajax.Request(vname, {onLoading:doLoading, onComplete:doComplete, onError:doError, onFail:doFail, parameters:param["parameters"]});
	},
	Tip : function(event, url, timeout){
		event = event ? event : (window.event ? window.event : null);
		timeout = timeout ? timeout : 3000;
		var eid = event.srcElement ? event.srcElement.id : event.target.id;
		var tid = eid + "_tip";
		var ele = $(eid);
		var pos = ele.getPosition();
		var atip  = $(tid);
		if(!atip) {
			atip = document.createElement("div");
			atip.id = tid;
			atip.style.display = "none";
			atip.className = "ajaxtip";
			document.body.appendChild(atip);
			atip.onclick = function(){$(tid).hide();};
		}
		atip.style.top = (pos.y + ele.offsetHeight + 2)  + "px";
		atip.style.left = pos.x + "px";
		atip.innerHTML = "";
		atip.style.display="";
		this.Update(url, {outid:tid, tipid:tid, onLoading:"Loading...", outhide:timeout, cursor:"wait"});
	}
}

document.write('<script src="http://pstatic.xunlei.com/js/webThunderDetect.js"></script><script src="http://pstatic.xunlei.com/js/base64.js"></script>');
