var cookieName = 'txtreaddata';
var cookieUserName = 'txtuserdata';
document.domain = "txtbbs.com";
//kefu留言浮窗
	init_feedback();
	
var original = initReadCook(0,'');  //初始化cookie   新阅读记录
	
//复制地址
function CopyURL(){ 
   if(window.clipboardData){
			var ok=window.clipboardData.setData("text",location.href);
			if(ok) alert("复制地址成功，按Ctrl + V <br />粘贴到MSN、QQ上发给你的好友们吧 ！");
		}else{
			alert("对不起，目前此功能只支持IE，请直接复制地址栏的地址！");
		}
}

function addFavoriteIE (sURL, sTitle) {
	try {
		window.external.addFavorite(sURL, sTitle);
		return false;
	} catch (e)  {
		try {
			window.sidebar.addPanel(sTitle, sURL, "");
			return false;
		} catch (e)  {
			alert("加入收藏夹失败，请使用Ctrl+D进行添加");
			return false;
		}
	}
}

//登录状态
function loginState(){
    if( USER=="" || UID=="" ){
        analysis();
    }
    if($("#userlogin").size()>0 ){
        if( USER!='' && UID>0 ){http://uc.txtbbs.com/index.php?c=list&act=BookFavList
            $("#userlogin").html('<a href="'+BBS_URL+'home.php?mod=space&uid='+UID+'"><b>'+USER+'</b></a> <a href="'+UC_URL+'">用户中心</a> <a style="display:none;" href="'+AUTHORPATH+'">作家中心</a>   <a href="'+UC_URL+'index.php?c=list&act=BookFavList">藏书架</a>  <a style="display:none;" href="'+AUTHORPATH+'">作家中心</a>   <a href="'+UC_URL+'index.php?c=user&act=Logout">退出</a>&nbsp;');
        }else{
            $("#userlogin").html('请<a href="'+UCENTERPATH+'index.php?c=user&act=Login">登录</a>或<a href="'+UCENTERPATH+'index.php?c=user&act=Reg">注册</a>');
        }
    }
}

//分析用户登录状态
function analysis(){
    $.base64.is_unicode = true;
    $_cook = $.cookie(cookieUserName);
    if($_cook){
        var logincookie = $.base64.decode($_cook);
        var _arr = logincookie.split("#");
        UID = _arr[0];
        USER = _arr[1];
    }
}

//弹出窗口方法
function open_window(title,url,width,height){
    tipsWindown(title,"iframe:"+url,width,height,"true","","true","leotheme");
}

//关闭窗口办法
function close_window(){
    $('#windownbg', window.parent.document).remove();
    $('#windown-box', window.parent.document).fadeOut("slow",function(){
        $(this).remove();
    });
}

//关闭并刷新窗口办法
function reload_and_close(){
    $('#windownbg', window.parent.document).remove();
    $('#windown-box', window.parent.document).fadeOut("slow",function(){
        $(this).remove();
    });
    parent.location.reload();
}

//下载弹窗
function bookDownView( url ){
    showFrameModal(url);
}

//书童
function hclose(domStr){
    var obj = $("#" + domStr);
    obj.hide();
}
function hopen(domStr) {
    var obj = $("#" + domStr);
    obj.toggle();
}
function changeClassName(domid, className) {
    var obj = document.getElementById(domid);
    $('#' + domid).removeClass().addClass(className);
}
function showOwnerDom(domStr,num){
    for(var i=0;i<=6;i++){
        if(i!=num){
            $("#"+domStr+"_"+i).hide();
        }else{
            $("#"+domStr+"_"+num).show();
        }
    }
}

