﻿
function selectTag(selfObj,tagsName,showContent,no){
	var tag = document.getElementById(tagsName).getElementsByTagName("li");
	var taglength = tag.length;
	for(i=0; i<3; i++){
		tag[i].className = "";
	}
	selfObj.parentNode.className = "selectTag";

	for(i=0; j=document.getElementById(showContent+i); i++){
		j.style.display = "none";
	}
	document.getElementById(showContent+no).style.display = "block";	
	
}








$(document).ready(function() {
	//切换									
	  $(".tabslist").find("li").mouseover(function(){	
					 var obj=$(this).parent();
					 var objf=obj.parent().parent().find(".tabcon");
					 if(obj.find("li").length== objf.length)
					 {
					 obj.find(".cur").removeClass("cur");
					 $(this).addClass("cur");
					 objf.hide();
					 var index=$(this).index();
					 $(".tabslist").parent().find(".tabcon:eq("+index+")").show();
					 }
												  });
	
	 var newssrcoll=setInterval('AutoScroll("#news-list")',3200);
	
	 $("#news-list").hover(function(){window.clearInterval(newssrcoll);}, function(){newssrcoll=setInterval('AutoScroll("#news-list")',5000); })
	 
	 $("#p1-list").scrollImg(288,999000,'p1lbt','p1rbt',200);
	 $("#p2-list").scrollImg(404,999000,'p2lbt','p2rbt',200);
	 //菜单切换
	 $("#nav li").hover(
     function () {
	  
      $(this).find("a").addClass("cur");
	  $(this).find(".subnavpan").fadeIn(50);
    },
    function () {
      $(this).find("a").removeClass("cur");
	  $(this).find(".subnavpan").fadeOut(50);
   }
  
  
); 
    //快速导航
    $(".i-quicklink").hover(function(){$(this).find(".pan").fadeIn(200)},function(){$(this).find(".pan").fadeOut(200)});
	 
});


function AutoScroll(obj){
	  
        $(obj).find("ul:first").animate({
                marginTop:"-33px"
        },500,function(){
                $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
        });
}

function setcurpage(v)
{
	SetCookie("curtreeitem",v);	
}

function SetCookie(name,value)
{
	
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}
(function($) {   
   	 /*
	 objid: 对象ID
	 w: 对象嵌套子项
	 sp_t:切换间隔时间
	 lcid:左控制id
	 rcid:右控制id
	 sc_t:滚动需要的时间
	 */	
     $.fn.scrollImg = function(w,sp_t,lcid,rcid,sc_t) {  
	    var curIndex=0;
	    var obj=new Object();
	    obj=this;
        obj.objid=this.attr("id");	
		obj.w=w;
		obj.sp_t=sp_t;
		obj.lcid=lcid;
		obj.rcid=rcid;
		obj.sc_t=sc_t;
	    obj.l = this.find("li").length * obj.w;
		if(curIndex<=0)
			{
				$("#"+lcid).css("background","#fff");
				
			}
			else
			{
				$("#"+lcid).css("background","none");
			}	
		var scrollImg=function(){
			
			
		    curIndex++;
			
        var lv = -1 * curIndex * obj.w;
        var abs_lv;
        if (lv > 0) {
                lv = 0;
        } else {
                abs_lv = Math.abs(lv);
                if (abs_lv % obj.w != 0) {
                        lv = ( - 1) * obj.w * (abs_lv / obj.w )
                }
                abs_lv = Math.abs(lv);
                if (abs_lv > (obj.l - obj.w)) {
                        lv = 0;
                        curIndex = 0;
                }				
               $("#"+obj.objid).animate({
                        left: lv,
                        top: [0, "swing"]
                },
                obj.sc_t);
        }	
		if(curIndex<=0)
			{
				
				$("#"+lcid).css("background","#fff");
				curIndex=0;
			}
			else
			{
				$("#"+lcid).css("background","none");
			}
			
			};
		obj.intervalId =setInterval(scrollImg, obj.sp_t);		
		
       $("#"+this.rcid).click(function() {
                scrollImg()
        });
        $("#"+this.lcid).click(function() {
                curIndex = curIndex - 2;
				 scrollImg();
              
        });
        obj.hover(function() {			   
                window.clearInterval(obj.intervalId);
        },
        function() {
                obj.intervalId = setInterval(scrollImg, obj.sp_t);
				
			}
        );	
		
		
		
    };	
	
})(jQuery);   

