var $IE = (navigator.appName == "Microsoft Internet Explorer");

function $_t(B, A, E) {
	var C = B.getElementsByTagName(A);
	for ( var D = 0; D < C.length; D++) {
		if (C[D].id == E) {
			return C[D]
		}
	}
	return null
}
function _(A) {
	var F = arguments;
	var G = 0;
	if (typeof (A) == "string") {
		A = document
	} else {
		G = 1
	}
	for ( var D = G; D < F.length; D++) {
		var E = A.getElementsByTagName("*");
		var C = false;
		for ( var B = 0; B < E.length; B++) {
			if (E[B].id == F[D]) {
				A = E[B];
				C = true;
				break
			}
		}
		if (!C) {
			return null
		}
	}
	return A
}
function $dele(o, fn, rv) {
	var r = function() {
		var s = arguments.callee;
		var args = [];
		for ( var i = 0; i < s.length; i++) {
			args[i] = s[i]
		}
		var argStr = args.join(",");
		if (argStr.length > 0) {
			argStr = "," + argStr
		}
		var callStr = "s.thiz[s.fn](" + argStr + ")";
		var v = eval(callStr);
		if (s.rv != null) {
			return s.rv
		} else {
			return v
		}
	};
	r.thiz = o;
	r.fn = fn;
	r.rv = rv;
	return r
}
function $ge(A) {
	if (A != null) {
		return A
	}
	if ($IE) {
		return window.event
	} else {
		return A
	}
}
function $gte(B, A) {
	if (!B.getElementById) {
		B = B.ownerDocument
	}
	if ($IE) {
		return A != null ? A : B.parentWindow.event
	} else {
		return A;
		throw new Error("this method can only execute in IE")
	}
}
function $addEL(F, E, D, C) {
	if ($IE) {
		if (F["$__listener_" + E] == null) {
			var B = function(J) {
				var I = arguments.callee;
				var G = I.fList;
				J = $ge(J);
				for ( var H = 0; H < G.length; H++) {
					G[H](J)
				}
			};
			B.fList = [];
			F["$__listener_" + E] = B;
			F["on" + E] = F["$__listener_" + E]
		}
		var A = F["$__listener_" + E].fList;
		A[A.length] = D
	} else {
		F.addEventListener(E, D, C)
	}
}
function $cancelEvent(A) {
	if ($IE) {
		A.returnValue = false;
		A.cancelBubble = true
	} else {
		A.preventDefault()
	}
}
function $cpAttr(D, C) {
	for ( var A in C) {
		var B = C[A];
		D[A] = B
	}
	return D
}