//后加载JS
function loadingJsFile(){
    var loadingJsStr = new String;
    var uri = typeof(GRILURL)!= "undefined" ? GRILURL : URL;
    loadingJsStr = '<script src="' + uri + 'static/js/transform.js" type="text/javascript" Charset="gb2312"><\/script>'; //简繁转换
    //loadingJsStr += '<script src="' + uri + 'data/txtbbs/hotsearch.js" type="text/javascript" Charset="gb2312"><\/script>'; //热门搜索
    //loadingJsStr += '<script src="' + uri + 'data/txtbbs/txt_pl.js" type="text/javascript" Charset="gb2312"><\/script>'; //评论
    //if(typeof(calls)== "undefined" || calls!= 1 || typeof(calls)== undefined){
    //    loadingJsStr += '<script src="' + uri + 'data/txtbbs/txt_st.js" type="text/javascript" Charset="gb2312"><\/script>'; //书童
    //}
    document.write(loadingJsStr);
    $("body").append("<script src='http://w.cnzz.com/c.php?id=30021793' language='JavaScript' charset='gb2312'></script>");
}

//加入收藏夹
function addFavorite( bid, tid ){
    if( bid!='' ){
        tid = tid ? tid : 0;
        var _str = '';
        _str = bid + '#' + tid;
        $.base64.is_unicode = true;
        _str = $.base64.encode(_str);
        $.ajax({
            type: "get",
            dataType: "json",
            url:  URL+"book.php",
            data: "c=user&act=AddFavorite&val="+_str+"&t="+Math.random(),
            error: function(){
                alert('Error');
            },
            success: function(msg){
                if(msg==1){
                    alert('操作成功！');
                }else if(msg==0){
                    alert('请先登录！');
					window.open("http://uc.txtbbs.com/index.php?c=user&act=Login",target='blank');
                    return false;
                }else if(msg==2){
                    alert('此作品已经被收藏！');
                    return false;
                }else if(msg==-1){
                    alert('参数错误！');
                    return false;
                }else{
                    alert('操作失败！');
                    return false;
                }
            }
        });
    }else {
        alert('缺少参数！');
        return false;
    }
}

//书童评论动态
function getnotice(){
    if($("#floatMarquee").size()>0){
        if(typeof(plarr)!= "undefined"){
            var str = "";
            for(var i=0;i<plarr.length;i++){
                str += '<li> ※ ['+plarr[i][3]+'] 【<a href="'+BBS_URL+'?'+plarr[i][2]+'" target="_blank">'+plarr[i][1]+'</a>】 对作品 <a href="'+plarr[i][4]+'" target="_blank">《'+plarr[i][0]+'》</a> 发表了评论！</li>\n';
            }
            $("#floatMarquee ul").html(str);
            $("#floatMarquee").Scroll({
                line:1,
                speed:1000,
                timer:2500,
                up:"btn1",
                down:"btn2"
            });
        }
    }
}

//热门搜索关键词
function gethotsearch(){
    if($("#hotsearch").size() > 0){
        if(typeof(soarr)!= "undefined"){
            var str = "";
            //for(var i=0;i<soarr.length;i++){
                //str += '<li> <a href="'+soarr[i][1]+'" target="_blank">'+soarr[i][0]+'</a> </li>\n';
            //}
            //str = '<a href="http://www.txtbbs.com/txt-2689.html" target="_blank">无尽剑装</a>&nbsp;&nbsp;<a href="http://www.txtbbs.com/txt-2526.html" target="_blank">遮天</a>&nbsp;&nbsp;';
            str += "<a href='http://tg.2g.cn/sxd/o.do?union=txt&mid=2' target='_blank'>唯美横版过关页游《神仙道》一起踏上修仙路</a>";
            $("#hotsearch").html(str);
        }
    }
}

//获取当前时间格式：yyyy-MM-dd hh:mm:ss
function getNowDateTime( type ){
    var d = new Date();
    var ret = d.getFullYear()+"-";
    ret += ("00"+(d.getMonth()+1)).slice(-2)+"-";
    ret += ("00"+d.getDate()).slice(-2)+" ";
    if(type==1){
        ret += ("00"+d.getHours()).slice(-2)+":";
        ret += ("00"+d.getMinutes()).slice(-2)+":";
        ret += ("00"+d.getSeconds()).slice(-2);
    }else if(type==3){
        ret = '';
        ret += ("00"+d.getHours()).slice(-2)+"点";
        ret += ("00"+d.getMinutes()).slice(-2)+"分";
        ret += ("00"+d.getSeconds()).slice(-2)+"秒";
    } else if(type == 4){
	   ret += ("00"+d.getHours()).slice(-2)+"点";	
	}
    return ret;
}

