﻿<!--

var baseurl = ''
var tplname = 'default'

document.write('<script src="' + baseurl + '/templates/' + tplname + '/js/fromopac.js" type="text/javascript"></script>')
document.write('<script src="' + baseurl + '/templates/' + tplname + '/js/educhina.js" type="text/javascript"></script>')
document.write('<script src="' + baseurl + '/templates/' + tplname + '/js/szdnet.js" type="text/javascript"></script>')
document.write('<script src="' + baseurl + '/templates/' + tplname + '/js/metalib.js" type="text/javascript"></script>')

var tmphtml = ''
var today = new Date()

// 显示日期、星期及当日开放时间
function showtoday() {
	var timenow = today.getTime()
	var isweekend = (today.getDay() == 0 || today.getDay() == 6) ? true : false
	/* 周末调整为工作日
	var timepoint_0 = (new Date(2011, 11, 31)).getTime()
	var timepoint_1 = (new Date(2012, 0, 1)).getTime()
	isweekend = isweekend ? ((timenow >= timepoint_0 && timenow < timepoint_1) ? false : true) : false	*/
	/* 2011年暑假
	var timepoint_2 = (new Date(2011, 6, 9)).getTime()
	var timepoint_3 = (new Date(2011, 8, 6)).getTime()	*/
	/* 2011年中秋
	var timepoint_2 = (new Date(2011, 8, 10)).getTime()
	var timepoint_3 = (new Date(2011, 8, 13)).getTime()	*/
	/* 2011年国庆
	var timepoint_2 = (new Date(2011, 9, 1)).getTime()
	var timepoint_3 = (new Date(2011, 9, 8)).getTime()
	var timepoint_4 = (new Date(2011, 9, 2)).getTime()	*/
	/* 2012年元旦
	var timepoint_2 = (new Date(2012, 0, 4)).getTime()	*/
	// 2012年春节
	var timepoint_0 = (new Date(2012, 0, 14)).getTime()
	var timepoint_1 = (new Date(2012, 0, 20)).getTime()
	var timepoint_2 = (new Date(2012, 0, 30)).getTime()
	var timepoint_3 = (new Date(2012, 1, 24)).getTime()
	var isholiday = (timenow >= timepoint_0 && timenow < timepoint_3) ? true : false
	var iscnyear = (timenow >= timepoint_1 && timenow < timepoint_2) ? true : false
	var opentime = isholiday ? '08:30' : '07:30'
	var closetime = isholiday ? '17:00' : '22:30'
	var linkto = isholiday ? '/fangdc/latest.hours.php' : '/service/hours.php'
	var cnstr = new Array("年","月","日","星期","日","一","二","三","四","五","六")
	var clstr = (iscnyear || isweekend) ? ' class="holiday"' : ''
	tmphtml = '<div id="today"><div id="today_date">'
	tmphtml += today.getFullYear().toString() + '<span class="instr_1">' + cnstr[0] + '</span>'
	tmphtml += (today.getMonth() + 1).toString() + '<span class="instr_1">' + cnstr[1] + '</span>'
	tmphtml += today.getDate().toString() + '<span class="instr_2">' + cnstr[2] + '</span></div>'
	tmphtml += '<div' + clstr + ' id="today_day">' + cnstr[3] + cnstr[today.getDay() + 4] + '</div>'
	tmphtml += '<div' + clstr + ' id="today_hour" onclick="window.open(\'' + baseurl + linkto + '\')" title="开放时间">'
	tmphtml += (iscnyear ? '春节闭馆' : (opentime + '<span class="instr_1">--</span>' + closetime)) + '</div></div>'
	document.write(tmphtml)
}

// 获取流量图
function getflowgraph(box) {
	$("#" + box + " > div").attr("style","background-image: none")
	$("#" + box + " > div").attr("style","background-image: url(http://opac.lib.szu.edu.cn/jgll/ShowFlowRate.aspx?type=s&r=" + Math.random() + ")")
	$("#" + box + " > div > a > img").attr("title","入馆人次统计表")
}

// 定时更新流量图
function refreshgraph(box,minutes) {
	setInterval(function() { getflowgraph(box) },(minutes * 60000))
}

// 显示幻灯片中的图片
function showsldimage(i,box_imgs,box_nums,mseconds) {
	$("#" + box_imgs).stop(true,false).animate({ top: -158 * i },mseconds)
	$("#" + box_nums + " li")
		.eq(i).addClass("on")
		.siblings().removeClass("on")
}

