function $_(n) {
	if(!n) return false;
	if(!document.getElementById(n)) return false;
	return document.getElementById(n)
}

function bubbling_no(e) {
	e = bubbling_ie(e); /* for ie */
	if (!e.cancelBubble) e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	return false;
}
function bubbling_ie(e) {
	if (!e) var e = window.event;
	return e;
}

function pagesize() {
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	
	arrayPagesize = new Array(w,h) 
	return arrayPagesize;
}

$(document).ready(function() {
	var obj = $_("x-window");
	if (obj) {
		obj.style.top = - Math.round(obj.offsetHeight) + "px";
		obj.style.marginLeft = - Math.round(obj.offsetWidth / 2) + "px";
		obj.style.marginTop = - Math.round(obj.offsetHeight / 2) + "px";
		
		$(obj).animate({"top": "50%"}, 5000);
		
		$(obj).click(function(e){ bubbling_no(e); });
		$(document).click(banner_close);
	}
});

function banner_close() {
	var obj = $_("x-window");
	var area = pagesize();
	var left = - obj.offsetWidth / 2 + "px";
	var top = - obj.offsetHeight + "px";
	
	$(obj).stop();

	obj.style.marginLeft = - Math.round($_("x-window").offsetWidth / 2) + "px";
	obj.style.top = $_("x-window").offsetTop + Math.round(obj.offsetHeight / 2) + "px"; // for ie
	
	$(obj).animate({"top": top}, 5000, function(){ $(obj).css({ display:"none" }); });
}