/*
 * based on jQuery 1.7.1
 * Copyright (c) 2011 THMZ.COM
 * @ Author: DevAnge.GuoCong
 * @ Update: 2012-02-15
 * @ Log: 
 */


var thmz = {};

function openUrl(url) {
	window.open(url);
}
function gotoUrl(url, delay) {
	setTimeout(function() {
		window.location.href = url;
	}, delay);
}
function closeWrp(o) {
	for (var i=0; i<o.length; i++) {
		o[i].fadeOut(200);
	}
}
function setfav(name, url) {
	if (navigator.appName == "Netscape") {
		window.sidebar.addPanel(name,url,"")
	} else {
		window.external.addFavorite(url,name);
	}
}
(function($) {
	$.fn.globalTips = function(o) {
		o = $.extend({
			id: null,
			content: "",
			autoClose: false,
			close: true
		}, o || {});
		return this.each(function() {
			var tipBar = $("<div class='global-tips' />"),
				content = $("<div id='"+ o.id +"' class='wrp' />"),
				_close = $('<a href="javascript:void(0);" class="close">X</a>');
			content.append(o.content);
			if (o.close) content.append(_close);
			tipBar.append(content);
			_close.click(function() {
				tipBar.slideUp(300);
			});
			$(this).prepend(tipBar);
			tipBar.slideDown(300, function() { refreshElementInDom("#hd") });
		});
	}
})(jQuery);
function refreshElementInDom(el) {
	$(el).hide().show();
}
function oopsSuchAnOldBrowser() {
	var oops = "您使用的浏览器版本过于陈旧，为了获得更好的浏览操作体验，请使用：<span class='firefox'><a href='http://www.firefox.com.cn/download/' target='_blank'>火狐浏览器</a></span>、<span class='chrome'><a href='http://www.google.com/chrome?brand=CHKZ&hl=zh-CN' target='_blank'>谷歌浏览器</a></span><!--，或者更新您的IE浏览器到最新版本<span class='ie9'><a href='http://windows.microsoft.com/zh-CN/internet-explorer/products/ie/home' target='_blank'>Internet Explorer 9</a></span>-->";
	if ( $.browser.msie && $.browser.version < 8 ) {
		setTimeout(function() {
			$("body").globalTips({
				id: "update-browser",
				content: oops
			});
		}, 1000);
	}
}
function sethome() {
	if (window.sidebar && navigator.appName == "Netscape") {
		try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } 
		catch (e) { alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true"); }
	} else {
		document.body.style.behavior="url(#default#homepage)";
		try { document.body.setHomePage(window.location.href); } catch (e) {};
	}
}
function date(format) {
	var today = new Date();
	var day = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],
		y = today.getFullYear()+"年",
		m = (today.getMonth()<9?("0"+(today.getMonth()-(-1))):(today.getMonth()-(-1)))+"月",
		d = (today.getDate()<10?"0"+today.getDate():today.getDate())+"日",
		day1 = day[today.getDay()],
		output;
	switch (format) {
		case "ymd":
			output = y+m+d;
		break;
		case "md":
			output = m+d;
		break;
		case "ym":
			output = y+m;
		break;
		case "mdd":
			output = m+d+" "+day1;
		break;
		default:
			output = y+m+d+" "+day1;
		break;
	}
	document.write(output);
}
function active(o) {
	for (var i=0; i<o.length; i++) {
		$(o[i]).hover(function() {
			$(this).addClass("active");
		}, function() {
			$(this).removeClass("active");
		});
	}
}
function checkForm(o,a) {
	var option, label;
	for (var i=0; i<a.length; i++) {
		option = o.find(".txt[name='"+a[i]+"']");
		label = o.find("label[for='"+a[i]+"']");
		if ( option.attr("type") == "radio" ) {
			if ( !option.is(":checked") ) {
				alert("请选择"+label.text());
				return false;
			}
		} else {
			if ( option.val() == option.data("def_val") || option.val() == "" ) {
				if ( label.length != 0 && label.text() != "" ) {
					alert("请输入"+label.text());
				} else if ( option.data("def_val") != "" ) {
					alert(option.data("def_val"));
				}
				option.focus();
				return false;
			}
		}
	}
}
function slide(id) {
	var slide_obj = $("#"+id);
	var slide_num = slide_obj.find(".tab-content li").length;
	slide_obj.find(".tab-content li").eq(0).addClass("current");
	if ( slide_obj.hasClass("focus-category") ) {
		var slide_wrp = slide_obj.find(".focus-opt");
		var triggerHeight = (slide_obj.height()-(4*(slide_num-1)))/slide_num;
		slide_wrp.find("li a").css({"height":triggerHeight+"px", "line-height":triggerHeight+"px"});
		slide_wrp.find("li s").css({"top":(triggerHeight-8)/2+"px"});
	} else {
		var slide_wrp = jQuery("<div class='focus-opt'>");
		var slide_ul = jQuery("<ul>");
		var slide_bar = "<div class='focus-opt-bar'>";
		slide_obj.find(".tab-content li a").each(function() {
			$(this).append("<div class='focus-opt-bar'>" + $(this).find("img").attr("alt") + "</div>");
		})
		for (var i = 0; i < slide_num; i++) {
			slide_ul.append("<li>"+(i+1)+"</li>")
		}
		slide_wrp.append(slide_ul);
		slide_obj.append(slide_wrp);
		slide_wrp.find("li").each(function(i) {
			$(this).find(".inner-wrp").html(i+1);
		});
		slide_obj.find(".tab-content li a").hover(function() {
			$(".focus-opt-bar", this).css({background:"rgba(0, 0, 0, 0.9)"});
		}, function() {
			$(".focus-opt-bar", this).css({background:"rgba(0, 0, 0, 0.7)"});
		})
	}
	slide_wrp.find("li").eq(0).addClass("current");
	var slide_t, slide_i = 1;
	var slide = function(i) {
		slide_i<(slide_num-1)?slide_i++:slide_i=0;
		var slide_content = slide_obj.find(".tab-content li").eq(i);
		slide_obj.find(".tab-content li").eq(i).fadeIn().siblings().fadeOut();
		slide_wrp.find("li").eq(i).addClass("current").siblings().removeClass("current");
	}
	slide_t = setInterval(function() {
		slide(slide_i);
	},4000);
	slide_wrp.find("li").hover(function() {
		slide_i = $(this).index();
		slide(slide_i);
	});
	slide_obj.hover(function() {
		clearInterval(slide_t);
	}, function() {
		slide_t = setInterval(function() {
			slide(slide_i);
		},4000);
	});
}

