
<!--
//
    var flag = false;
    var Cookie = new Object();
    
    Cookie.getCookie = function(name){
    	var cookieArray = document.cookie.split("; ");
    	var cookie = new Object();
    	for(var i=0;i<cookieArray.length;i++){
    		var arr = cookieArray[i].split("=");
    		if(arr[0]==name)return decodeURI(arr[1]);
    	}
    	return "";
    }
    
    Cookie.setCookie = function(name,value,option){
    	var str = name+"="+encodeURI(value);
    	if(option){
    		if(option.expireDays){
    			var date = new Date();
    			var ms = option.expireDays*24*3600*1000;
    			date.setTime(date.getTime()+ms);
    			str+="; expires="+date.toGMTString();
    		}
    		if(option.path)str+="; path="+option.path;
    		if(option.domain)str+="; domain="+option.domain;
    		if(option.secure)str+="; true";
    	}
    	document.cookie=str;
    }
    
    Cookie.deleteCookie = function(name){
    	this.setCookie(name,"",{expireDays:-1});
    }
    
    Cookie.delCookie = function() {
    	var cookieArray = document.cookie.split("; ");
    	var cookie = new Object();
    	var date = new Date();
    	date.setTime(date.getTime()-10000);
    	for(var i=0;i<cookieArray.length;i++){
    		var arr = cookieArray[i].split("=");
	    	//this.setCookie(arr[0],"",{expireDays:-1});
	    	document.cookie=arr[0]+"; "+"expire="+date.toGMTString();
    	}
    }
    
    
    var userName="";
    userName = Cookie.getCookie("userName");
    var loginPhpUID = Cookie.getCookie("loginPhpUID");  
    if (userName!="" && loginPhpUID!="") flag = true;
    else flag = false;
//2008-11-6 add
    var userKind="";
    userKind = Cookie.getCookie("userKind"); 	
	//2011-1-12 add zxx
	var activate = getCookieval_r();
	function getCookieval_r() {
		if(document.cookie.indexOf("activate=")!=-1){
			var strs = document.cookie.split("activate=");
			if(strs.length>=2){
				return strs[1].substring(0,strs[1].indexOf(";"));
			}else{
				return "1";
			}
		}else{
			return "1";
		}
		
	}
	var activateurl = "";
    if(activate == "0"){
		activateurl = '<a href="http://user.du8.com/people/activate.do" title="成功激活增加3天vip阅读时间"><img src="http://www.du8.com/images_user/ad01.gif"/></a>&nbsp;';
	}
	//--end zxx
//    if(!flag)
//    {
//        window.location.href="top-1.html";
//    }

  function reloads(){
	  window.location.reload();
  }

	function logoutUser(){
    document.write('<iframe src="http://www.du8.com/delcookie.jsp" width="0" height="0" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" ></iframe>');
		
		//document.write("<object type='text/x-scriptlet' width='0'  height='0' data='http://www.du8.com/delcookie.jsp'></object>");
		//setTimeout("eval(parent).reloads()",500);
		
	}

    

  function showUserName()
  {
      document.write(userName);
  }
  
  function sethomepages(){
  	this.homepage.style.behavior="url(#default#homepage)";
  	this.homepage.sethomepage("http://www.du8.com/");
  	
//			this.style.behavior="url(#default#homepage)";
//			this.setHomePage("http://www.du8.com/");
//			return(false);
  }
//收藏，已改成投诉与建议
//  function setshoucang(){
//window.external.AddFavorite("http://www.du8.com/", "“书生读吧-电子书门户”/www.du8.com");
//  	}
  	
  	
//function QueryString(surl)
//{
//	if(surl==1){
//		surl = "http://user.du8.com/people/user/logout.jsp?fromURL=";
//	}else if(surl==2){
//		surl = "http://user.du8.com/people/user/login.jsp?fromURL=";
//	}
//	var sSource = String(window.document.location);
//	var sReturn = "";
//	var sQUS = "/";
//	var dot=".";
//	var iPos;
//	var iDot;
//	iPos = sSource.indexOf(sQUS)+2;
//	iDot = sSource.indexOf(dot);
//	var strQuery = sSource.substr(iPos, iDot - iPos);
//	sReturn = strQuery;
//	if (strQuery == -1){
//		return surl+"www";
//	}
//	return surl+sReturn;
//}
function QueryString(surl)
{
	if(surl==1){
		surl = "http://user.du8.com/people/logout.do?forward=";
	}else if(surl==2){
		surl = "http://user.du8.com/people/userlogin.do?forward=";
	}else if(surl==3){
		surl = "http://user.du8.com/people/regist.do?forward=";
	}
	var sSource = String(window.document.location);
	
   var sSource = encodeURI(utf16to8(sSource));
   for(var i=0;i<sSource.split('/').length+2;i++){
    sSource = sSource.replace("/","%2F");
   }
	
	return surl+encodeURI(sSource);
}

