/*
 * Danyang.com JavaScript Library based on jQuery 1.4.4
 * Copyright (c) 2010 Danyang Broadcasting & Television Corporation
 * @ Author: DevAnge.GuoCong
 * @ Version: 0.2 alpha / 2011-01-31
 * @ Update Log: slide() / SideVideoAD / forum search form charset / tab()
 */


/* 打开链接 */
function openUrl(url) {
	window.open(url);
}

/* 关闭层 */
function closeWrp(o) {
	for (var i=0; i<o.length; i++) {
		o[i].fadeOut("fast");
	}
}

/* 日期 */
function date() {
	var today = new Date();
	var day = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
	var y = today.getFullYear()+"年";	
	var m = (today.getMonth()<9?("0"+(today.getMonth()-(-1))):(today.getMonth()-(-1)))+"月";	
	var d = (today.getDate()<10?"0"+today.getDate():today.getDate())+"日";
	var day1 = day[today.getDay()];
	document.write(y+m+d+" "+day1);
}

/* 鼠标高亮 */
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.val() == option.data("def_val") || option.val() == "" ) {
			if ( label.length != 0 ) {
				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;
	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 if ( slide_obj.hasClass("focus-category-h") ) {
		var slide_wrp = slide_obj.find(".focus-opt");
		var triggerWidth = (slide_obj.width()-(slide_num+1))/slide_num;
		if (slide_num != 6) {
			slide_wrp.find("li a").css({"width":triggerWidth+"px"});
			slide_wrp.find("li s").css({"left":(triggerWidth-6)/2+"px"});
		}
	} else {
		var slide_wrp = jQuery("<div class='focus-opt'>");
		var slide_ul = jQuery("<ul>");
		for (var i = 0; i < slide_num; i++) {
			slide_ul.append("<li><div class='inner-wrp'>"+(i+1)+"</div></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_wrp.find("li").eq(0).addClass("current");
	slide_obj.find(".tab-content 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);
	},3000);
	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);
		},3000);
	});
}

/* 标签切换 */
function tab() {
	var t;
	$(".block-1 .tab li").not(".disabled").each(function() {
		if ($(this).parents().hasClass("sub")) {
			var bar_width = $(this).parents(".bar").width();
			var tab_width = bar_width/$(this).parent().find("li").length-(parseInt($(this).parent().find("li .inner-wrp").css("padding-left"))*2)-2;
			$(this).find(".inner-wrp").width(tab_width);
		}
		$(this).hover(function() {
			var self = $(this);
			var tab_content = self.parents('.block-1').find(".tab-content>li").eq(self.index());
			t = setTimeout(function() {
				self.addClass("current").siblings().removeClass("current");
				tab_content.show().siblings().hide();
			}, 50);
		}, function () {
			clearTimeout(t);
		});
	});
	$(".block-2 .tab li").not(".disabled").each(function() {
		$(this).hover(function() {
			var self = $(this);
			var tab_content = self.parents('.block-2').find(".tab-content>li").eq(self.index());
			t = setTimeout(function() {
				self.addClass("current").siblings().removeClass("current");
				tab_content.show().siblings().hide();
			}, 50);
		}, function () {
			clearTimeout(t);
		});
	});
}

/* 双栏等高 */
function equalHeight(group) {
	var refer = $(group[0]).height();
	for (var i = 1; i < group.length; i++) {
		$(group[i]).height(refer-12);
	}
}

/* 文章打印 */
function printArticle() {
	$(".innerPage-bd .sub").hide();
	$(".innerPage-bd .main").width("100%");
	$("#global-hd,.ads,.innerPage-bd .block-1").hide();
	window.print();
}

/* 复制 */
function copyToClipboard(txt) {
	if(window.clipboardData) {
		window.clipboardData.clearData();
		window.clipboardData.setData("Text", txt);   
		alert("复制成功！");
	} else if(navigator.userAgent.indexOf("Opera") != -1) { 
		window.location = txt;
		alert("复制成功！");
	} else if (window.netscape) {
		try {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		} catch (e) {
			alert("此浏览器不支持剪贴板，建议手动复制！\n如果想打开剪贴板，请在浏览器地址栏输入'about:config'并回车；\n然后将'signed.applets.codebase_principal_support'设置为'true'。");
		}
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext = txt;
		str.data = copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid = Components.interfaces.nsIClipboard;
		if (!clip) return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
		alert("复制成功！");
	}
}