// 演示幻灯片
function showslider(box,box_imgs,box_nums,seconds,mseconds) {
	var int = seconds * 1000
	$(function() {
		var n = $("#" + box_nums + " > li").length
		var i = 0
		$("#" + box_nums + " li").mouseover(function() {
			i = $("#" + box_nums + " li").index(this)
			showsldimage(i,box_imgs,box_nums,mseconds)
		})
		$("#" + box).hover(function() {
			if (timeobj) {
				clearInterval(timeobj)
			}
		},function() {
			timeobj = setInterval(function() {
				showsldimage(i,box_imgs,box_nums,mseconds)
				i++
				if (i == n) {
					i = 0
				}
			},int)
		})
		var timeobj = setInterval(function() {
			showsldimage(i,box_imgs,box_nums,mseconds)
			i++
			if (i == n) {
				i = 0
			}
		},int)
	})
}

// 从公告系统载入数据
function gettopxnews(n_type,x_top,w_max,showdate,showhits,box) {
	var tmpstr = '/board/topxnews.asp?type=' + n_type + '&topx=' + x_top + '&maxw=' + w_max
	tmpstr += '&showdate=' + ((showdate == 1) ? 'yes' : 'no') + '&showhits=' + ((showhits == 1) ? 'yes' : 'no')
	g(box).innerHTML = '<p class="loading">正在载入，请稍候……</p>'
	$.get(tmpstr,
	function(data) {
		$("#" + box).html(data)
	})
}

// 转换标签
function changetab(tabobj) {
	var numstr = tabobj.id.replace("tablink","")
	var n_array = numstr.split("_")
	var numstr_p = "_" + n_array[1] + "_" + n_array[2]
	var n = parseInt(n_array[3])
	var s = parseInt(g("s_boxtab" + numstr_p).value)
	var tab_now = g("boxtab" + numstr)
	var list_now = g("boxbody" + numstr)
	if (tab_now.className.indexOf("_off") > -1) {
		for (var i = 1; i <= s; i++) {
			if (g("boxtab" + numstr_p + "_" + i).className.indexOf("_on") > -1) {
				var tab_prev = g("boxtab" + numstr_p + "_" + i)
				var list_prev = g("boxbody" + numstr_p + "_" + i)
				tab_prev.className = tab_prev.className.replace("_on","_off")
				list_prev.style.display = "none"
				if (i == s) {
					g("tabrow" + numstr_p).style.backgroundPosition = "right top"
				}
			}
		}
		tab_now.className = tab_now.className.replace("_off","_on")
		list_now.style.display = ""
		if (n == s) {
			g("tabrow" + numstr_p).style.backgroundPosition = "right -50px"
		}
		if (!list_now.innerHTML && tabobj.name) {
			var name_array = tabobj.name.split("_top")
			var from = name_array[0]
			var x = parseInt(name_array[1])
			var box = "boxbody" + numstr
			if (from.indexOf("news_") > -1) {
				var news_array = from.split("_")
				var n_type = parseInt(news_array[1])
				var w_max = parseInt(news_array[2])
				var showdate = parseInt(news_array[3])
				var showhits = parseInt(news_array[4])
				gettopxnews(n_type,x,w_max,showdate,showhits,box)
			} else if (from.indexOf("opac_") > -1) {
				getopacdata(from.replace("opac_",""),x,box)
			}
		}
	}
}

// -------- 检索框提示文字 begin -------- //

var fw_inputs = new Array("fw_opac","fw_educhina","fw_szdnet","fw_metalib")
var fw_tips = new Array("搜索本校馆藏书刊资料","搜索全国高校图书馆所有资源","搜索本馆、深圳市图书馆、大学城图书馆所有资源","搜索本馆学术资源门户")

// 检索框中预置提示文字
window.onload = function() {
	for (var i = 0; i < fw_inputs.length; i++) {
		var f = g(fw_inputs[i])
		f.value = fw_tips[i]
		f.className = "tip"
		f.blur()
	}
}

// 焦点事件
function onfocusornot(obj,n) {
	var m = -1
	for (var i = 0; i < fw_inputs.length; i++) {
		if (obj.id == fw_inputs[i]) {
			m = i
			break
		}
	}
	if (m < 0) {
		return false
	} else {
		switch(n) {
			case 1:
				if (obj.value == fw_tips[m]) {
					obj.value = ""
				}
					obj.className = "gen"
				break
			case 0:
				if (!obj.value) {
					obj.value = fw_tips[m]
					obj.className = "tip"
				} else if (obj.value == fw_tips[m]) {
					obj.className = "tip"
				}
				break
		}
	}
}

// 提交前清除初始提示文字
function cleartip(n) {
	var f = g(fw_inputs[n])
	if (f.value == fw_tips[n]) {
		f.value = ""
		f.focus()
	}
}

// -------- 检索框提示文字 end -------- //

// 切换检索表单
function changeform(formobj) {
	for (var i = 1; i <= fw_inputs.length+1; i++) {
		if (formobj.id == "formtab_" + i) {
			g("forms").style.backgroundPosition = "left -" + ((i - 1) * 162) + "px"
			g("formbody_" + i).style.display = ""
		} else {
			g("formbody_" + i).style.display = "none"
		}
	}
}

// -->