//////////////////////////////////////////////////////////
function utf16to8(str) {

    var out, i, len, c;

    out = "";

    len = str.length;

    for(i = 0; i < len; i++) {

 c = str.charCodeAt(i);

 if ((c >= 0x0001) && (c <= 0x007F)) {

     out += str.charAt(i);

 } else if (c > 0x07FF) {

     out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));

     out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));

     out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));

 } else {

     out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));

     out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));

 }

    }

    return out;

}

function utf8to16(str) {

    var out, i, len, c;

    var char2, char3;

    out = "";

    len = str.length;

    i = 0;

    while(i < len) {

 c = str.charCodeAt(i++);

 switch(c >> 4)

 {

   case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:

     // 0xxxxxxx

     out += str.charAt(i-1);

     break;

   case 12: case 13:

     // 110x xxxx   10xx xxxx

     char2 = str.charCodeAt(i++);

     out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));

     break;

   case 14:

     // 1110 xxxx  10xx xxxx  10xx xxxx

     char2 = str.charCodeAt(i++);

     char3 = str.charCodeAt(i++);

     out += String.fromCharCode(((c & 0x0F) << 12) |

        ((char2 & 0x3F) << 6) |

        ((char3 & 0x3F) << 0));

     break;

 }

    }

    return out;

}
//////////////////////////////////////////////////////////
   var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  //将Ansi编码的字符串进行Base64编码
   function encode64(input) {
      var output = "";
      var chr1, chr2, chr3 = "";
      var enc1, enc2, enc3, enc4 = "";
      var i = 0;

      do {
                 chr1 = input.charCodeAt(i++);
         chr2 = input.charCodeAt(i++);
         chr3 = input.charCodeAt(i++);

         enc1 = chr1 >> 2;
         enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
         enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
         enc4 = chr3 & 63;

         if (isNaN(chr2)) {
            enc3 = enc4 = 64;
         } else if (isNaN(chr3)) {
            enc4 = 64;
         }

         output = output + 
            keyStr.charAt(enc1) + 
            keyStr.charAt(enc2) + 
            keyStr.charAt(enc3) + 
            keyStr.charAt(enc4);
         chr1 = chr2 = chr3 = "";
         enc1 = enc2 = enc3 = enc4 = "";
      } while (i < input.length);

      return output;
   }

  //将Base64编码字符串转换成Ansi编码的字符串
   function decode64(input) {
      var output = "";
      var chr1, chr2, chr3 = "";
      var enc1, enc2, enc3, enc4 = "";
      var i = 0;
          
          if(input.length%4!=0)
          {
                    return "";
          }
      var base64test = /[^A-Za-z0-9\+\/\=]/g;
          if (base64test.exec(input))
          {
                    return "";
          }

      do {
         enc1 = keyStr.indexOf(input.charAt(i++));
         enc2 = keyStr.indexOf(input.charAt(i++));
         enc3 = keyStr.indexOf(input.charAt(i++));
         enc4 = keyStr.indexOf(input.charAt(i++));

         chr1 = (enc1 << 2) | (enc2 >> 4);
         chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
         chr3 = ((enc3 & 3) << 6) | enc4;
                 
                 output = output + String.fromCharCode(chr1);

         if (enc3 != 64) {
                        output+=String.fromCharCode(chr2);
         }
         if (enc4 != 64) {
                        output+=String.fromCharCode(chr3);
         }

         chr1 = chr2 = chr3 = "";
         enc1 = enc2 = enc3 = enc4 = "";

      } while (i < input.length);

      return output;
   }
  	
