(function ($, plugin) {
	var data = {}, id = 1, etid = plugin + 'ETID';

	// 延时构造器
	$.fn[plugin] = function (speed, group) {
		id ++;
		group = group || this.data(etid) || id;
		speed = speed || 150;

		// 缓存分组名称到元素
		if (group === id) this.data(etid, group);

		// 暂存官方的hover方法
		this._hover = this.hover;

		// 伪装一个hover函数，并截获两个回调函数交给真正的hover函数处理
		this.hover = function (over, out) {
			over = over || $.noop;
			out = out || $.noop;
			this._hover(function (event) {
				var elem = this;
				clearTimeout(data[group]);
				data[group] = setTimeout(function () {
					over.call(elem, event);
				}, speed);
			}, function (event) {
				var elem = this;
				clearTimeout(data[group]);
				data[group] = setTimeout(function () {
					out.call(elem, event);
				}, speed);
			});

			return this;
		};

		return this;
	};

	// 冻结选定元素的延时器
	$.fn[plugin + 'Pause'] = function () {
		clearTimeout(this.data(etid));
		return this;
	};

	// 静态方法
	$[plugin] = {
		// 获取一个唯一分组名称
		get: function () {
			return id ++;
		},
		// 冻结指定分组的延时器
		pause: function (group) {
			clearTimeout(data[group]);
		}
	};

})(jQuery, 'mouseDelay');


jQuery(document).ready(function($) {
	//$(".custom-part img").removeAttr("width").removeAttr("height");
	
	$("img").removeAttr("width").removeAttr("height").removeAttr("title");
	
	$("#gallery img").eq(0).addClass("first-pic");
	
	$(".custom-part:empty").parent().hide();
	
	var nowUrl = window.location.href;
    $(".sub-masters a").each(function(i){
        if($(this).attr("href") == nowUrl ) {
            $(this).parent().removeClass("off").addClass("on");
            }
        })
		
	$(".sub-masters ul li.on").animate({top:-30},{queue: false, duration:300}).unbind("hover");
	
	
	$(".sub-masters ul li.off").hover(function(){
		$(this).animate({top:-30},{queue: false, duration:300}).css({"z-index":100})
		},function(){
		$(this).animate({top:0},{queue: false, duration:300}).css({"z-index":10})
		});
		
	
	$(".ystd a[rel='tag']").each(function(){
		$(this).contents().unwrap();
		})
	$(".pika-image img").each(function(){
		$(this).unwrap();
		})
			
	$(".cal-block").each(function(){$(this).addClass($(this).find(".block-date").text()).css({ top: (Number($(this).find(".hour").text())-13)*120 + (Number($(this).find(".min").text())/10)*20 + 117 })})

	$(".meta-nav").parent().remove();
	
	$(".post-pic:empty").parent().addClass("no-pic");
	
	$(".single-post .post-text h2").unwrap();
	
	$(".sub-menu li:last-child").css({"background": "none"});
	
	//$(".single-post #menu-item-29").addClass("current-menu-ancestor,current-menu-parent");
	$(".single-expo-show #menu-item-47").addClass("current-menu-parent");
	$(".single-expo-show #menu-item-365").addClass("current-menu-item");
	
		
	$(".single-green-note #menu-item-677,.single-green-note #menu-item-606,.single-post #menu-item-510,.single-post #menu-item-656,.single-expo-show #menu-item-667,.single-expo-show #menu-item-548").addClass("current-menu-item");
	
	$(".breadcrumb .post-categories a").unwrap().unwrap();
	
	$(".ystd .cal-block .tit").fadeTo(300,0.5);
	
	$(".week-content1 ul li").each(function(){
		$(this).css({ top:(Number($(this).find(".time").text())-8)*260 + 42,left: Math.floor(Number($(this).find(".date").text())/4 )*400 + (Number($(this).find(".date").text())%4 - 1)*100 + 7 })
		//alert((Number($(this).find(".date").text())%4)*100)
		})
	
	$(".week-content1 ul li").hover(function(){
		$(this).find("img:first-child").hide();
		},function(){
		$(this).find("img:first-child").show();
		})
		
	$(".xuzhi ul li span").after("<div class='clear'></div>");
	
		$(".breadcrumb a:eq(0)").after(' \\ ' + $("#menu-main-menu>li>ul:visible").parent().html());

	
	$(".home-news ul li span").each(function(){
		var maxwidth=50;
		if($(this).text().length>maxwidth){
		$(this).text($(this).text().substring(0,maxwidth));
		$(this).html($(this).html()+'…');
		}
		});
		
	$(".jiepai").parents("#main").find(".act1").removeClass("off").fadeTo(300,1);
	$(".yinyuehui").parents("#main").find(".act2").removeClass("off").fadeTo(300,1);
	$(".huancheng").parents("#main").find(".act3").removeClass("off").fadeTo(300,1);	
	$(".act-bot ul li.off").fadeTo(300,0.4);
	$(".act-bot ul li.off").hover(function(){
		$(this).fadeTo(300,0.8)
		},function(){
		$(this).fadeTo(300,0.4)
		})

	$(".cal-tit2011 .btn16_,.gn-change .gn16").click(function(){
		$(".greennote15,.woodenstage15,.riversidestage15,.intheater15,.earthlounge15").hide();
		$(".greennote16,.woodenstage16,.riversidestage16,.intheater16,.earthlounge16").show();
		$(".cal-tit2011").css("background-position","right top");
		$(".gn-change").css("background-position","-277px bottom");
		})
	$(".cal-tit2011 .btn15_,.gn-change .gn15").click(function(){
		$(".greennote16,.woodenstage16,.riversidestage16,.intheater16,.earthlounge16").hide();
		$(".greennote15,.woodenstage15,.riversidestage15,.intheater15,.earthlounge15").show();
		$(".cal-tit2011").css("background-position","left top");
		$(".gn-change").css("background-position","left bottom");
		})
	
		
	$(".block_ds ul li").mouseDelay(150).hover(function(){
		$(".block_ds ul li").not($(this)).fadeTo(300,0.5);
		$(this).fadeTo(300,1);
		},function(){
		$(".block_ds ul li").fadeTo(300,1);
		})
		
	$(".home-btn ul li").mouseDelay(150).hover(function(){
		$(".home-btn ul li").not($(this)).fadeTo(300,0.5);
		$(this).fadeTo(300,1);
		},function(){
		$(".home-btn ul li").fadeTo(300,1);
		})
		
	
	$(".turn-r").click(function(){
		$(this).hide();
		$(".turn-l").show();
		$(".map-in").animate({left:"-511px",top:0},{queue:false, duration:400, easing:"circEaseOut"});
		})
	$(".turn-l").click(function(){
		$(this).hide();
		$(".turn-r").show();
		$(".map-in").animate({left:0,top:"-105px"},{qduration:400, easing:"circEaseOut"})
		})

	$(".tab_cont div").hide();
	$(".tab_cont div.tab1").show();
	$(".tab_menu li").each(function(){
		$(this).click(function(){
			//alert($(".tab_cont div." + $(this).attr("id")).html());
			$(".tab_menu li").removeClass("on");
			$(this).addClass("on");
			$(".tab_cont div").hide();
			$(".tab_cont div." + $(this).attr("id")).show();
		})
	})
		
});

	