//设置阅读记录cookie
function setReadCookie(){
    if((typeof(bookreadstr)!= "undefined" && bookreadstr!='') || (typeof(textreadstr)!= "undefined" && textreadstr!='')){
        var _cook = '';
        var bid = '';
        //var datetime = getNowDateTime(4);
        $.base64.is_unicode = true;
        if(typeof(bookreadstr)!= "undefined" && bookreadstr!=''){
            var bookarr = $.base64.decode(bookreadstr).split("#");
            bid = bookarr[0];
            _cook = $.base64.decode(bookreadstr)+ '||';
        }
        if(typeof(textreadstr)!= "undefined" && textreadstr!=''){
            var textarr = $.base64.decode(textreadstr).split("#"); //解开章节cookie串
            bid = textarr[0];
            _cook = $.base64.decode(textreadstr) + '||';
        }
		var pub_cook = initReadCook(bid,_cook);	//初始化并种cookie
        /*var _data = $.cookie(cookieName);
        var new_cook = '';
        var num = 0;
        if(_data){
            _data = $.base64.decode(_data);
            var tmp = _data.split("||");
            for(i=0;i<tmp.length;i++){
                var one = tmp[i].split("#");
                if (one[0]==bid || one[0]==''){
					if (one[0]==bid &&typeof(textreadstr)== "undefined"){
						//新的cookie  处理
						//_cook = tmp[i] + '||';
						if(typeof(one[2])!= "undefined"){
							_cook = one[0] + '#' + one[1] + '||';
						}
					}
						continue;
                }else{
					//原章节长COOKIE
					if(typeof(one[4])!= "undefined"){
						tmp[i] = '';
					} else if(typeof(one[3])!= "undefined"){//原book长COOKIE或新章节
						//判断 3是不是纯数字  是就是原BOOK长COOKIE  不是 就是新章节
						
						tmp[i] = '';
					} else if(typeof(one[2])!= "undefined") {
						//判断 2是不是纯数字  是就是新BOOK长COOKIE  不是 就是新BOOK  只有一个bid
					}
                    new_cook = new_cook + tmp[i] + '||';
                    num = num + 1;
                }
                if (num>=9) break;
            }
        }*/
      
    }
}
//如果没有，都可以为空 initReadCook(0,'');
function initReadCook(bid,_cook){
	 var _data = $.cookie(cookieName);
        var new_cook = '';
        var num = 0;
        if(_data){
			$.base64.is_unicode = true;
            _data = $.base64.decode(_data);//alert(_data);
            var tmp = _data.split("||");
            for(i=0;i<tmp.length;i++){
                var one = tmp[i].split("#");
				
				if(one[0] == '' || typeof(one[0]) == "undefined"){continue;}
				if(i == 0 && typeof(one[1]) == "undefined"){continue;}
                if (one[0]==bid || one[0]==''){
					if (one[0]==bid &&typeof(textreadstr)== "undefined"){
						//新的cookie  处理
						//_cook = tmp[i] + '||';
						if(typeof(one[2])!= "undefined"){
							_cook = one[0] + '#' + one[1] + '||';
						}
					}
						continue;
                }else{
					if(_cook !='' || i!=0){ //初始化时，当新记录为空时，第一个不进行初始化
						//原章节长COOKIE
						if(typeof(one[7])!= "undefined"){
							tmp[i] = one[0] +'#'+one[5];
						} else if(typeof(one[3])!= "undefined"){//原book长COOKIE或新章节
							//判断 3是不是日期格式  是就是原BOOK长COOKIE  不是 就是新章节
							reg = /^\d{3,4}-\d{1,2}-\d{1,2}/;
							if (reg.test(one[3])){
								tmp[i] = one[0];
							} else {
								tmp[i] = one[0]+'#'+one[2];
							}
							
						} else if(typeof(one[1])!= "undefined") {
							//判断 2是不是纯数字  是就是新BOOK长COOKIE  不是 就是新BOOK  只有一个bid
							reg = /^\d{1,10}$/;
							if (!reg.test(one[1])){
								tmp[i] = one[0];
							}
						}
					} else {
						if(typeof(one[7])!= "undefined"){
							tmp[i] = one[0] +'#'+one[1] +'#'+one[5] +'#'+one[7]+'#'+one[8]+'#'+one[4]+'#'+one[6];
						} else if(typeof(one[3])!= "undefined"){//原book长COOKIE或新章节
							//判断 3是不是日期格式  是就是原BOOK长COOKIE  不是 就是新章节不处理
							reg = /^\d{3,4}-\d{1,2}-\d{1,2}/;
							if (reg.test(one[3])){
								tmp[i] = one[0]+'#'+one[1];
							}
							
						}
					}
                    new_cook = new_cook + tmp[i] + '||';
                    num = num + 1;
                }
                if (num>=10) break;
            }
        }
		
        var pub_cook =  new_cook ? _cook + new_cook : _cook;
		 $.cookie(cookieName,null);
        $.cookie(cookieName, $.base64.encode(pub_cook), {
            expires: 365,
            path: '/',
            domain: document.domain
        });
		return pub_cook;
}