/** ÉèÖÃÄ¬ÈÏÖµ*/
function $getValue(A, B) {
	return A == null ? B : A
}
var $gv = $getValue;
var $dom = {
	parseInt : function(A) {
		if (A == null || A == "" || typeof (A) == "undefined") {
			return 0
		}
		return parseInt(A)
	},
	getClientSize : function(G) {
		if ($IE) {
			var D = {
				x :G.clientLeft,
				y :G.clientTop
			};
			D.l = D.x;
			D.t = D.y;
			D.r = G.clientRight;
			D.b = G.clientBottom;
			D.w = G.clientWidth;
			D.h = G.clientHeight;
			return D
		} else {
			var C = G.style;
			if (C.borderLeftWidth.length == 0 || C.borderTopWidth.length == 0
					|| C.borderRightWidth.length == 0
					|| C.borderBottomWidth.length == 0) {
				var B = G.offsetWidth;
				C.borderLeftWidth = "0px";
				B -= G.offsetWidth;
				var E = G.offsetWidth;
				C.borderRightWidth = "0px";
				E -= G.offsetWidth;
				var F = G.offsetHeight;
				C.borderTopWidth = "0px";
				F -= G.offsetHeight;
				var A = G.offsetHeight;
				C.borderBottomWidth = "0px";
				A -= G.offsetHeight;
				C.borderLeftWidth = B + "px";
				C.borderTopWidth = F + "px";
				C.borderRightWidth = E + "px";
				C.borderBottomWidth = A + "px";
				var D = {
					l :B,
					r :E,
					t :F,
					b :A,
					x :B,
					y :F
				};
				return D
			} else {
				var D = {
					x :this.parseInt(G.style.borderLeftWidth),
					y :this.parseInt(G.style.borderTopWidth),
					r :this.parseInt(G.style.borderRightWidth),
					b :this.parseInt(G.style.borderBottomWidth)
				};
				D.l = D.x;
				D.t = D.y;
				return D
			}
		}
	},
	getSize : function(D, B) {
		var C = {
			x :D.offsetWidth != null ? D.offsetWidth : 0,
			y :D.offsetHeight != null ? D.offsetHeight : 0
		};
		if (B) {
			var A = this.getMargin(D);
			C.x += A.l + A.r;
			C.y += A.t + A.b
		}
		return C
	},
	setSize : function(E, B, H, F) {
		if ($IE) {
			if (F) {
				var A = this.getMargin(E);
				B -= A.l + A.r;
				H -= A.t + A.b
			}
			E.style.width = B;
			E.style.height = H
		} else {
			var G = this.getClientSize(E);
			var D = G.l + G.r;
			var C = G.t + G.b;
			E.style.width = B - D + "px";
			E.style.height = H - C + "px"
		}
	},
	getPosition : function(B, C) {
		var D;
		D = {
			x :B.offsetLeft,
			y :B.offsetTop
		};
		if (C) {
			var A = this.getMargin(B);
			D.x -= A.l;
			D.y -= A.t
		}
		return D
	},
	setPosition : function(B, A, D, C) {
		if (C) {
		}
		B.style.left = A + "px";
		B.style.top = D + "px"
	},
	setAlpha : function(B, A) {
		return;
		B.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + A* 100 + ");";
		B.style.opacity = A;
		B.style.MozOpacity = A
	}
};
var $motion = {
	smooth : function(B, C, A) {
		if (A > 1) {
			A = 1
		}
		return (C - B) * A + B
	}
};
function PopUp(D, A) {
	this.id = D;
	var C = this.config = A;
	C.width = $gv(C.width, 300);
	C.height = $gv(C.height, 200);
	C.bottom = $gv(C.bottom, 0);
	C.right = $gv(C.right, 20);
	C.display = $gv(C.display, true);
	C.contentUrl = $gv(C.contentUrl, "");
	C.motionFunc = $gv(C.motionFunc, $motion.smooth);
	C.position = {
		x :0,
		y :0
	};
	var B = C.time;
	B.slideIn = $gv(B.slideIn, 10);
	B.hold = $gv(B.hold, 10);
	B.slideOut = $gv(B.slideOut, 10);
	B.slideIn *= 1000;
	B.hold *= 1000;
	B.slideOut *= 1000;
	this.container = document.body;
	this.popup = null;
	this.content = null;
	this.switchButton = null;
	this.moveTargetPosition = 0;
	this.startMoveTime = null;
	this.startPosition = null;
	this.status = PopUp.STOP;
	this.intervalHandle = null;
	this.mm = "max";
	this.baseUrl = "http://images.koolearn.com/www09/class/tips";
	this.imgMin1 = this.baseUrl + "/box_min.gif";
	this.imgMin2 = this.baseUrl + "/box_max.gif";
	this.imgMax =  this.baseUrl + "/box_colse.gif";
}
PopUp.STOP = 0;
PopUp.MOVE_DOWN = 1;
PopUp.MOVE_UP = 2;
PopUp.SWITCH_TO_MIN = PopUp.MOVE_DOWN | 4;
PopUp.SWITCH_TO_MAX = PopUp.MOVE_UP | 8;
var __o = {
	create : function() {
		var G = document;
		var H = this.config;
		var F = this.popup = G.createElement("div");
		this.container.appendChild(F);
		F.id = this.id;
		F.style.cssText = "position:absolute;z-index:65531 !important;overflow:hidden;border:0px solid #f00;";
		$dom.setSize(F, H.width, H.height);
		var D = this.content = G.createElement("div");
		F.appendChild(D);
		D.id = this.id + "_content";
		D.style.cssText = "position:absolute;z-index:1;overflow:hidden;";
		$dom.setSize(D, H.width, H.height);
		$dom.setPosition(D, 0, 0);
		H.position.y = H.height;
		this.onresize();
		var C = "<a id='closeButton' href='#'></a><a id='switchButton' href='#'></a><div id='ifm_div' style='height:"
				+ this.config.height + "px;'><iframe id='"
				+ this.id + "_content_iframe' src="
				+ H.contentUrl + " frameborder=0 scrolling=no width='100%' height='100%' allowTransparency='true'></iframe></div>";
		D.innerHTML = C;
		var E = this.switchButton = $_t(D, "a", "switchButton");
		E.style.cssText = 'position:absolute;z-index:2;font-size:0px;line-height:0px;left:'+(this.config.width-40)+'px;top:8px;width:13px;height:13px;background-image:url("' +	this.imgMin1 + '");';
		$addEL(E, "click", $dele(this, "switchMode"), true);
		$addEL(E, "click", $cancelEvent, true);
		var B = $_t(D, "a", "closeButton");
		B.style.cssText = 'position:absolute;z-index:2;font-size:0px;line-height:0px;left:'+(this.config.width-25)+'px;top:8px;width:13px;height:13px;background-image:url("'+	this.imgMax +'");';
		$addEL(B, "mouseover", function(I) {
			$dom.setAlpha(this, 0.4)
		}, true);
		$addEL(B, "mouseout", function(I) {
			$dom.setAlpha(this, 1)
		}, true);
		$addEL(B, "click", $dele(this, "hide"), true);
		$addEL(B, "click", $cancelEvent, true);
		var A = $IE ? document.body : document.documentElement;
		$addEL(document.body, "resize", $dele(this, "onresize"), true);
		this.__hackTimer = window.setInterval("__popup.onresize()", 50);
		$addEL(A, "scroll", $dele(this, "onresize"), true);
		this.onresize()
	},
	show : function() {
		if (!this.config.display) {
			return
		}
		this.moveTargetPosition = 0;
		this.status = PopUp.MOVE_UP;
		this.startMove()
	},
	hide : function() {
		this.status = PopUp.MOVE_DOWN;
		this.stopMove();
		if (typeof (quitAdSrc) != "undefined" && quitAdSrc != null
				&& quitAdSrc != "" && this.mm == "max") {
			$_t(this.content, "a", "closeButton").style.visibility = "hidden";
			$_t(this.content, "a", "switchButton").style.visibility = "hidden";
			$_t(this.content, "div", "ifm_div").style.visibility = "hidden";
			var B = $_t(this.content, "div", "closeswf_div");
			B.style.visibility = "visible";
			var A = this.popup;
			setTimeout( function() {
				A.innerHTML = ""
			}, 3500);
		} else {
			validWriteCookie(this.config.bdsp);
			this.moveTargetPosition = this.config.height;
			this.status = PopUp.MOVE_DOWN;
			this.startMove()
		}
	},
	minimize : function() {
		this.mm = "min";
		this.moveTargetPosition = this.config.height - 28;
		this.status = PopUp.SWITCH_TO_MIN;
		this.startMove();
		var B = this.switchButton.style;
		var A = B.backgroundImage;
		if (A.indexOf(this.imgMin1) > -1) {
			A = A.replace(this.imgMin1, this.imgMin2);
			B.backgroundImage = A
		}
	},
	maximize : function() {
		if (!this.config.display) {
			return
		}
		this.mm = "max";
		this.moveTargetPosition = 0;
		this.status = PopUp.SWITCH_TO_MAX;
		this.startMove();
		var B = this.switchButton.style;
		var A = B.backgroundImage;
		if (A.indexOf(this.imgMin2) > -1) {
			A = A.replace(this.imgMin2, this.imgMin1);
			B.backgroundImage = A
		}
	},
	delayHide : function() {
		window.setTimeout("__popup.hide()", this.config.time.hold)
	},
	delayMin : function() {
		window.setTimeout("__popup.minimize()", this.config.time.hold)
	},
	switchMode : function() {
		if (this.mm == "min") {
			this.maximize()
		} else {
			this.minimize()
		}
	},
	startMove : function() {
		this.stopMove();
		this.intervalHandle = window.setInterval("__popup.move()", 100);
		this.startMoveTime = new Date().getTime();
		this.startPosition = this.config.position.y
	},
	stopMove : function() {
	},
	move : function() {
		var A = new Date().getTime();
		A = A - this.startMoveTime;
		var B = this.status & PopUp.MOVE_UP ? this.config.time.slideIn
				: this.config.time.slideOut;
		var C = this.config.motionFunc(this.startPosition,
				this.moveTargetPosition, A / B);
		this.config.position.y = C;
		this.onresize();
		if (A >= B) {
			this.onFinishMove()
		}
	},
	onFinishMove : function() {
		this.stopMove();
		if (this.status == PopUp.MOVE_UP && this.config.time.hold > 0) {
			this.delayMin()
		} else {
			if (this.__hackTimer != null) {
				window.clearInterval(this.__hackTimer)
			}
		}
		this.status = PopUp.STOP
	},
	onresize : function() {
		var F = this.config;
		var D = document.documentElement;
		var D = (document.compatMode.toLowerCase() == "css1compat") ? document.documentElement
				: document.body;
		var C = D.clientWidth + D.scrollLeft;
		var B = D.clientHeight + D.scrollTop;
		var A = C - F.right - F.width;
		var E = B - F.bottom - F.height + F.position.y;
		$dom.setPosition(this.popup, A, E);
		$dom.setSize(this.popup, F.width, F.height - F.position.y)
	}
};
$cpAttr(PopUp.prototype, __o);
function readCookie(A) {
	var C = "";
	var B = A + "=";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(B);
		if (offset != -1) {
			offset += B.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) {
				end = document.cookie.length
			}
			C = unescape(document.cookie.substring(offset, end))
		}
	}
	return C
}
function writeCookie(C, D, A) {
	var B = "";
	if (A != null) {
		B = new Date((new Date()).getTime() + A * 3600000 * 1000);
		B = "; expires=" + B.toGMTString()
	}
	document.cookie = C + "=" + escape(D) + B + ";path=/"
}
function job(url,wi,hei) {
	var D = {
		width :wi,
		height :hei,
		bottom :2,
		right :1,
		display :true,
		contentUrl :url,
		bdsp:"BDSP_DISPLAY",
		time : {
			slideIn :1,
			hold :60,
			slideOut :1
		}
	};
	function U() {
		var W = new PopUp("green", D);
		window.__popup = W;
		W.create();
		W.show()
	}
	var S = D.bdsp;
	var J = readCookie(S);
	var B = new Date().getTime();
	if (J == null || B > J) {
		U();
		//validWriteCookie(S);
	}
}