function tab(id) {
	if (document.getElementById("livcell_hidden")) jQuery.noConflict();
	(function($) { 
		if ($(id).hasClass("tab-block")) {
			var t;
			$(id).find(".tab-title>span").each(function() {
				$(this).hover(function() {
					var self = $(this);
					var tab_content = self.parents('.tab-block').find(".tab-content>ul,.tab-content>.tab-content-i").eq(self.index());
					t = setTimeout(function() {
						self.addClass("current").siblings().removeClass("current");
						tab_content.addClass("current").siblings().removeClass("current");
					}, 50);
				}, function () {
					clearTimeout(t);
				});
			});
		}
	})(jQuery);
}

Array.prototype.max = function() {
	return Math.max.apply({},this);
}
function equalHeight(group) {
	var heightArray = [];
	setTimeout(function() {
		for (var k = 0; k < group.length; k++) {
			heightArray.push($(group[k]).height());
		}
		var heightMax = heightArray.max();
		for (var i = 0; i < group.length; i++) {
			var bh = 0, row, margin;
			if ( $(".main-wrp", group[i]).size()!=0 ) {
				for (var j = 0; j < $(group[i]).find(".main-wrp .block").size()-1; j++) {
					var block = $(group[i]).find(".main-wrp>div").hasClass("inner-main") ? $(group[i]).find(".main-wrp .block") : $(group[i]).find(".main-wrp>div");
					margin = parseInt(block.css("margin-top")) + parseInt(block.css("margin-bottom")) + parseInt(block.css("border-top-width")) + parseInt(block.css("border-bottom-width"));
					bh += $(group[i]).find(".main-wrp:last .block").eq(j).height()+margin;
				}
				margin = parseInt($(group[i]).find(".main-wrp:last .block:last").css("margin-top")) + parseInt($(group[i]).find(".main-wrp:last .block:last").css("margin-bottom"));
				$(group[i]).find(".main-wrp:last .block:last").height(heightMax-bh-margin);
			} else {
				for (var j = 0; j < $(group[i]).find(">div").size()-1; j++) {
					var block = $(group[i]).find(">div>div");
					margin = parseInt(block.css("margin-top")) + parseInt(block.css("margin-bottom")) + parseInt(block.css("border-top-width")) + parseInt(block.css("border-bottom-width"));
					bh += $(group[i]).find(">div>div").eq(j).height()+margin;
				}
				margin = parseInt($(group[i]).find(">div:last>div").css("margin-top")) + parseInt($(group[i]).find(">div:last>div").css("margin-bottom"));
				$(group[i]).find(">div:last>div").height(heightMax-bh-margin);
			}
		}
	}, 100);
}