//显示阅读记录
function getReadCookie(){
    var res = '';
	$.ajax({
            type: "get",
            async:false,
            dataType: "jsonp",
            url:  URL + "book.php",
            //url:  "/book.php",
            data: "c=book&act=bookshelf&cn="+cookieName+'&type=read',
            jsonp:'callback',
            jsonpCallback:"jsonpback",
			success: function(msg){
				msgs = msg.responseText;
				var res = '';
				if(msgs){
					$.base64.is_unicode = true;
			    msgs = $.base64.decode(msgs);
					var o_arr = msgs.split("||");        
					var bookurl = '';
					for( i=0; i<o_arr.length; i++ ){
						var one_arr = o_arr[i].split("#");
						if(one_arr[0]=='') {
							continue;
						}
						bookurl = URL;
						res = res + '<li><a href="' + bookurl + 'txt-' + one_arr[0] + '.html" target="_blank">《'+one_arr[1]+'》</a>';
						if(one_arr[2]!='undefined' && one_arr[2]!='' && one_arr[2]!=undefined){
							if(one_arr[4]==1){
								res = res + '<span><a href="' + VIP_URL + 'read/readviptext.php?bid=' + one_arr[5] + '&tid=' + one_arr[6] + '&b_id=' + one_arr[0] + '&t_id=' + one_arr[2] + ' target="_blank" title="前往章节：' + one_arr[3] + '">章节</a></span>';
							}else{
								res = res + '<span><a href="' + bookurl + 'txt-' + one_arr[0] + '-' + one_arr[2] + '.html" target="_blank" title="前往章节：' + one_arr[3] + '">章节</a></span>';
							}
						}
						res = res + '</li>';
					}
				}else{
					res = '<li>还没有浏览记录</li>';
				}
				$("#reabookdlog").html(res);
            },
            error: function(msg){
			}
		});

}