/* = 搜索类型切换
------------------------------------*/
function changeSearch(type) {
	var form = $("#search form");
	var action, input_name, input_val, option_name, option_val, selector, selector_li = "";
	form.removeAttr("onsubmit");
	switch (type) {
		case "search-article": {
			action = "http://www.danyang.com/search/search.php";
			input_name = "searchkey";
			//input_val = "请输入关键词";
			option_name = "searchfield";
			selector = [["标题　","摘要　","关键词"],["title","brief","keywords"]];
			form.removeAttr("accept-charset");
		} break;
		case "search-forum": {
			action = "http://f.danyang.com/search.php";
			input_name = "srchtxt";
			//input_val = "请输入关键词";
			option_name = "srchfilter";
			selector = [["全部主题","精华主题","置顶主题"],["all","digest","top"]];
			form.attr({"accept-charset":"gbk"});
			form.append('<input type="hidden" name="srchtype" value="title" /><input type="hidden" name="searchsubmit" value="true" />');
		} break;
		case "search-video": {
			action = "";
			input_name = "";
			input_val = "";
			option_name = "";
			selector = [[""],[""]];
		} break;
	}
	option_val = selector[1][0];
	form.attr({action:action});
	document.getElementById("search").getElementsByTagName("form")[0].setAttribute("onSubmit","return checkForm($(this),['"+input_name+"']);");
	form.find("input.txt").attr({name:input_name});
	form.find("input.option").attr({name:option_name, value:option_val});
	for (var i = 0; i < selector[0].length; i++) {
		selector_li += '<li title="' + selector[1][i] + '">' + selector[0][i] + '</li>';
	}
	form.find(".selector-list").html(selector_li);
	form.find(".selector").width("auto");
	form.find(".selector-current-option").html(selector[0][0]);
	active([form.find(".selector-list li")]);
	form.find(".selector-list li").click(function() {
		form.find(".selector-current-option").text($(this).text());
		form.find("input.option").val($(this).attr("title"));
	});
}

/* = URL PARM
------------------------------------*/
(function($) {
	$.fn.getParmByUrl = function(o){
		var url = window.location.toString();
		var tmp;
		if(url && url.indexOf("?")){
			var arr = url.split("?");
			var parms = arr[1];
			if(parms && parms.indexOf("&")){
				var parmList = parms.split("&");
				jQuery.each(parmList,function(key,val){
					if (val && val.indexOf("=")) {
						var parmarr = val.split("=");
						if (o) {
							if (typeof(o) == "string" && o == parmarr[0]) {
								tmp = parmarr[1] == null?'':parmarr[1];
							}
						} else {
							tmp = parms;
						}
					}
				});
			}
		}
		return tmp;
	}
})(jQuery);

/* = scroll
------------------------------------*/
(function($) {
	$.fn.ListScroll = function(o) {
		o = $.extend({
			btn_prev: null,
			btn_next: null,
			vertical:true,
			auto: true,
			num: 1,
			speed: 3000
		}, 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;
			if (_this.find(".top-news-category").size() != 0) {
				ul = _this.children(".scroll-list");
				li = $(".top-news-category", this);
			} else {
				ul = $("ul", this);
				li = $("ul li", this);
			}
			ul.css({"position":"absolute","z-index":99,top:0});
			li_num = li.size();
			li_h = li.height()+parseInt(li.css("padding-top"))+parseInt(li.css("padding-bottom"));
			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);
			function scroll_prev() {
				now_top = parseInt(ul.css("top"));
				ul.animate({top: (now_top+mh)}, "slow");
				if (now_top >= def_top-mh*2) {
					setTimeout(function () {
						ul.css("top", -def_top-h);
					}, 2000)
				}
			}
			function scroll_next() {
				now_top = parseInt(ul.css("top"));
				ul.animate({top: (now_top-mh)}, "slow");
				if (now_top <= -def_top-h-mh) {
					setTimeout(function () {
						ul.css("top", def_top-mh*2);
					}, 2000)
				}
			}
			if (o.btn_prev) {
				_this.parent().find(o.btn_prev).click(function () {
					scroll_prev();
				});
			}
			if (o.btn_next) {
				_this.parent().find(o.btn_next).click(function () {
					scroll_next();
				});
			}
			if (o.auto) {
				t = setInterval(function () {
					scroll_next();
				}, o.speed);
				$(this).hover(function () {
					clearInterval(t);
				}, function () {
					clearInterval(t);
					t = setInterval(function () {
						scroll_next();
					}, o.speed);
				})
			}
		});
	}
})(jQuery);

