// JavaScript Document
//plugin in show getid 20110401
function GetQueryString(name) {

   var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");

   var r = window.location.search.substr(1).match(reg);

   if (r!=null) return unescape(r[2]); return null;

}
$(function(){
		  var cid=GetQueryString("CateId");
		  if($("#cssid"+cid).length>0)
		  {
			if($("#cssid"+cid).siblings("ul").children("li").length>0){
				setTimeout(function(){$("#cssid"+cid).siblings("ul").slideDown().end().parent().addClass("hover").siblings().removeClass("hover").siblings("ul").hide()},500);
				}
			}
		  
		   });
//plugin tabbox
$(function(){
		   $(".tab a").bind("mouseover",function(){
												 $(this).addClass("hover").siblings().removeClass("hover");
												 var num=$(this).parent(".tab").children("a:not(.more)").index(this);
												 $(this).parent().parent().children(".tabcon").children().eq(num).show().siblings().hide();
												 })
		   });
//plugin jxtab
//plugin in tab
$(function(){
		   $.fn.extend({"jxtab":function(c){
					            $(this).bind(c||"click",function(){
													   var n=$(this).parent().children().index(this);
													   $(this).addClass("hover").siblings().removeClass("hover");
													   $(this).parent().parent().siblings(".tabcon").children().hide().eq(n).show();
													   });
							   }
							   });
		   })
////.....
$(function(){
		   $(".news_list_t p a").jxtab("mouseover");
		   })

//scroll+tab
$(function(){
		   $(".tbox p a").bind("mouseover",function(){
			$(this).addClass("hover").siblings().removeClass("hover");
			var $ns=$(this).parent().children().index(this);
			var $this=$(this).parent().parent().siblings().children().children(".scrollcon").eq($ns);
			$this.show().siblings(".scrollcon").hide();
			gg($this);
			}).eq(0).trigger("mouseover");
		   function gg(obj){
			$(".gleft,.gright").unbind("click");
			var $n=$t=0;
			var $slen= obj.children(".scon").children("li").length;
			var $swidth=parseInt(obj.children(".scon").children("li").innerWidth(true));//计算显示块的大小
			var $scrollul=obj.children(".scon");//获得显示内容总长度对象
			var $sw_=parseInt(obj.width());//取得显示屏大小
			var $slen_=Math.ceil($sw_/$swidth);//计算显示块的大小的最小数
			$t=$slen>$slen_?($slen%$slen_==0?Math.floor($slen/$slen_)-1:Math.floor($slen/$slen_)):0;//取得显示屏数
			var $sws=$slen_*$swidth;
			$scrollul.css("left","0");
			$(".gleft").bind("click",function(){
            if($n>0&&!$scrollul.is(":animated"))
			{$scrollul.animate({left:"+="+$sws},350);
			  $n--;
			}
			});
			$(".gright").bind("click",function(){
			if($n<$t&&$t>0&&!$scrollul.is(":animated"))
			{$scrollul.animate({left:"-="+$sws},350);
			  $n++;
			  }
			});
			   }
		   });
//plugin load img
jQuery.fn.loadthumb = function(options) {
	options = $.extend({
		 src : ""
	},options);
	var _self = this;
	_self.hide();
	var img = new Image();
	$(img).load(function(){
		_self.attr("src", options.src);
		_self.fadeIn("slow");
	}).attr("src", options.src);
	return _self;
};
// img show
$(function(){
	       function showimg(index){
			   var obj=$("#news_imglist a").eq(index);
			   obj.addClass("hover").siblings().removeClass("hover");
			   $("#bigimg img").loadthumb({src:obj.attr("rel")});
			   $("#txt_img a").text(obj.attr("title")).attr("href",$(this).attr("href"));
			   }
		   var len  = $("#news_imglist a").length;
		   var index = 0;
		   var adTimer; 
		   $("#news_imglist a").bind("mouseover",function(){
															index  =   $("#news_imglist a").index(this);
															showimg(index);
														 }).eq(0).mouseover().click(function(){return false;});
														 $('.news_flash').hover(function(){
																 clearInterval(adTimer);
															 },function(){
																 adTimer = setInterval(function(){
																	index++;
																	if(index==len){index=0;}
																	showimg(index);	
																  } , 3000);
														 }).trigger("mouseleave");
														  
		   });

//left Menu
$(function(){
		   $(".leftMenu p a").bind("click",function(){
											$(this).addClass("hover").parent().siblings("ul").hide().siblings("p").children().removeClass();
											$(this).addClass("hover").parent().next("ul").toggle(300);
											})
		   $(".leftMenu p a.hover").parent().next("ul").show(300);
		   })