//快速阅读记录
function getfastreadlog(){
    var res = '';
    if(original){
	$.base64.is_unicode = true;
        var o_arr = original.split("||");
        if(o_arr.length>0){
            var one_arr = o_arr[0].split("#");
            if(one_arr[0]!='' && one_arr[1]!='') {
                var bookurl = URL;                
                res = '您上次阅读到：《<a href="' + bookurl + 'txt-' + one_arr[0] + '.html"><strong>' + one_arr[1] + '</strong></a>》';  
                if(one_arr[2]!='undefined' && one_arr[2]!='' && one_arr[2]!=undefined){
                    if(one_arr[4]==1){
                        res = res + '&nbsp;<a href="' + VIP_URL + 'read/readviptext.php?bid=' + one_arr[5] + '&tid=' + one_arr[6] + '&b_id=' + one_arr[0] + '&t_id=' + one_arr[2] + ' target="_blank" class="orange" title="前往章节：' + one_arr[3] + '">' + one_arr[3] + '</a>';
                    }else{
                        res = res + '&nbsp;<a href="' + bookurl + 'txt-' + one_arr[0] + '-' + one_arr[2] + '.html" target="_blank" title="前往章节：' + one_arr[3] + '" class="orange">' + one_arr[3] + '</a>';
                    }
                }
            }else{
                res = '您最近未有阅读记录，超级精彩的新内容等着您阅读。';
            }
        }
    }else{
        res = '您最近未有阅读记录，超级精彩的新内容等着您阅读。';
    }
    $("#record").html(res);
}

//显示阅读记录
function mybookshelf(){
	var continue_text = $('#continue_text').size()>0;
	var bid = (continue_text) ? $('#continue_text').attr('bid') : false;
	if(bid){
		var o_arr = original.split("||");        
            var bookurl = URL + 'txt-';
            for( i=0; i<o_arr.length; i++ ){
                var one_arr = o_arr[i].split("#");
				if(bid == one_arr[0]){
					if(i == 0 && one_arr[2]!='undefined'){
						$('#continue_text').attr('href',bookurl + one_arr[0] + '-' + one_arr[2] + '.html');
					} else if(one_arr[1]!='undefined'){
						$('#continue_text').attr('href',bookurl + one_arr[0] + '-' + one_arr[1] + '.html');
					}
				}
			}
	}
	//typeof($("#mybookshelf"))!= "undefined" 
    if($('#mybookshelf').length>0){
		ajax_mybookshelf(false);  //false 取cdn  返回CDN时间戳
    }
        
}
//ajax请求临时书架，  t 是否取最近的，不走cdn
function ajax_mybookshelf(t){
	var para = t ? '&t='+t : '';
	$.ajax({
            type: "get",
            dataType: "json",
            url: "/book.php",
            //url:  "/book.php",
            data: "c=book&act=bookshelf&cn="+cookieName+'&b=1'+para,
			error: function(msg){
			//$("#mybookshelf").html(msg.responseText);
			msgs = msg.responseText;
			var res = '';
		if(msgs.length>1){
            $.base64.is_unicode = true;
			 var i_arr = msgs.split("&&");
			 msgs = i_arr[0];
			$("#mybookshelf").html(msgs);
			
			var d = new Date();
			var t = d.getTime();
			t = parseInt(t / 1000);
			if(t - i_arr[1] >= 60){
				//ajax_mybookshelf(t);	
			} else {
				t = 60 - (t - i_arr[1]);
				$('.sj_time').text(t+'秒后查看新数据');
			}
        }else{
            res = '<li>还没有浏览记录</li>';
			$("#mybookshelf").html(res);
			return false;
        }
       },
    success: function(msg){
	}
  });
}

function delReadCookie(bid){
	var _data = $.cookie(cookieName);
	var new_cook = '';
	 if(_data){
            _data = $.base64.decode(_data);
            var tmp = _data.split("||");
            for(i=0;i<tmp.length;i++){
                var one = tmp[i].split("#");
                if (one[0]==bid || one[0]==""){
                    continue;
                }else{
                    new_cook = new_cook + tmp[i] + '||';
                }
            }
        }
	  $.cookie(cookieName,null);
        $.cookie(cookieName, $.base64.encode(new_cook), {
            expires: 365,
            path: '/',
            domain: document.domain
        });
	$('.readbook_'+ bid).hide();
}
//全局阅读记录
function headerReadLog(){ 
    //书童阅读记录
    if($("#reabookdlog").size() > 0 ){
        getReadCookie();//书童的阅读记录
    }
    if(typeof($("#record"))!= "undefined" ){
        getfastreadlog();
    }    
}