/* = popup
------------------------------------*/
(function($) {
	$.fn.PopUp = function(o) {
		o = $.extend({
			width: 400,
			frame: true,
			title: null,
			content: "",
			allcover: true,
			drag: true,
			callback: function () {}
		}, o || {});
		return this.each(function() {
			var cover = jQuery("<div class='cover-layer'>"),
				popup_wrp = jQuery("<div class='popup-wrp'>"),
				popup = jQuery("<div class='popup'>"),
				popup_frame = jQuery("<div class='block-1'>"),
				popup_content = "<div class='content'>"+o.content+"</div>",
				popup_title = "", win_h, popup_top, windowTop;
			popup.width(o.width);
			if (o.title) popup_title="<div class='bar'><div class='inner-wrp'><a href='javascript:void(0);' class='close' title='关闭'></a>"+o.title+"</div></div>";
			if (o.frame) {
				popup_frame.append(popup_title);
				popup_frame.append(popup_content);
				popup.append(popup_frame);
			} else {
				popup.append(popup_content);
			}
			popup_wrp.append(popup);
			if (o.content.indexOf("<img") != -1) {
				var img = popup.find("img:first");
				setTimeout(function(){
					popup.css("width", img.width()+12);
				}, 10);
			}
			$(this).append(cover);
			$(this).append(popup_wrp);
			function pos() {
				win_h = $(window).height();
				popup_top = (win_h-popup.height())/2;
				cover.height(win_h);
				popup_wrp.css("top", popup_top+"px");
			}
			function posIE6(){
				win_h = $(window).height();
				popup_top = (win_h-popup.height())/2;
				windowTop=$(window).scrollTop();
				cover.height(win_h);
				if(cover.css("display")!="none") cover.css("top",windowTop+"px");
				if(popup_wrp.css("display")!="none") popup_wrp.css("top",popup_top+windowTop+"px");
			}
			popup_wrp.fadeIn("fast");
			if ($.browser.msie) {
				if (parseInt($.browser.version) <= 6) {
					$(window).scroll(posIE6);
					$(window).resize(posIE6);
					$(document).ready(posIE6);
				} else {
					if (o.allcover) cover.show();
					$(document).ready(pos);
					$(window).resize(pos);
				}
			} else {
				$(document).ready(pos);
				$(window).resize(pos);
				if (o.allcover) cover.fadeIn("fast");
			}
			cover.click(function () {
				closeWrp([popup_wrp,cover]);
				o.callback();
			});
			if (!o.title) {
				popup_wrp.click(function () {
					closeWrp([popup_wrp,cover]);
					o.callback();
				});
			}
			$(".popup .close").click(function () {
				closeWrp([popup_wrp,cover]);
				o.callback();
				return false;					  
			});
		});
	}
})(jQuery);

/* = advertisement
------------------------------------*/
(function($) {
	$.fn.CoupletAD = function(o) {
		o = $.extend({
			left: null,
			right: null,
			close: true
		}, 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:80px;",
				_close = '<a href="javascript:void(0);" onclick="closeWrp([$(this).parent()]);return false;" class="close"><img src="http://www.danyang.com/liv_loadfile/fold1/1290852006_65150900.gif" alt="关闭" width="100" height="14" /></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",80+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;margin-top:-10px;'>"),
					_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.danyang.com/statics/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",
			callback: function () {}
		}, o || {});
		return this.each(function() {
			if ($("#bottomAD").html()==null) {
				var bottom_ad_wrp = jQuery("<div id='bottomAD' class='ads wrp' 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.danyang.com/statics/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);
			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 ads">'),
				sr = jQuery('<div id="side-ADbar-right" class="side-ADbar ads">'),
				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.danyang.com/"
		}, o || {});
		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);
			swfobject.embedSWF("http://www.danyang.com/statics/videoAd.swf","SideVideoAD-swf",320,240,"9.0.0","http://www.danyang.com/statics/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);

