//----------------------滚动logo-----------------------------
(function($){
$.fn.extend({
        Scroll:function(opt,callback){
                //参数初始化
                if(!opt) var opt={};
                var _this=this.eq(0).find("ul:first");
                var        lineH=_this.find("li:first").height(), //获取行高
                        line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
                        speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度，数值越大，速度越慢（毫秒）
                        timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
                if(line==0) line=1;
                var upHeight=0-line*lineH;
                //滚动函数
                scrollUp=function(){
                        _this.animate({
                                marginTop:upHeight
                        },speed,function(){
                                for(i=1;i<=line;i++){
                                        _this.find("li:first").appendTo(_this);
                                }
                                _this.css({marginTop:0});
                        });
                }
                //鼠标事件绑定
                _this.hover(function(){
                        clearInterval(timerID);
                },function(){
                        timerID=setInterval("scrollUp()",timer);
                }).mouseout();
        }        
})
})(jQuery);

$(function(){
//去掉A链接虚线框
	$("a").bind("focus",function(){if(this.blur)this.blur();});
	autoTab();
//滚动广告
	//adRollScr([["images/adroll1.jpg","1.html"],["images/adroll2.jpg","2.html"],["images/adroll1.jpg","3.html"],["images/adroll2.jpg","4.html"]]);
//滚动logo
	$("#scrollLogo").Scroll({line:1,speed:500,timer:3000});
//左侧菜单折叠
	$(".lySideMenu li a").each(function(s){
		$(this).click(function(){
			var sidemenustate = $(this).parents("ul").attr("class");
		})
	})
	$('.lySideMenu h3').click(function() {
		$('.lySideMenu h3').next().hide();	
		$(this).next().show();
		$(".lySideMenu h3.active").removeClass("active");
		$(this).addClass("active");
	});

	
//文本框提示文字
	$(".lyLogin input[type=text]").focus(function(){
		tmptxt = $(this).attr("title");
		if(tmptxt){
			nowtxt = $(this).val();
			if(tmptxt==nowtxt){
				$(this).val("");
				$(this).css("color","#000");
			}
		}
	}).blur(function(){
		if($(this).val()==""){
			$(this).val(tmptxt);
			$(this).css("color","#999");
		}
	})

//三级导航弹出
	$(".lyNavSec li a").hover(function(){
			var obj = $(this);
			$(this).addClass("active");
			$(".lyNavThdWrap").hide();
			x = setTimeout(function(){
				if($(".lyNavThdWrap:visible")){
					$("#"+ obj.attr("rel")).show();
				}
			},300);
	},function(){
			$(this).removeClass("active");
			try {
			window.clearTimeout(x);	
		} catch(err) {}
			y = setTimeout(function(){$(".lyNavThdWrap").hide()},300);
	})
	
	$(".lyNavThdWrap").mouseover(function(){
		$(".lyNavSec li a[rel="+$(this).attr("id")+"]").addClass("active");
		window.clearTimeout(y);
		try {
			window.clearTimeout(z);	
		} catch(err) {}
		$(this).show();
	}).mouseout(function(){
		var obj = $(this);
		z = setTimeout(function(){
			obj.hide();
			$(".lyNavSec li a[rel="+obj.attr("id")+"]").removeClass("active");
		},300);
	})
	
//首页tab
	$(".indexTab li a").click(function(){
		var tabTitCont = $(this).parent().parent("ul");
		var tabCont = tabTitCont.attr("title");
		$("a",tabTitCont).removeAttr("class");
		$(this).attr("class","now");
		$("."+tabCont).hide();
		$("."+tabCont).eq(parseInt($(this).attr("id"))-1).show();
		return false;
	})
	//关闭弹出层
	$(".popArea .close,.popAreaOk .close,.popAreaErr .close, .popAreaConf .close, .popArea .pop_close, .popAreaShop .close").live("click",function(id){
		$(".masklay,.popArea,.popAreaOk,.popAreaErr,.popAreaConf").remove();
		$("body","html").css({height: "auto", width: "auto"});
		$("select").show();
		var O_input = $(this).attr("info1");
		$("#"+O_input).focus();
		return false;
	})
})


//--------------------------滚动广告----------------------------
announceNun = 1;
setInterval(function(){
	announceNun = announceNun%($("#scrollAnnounce li").length);
	$("#scrollAnnounce li").hide();
	$("#scrollAnnounce li").eq(announceNun).fadeIn("slow");
	announceNun++;
},4000);
function adRollScr(adArr){
	var rollCont = 0;
	var adpage = "";
	
	//构造翻页页码
	for (var i=1; i<adArr.length+1; i++){
		adpage += "<li><a href='#'>"+ i +"</a></li>";
	}
	$(".adRoll ul").html(adpage);
	$(".adRoll ul li").eq(0).attr("id","adpNow");
	
	function autoRoll(){
		$(".adRollCont").hide();
		$("#adpNow").removeAttr("id");
		$(".adRoll ul li").eq(rollCont).attr("id","adpNow");
		
		$(".adRollCont a").attr("href",adArr[rollCont][1]);
		$(".adRollCont img").attr("src",adArr[rollCont][0]);
		
		rollCont < adArr.length-1 ? rollCont++ : rollCont = 0;
		$(".adRollCont").fadeIn(500);
		$(".adRollCont").show();
	}
	autoRoll();
	autoR = setInterval(autoRoll,3000);
	
	//页码点击
	$(".adRollpage ul li").each(function(adPageNum){
		$(this).click(function(){
			$("#adpNow").removeAttr("id");
			$(this).attr("id","adpNow");
			
			$(".adRollCont a").attr("href",adArr[adPageNum][1]);
			$(".adRollCont img").attr("src",adArr[adPageNum][0]);
			
			rollCont = adPageNum;
		})
	})
}
//--------------------------页签自动滚动函数----------------------------
function autoTab(i){
	if($(".rightTab").length>4){
		var i=0;

		autoT = setInterval(function(){
			$(".rightTab:visible").hide();
			$(".rightTab").eq(i).show();
			$("ul[title='rightTab'] li a.now").removeClass("now");
			$("ul[title='rightTab'] li a").eq(i).attr("class","now");
			if (i==$("ul[title='rightTab'] li a").length-1)
				i=0;
			else
				i++;
		},5000)
	}
}