//页面底部客服
function footerService(){
    if($("#footerservice").size() > 0 ){
        var serviceStr = new String;
        serviceStr = '作者签约咨询请联系：TXT小说论坛 事务受理 ；读者咨询，意见反馈及其他问题请TXT小说论坛 疑难互助';
        $("#footerservice").html(serviceStr);
    }
}

//总首页头部JS内容
function home_top_con(){
    var payuri = typeof(PAYURL)!= "undefined" ? PAYURL : 'http://pay.txtbbs.com/';
    if(typeof($("#topright"))!= "undefined" ){
        $("#topright").html('<a onclick="window.external.addFavorite(\'' + URL + '\',\'txt小说网\');" href="javascript:void(0);">加为收藏</a> <a id="HomePage" onclick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'' + URL + '\');return(false);" href="' + URL + '">设为首页</a>');
    }
    if(typeof($(".recharge"))!= "undefined" ){
        $(".recharge").html('<a href="' + payuri + 'pay.php?a=pay">充值</a>');
    }
}

//广告
function loadingAd(){

    //总首页banner
    if($("#indexbanner").size() > 0){
        $("#indexbanner").html('<iframe width="470" height="60" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="http://www.txtbbs.com/data/txtbbs/indexbanner.html"></iframe>');
    }
    
    //总首页通栏1
    if($("#indextonglan1").size() > 0){
        $("#indextonglan1").remove();
    }
    
    //总首页通栏2
    if($("#indextonglan2").size() > 0){
        $("#indextonglan2").remove();
    }
    
    //作品页通栏1
    if($("#tonglan1").size() > 0){
        $("#tonglan1").remove();
    }

    //作品页评论上面通栏
    if($("#tonglan2").size() > 0){
        $("#tonglan2").remove();
    }
    
    //作品页通栏3
    if($("#tonglan3").size() > 0){
        //$("#tonglan3").html('<iframe width="200" height="200" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="http://www.txtbbs.com/data/txtbbs/tonglan3.html"></iframe>');
    }
    
    //首页通栏1
    if($("#mmtonglan1").size() > 0){
        $("#mmtonglan1").html('<iframe width="960" height="60" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="http://www.txtbbs.com/data/txtbbs/mmtonglan1.html"></iframe>');
    }
   
    //首页通栏2
    if($("#mmtonglan2").size() > 0 ){
        $("#mmtonglan2").remove();
    }
   
    //首页通栏3
    if($("#mmtonglan3").size() > 0 ){
        $("#mmtonglan3").remove();
    }

    //全站头部banner
    if($("#mmbanner").size() > 0 ){
        $("#mmbanner").html('<iframe width="470" height="60" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="http://www.txtbbs.com/data/txtbbs/mmbanner.html"></iframe>');
    }
    
    //章节目录页通栏1
    if($("#booktonglan1").size() > 0 ){
        $("#booktonglan1").remove();
    }
    
    //章节目录页通栏2
    if($("#booktonglan2").size() > 0 ){
        $("#booktonglan2").remove();
    }
    
    //阅读页通栏1
    if($("#readtonglan1").size() > 0 ){
        $("#readtonglan1").remove();
    }
    
    //阅读页3小方块
    if(typeof($("#read3fk"))!= "undefined" ){
    //    $("#read3fk").html('<iframe width="992" height="309" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="http://www.txtbbs.com/data/txtbbs/read3fk.html"></iframe>');
    }
    
    //阅读页通栏2
    if(typeof($("#readtonglan2"))!= "undefined" ){
        //$("#readtonglan2").html('<iframe width="960" height="60" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="http://www.txtbbs.com/data/txtbbs/readtonglan2.html"></iframe>');
    }
    
    //男版幻侠推荐
    /*if($("#huanxiatj_source").html() != null && $("#huanxiatj_source").html() != "null"){
        document.getElementById('huanxiatj').innerHTML = document.getElementById('huanxiatj_source').innerHTML;
    }*/    
    
    //总首页友情链接
    if($(".link span").size() > 0 ){
        $(".link span").html(' | <a href="http://www.1166.com" target="_blank">1166网址</a> | <a href="http://www.114.com.cn/" target="_blank">114网址导航</a> | <a href="http://www.657.com/" target="_blank">657网址导航</a> | <a href="http://www.lvse.com/" target="_blank">绿色网址大全</a>');
    }
}