function validWriteCookie(S){
		var C = [ "7+7" ];
		//var Q = "once";
		var P = {};
		var A = [];
		for ( var N = 0; N < C.length; N++) {
			var I = C[N];
			var H = I.split("+");
			var E = parseInt(H[0]);
			for ( var K = 0; K < H.length - 1; K++) {
				H[K] = H[K + 1]
			}
			P[E] = true;
			for ( var M = 0; M < H.length; M++) {
				P[E + parseInt(H[M])] = true
			}
		}
		C = [];
		for ( var N in P) {
			var F = parseInt(N);
			if (isNaN(F)) {
				continue
			}
			C[C.length] = F
		}
		C = C.sort();

		var V = new Date().getHours();
		var T = 60 * 60 * 1000;
		var L = C.concat(), O = L.length;
		for ( var N = 0; N < O; N++) {
			L[O + N] = L[N] + 24
		}
		for ( var N = 0; N < L.length && V >= L[N]; N++) {
		}
		var G = new Date();
		G.setHours(L[N] > 23 ? L[N] - 24 : L[N]);
		var R = G.getTime();
		if (L[N] > 23) {
			R += T * 24
		}
		writeCookie(S, R, 24)
}

function doit(url,wi,hei) {
	if ($IE) {
		if (document.readyState == "loaded" || document.readyState == "complete") {
			job(url,wi,hei)
		} else {
			window.setTimeout(function(){doit(url,wi,hei);}, 500);
			return
		}
	} else {
		job(url,wi,hei)
	}
}

