//下拉菜单
$(function(){
	$('#nav li').hover(function(){
		$(this).children('ul').stop(true,true).slideDown(200);
	},function(){
		$(this).children('ul').stop(true,true).slideUp(200);
	});
	
	$('#nav li').hover(function(){
		$(this).children('div').stop(true,true).slideDown('slow');
	},function(){
		$(this).children('div').stop(true,true).slideUp('slow');
	});
});

//无刷新切换选项卡
$(document).ready(function() { 
//Default Action 
$(".tab_content").hide(); //Hide all content 
$("ul.tabs li:first").addClass("active").show(); //Activate first tab 
$(".tab_content:first").show(); //Show first tab content 

//On Click Event 
$("ul.tabs li").click(function() { 
$("ul.tabs li").removeClass("active"); //Remove any "active" class 
$(this).addClass("active"); //Add "active" class to selected tab 
$(".tab_content").hide(); //Hide all tab content 
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
$(activeTab).fadeIn(); //Fade in the active content 
return false; 
}); 
});


//图片显隐特效
$(function () {
$('img').hover(
function() {$(this).fadeTo("fast", 0.8);},
function() {$(this).fadeTo("fast", 1);
});
});


//公告
$(document).ready(function(){
    $("#web-tip li:not(:first)").css("display","none");
    var B=$("#web-tip li:last");
    var C=$("#web-tip li:first");
    setInterval(function(){
    if(B.is(":visible")){
    C.fadeIn(500).addClass("in");B.hide()
    }else{
    $("#web-tip li:visible").addClass("in");
    $("#web-tip li.in").next().fadeIn(500);
    $("li.in").hide().removeClass("in")}
    },5000) //每3秒钟切换一条，你可以根据需要更改
})


//搜索框聚焦
$(document).ready(function(){				   
	$('#ls').focus(
		function() {
			if($(this).val() == '搜索关键字') {
				$(this).val('').css({color:"#222"});
			}
		}
	).blur(
		function(){
			if($(this).val() == '') {
				$(this).val('搜索关键字').css({color:"#787878"});
			}
		}
	);
});
	


//评论框聚焦
$(document).ready(function(){
	$('#comment').focus(
		function() {
			if($(this).val() == '添加评论内容') {
				$(this).val('').css({color:"#222"});
			}
		}
			
	).blur(
		function(){
			if($(this).val() == '') {
				$(this).val('添加评论内容').css({color:"#454545"});
			}
		}
	);
});


//Crel+Enter快捷回复
$(document).keypress(function(e){
	if(e.ctrlKey && e.which == 13 || e.which == 10) { 
		$("#submit").click();
			document.body.focus();
		} else if (e.shiftKey && e.which==13 || e.which == 10) {
			$("#submit").click();
        }          
})



//滚动图片
var Speed = 10; //速度(毫秒)
var Space = 20; //每次移动(px)
var PageWidth = 672; //翻页宽度
var interval = 4000; //翻页间隔时间
var fill = 0; //整体移位
var MoveLock = false;
var MoveTimeObj;
var MoveWay="right";
var Comp = 0;
var AutoPlayObj=null;
function GetObj(objName){
	if(document.getElementById){
		return eval('document.getElementById("'+objName+'")')
		}
		else{
			return eval('document.all.'+objName)
			}
			}
function AutoPlay(){
	clearInterval(AutoPlayObj);
	AutoPlayObj=setInterval('ISL_GoRight();ISL_StopRight();',interval)
	}
function ISL_GoLeft(){
	if(MoveLock)return;
	clearInterval(AutoPlayObj);
	MoveLock=true;
	MoveWay="left";
	MoveTimeObj=setInterval('ISL_ScrLeft();',Speed);
	}
function ISL_StopLeft(){
	if(MoveWay == "right"){
		return
		};
		clearInterval(MoveTimeObj);
		if((GetObj('ISL_Cont').scrollLeft-fill)%PageWidth!=0){
			Comp=fill-(GetObj('ISL_Cont').scrollLeft%PageWidth);
			CompScr()}else{MoveLock=false
			}
AutoPlay()
}
function ISL_ScrLeft(){
	if(GetObj('ISL_Cont').scrollLeft<=0){
		GetObj('ISL_Cont').scrollLeft=GetObj('ISL_Cont').scrollLeft+GetObj('pic-list1').offsetWidth
		}
GetObj('ISL_Cont').scrollLeft-=Space
}
function ISL_GoRight(){
	clearInterval(MoveTimeObj);
	if(MoveLock)return;
	clearInterval(AutoPlayObj);
	MoveLock=true;
	MoveWay="right";
	ISL_ScrRight();
	MoveTimeObj=setInterval('ISL_ScrRight()',Speed)
	}
function ISL_StopRight(){
	if(MoveWay == "left"){return};
	clearInterval(MoveTimeObj);
	if(GetObj('ISL_Cont').scrollLeft%PageWidth-(fill>=0?fill:fill+1)!=0){
		Comp=PageWidth-GetObj('ISL_Cont').scrollLeft%PageWidth+fill;
		CompScr()}else{MoveLock=false
		}
AutoPlay()
}
function ISL_ScrRight(){
	if(GetObj('ISL_Cont').scrollLeft>=GetObj('pic-list1').scrollWidth){
		GetObj('ISL_Cont').scrollLeft=GetObj('ISL_Cont').scrollLeft-GetObj('pic-list1').scrollWidth
		}
GetObj('ISL_Cont').scrollLeft+=Space
}
function CompScr(){
	if(Comp==0){
		MoveLock=false;return
		}
var num,TempSpeed=Speed,TempSpace=Space;
if(Math.abs(Comp)<PageWidth/2){
	TempSpace=Math.round(Math.abs(Comp/Space));
	if(TempSpace<1){TempSpace=1
	}
	}
if(Comp<0){
	if(Comp<-TempSpace){
		Comp+=TempSpace;num=TempSpace
		}
		else{
			num=-Comp;
			Comp=0
			}
GetObj('ISL_Cont').scrollLeft-=num;setTimeout('CompScr()',TempSpeed)
}
else{
	if(Comp>TempSpace){
		Comp-=TempSpace;num=TempSpace
		}
		else{
			num=Comp;Comp=0
			}
GetObj('ISL_Cont').scrollLeft+=num;
setTimeout('CompScr()',TempSpeed)
}
}
function picrun_ini(){
GetObj("pic-list2").innerHTML=GetObj("pic-list1").innerHTML;
GetObj('ISL_Cont').scrollLeft=fill>=0?fill:GetObj('List1').scrollWidth-Math.abs(fill);
GetObj("ISL_Cont").onmouseover=function(){clearInterval(AutoPlayObj)}
GetObj("ISL_Cont").onmouseout=function(){AutoPlay()}
AutoPlay();
}