loadingJsFile(); //加载缓存JS和页面必须的JS

//页面载入完毕后执行
$(document).ready(function (){
    $("#translateLink").click(function(){
        translateInitilization();
    });
    setReadCookie(); //写浏览记录cookie
    loginState(); //登录状态
    headerReadLog(); //全局阅读记录
    //getnotice(); //评论
   // gethotsearch(); //热门搜索    
    footerService(); //页面底部客服
    home_top_con(); //总首页头部JS内容
    loadingAd(); //写入广告
    mybookshelf();
})


//男版首页左上角的推荐动图js

	$('.week .title a').click(function(){
		var val = $(this).children().attr('col');
		$('.on').attr('class', 'off');
		$(this).children().attr('class', 'on');
		$('.'+ val).show(); 
		if(val != 'on1'){
			$('.on1').hide();	
		} 
		if(val != 'off1'){
			$('.off1').hide();	
		} 
	});

var _c = _h = 0;
$(function(){
	if(1 >= 0){
		$('.small > a').click(function(){
			var i = $(this).attr('alt') - 1;
			_c = i;
			play();
			change(i);        
		})
		$(".small a").hover(function(){play()});
		play();
	}
})
function play()
{
        clearInterval(_h);
    _h = setInterval("auto()", 3000);
}
function change(i)
{
	$('.small a').removeClass('tj_1').eq(i).addClass('tj_1').blur();
	$(".big > span").hide().eq(i).fadeIn('slow');
	$(".focus > span").hide().eq(i).fadeIn('slow');
}
function auto()
{
    _c = _c > 1 ? 0 : _c + 1;
    change(_c);
}

//$('.zx_tmbox li').eq(0).html('<a href="http://hot.onlylady.com/2012/0731/2294819.shtml?txt"><img src="http://www.txtbbs.com/data/outsit/adv3.jpg" width="80" height="110" title="屌丝的逆袭遭遇拜金女"/><br />屌丝的逆袭遭遇拜金女</a>');