/* 内页 */
function listSeprator(el, n) {
	var sep = "<li class='hr'></li>";
	var len = $(el).length;
	$(el).not('.hr').each(function(i) {
		var _this = $(this);
		if ((i+1)%n == 0 && i != (len-1)) _this.after(sep);
	});
}
function printArticle() {
	$("#bd .sub, #browse-mode").hide();
	$("#bd .main-wrp").css({"width":"100%", "padding-right":0});
	window.print();
}
function articlePage() {
	var article = $("#bd div.article");
	if ( article.length > 0 ) {
		article.find(".related dd").append($("#temp").html()); //相关新闻
		$("#temp").remove();
		var _switch = $('<div id="browse-mode"><a class="browse-mode-n" href="javascript:void(0)" title="折叠侧栏">折叠侧栏/展开侧栏</a></div>'); //文章浏览模式（折叠/展开侧栏）
		article.after(_switch);
		var _switch_top = $("#hd").height();
		var main = _switch.parents(".wrp").find(".main-wrp");
		var main_size = main.css("padding-right");
		_switch.find("a").toggle(function() {
			$(this).attr({"class":"browse-mode-w", "title":"展开侧栏"})
			_switch.parents(".wrp").find(".sub").hide();
			main.css({"padding-right": 0});
		}, function() {
			$(this).attr({"class":"browse-mode-n", "title":"折叠侧栏"})
			_switch.parents(".wrp").find(".sub").show();
			main.css({"padding-right": main_size});
		});
		$(window).scroll(function() { 
			if ( $(window).scrollTop() > _switch_top ) {
				_switch.css("top", $(window).scrollTop()-_switch_top);
			} else {
				_switch.css("top", 0);
			}
		});
		article.find("a.ico-print").click(printArticle);
		article.find("a.ico-close").click(function() { window.close(); });
		
		//分享按钮
		var _share = $('<div id="share" class="clearfix" />'),
			_share_normal = $('<div id="share-normal"><ul></ul><label>分享到：</label></div>'),
			_share_sina = $("<li class='sina'><a href='javascript:void(0);' title='分享到新浪微博'></a></li>"),
			_share_qq = $("<li class='qq'><a href='javascript:void(0);' title='分享到腾讯微博'></a></li>"),
			_share_jiathis = $('<div id="ckepop" class="fr"><span class="jiathis_txt">分享到：</span><a class="jiathis_button_tsina">新浪微博</a><a class="jiathis_button_tqq">腾讯微博</a><a class="jiathis_button_renren">人人网</a><a class="jiathis_button_qzone">QQ空间</a><a class="jiathis_button_copy">复制网址</a><a class="jiathis_button_fav">收藏夹</a><a href=" http://www.jiathis.com/share?uid=907308" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a></div>');
		_share_normal.find("ul").append(_share_sina).append(_share_qq);
		_share_qq.click(function() { shareTo("qq") });
		
		_share.append(_share_jiathis);
		if (article.find(".page").length > 0) {
			article.find(".page").after(_share);
		} else {
			article.find(".ft").prepend(_share);
		}
		var jiathis_config={
			data_track_clickback:true,
			summary:"",
			appkey:{
				"tsina":"1428462468",
				"tqq":"6d8f1465882a4826a342083cd05d7f6d"
			},
			hideMore:false
		}
		$.getScript('http://v2.jiathis.com/code/jia.js?uid=907308');
		if (thmz.channel == "v") {
			_share_jiathis.attr("class", "clearfix");
			article.find("div.hd").append($('<div id="share-hd" class="tips" />').append(_share_jiathis.clone()));
		}
		
		//评论框
		(function(){
			var _w = "100%", _h = 500;
			var param = {
				url:location.href,
				width:'0',
				height:'500',
				appkey:'1428462468', /**您申请的应用appkey,显示分享来源(可选)*/
				border:'1',/**是否显示边框*/
				skin:'1',
				titlebar:'0',/**是否显示标题栏*/
				colordiy:'0',/**是否自定义样式*/
				color:'',
				rnd:new Date().valueOf(),
				dpc:1
			}
			var temp = [];
			for ( var p in param ) {
				temp.push(p + '=' + encodeURIComponent( param[p] || '' ));
			}
			article.after('<iframe id="weibo-comment" allowTransparency="true" frameborder="0" scrolling="no" src="http://widget.weibo.com/distribution/comments.php?' + temp.join('&') + '" width="'+ _w+'" height="'+_h+'"></iframe>');
		})();
		
		//点击图片跳转下一页
		var url = document.location.href;
		var urlArray = url.split("_");
		var totalPage = parseInt(article.find(".page li:last span").text());
		var nextPage;
		if (urlArray.length==1) {
			nextPage = url.substring(0,url.length-5)+"_2.html";
		} else {
			if (parseInt(urlArray[1]) == totalPage) {
				nextPage = urlArray[0]+".html";
			} else {
				nextPage = urlArray[0]+"_"+(parseInt(urlArray[1])+1)+".html";
			}
		}
		if (totalPage > 1) {
			article.find(".bd img").each(function() {
				$(this).wrap('<a href="'+nextPage+'" title="点击查看下一页" />');
			});
		}
	}
}
/* 分享 */
function shareTo(target){
	switch (target) {
		case "qq":
			var _t = encodeURI(document.title);
			var _url = encodeURIComponent(document.location);
			var _appkey = encodeURI("6d8f1465882a4826a342083cd05d7f6d");
			var _pic = encodeURI('');
			var _site = '';
			var _u = 'http://v.t.qq.com/share/share.php?url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic+'&title='+_t;
			window.open( _u,'', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
		break;
	}
} 

/* 文本框效果 */
function inputEffect() {
	$(".input-txt input,.input-txt textarea").each(function() {
		$(this).data("def_val", $(this).val()); //记录初始值
		var def_val;
		$(this).focus(function () {
			def_val = $(this).data("def_val");
			$(this).addClass("active");
			if ( $(this).attr("autocomplete") == "off" && $(this).val() == def_val ) $(this).val("");
			$(this).blur(function () {
				$(this).removeClass("active");
				if ( $(this).val() == "" ) $(this).val(def_val);
			});
		});
	});
	$(".input-file input").each(function() {
		var t = $(this), f = $(this).parents("li");
		t.hover(function () {
			f.find(".btn a").addClass("hover");
		}, function () {
			f.find(".btn a").removeClass("hover");
		});
	});
}
/* 模拟下拉 */
function selector(o) {
	var sel = $("."+o).parents(".selector");
	sel.each(function() {
		var _this = $(this),
			drop = _this.find(".selector-list");
		var trigger = _this;
		var t, t1;
		trigger.click(function() {
			if (drop.is(":hidden")) {
				drop.slideDown("fast");
			} else {
				drop.slideUp("fast");
			}
		});
		_this.hover(function() {
			t1 = setTimeout(function() { _this.addClass("active"); }, 50);
			clearTimeout(t);
		}, function() {
			clearTimeout(t1);
			_this.removeClass("active");
			t = setTimeout(function() { drop.slideUp("fast"); }, 500);
		});
		_this.find(".selector-list li").click(function() {
			_this.find(".selector-current-option").text($(this).text());
			_this.find("input.option").val($(this).attr("title"));
			drop.slideUp("fast");
		});
	});
}

/* = gallery slider
------------------------------------*/
(function($) {
	$.fn.GallerySlider = function(o) {
		o = $.extend({
			auto: true,
			speed: 3000
		}, o || {});
		return this.each(function() {
			var n = 0, t, $this = $(this), data = [],
				thumb = $("<div class='slider-thumb' />"),
				desc = $("<div class='slider-desc' />"),
				bar = $("<div class='slider-desc-bar' />"),
				arrow = $("<s></s>"),
				img_li = $("li", $this),
				num = img_li.length;
			img_li.each(function() {
				data.push({
					"name": $(this).find("img").attr("alt"),
					"pic": $(this).find("img").attr("src"),
					"link": $(this).find("a").attr("href")
				});
			});
			var img_content = "<ul>", desc_content = "<ul>";
			for (var i=0; i<num; i++) {
				img_content += '<li><a href="'+ data[i].link +'" target="_blank"><img src="'+ data[i].pic +'" /></a></li>';
				desc_content += '<li><a href="'+ data[i].link +'" target="_blank">'+ data[i].name +'</a></li>';
			}
			img_content += "</ul>";
			desc_content += "</ul>";
			thumb.append(img_content).append(arrow);
			desc.append(desc_content);
			$this.append(bar).append(desc).append(thumb);
			var thumb_li = $("li", thumb),
				thumb_li_w = thumb_li.width()+2,
				desc_li = $("li", desc),
				desc_h = bar.css("height"),
				arrow_w = 8,
				position = (thumb_li.width()/2)-(arrow_w/2);
			thumb_li.hover(function () {
				if (o.auto) clearInterval(t);
				n = $(this).index();
				play(n);
			}, function () {
				if (o.auto) autoPlay();
			});
			function play(n) {
				arrow.animate({"left": thumb_li_w*n+position}, "fast");
				thumb_li.eq(n).animate({"opacity": "1"}, "fast").siblings().animate({"opacity": ".5"}, "fast");
				img_li.eq(n).animate({"opacity": "1"}, "fast").css({"z-index": "1"}).siblings().animate({"opacity": "0"}, "fast").css({"z-index":"0"});
				desc_li.eq(n).animate({"top": "0"}, "fast").siblings().animate({"top": desc_h}, "fast");
			}
			function autoPlay() {
				t = setInterval(function () {
					n==num-1?n=0:n+=1;
					play(n);
				}, o.speed);
			}
			play(n);
			if (o.auto) autoPlay();
		});
	}
})(jQuery);

/* = url parma
------------------------------------*/
(function($) {
	$.fn.getParmByUrl = function(o){
		var url = window.location.toString();
		var tmp;
		if (url && url.indexOf("?")) {
			var arr = url.split("?");
			var parms = arr[1];
			for (var i = 2; i < arr.length; i++) {
				parms += "?" + arr[i];
			}
			if (parms && parms.indexOf("#")) {
				var arr1 = parms.split("#");
				parms = arr1[0];
			}
			
			if (parms && parms.indexOf("&")) {
				var parmList = parms.split("&");
				jQuery.each(parmList,function(key,val){
					if (val && val.indexOf("=")) {
						var parmarr = val.split("=");
						var parms1 = parmarr[1];
						for (i = 2; i < parmarr.length; i++) {
							parms1 += "=" + parmarr[i];
						}
						if (o) {
							if (typeof(o) == "string" && o == parmarr[0]) {
								tmp = parms1 == null?'':parms1;
							}
						} else {
							tmp = parms;
						}
					}
				});
			}
		}
		return tmp;
	}
})(jQuery);

/* = set cookies
------------------------------------*/
jQuery.cookie = function(name, value, options) {
	if (typeof value != 'undefined') { // name and value given, set cookie
		options = options || {};
		if (value === null) {
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
		}
		// CAUTION: Needed to parenthesize options.path and options.domain
		// in the following expressions, otherwise they evaluate to undefined
		// in the packed version for some reason...
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
	} else { // only name given, get cookie
		var cookieValue = null;
		if (document.cookie && document.cookie != '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};

/* = scroll
------------------------------------*/
(function($) {
	$.fn.ListScroll = function(o) {
		o = $.extend({
			btn_prev: null,
			btn_next: null,
			vertical:true,
			auto: true,
			num: 1,
			speed: 5000
		}, o || {});
		return this.each(function() {
			var _this = $(this);
			var ul, li, li_num, li_h, h, mh, i, def_top, now_top, t, current = 0;
			ul = $("ul", _this);
			li = $("ul li", _this);
			li_num = li.size();
			var scroll_prev, scroll_next;
			if (o.vertical) {
				ul.css({"position":"absolute","z-index":9,"top":0});
				li_h = li.outerHeight(true);
				h = li_h * li_num;
				mh = li_h * o.num;
				li.parent().prepend(li.slice(li_num-o.num*2).clone()).append(li.slice(0, o.num*2).clone());
				def_top = parseInt(ul.css("top"));
				ul.css("top", def_top-mh*2);
				scroll_prev = function () {
					now_top = parseInt(ul.css("top"));
					ul.animate({top: (now_top+mh)}, 1000);
					if (now_top >= def_top-mh*2) {
						setTimeout(function () {
							ul.css("top", -def_top-h);
						}, 1200)
					}
				}
				scroll_next = function () {
					now_top = parseInt(ul.css("top"));
					ul.animate({top: (now_top-mh)}, 1000);
					if (now_top <= -def_top-h-mh) {
						setTimeout(function () {
							ul.css("top", def_top-mh*2);
						}, 1200)
					}
				}
			} else {
				ul.css({"position":"absolute","z-index":9,"left":0});
				h = 0;
				li.each(function(){
					li_h = $(this).outerWidth(true);
					h += li_h;
				});
				mh = li_h * o.num;
				li.parent().prepend(li.clone()).append(li.clone());
				def_top = parseInt(ul.css("left"));
				ul.css("left", def_top-h);
				scroll_prev = function () {
					
				}
				scroll_next = function () {
					now_top = parseInt(ul.css("left"));
					ul.css({left: now_top-1});
					if ((now_top-1) <= -h) {
						ul.css("left", 0);
					}
				}
			}
			if (o.btn_prev) _this.parent().find(o.btn_prev).click(scroll_prev);
			if (o.btn_next) _this.parent().find(o.btn_next).click(scroll_next);
			if (o.auto) {
				t = setInterval(scroll_next, o.speed);
				$(this).hover(function () {
					clearInterval(t);
				}, function () {
					clearInterval(t);
					t = setInterval(scroll_next, o.speed);
				})
			}
		});
	}
})(jQuery);

/* = advertisement
------------------------------------*/
(function($) {
	$.fn.CoupletAD = function(o) {
		o = $.extend({
			left: null,
			right: null,
			close: true,
			top:80
		}, o || {});
		return this.each(function() {
			var cl = "", cr = "",
				cl_wrp = "", cr_wrp = "",
				c_wrp = '<div style="margin-bottom:5px;">',
				style = "position:fixed;z-index:9999;top:"+o.top+"px;",
				_close = '<a href="javascript:void(0);" onclick="closeWrp([$(this).parent()]);return false;"><img src="http://www.thmz.com/liv_loadfile/fold4/1271913488_76361300.gif" alt="关闭" /></a></div>';
			if (o.left) {
				cl_wrp = jQuery('<div id="couplet-left" class="couplet ads" style="'+style+'left:3px;">');
				for (var i=0; i<o.left.length; i++) {
					cl = c_wrp+"<a href='"+o.left[i].url+"' target='_blank'><img src='"+o.left[i].img+"' alt='"+o.left[i].txt+"' /></a>";
					o.close?cl=cl+_close:cl=cl+"</div>";
					cl_wrp.append(cl);
				}
			}
			if (o.right) {
				cr_wrp = jQuery('<div id="couplet-right" class="couplet ads" style="'+style+'right:3px;">')
				for (var i=0; i<o.right.length; i++) {
					cr = c_wrp+"<a href='"+o.right[i].url+"' target='_blank'><img src='"+o.right[i].img+"' alt='"+o.right[i].txt+"' /></a>"
					o.close?cr=cr+_close:cr=cr+"</div>";
					cr_wrp.append(cr);
				}
			}
			function updateTop(){
				var windowTop=$(window).scrollTop();
				if($(".couplet").css("display")!="none") $(".couplet").css("top",o.top+windowTop+"px");
			}
			$(this).append(cl_wrp);
			$(this).append(cr_wrp);
			if ($.browser.msie) {
				if (parseInt($.browser.version) <= 6) {
					$(".couplet").css("position","absolute");
					$(window).scroll(updateTop);
					$(document).ready(updateTop);
				}
			}
		});
	}
})(jQuery);
(function($) {
	$.fn.TopAD = function(o) {
		o = $.extend({
			topic: null,
			timer: 6000,
			close: true,
			close_color: "#fff",
			callback: function () {}
		}, o || {});
		return this.each(function() {
			if ($("#topAD").html()==null) {
				var top_ad_wrp = jQuery("<div id='topAD' class='ads wrp relative hide' style='height:"+o.topic.height+"px;'>"),
					_close = '<a href="javascript:void(0);" class="close" style="position:absolute;bottom:7px;right:7px;z-index:9999;color:'+o.close_color+';">关闭</a>';
				if (o.topic.img) {
					var content = "<a href='"+o.topic.url+"' target='_blank'><img src='"+o.topic.img+"' alt='"+o.topic.txt+"' style='display:block;' /></a>";
				} else if (o.topic.flash) {
					var content = jQuery("<div id='topAD-swf'>");
					swfobject.embedSWF(o.topic.flash,"topAD-swf",o.topic.width,o.topic.height,"9.0.0","http://www.thmz.com/expressInstall.swf",{},{wmode:"transparent"},{});
				}
				top_ad_wrp.append(content);
			} else {
				var top_ad_wrp = $("#topAD");
			}
			if (o.close) top_ad_wrp.append(_close);
			var t;
			function top_ad_show() {
				top_ad_wrp.slideDown();
				t = setTimeout(top_ad_close, o.timer);
			}
			function top_ad_close() { 
				clearTimeout(t);
				top_ad_wrp.slideUp();
				o.callback();
				return false;
			}
			top_ad_wrp.find(".close").click(top_ad_close);
			$(this).prepend(top_ad_wrp);
			$(document).ready(top_ad_show);
		});
	}
})(jQuery);
(function($) {
	$.fn.BottomAD = function(o) {
		o = $.extend({
			topic: null,
			close: true,
			close_color: "#333",
			timer: null,
			callback: function () {}
		}, o || {});
		return this.each(function() {
			if ($("#bottomAD").html()==null) {
				var bottom_ad_wrp = jQuery("<div id='bottomAD' class='ads wrp tc' style='position:fixed;z-index:9999;bottom:0;height:"+o.topic.height+"px;'>"),
					_close = '<a href="javascript:void(0);" class="close" style="position:absolute;bottom:7px;right:7px;z-index:10000;color:'+o.close_color+';">关闭</a>';
				if (o.topic.img) {
					var content = "<a href='"+o.topic.url+"' target='_blank'><img src='"+o.topic.img+"' alt='"+o.topic.txt+"' /></a>";
				} else if (o.topic.flash) {
					var content = jQuery("<div id='bottomAD-swf'>");
					swfobject.embedSWF(o.topic.flash,"bottomAD-swf",o.topic.width,o.topic.height,"9.0.0","http://www.thmz.com/expressInstall.swf",{},{wmode:"transparent"},{});
				}
				bottom_ad_wrp.append(content);
			} else {
				var bottom_ad_wrp = $("#bottomAD");
				bottom_ad_wrp.fadeIn("fast");
			}
			if (o.close) bottom_ad_wrp.append(_close);
			if (typeof(o.timer) == "number") {
				setTimeout(function () {
					closeWrp([bottom_ad_wrp]);
				}, o.timer);
			}
			function bottom_ad_close() { 
				bottom_ad_wrp.fadeOut("fast");
				o.callback();
				return false;
			}
			bottom_ad_wrp.find(".close").click(bottom_ad_close);
			function posLeft() {
				left_pos_left = ($(window).width()-$(".wrp").width())/2;
				bottom_ad_wrp.css("left", left_pos_left+"px");
			}
			$(window).resize(posLeft);
			$(document).ready(posLeft);
			function updateTop(){
				var windowTop=$(window).scrollTop();
				if($("#bottomAD").css("display")!="none") $("#bottomAD").css("top",windowTop+$(window).height()-$("#bottomAD").height()+"px");
			}
			$(this).append(bottom_ad_wrp);
			if ($.browser.msie) {
				if (parseInt($.browser.version) <= 6) {
					$("#bottomAD").css({position:"absolute",bottom:"auto"});
					$(window).scroll(updateTop);
					$(document).ready(updateTop);
				}
			}
		});
	}
})(jQuery);
(function($) {
	$.fn.CommonAD = function(o) {
		o = $.extend({
			id: null,
			style: null,
			topic: null,
			close: true,
			callback: function () {}
		}, o || {});
		return this.each(function() {
			var ad_wrp = jQuery("<div id='"+o.id+"' style='"+o.style+"' class='ads'>"),
				content = "<a href='"+o.topic.url+"' target='_blank'><img src='"+o.topic.img+"' alt='"+o.topic.txt+"' /></a>",
				_close = '<a href="javascript:void(0);" class="close" style="position:absolute;bottom:9px;left:9px;z-index:9999;display:block;width:46px;height:12px;*background:#000;*filter:alpha(opacity=0);">　　　</a>';
			ad_wrp.append(content);
			if (o.close) ad_wrp.append(_close);
			function ad_close() { 
				ad_wrp.fadeOut("fast");
				o.callback();
				return false;
			}
			ad_wrp.find(".close").click(ad_close);
			$(this).prepend(ad_wrp);
		});
	}
})(jQuery);
(function($) {
	$.fn.SideADBar = function(o) {
		o = $.extend({
			left: null,
			left_img_bar: "#",
			left_ad_type: "PopUp",
			left_auto_open: false,
			left_auto_close: false,
			right: null,
			right_img_bar: "#",
			right_ad_type: "PopUp",
			right_auto_open: false,
			right_auto_close: false,
			timer: 6000
		}, o || {});
		return this.each(function() {
			var sl = jQuery('<div id="side-ADbar-left" class="side-ADbar">'),
				sr = jQuery('<div id="side-ADbar-right" class="side-ADbar">'),
				sl_bar, sr_bar,
				left_pos_left, right_pos_left, pos_top,
				sl_replay = '<a href="javascript:void(0);" class="replay" title="重播"></a>',
				sr_replay = '<a href="javascript:void(0);" class="replay" title="重播"></a>',
				_close = '<a href="javascript:void(0);" class="close" title="关闭" onclick="closeWrp([$(this).parent()]);return false;"></a>';
			if (o.left) {
				sl_bar = "<a href='javascript:void(0);'><img src='"+o.left_img_bar+"' width='25' height='150' alt='"+o.left.txt+"' /></a>";
				sl.append(sl_bar);
				sl.append(sl_replay);
				sl.append(_close);
				$(this).append(sl);
			}
			if (o.right) {
				sr_bar = "<a href='javascript:void(0);'><img src='"+o.right_img_bar+"' width='25' height='150' alt='"+o.right.txt+"' /></a>";
				sr.append(sr_bar);
				sr.append(sr_replay);
				sr.append(_close);
				$(this).append(sr);
			}
			function posLeft() {
				left_pos_left = ($(window).width()-$(".wrp").width())/2-$(".side-ADbar").width()-1;
				right_pos_left = ($(window).width()+$(".wrp").width())/2+1;
				sl.css("left", left_pos_left+"px");
				sr.css("left", right_pos_left+"px");
			}
			function posBottom() {
				pos_top = $(window).height()-304+$(window).scrollTop();
				sl.css("top",pos_top+"px");
				sr.css("top",pos_top+"px");
			}
			if ($.browser.msie) {
				if (parseInt($.browser.version) <= 6) {
					$(window).scroll(posBottom);
				}
			}
			$(window).resize(posLeft);
			$(document).ready(posLeft);
			function callAD(which, type) {
				switch (type) {
					case "PopUp":
						if (which == "left") {
							$("body").PopUp({
								frame: false,
								content: "<a href='"+o.left.url+"' target='_blank'><img src='"+o.left.img+"' alt='"+o.left.txt+"'></a>",
								callback: function () {
									$("#side-ADbar-"+which).fadeIn("fast");
								}
							});
						} else {
							$("body").PopUp({
								frame: false,
								content: "<a href='"+o.right.url+"' target='_blank'><img src='"+o.right.img+"' alt='"+o.right.txt+"'></a>",
								callback: function () {
									$("#side-ADbar-"+which).fadeIn();
								}
							});
						}
					break;
					case "TopAD":
						if (which == "left") {
							$("body").TopAD({
								topic: o.left,
								callback: function () {
									$("#side-ADbar-"+which).fadeIn("fast");
								}
							});
						} else {
							$("body").TopAD({
								topic: o.right,
								callback: function () {
									$("#side-ADbar-"+which).fadeIn("fast");
								}
							});
						}
					break;
					case "BottomAD":
						if (which == "left") {
							$("body").BottomAD({
								topic: o.left,
								callback: function () {
									$("#side-ADbar-"+which).fadeIn("fast");
								}
							});
						} else {
							$("body").BottomAD({
								topic: o.right,
								callback: function () {
									$("#side-ADbar-"+which).fadeIn("fast");
								}
							});
						}
					break;
				}
			}
			sl.find("a").not(".close").click(function () {
				closeWrp([sl]);
				if(o.left_ad_type=="TopAD") scroll(0,0);
				callAD("left", o.left_ad_type);
				return false;
			});
			sr.find("a").not(".close").click(function () {
				closeWrp([sr]);
				if(o.right_ad_type=="TopAD") scroll(0,0);
				callAD("right", o.right_ad_type);
				return false;
			});
			if (o.left_auto_open) {
				callAD("left", o.left_ad_type);
				sl.hide();
			}
			if (o.right_auto_open) {
				callAD("right", o.right_ad_type);
				sr.hide();
			}
		});
	}
})(jQuery);
(function($) {
	$.fn.SideVideoAD = function(o) {
		o = $.extend({
			video: null,
			url: "http://www.thmz.com/"
		}, o || {});
		var s = document.getElementsByTagName("script"),
			hasSo = 0;
		for (var si=0; si<s.length; si++) {
			if (s[si].src.indexOf("swfobject")>0) {
				hasSo++;
			}
		}
		if (hasSo==0) {
			var so = document.createElement("script");
			so.src = "http://www.thmz.com/script/swfobject.js";
			document.body.appendChild(so);
		}
		return this.each(function() {
			var wrapper = jQuery("<div id='SideVideoAD' class='ads' style='position:fixed;right:0;bottom:20px;z-index:9999;'>"),
				swfContainer = jQuery("<div id='SideVideoAD-swf'>");
			wrapper.append(swfContainer);
			$(this).append(wrapper);
			if (so) {
				so.onload = function() {
					if ( ! so.onloadDone ) {
						so.onloadDone = true;
						swfobject.embedSWF("http://www.thmz.com/statics/side_player.swf","SideVideoAD-swf",320,240,"9.0.0","http://www.thmz.com/expressInstall.swf",{url:o.url,flv:o.video},{wmode:"transparent"},{});
					}
				};
				so.onreadystatechange = function() {
					if ( ( "loaded" === so.readyState || "complete" === so.readyState ) && ! so.onloadDone ) {
						so.onloadDone = true;
						swfobject.embedSWF("http://www.thmz.com/statics/side_player.swf","SideVideoAD-swf",320,240,"9.0.0","http://www.thmz.com/expressInstall.swf",{url:o.url,flv:o.video},{wmode:"transparent"},{});
					}
				}
			} else {
				swfobject.embedSWF("http://www.thmz.com/statics/side_player.swf","SideVideoAD-swf",320,240,"9.0.0","http://www.thmz.com/expressInstall.swf",{url:o.url,flv:o.video},{wmode:"transparent"},{});
			}
			function updateTop(){
				var windowTop=$(window).scrollTop();
				if($("#SideVideoAD").css("display")!="none") $("#SideVideoAD").css("top",windowTop+$(window).height()-$("#SideVideoAD").height()-20+"px");
			}
			if ($.browser.msie) {
				if (parseInt($.browser.version) <= 6) {
					$("#SideVideoAD").css("position","absolute");
					$(window).scroll(updateTop);
					$(document).ready(updateTop);
				}
			}
		});
	}
})(jQuery);

