// JavaScript Document
$(function() {
    //显示通知公告类别
    var ss = "";
    $("#sub1 >ul li").each(function() {
        ss = $(this).find(".sp1").html().split("{fengefu}");
        $(this).find(".sp1").html("<b>[</b>" + ss[1] + "<b>]</b>");

        var link_ss = "";
        link_ss = $(this).find("a").attr("href");

        if (ss[0] == "1") {
            $(this).find("a").attr("href", link_ss + "&page_id=1");
        }
        else {
            $(this).find("a").attr("href", link_ss + "&page_id=2");
        }
    })



    //读者图书推
    var timer = 4000;
    var timeID;
    var autoPlay = function() { if (timer) timerID = window.setInterval('AutoScroll(".bookjj")', timer); };
    var autoStop = function() { if (timer) window.clearInterval(timerID); };
    autoPlay();
    $(".bookjj").mouseover(autoStop).mouseout(autoPlay);


    //内容去html
    $(".dfwx").each(function() {
        noimg = $(this).find(".nr_erdfwx").html();
        var len = noimg.indexOf("阅读器下载");
        if (len < 0) {
            $(this).find(".nr_erdfwx").html(noimg.replace(/<[a-zA-Z\/][^>]*>/g, ""));
        }
        else {
            var urler = $(this).find(".a1").attr("href");
            $(this).find(".nr_erdfwx").html(noimg.replace(/<[a-zA-Z\/][^>]*>/g, ""));
            var aa = $(this).find(".nr_erdfwx").html();
            aa = aa.replace("全文阅读", " <a href='" + urler + "'>全文阅读</a> ");
            aa = aa.replace("在线阅读器下载", " <a href='http://www.yytsg.cn/userfilesfile/FoxitReader_Setup_chs.exe'>在线阅读器下载</a> ");
			aa = aa.replace("专用阅读器下载", " <a href='http://www.yytsg.cn/userfilesfile/FoxitReader_Setup_chs.exe'>专用阅读器下载</a> ");
            $(this).find(".nr_erdfwx").html(aa);
        }
    })
	
	//表格约束
	$("table").each(function(){
							 		var ss=0;
									var ss1=0;
									if($(this).attr("width")!=null)
									{
										ss=$(this).attr("width");
									}
									if($(this).css("width")!=null)
									{
										ss1=$(this).css("width");
									}
									if($(this).css("width")=="auto")
									{
										ss1=660;
									}
									if(ss>660|| ss1>660)
									{
										$(this).attr("width","660");
										$(this).css("width","660");
									}
							  }
			   		)
	
	//其它列表内容去html
	$(".th .nr_er").each(function(){
		noimg=$(this).html();
		$(this).html(noimg.replace(/<[a-zA-Z\/][^>]*>/g,""));
	})

    //新书推荐简介去html
    $(".newbookjj_er").each(function() {
        noimg = $(this).html();
        $(this).html(noimg.replace(/<[a-zA-Z\/][^>]*>/g, ""));
    })

    //首页联系姚图去掉图片
    $(".lianxi_bg img").hide();
    //.css("display","none");
    //alert($("#wenzhangonly").html());
    wenzhangfengyue();

    //首页图片移动
    if ($("#marquee1").html() != null) {
        $('#marquee1').kxbdMarquee({ isEqual: false });
    }
	
	//开放时间去掉图片
	if($("#open_time").val()=="开放时间")
	{
		$(".open_time_content").find("img").hide();	
	}
})

/*--获取网页传递的参数--*/
//调用这个 request就可以了，这里可以调用request("ID")
function request(paras)
{ 
	var url = location.href; 
	var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
	var paraObj = {} 
	for (i=0; j=paraString[i]; i++){ 
	paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length); 
	} 
	var returnValue = paraObj[paras.toLowerCase()]; 
	if(typeof(returnValue)=="undefined"){ 
	return ""; 
	}else{ 
	return returnValue; 
	} 
}

/*下面是文章分页的*/
function wenzhangfengyue()
{	
	if($("#wenzhangonly").html()!=null)
	{
		//根据标记分章
		var url_str_only="";
		//获取url
		url_str_only=window.location.toString();
		var wz_ary_only=""; 
		wz_ary_only=$("#wenzhangonly").html().split("[page]");
		//分章数
		var ary_len_only=0;
		ary_len_only=wz_ary_only.length;
		//分页字符串
		var page_str_only="";
		var fyid_str_only="";
		fyid_str_only=request("fpage");
		url_str_only=window.location.toString().replace("&fpage="+fyid_str_only,"");
		for(var i=0; i<ary_len_only; i++){
			if (fyid_str_only == i)
			{
				page_str_only=page_str_only+"<a href='"+url_str_only+"&fpage="+i+"' style='font-weight:bold; font-size:10pt; color:#FF0000'>"+(i+1)+"</a>&nbsp;&nbsp;";
			}else{
				page_str_only=page_str_only+"<a href='"+url_str_only+"&fpage="+i+"'>"+(i+1)+"</a>&nbsp;&nbsp;";	
			}
		}
		if (ary_len_only == 1){
			page_str_only = "";
		}
		//显示
		if(fyid_str_only==""){
			$("#wenzhangonly").html(wz_ary_only[0]);
		}
		else{
			$("#wenzhangonly").html(wz_ary_only[fyid_str_only]);
		}
		$("#fengyeonly").html(page_str_only);	
	}
}


//读者图书推
function AutoScroll(obj){
            $(obj).find("ul:first").animate({
                    marginTop:"-190px"
            },1000,function(){
		            $(this).css({marginTop:"0px"}).find("li:first, li:eq(1)").appendTo(this);
            });
        }


//导航单菜
function page_shijian(n)
{
	$(".zinav_bg ul").each(function(){
		$(this).hide();							
	})
	
	$("#zhi"+n).show();
	
	if(n==1)
	{
		$(".zinav_bg ul").each(function(){
			$(this).hide();							
		})
	}
}


//菜单切换
function doClick(o) {
	var j;
	var id;
	var e;
	for (var i = 1; i <= 2; i++) {
		id = "nav" + i;
		e = document.getElementById("sub" + i);
		if (id != o.id)
		{
			e.style.display = "none";
			$("#"+id).attr("class","a2");
			$("#sp_link").attr("href","/?f=tongzhi_gglist.html&page_id=1");
		}
		else
		{
			e.style.display = "block"
			$("#"+id).attr("class","a1");
			$("#sp_link").attr("href","/?f=message.html");
		}
	}
}


//点击显示隐藏新书内容
function MM_effectBlind(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoBlind(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
	if ($("#bian_sj").html()!=null)
	{
		if ($("#bian_sj").html() == "我要提问"){
			$("#bian_sj").html("关闭提问");
		}else{
			$("#bian_sj").html("我要提问");
		}
	}
}


//书目检索
function normalSearch(){
	document.forms["form2"].action="http://202.107.212.148/opac/websearch/bookSearch?pageNo=1&filter=%28"+encodeURIComponent($("#col1").val())+"%3A"+encodeURIComponent($("#val1").val())+"%29+AND+%28hasholding%3Ay%29&cmdACT=list&linkLable=&xsl=BOOK_list.xsl&mod=oneXSL&searchSign=&raws=10&q=&ISFASTSEARCH=true&sortSign=pubdate_sort&orderSign=true&col1="+encodeURIComponent($("#col1").val())+"&val1="+encodeURIComponent($("#val1").val())+"";
	document.forms["form2"].target="_blank";
	document.forms["form2"].submit();
}




