<!--
//
    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"); 	
	
//    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('<link href="http://www.du8.com/images_www/css_generic.css" type="text/css" rel="stylesheet" />');

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('<!-- 头部导航区域开始-->');
document.write('<div id="headerarea">');
document.write('  <div id="header">');
document.write('<div id="headerlogo"><div><a href="http://www.du8.com"><img src="http://www.du8.com/images_www/site_logo.gif" border="0" /></a></div><div style="height:20px; line-height:20px; text-align:center; letter-spacing:0px; font-size:12px; color:#555">全球最大电子书门户</div></div>');
document.write('    <div id="headnavarea">');
document.write('      <table border="0" cellspacing="0" cellpadding="0">');
document.write('        <tr>');
document.write('          <td><img src="http://www.du8.com/images_www/nav_bgleft.gif" /></td>');
document.write('          <td class="navbg"><a href="http://vip.du8.com" title="读吧VIP用户专区首页"><font color="#F0FF00">VIP专区</font></a> | <a href="http://www.du8.com/sort/9110/1.shtml" title="职场励志">职场励志</a> | <a href="http://www.du8.com/sort/3799/1.shtml" title="经济管理">经济管理</a> | <a href="http://www.du8.com/sort/1523/1.shtml" title="法律知识">法律知识</a> | <a href="http://www.du8.com/sort/373/1.shtml" title="读吧藏书_财经企管类">财经企管</a> | <a href="http://www.du8.com/sort/4062/1.shtml" title="读吧藏书_科学技术类">科学技术</a> | <a href="http://www.du8.com/sort/5830/1.shtml" title="读吧藏书_人文历史类">人文历史</a> | <a href="http://s.du8.com/search/index.html" title="最棒的图书搜索引擎，能快捷、方便地找到互联网上95%的电子图书">读吧搜书</a> | <a href="http://k.du8.com" title="免费阅读最火、最新的小说章节，更新最快，内容最全，页面清爽，高速带宽"><font color="#F0FF00">读吧快眼</font></a></td>');
document.write('          <td><img src="http://www.du8.com/images_www/nav_bgright.gif" /></td>');
document.write('        </tr>');
document.write('      </table>');
document.write('      <div id="sclassnav"><a href="http://www.du8.com/channel/2_10010001_1.html" title="读吧专有图书，原汁原味保有纸质图书版式，可以在线或者使用书生阅读器下载离线阅读">原味书屋</a>　<a href="http://www.du8.com/channel/3_10010001_1.html" title="最近正式出版的图书，尝鲜试阅">新书尝鲜</a>　<a href="http://www.du8.com/sort/773958/1.shtml" title="最全、最流行的网络原创图书">网络流行</a>　<a href="http://www.du8.com/sort/7949/1.shtml">玄幻</a>　<a href="http://www.du8.com/sort/7560/1.shtml">武侠</a>　<a href="http://www.du8.com/sort/8108/1.shtml">言情</a>　<a href="http://www.du8.com/sort/5609/1.shtml">青春</a>　<a href="http://www.du8.com/sort/7952/1.shtml">悬疑</a>　<a href="http://www.du8.com/sort/4569/1.shtml">旅游</a>　<a href="http://www.du8.com/sort/1523/1.shtml">法律</a>　<a href="http://www.du8.com/sort/3799/1.shtml">经济</a>　<a href="http://www.du8.com/sort/8676/1.shtml">娱乐</a>　<a href="http://www.du8.com/special/speciallist/1.shtml" target="_blank" style="color:#ff0000">专题</a></div>');
document.write('    </div>');
document.write('    <!-- 右边搜索区域-->');

document.write('<style>#BookSearchForm,.searchform,#lg {position: relative;}   #kw{line-height: 10px;font: 10px arial} #st{table-layout:fixed;} #st td{padding:3px 0 0 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis!important;font: 12px arial!important}</style>');
document.write('<script src=http://s.du8.com/search/js/du8sug.js><\/script>');
document.write('    <div id="topsearcharea">');
document.write('      <table height="28" border="0" cellpadding="0" cellspacing="0" class="s_txt">');
document.write('        <tr>');
document.write('          <td width="25"><img src="http://www.du8.com/images_www/s_txt_01.gif" width="25" height="28" alt="" /></td>');
document.write('          <td class="topsearchtext"><marquee direction="left" scrollamount="1" scrolldelay="50" width="200" class="mq1"><a href="http://du8.cn" target="_blank" style="color:#cc0000;font-weight:bold">读吧快眼手机版开通啦~！上du8.cn从此阅读最新章节不再受时间地点电脑的限制，抢先阅读同步于首发网站的最新章节</a></marquee></td>');
document.write('          <td width="26"><img src="http://www.du8.com/images_www/s_txt_03.gif" width="26" height="28" alt="" /></td>');
document.write('        </tr>');
document.write('      </table>');
document.write('      <table border="0" cellspacing="2" cellpadding="0" class="topsearch">');
document.write('          <tr>');
document.write('            <td><img src="http://www.du8.com/images_www/icon_topsearch.gif" /></td>');
document.write('       <td> <form action="" method="post" name="BookSearchForm" id="BookSearchForm" onsubmit="return checkSubmit(\'kw\')">');
document.write('            <input  name="kw" id="kw" type="text" class="top_input_19" onfocus="if(this.value==\'书名 作者 类别……\')this.value=\'\';"   onblur="if(this.value==\'\')this.value=\'书名 作者 类别……\';"  value="书名 作者 类别……"/>');
document.write('            <input name="提交" type="submit" class="btn_search" value=" 搜书！" />');
document.write('        </form>');
document.write('         </td> </tr>');
document.write('      </table>');
document.write('    </div>');
document.write('    <!-- 搜索区域结束-->');
document.write('  </div>');
document.write('  <!--位置开始（或者是新消息）-->');
//document.write('    <script  language="javascript" src="http://bbs.du8.com/shusheng/pms_getbar.php" />');
document.write('  <!--位置结束-->');
document.write('</div>');
document.write('<!-- 头部导航区域结束-->');
document.charset='gb2312';



