// JavaScript Document
window.onload=init;
function init(){
	if (window.navigator.userAgent.indexOf("MSIE")>=1){//如果浏览器为IE
		runSlideShow();	
	}else{ //如果浏览器为Firefox	
		if (window.navigator.userAgent.indexOf("Firefox")>=1){
 			rotate();
		}
	}	
	//搜索功能实现
	document.getElementById("searchItems").onchange=searchfun;
	//默认使用百度搜索
	document.getElementById("searchForm").setAttribute("action","http://www.baidu.com/baidu");
	document.getElementById("searchText").setAttribute("name","word");
	//移动专题
	initMoveText();
	 //onMouseOver="stopmove()"   onMouseOut="start()"
	document.getElementById("id_topic").onmouseover=stopmove;
	document.getElementById("id_topic").onmouseout=start;
}

/*
 *IE处理图片翻转，有渐变效果
 */

// 设置轮番显示速度 Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// 匀滑转换时间 Duration of crossfade (seconds)
var crossFadeDuration =3;
// 指定图像文件 Specify the image files
var aPic = new Array( "images/pic01.jpg", "images/pic02.jpg", "images/pic03.jpg", "images/pic04.jpg", "images/pic05.jpg");
var index= 0;
var preLoad = new Array();
for (i = 0; i < aPic.length; i++) {
	preLoad[i] = new Image();
	preLoad[i].src = aPic[i];
}
function runSlideShow() {
	var oPic=document.getElementById("SlideShow");
	oPic.style.filter="blendTrans(duration=2)";
	oPic.style.filter="blendTrans(duration=crossFadeDuration)";
	oPic.filters.blendTrans.Apply();
	oPic.src = preLoad[index].src;
	oPic.filters.blendTrans.Play();
	index = index + 1;
	if (index==preLoad.length) index = 0;
	setTimeout('runSlideShow()', slideShowSpeed);
}
/*
 *Firefox处理图片翻转，无渐变效果
 */
function rotate() {
	document.getElementById("SlideShow").src =preLoad[index].src;
	index++;
	if (index==preLoad.length) {
		index = 0;
	}
	setTimeout("rotate()", 5 * 1000);
}

//专题移动	
var  tm=null   
function  newsScroll(){
var scrolltext=document.getElementById("scrolltext");
if(scrolltext.parentNode.scrollLeft!=(scrolltext.clientWidth/2))   
	scrolltext.parentNode.scrollLeft++;   
	else   
	scrolltext.parentNode.scrollLeft=0   
}   
function initMoveText(){
var stext=document.getElementById("stext");
var stext2=document.getElementById("stext2");
	stext2.innerHTML=stext.innerHTML;   
	
	if (window.navigator.userAgent.indexOf("MSIE")>=1){//如果浏览器为IE
		tm=setInterval('newsScroll()',20);
	}else{ //如果浏览器为Firefox	
		if (window.navigator.userAgent.indexOf("Firefox")>=1){
 			tm=setInterval('newsScroll()',30)
		}
	}
}
function  stopmove(){   
  clearInterval(tm)   
}   
function  start(){      
	 	if (window.navigator.userAgent.indexOf("MSIE")>=1){//如果浏览器为IE
		tm=setInterval('newsScroll()',20);
	}else{ //如果浏览器为Firefox	
		if (window.navigator.userAgent.indexOf("Firefox")>=1){
 			tm=setInterval('newsScroll()',30)
		}
	}  
}

/* 搜索功能实现*/
function searchfun()
{
	var oSitems=document.getElementById("searchItems");
	var iIndex=oSitems.selectedIndex;
	var oSform=document.getElementById("searchForm");
	switch(iIndex)
	{
		case 0:
			//使用baidu搜索
			oSform.setAttribute("action","http://www.baidu.com/baidu");
			document.getElementById("searchText").setAttribute("name","word");
			break;
		case 1:
			//使用google搜索
			oSform.setAttribute("action","http://www.google.com/search");
			document.getElementById("searchText").setAttribute("name","q");
			break;
		case 2:
			//站内搜索
			oSform.setAttribute("action","http://google.jlnu.edu.cn/search");
			document.getElementById("searchText").setAttribute("name","q");
			break;
		default:break;
	}
}

//公共服务，Other Language 菜单JS实现
var mmOpenContainer = null;
var mmOpenMenus = null;
var mmHideMenuTimer = null;

function MM_menuStartTimeout(hideTimeout) {
	mmHideMenuTimer = setTimeout("MM_menuHideMenus()", hideTimeout);	
}

function MM_menuHideMenus() {
	MM_menuResetTimeout();
	if(mmOpenContainer) {
		var c = document.getElementById(mmOpenContainer);
		c.style.visibility = "inherit";
		mmOpenContainer = null;
	}
	if( mmOpenMenus ) {
		for(var i in mmOpenMenus) {
			var m = document.getElementById(mmOpenMenus[i]);
			m.style.visibility = "hidden";			
		}
		mmOpenMenus = null;
	}
}

function MM_menuHideSubmenus(menuName) {
	if( mmOpenMenus ) {
		var h = false;
		var c = 0;
		for(var i in mmOpenMenus) {
			if( h ) {
				var m = document.getElementById(mmOpenMenus[i]);
				m.style.visibility = "hidden";
			} else if( mmOpenMenus[i] == menuName ) {
				h = true;
			} else {
				c++;
			}
		}
		mmOpenMenus.length = c+1;
	}
}

function MM_menuOverMenuItem(menuName, subMenuSuffix) {
	MM_menuResetTimeout();
	MM_menuHideSubmenus(menuName);
	if( subMenuSuffix ) {
		var subMenuName = "" + menuName + "_" + subMenuSuffix;
		MM_menuShowSubMenu(subMenuName);
	}
}

function MM_menuShowSubMenu(subMenuName) {
	MM_menuResetTimeout();
	var e = document.getElementById(subMenuName);
	e.style.visibility = "inherit";
	if( !mmOpenMenus ) {
		mmOpenMenus = new Array;
	}
	mmOpenMenus[mmOpenMenus.length] = "" + subMenuName;
}

function MM_menuResetTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
}

function MM_menuShowMenu(containName, menuName, xOffset, yOffset, triggerName) {
	MM_menuHideMenus();
	MM_menuResetTimeout();
	MM_menuShowMenuContainer(containName, xOffset, yOffset, triggerName);
	MM_menuShowSubMenu(menuName);
}

function MM_menuShowMenuContainer(containName, x, y, triggerName) {	
	var c = document.getElementById(containName);
	var s = c.style;
	s.visibility = "inherit";
	
	mmOpenContainer = "" + containName;
}