function fLoginFormSubmit()
{
  if (document.BookSearchForm.keyword.value == ""||document.BookSearchForm.keyword.value == '书名 作者 类别……'){
	document.BookSearchForm.keyword.focus();
	alert (" 请输入关键词");
	return false;
  }
	var searchkeys = new String();
	
	var strTmp = new String();
	strTmp = document.BookSearchForm.keyword.value;
	var iu, iuu,regArray=new Array("◎","■","●","№","↑","→","↓"+
         "!","@","#","$","%","^","&","*","(",")","\\","￥","/","[","]","？","~","`");  
	iuu=regArray.length;
					  for(iu=1;iu<=iuu;iu++){
							if (strTmp.indexOf(regArray[iu])!=-1){
								   alert("查询的关键字请不要包含：" + regArray[iu]);
								   return false;
							}
						}
	//document.BookSearchForm.action="http://s.du8.com/search/search.do?keyword="+searchkeys;
	window.open("http://s.du8.com/search/"+encodeURI(strTmp)+"/1.html");
	//document.location.href("http://s.du8.com/search/"+encodeURI(searchkeys)+"/1.html");
	return false;
}

Date.prototype.Format = function(fmt)
{
  var o = {
    "M+" : this.getMonth()+1,                 //月份
    "d+" : this.getDate(),                    //日
    "h+" : this.getHours(),                   //小时
    "m+" : this.getMinutes(),                 //分
    "s+" : this.getSeconds(),                 //秒
    "q+" : Math.floor((this.getMonth()+3)/3), //季度
    "S"  : this.getMilliseconds()             //毫秒
  };
  if(/(y+)/.test(fmt))
    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
  for(var k in o)
    if(new RegExp("("+ k +")").test(fmt))
  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
  return fmt;
}

function killErrors() {
return true;
}
window.onerror =killErrors;

function setFzCookie(name,value){//设置cookie
	var t = new Date();
	t.setTime(t.getTime()+1*3600000);
	document.cookie = name + "=" + value + ";expires=" + t.toGMTString()+";path=/;domain=du8.com";
}
function getCookieVal1(offset){//取得offset位置的cookie值
	var endstr = document.cookie.indexOf (";", offset);
	if(endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name){//取得名称为name的cookie值
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal1(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0) break;
	}
	return null;
}
function $(objId){
	return document.getElementById(objId);
}


document.write('<style>#login_area {width: 100%;height:29px;text-align:center;margin: auto;background-image: url(http://www.du8.com/images_z/login_area_bg.gif);}#top_login {width: 980px ;height:23px;margin: auto;padding-top:6px;color:#999;background:none !important;}#toploginarea{ width:100%; height:33px; background:url(http://www.du8.com/images_z/toploginbg.gif) repeat-x}#toplogin{ width:980px; margin:auto; padding:5px 0px 0px 0px;}.header{ height:85px; overflow:hidden; width:980px; margin:0 auto;}.logo{ width:112px; height:36px; margin-top:22px; float:left}.siteName{float:left; width:120px; font-size:28px; font:"黑体"; font-family:"黑体"; margin-top:25px}.topSearchArea{float:left; margin:23px 0 0 20px;}.siteName a{}.topSearch{border-top:1px solid #84a5ce; border-left:1px solid #84a5ce; border-right:1px solid #c1d2e7; border-bottom:1px solid #c1d2e7;background:#f7fbff;height:23px;width:300px;padding:5px 0 0 5px;font-size:14px;font-family:Arial;font:Arial;color:#666; width:370px}.searchBtn{height:30px; width:74px; background:url(http://www.du8.com/images_z/btn_search.gif); border:none; font-size:16px; text-align:left; padding-left:17px; cursor:pointer}.nav{ background:#0c3e84; height:25px; width:980px; margin:auto}.nav ul{}.nav ul li{ float:left; height:25px; line-height:25px; margin:0 10px}.nav ul li a{ font-size:14px; color:#fff; text-decoration:none; font-weight:bold}.nav ul li a:hover{ font-size:14px; color:#fff; text-decoration:none; font-weight:bold}.nav ul li a:visited{ font-size:14px; color:#fff; text-decoration:none; font-weight:bold}.nav ul li a:active{ font-size:14px; color:#fff; text-decoration:none; font-weight:bold}</style>');