if($('.tj_txt').size() > 0 && $(".tj_txt") != null) {
	$.ajax({
            type: "get",
            dataType: "json",
            url: "book.php",
            //url:  "/book.php",
            data: "c=book&act=getIndexTJ&t="+Math.random(),
		 error: function(msg){
			$(".tj_txt").html(msg.responseText);
            },
            success: function(msg){
			$(".tj_txt").html(msg);
            }
        });
}
if($("form.sousuo > dl").length > 0){
$(function() {
	$("form.sousuo > dl").hover(function() {
		$(this).find('dd').show();
		$(this).find('dt').attr('class','show');
	}, function() {
		$(this).find('dd').hide();
		$(this).find('dt').attr('class','normal');
	})
	$("form.sousuo > dl > dd > a").click(function() {
		var _form = $("form.sousuo");
		var type = $(this).attr('type');
		$('.type').val(type);
		_form.find("dl > dt").text($(this).text().replace('按', ''));
		_form.attr('col', $(this).attr('col'));
		$(this).parent('dd').hide();
		_form.find("input[type='text']").focus();
	})
						
	$("form.sousuo").submit(function() {
		var kw = $(this).find("input[type='text']").val();
		var type = $('.type').val();
		$(this).attr('action',so_uri+'kw/'+kw+'/col/'+$(this).attr('col'));
	})
})
}
var ci =1;
//留言浮窗
function init_feedback(){
	if($.browser.msie && parseFloat($.browser.version) < '8.0'){
		$('html').css({"overflow-x":"hidden"});
	}
	var height    = $(window).height()-50;
	var showtxt   = '欢迎给我们提出使用中遇到的问题、咨询、投诉、赞扬、建议等！ 请留下联系方式，将有机会获得VIP帐号！';
	var showqq    = "QQ、手机号和邮箱";
	var container = '<dl class="kefu_box"  id="kefu_container"><dt><a href="javascript:;;" id="kefu_info">意见与建议</a></dt><dd><form name="myformbox" id="myformbox" action="/" method="post"><textarea id="content" name="content" onfocus="if(this.value ==\''+showtxt+'\') this.value =\'\';" placeholder="'+showtxt+'">'+showtxt+'</textarea><ul><li><label>联系方式:</label><input  placeholder="'+showqq+'" onfocus="if(this.value ==\''+showqq+'\') this.value =\'\';" value="'+showqq+'" type="text" id="qq" name="qq" value=""/></li></ul><input type="submit" value="提交" class="kf_btn"/></form></dd></dl>';
	$('body').append(container);
	$("#kefu_container dt").click(function(){
		//立刻停止隐藏，并且显示
		if(ci % 2){
			$(this).parent().stop(true).animate({right:'-2px'},200,function(){});
			$("#kefu_info").html('意见关闭');
		} else {
			$(this).parent().animate({right:"-201px"},400,function(){});
			$("#kefu_info").html('意见与建议');
		}
		ci++;
	  });
	$("form[id='myformbox']").submit(function() { /*ajax submit*/
		var content  = $("#content").val();
		var qq       = $("#qq").val();
		if(qq==showqq) qq = '';
		if(content == showtxt || content.length<1) {
			alert("提示：\n\n请输入留言");
			$("#content").focus();
			return false;
		}
		
		if (content.length > 1000 ){
			alert ("提示：\n\n留言长度最多1000汉字！");
			$("#content").focus();
			return false;
		}

		reg = /(\d{4,12}|(\d{3,4}-)?\d{7,8}(-\d{1,4})?|\w{1,20}@\w{1,10}\.\w{2,4}(\.\w{2,3})?)$/;
		
		if (qq!='' && !reg.test(qq)){
			alert ("提示：\n\n联系方式可以是：电话 手机 QQ 邮箱");
			$("#qq").focus();
			return false;
		}
		var url = '/book.php?c=book&act=ajax_question';
		$.ajax({
			type: "POST",
			url: url,
			data:'content='+encodeURI(encodeURI(content))+'&qq='+qq,
			dataType:'json',
			timeout:3000,
			success: function(data){
				if(data.status) {
					alert('留言成功');
				}else {
					if(data.msg == 'Too often'){
						alert('操作频繁');
					}else{
					$.base64.is_unicode = true;
					data = $.base64.decode(data.time);
						alert('还有'+data+'后才可以再次反馈。');
					}
				}
			},
			error:function(xmlobj, errorstr,e){  
				alert('留言失败');
			}
		});
		$("form[id='myformbox'] :submit").attr("disabled","disabled");
		return false;
	});
	
}

//章节页和内容页的链接反馈使用
	function feedback_link(o){
		var content = $(o).text();
		var url = '/book.php?c=book&act=ajax_question';
		$.ajax({
			type: "POST",
			url: url,
			data:'content='+encodeURI(encodeURI(content)),
			dataType:'json',
			timeout:5000,
			success: function(data){
				if(data.status) {
					alert('举报成功');
				}else {
					if(data.msg == 'Too often'){
						alert('操作频繁');
					}else{
					$.base64.is_unicode = true;
					data = $.base64.decode(data.time);
						alert('还有'+data+'后才可以再次反馈。');
					}
				}
			},
			error:function(xmlobj, errorstr,e){  
				alert('留言失败');
			}
		});
	}
