// JavaScript Document

//
$(function(){
	  
	  /*图片集锦的切换效果*/
	  var _index5=0;
		$("#four_flash .but_right img").click(function(){
			_index5++;
			var len=$(".flashBg ul.mobile li").length;
			if(_index5+5>len){
				$("#four_flash .flashBg ul.mobile").stop().append($("ul.mobile").html());
			}
			$("#four_flash .flashBg ul.mobile").stop().animate({left:-_index5*270},1000);
			});
		
			
		$("#four_flash .but_left img").click(function(){
			if(_index5==0){
				$("ul.mobile").prepend($("ul.mobile").html());
				$("ul.mobile").css("left","-1380px");
				_index5=6
			}
			_index5--;
			$("#four_flash .flashBg ul.mobile").stop().animate({left:-_index5*270},1000);
			});
		
		
	/*新闻动态切换*/
	$(".new_tp_rt ul li").hover(function(){
		$(this).attr("class"," list_yd").siblings().removeClass("list_yd");
		var bb=$(this).attr("dd");
		$(".nva_topmer").hide();
		$(".tab"+bb).show();
	})
	
	
	
	
	
	/*首页保安报*/
	$.fn.extend({
		xulCarousel: function () {
			var params = {
				prev:  arguments[0].prev ? $("#" + arguments[0].prev) : null,  // prev ID
				next: arguments[0].next ? $("#" + arguments[0].next) : null,   // next ID
				auto: arguments[0].auto || null,    // auto scroll time
				speed: arguments[0].speed || 300    // scroll speed
			};
  
			var $me = this;
			var $li = this.children("li");
  
			if ($li.length < 2) return;
			$me.parent().css("overflow", "hidden");
  
			var liWidth = $li.eq(0).outerWidth(true);
			
			$li.each(function(){
				$(this).width(liWidth);
			});
			
			var autoScroll = {
				hTimer: null,
				start: function () {
					if (!params.auto) return;
  
					this.hTimer = setInterval(function () {
						procNext();
					}, params.auto);
				},
				stop: function () {
					if (this.hTimer) clearInterval(this.hTimer);
					this.hTimer = null;
				}
			};
  
			if (params.auto) {
				autoScroll.start();
			}
  
			this.width(liWidth * ($li.length + 1));
  
			function procNext(callback) {
				$me.animate({ marginLeft: -liWidth }, params.speed, function () {
					var $liFirst = $me.children("li:first").clone();
					$me.css({ marginLeft: 0 });
					$me.children("li:first").remove();
					$me.append($liFirst);
  
					callback && callback();
				});
			}
  
			function procPrev(callback) {
				var $liLast = $me.children("li:last").clone();
				$me.css({ marginLeft: -liWidth });
				$me.prepend($liLast);
				$me.children("li:last").remove();
  
				$me.animate({ marginLeft: 0 }, params.speed);
  
				callback && callback();
			}
  
			params.next && params.next.click(function () {
				autoScroll.stop();
				procNext(function () {
					autoScroll.start();
				});
			});
  
			params.prev && params.prev.click(function () {
				autoScroll.stop();
				procPrev(function () {
					autoScroll.start();
				});
			});
  
			this.mouseover(function () {
				autoScroll.stop();
			}).mouseleave(function () {
				autoScroll.start();
			});
  
			return this;
		}
	});
	
    $("#rep_dom>ul").xulCarousel({ prev: "pre_left", next: "pre_right", auto: false });
});
































