// JavaScript Document

function addLoadListener(func) {
	if (window.addEventListener) {
		window.addEventListener("load", func, false);
	} else if (document.addEventListener) {
		document.addEventListener("load", func, false);
	} else if (window.attachEvent) {
		window.attachEvent("onload", func);
	}
}
function addUnloadListener(func) {
	if (window.addEventListener) {
		window.addEventListener("unload", func, false);
	} else if (document.addEventListener) {
		document.addEventListener("unload", func, false);
	} else if (window.attachEvent) {
		window.attachEvent("unonload", func);
	}
}

window.size = function() {
	var w = 0;
	var h = 0;
	//IE
	if(!window.innerWidth) {
		if(!(document.documentElement.clientWidth == 0)) {//strict mode
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		} else { //quirks mode
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else { //w3c
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return { width:w, height:h };
}

window.center = function() {
	var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};
	var _x = 0;
	var _y = 0;
	var offsetX = 0;
	var offsetY = 0;
	_x = ((this.size().width-hWnd.width)/2)+offsetX;
	_y = ((this.size().height-hWnd.height)/2)+offsetY;
	return { x:_x, y:_y };
}

function showError(error) {
	amBox.open('<center><b>'+error+'</b></center>',{width:300,height:20,border:'solid 6px #9c141c'});
}

function facebookShare() {
	u = location.href;
	t = document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
function mailShare() {
	u = location.href;
	t = document.title;
	document.location = 'mailto:?body='+encodeURIComponent(u)+'&subject='+encodeURIComponent(t);
	return false;
}
