// JavaScript Document

var amBox = new Object();
amBox.padding = 10;
var __swfID__ = null;

amBox.init = function(id) {
	__swfID__ = id;
	//window.document.write('<div id="amb-container"><div id="amb-overlay"><div id="amb-content">CONTENT</div></div></div>');
	//alert("amBox.init('"+__swfID__+"')");
}
amBox.popup = function(src,width,height) {
	if (!width) width = 360;
	if (!height) height = 240;
	var left = (screen.width-width)/2;
	var top = (screen.height-height)/2;
	//alert(url+"\n"+"width="+width+",height="+height+",top="+point.y+",left="+point.x+",scrollbars=no");
	window.open(src,"amBoxPopup","top="+top+",left="+left+",width="+width+",height="+height+",scrollbars=no");
}
amBox.open = function(src,params) {
	//alert("amBox.open('"+width+"','"+height+"')");
	if (params == null) params = {};
	if (params.width == undefined) params.width = 200;
	if (params.height == undefined) params.height = 80;
	if (src.substr(0,4) == "http") params.url = src;
	else params.innerHTML = src;
	//alert("width : "+params.width+"\nheight : "+params.height+"\ninnerHTML : "+params.innerHTML+"\nurl : "+params.url);
	var container = document.getElementById("amb-container");
	container.style.visibility = "visible";
	container.style.display = "block";
	var content = document.getElementById("amb-content");
	content.style.width = params.width + "px";
	content.style.height = params.height + "px";
	content.style.padding = this.padding + "px";
	if (params.border) content.style.border = params.border;
	container.onclick = amBox.close;
	window.onresize = amBox.place;
	amBox.place();
	if (params.innerHTML) content.innerHTML = params.innerHTML;
	else if (params.url) content.innerHTML = '<iframe src="'+params.url+'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'+params.width+'px; height:'+params.height+'px;" allowTransparency="true"></iframe>';
	if (__swfID__ != null) {
		var swf = document.getElementById(__swfID__);
		if (swf) swf.onOpenBox();
	}
}
amBox.place = function() {
	var content = document.getElementById("amb-content");
	var point = window.center({width:parseInt(content.style.width) + (2*this.padding), height:parseInt(content.style.height) + (2*this.padding)});
	content.style.left = point.x + "px";
	content.style.top  = point.y + "px";
}
amBox.close = function() {
	var container = document.getElementById("amb-container");
	container.style.visibility = "hidden";
	container.style.display = "none";
	container.onclick = null;
	window.onresize = null;
	if (__swfID__ != null) {
		var swf = document.getElementById(__swfID__);
		if (swf) swf.onCloseBox();
	}
}