function goLogouted(){
document.write('<!-- 登录-->');
document.write('<div id="login_area">');
document.write('  <div id="top_login">');
document.write('    <div class="leftdiv"><a href="javascript:window.location.href=QueryString(3)" target="_top">用户注册</a>　|　<a href="javascript:window.location.href=QueryString(2)" target="_top">用户登录</a>　|　<a href="http://share.du8.com/publish/loginPublish.vm">出版社登录</a></div>');
document.write('    <div class="rightdiv"><a onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'www.du8.com\');" href="#">设为首页</a>　|　<a href="#" onclick="window.external.AddFavorite(location.href,document.title);return false;">收藏当前页</a>　|　<a href="http://www.du8.com/download/index.html">书生阅读器下载</a>　|　<span id="jz_font_lang"></span></div>');
document.write('  </div>');
document.write('</div>');
document.write('<!--登录结束-->');
}


function goLogined(){
document.write('<!-- 登录-->');
document.write('<div id="login_area">');
document.write('  <div id="top_login">');
if (userKind == "unit")
document.write('    <div class="leftdiv"><font color="#FF0000"><span id="spanName" title="">' + userName + '</span></font>  您好　[ <a href="http://k.du8.com">查看我的收藏</a> ]　 [ <a href="http://bbs.du8.com/pm.php">短消息</a> ] 　[ <a href="javascript:window.location.href=QueryString(1)" target="_top">退出</a> ]</div>');
else
document.write('    <div class="leftdiv"><font color="#FF0000"><span id="spanName" title="">' + userName + '</span></font>  您好　[ <a href="http://user.du8.com" target="_parent">进入用户中心</a> ] 　[ <a href="http://k.du8.com">查看我的收藏</a> ]　 [ <a href="http://bbs.du8.com/pm.php">短消息</a> ] 　[ <a href="javascript:window.location.href=QueryString(1)" target="_top">退出</a> ]</div>');
document.write('    <div class="rightdiv"><a onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'www.du8.com\');" href="#">设为首页</a>　|　<a href="#" onclick="window.external.AddFavorite(location.href,document.title);return false;">收藏当前页</a>　|　<a href="http://www.du8.com/download/index.html">书生阅读器下载</a>　|　<span id="jz_font_lang"></span></div>');
document.write('  </div>');
document.write('</div>');
document.write('<!--登录结束-->');
}


if(flag)
    {
        goLogined();
    }
    else {
    	goLogouted();
    }



document.write('<!--登录结束--><div class="header"><div class="logo"><a href="http://www.du8.com"><img src="http://www.du8.com/images_z/k_logo_v2.gif"/></a></div><div class="siteName"><a href="http://k.du8.com" style=" text-decoration:none">快眼看书</a></div><div class="topSearchArea"><table border="0" cellpadding="0" cellspacing="2"><form action="" method="post" name="BookSearchForm" id="BookSearchForm" onsubmit="return fLoginFormSubmit();"><tr><td><input  name="keyword" type="text" class="topSearch" onfocus="if(this.value==\'书名 作者 类别……\')this.value=\'\';"   onblur="if(this.value==\'\')this.value=\'书名 作者 类别……\';"  value="书名 作者 类别……"/ ></td><td><input type="submit" name="button" id="button" value="搜书" class="searchBtn"/></td></tr></form></table></div></div><!--nav--><div class="nav"><ul><li><a href="http://www.du8.com/">读吧首页</a></li><li><a href="http://www.du8.com/channel/2_10010001_1.html">原味书屋</a></li><li><a href="http://www.du8.com/channel/3_10010001_1.html">新书尝鲜</a></li><li><a href="http://www.du8.com/wllx/index/1.shtml">网络流行</a></li><li><a href="http://vip.du8.com/">VIP专区</a></li><li><a href="http://s.du8.com/search/index.html">读吧搜书</a></li><li><a href="http://du8.cn/" target="_blank">手机读吧</a></li><li><a href="http://k.du8.com/">快眼看书</a></li></ul></div>');

document.charset='gb2312';
