// JavaScript Document

function align(o){

	var lmt = document.getElementById(o);
	var container = document.documentElement;

	if(lmt && container){
	    var containerWidth;
	    var containerHeight;
	    if (container.innerWidth){
            containerWidth = container.innerWidth;
            containerHeight = container.innerHeight;
		}else{
            containerWidth = container.clientWidth;
            containerHeight = container.clientHeight;
		}
		
	    var lmtWidth;
	    var lmtHeight;
	    if (lmt.innerWidth){
            lmtWidth = lmt.innerWidth;
            lmtHeight = lmt.innerHeight;
		}else{
            lmtWidth = lmt.offsetWidth;
            lmtHeight = lmt.offsetHeight;
		}
		
		if(o=="site"){
			var x = Math.ceil((containerWidth - lmtWidth) / 2)-48;
		}else{
			var x = Math.ceil((containerWidth - lmtWidth) / 2);
		}
		
		var y = Math.ceil((containerHeight - lmtHeight) / 2);
		if(y<0){
			y = 0;
		}
		if(x<0){
			x = 0;
		}
		
		// adjust site
		lmt.style.position = "relative";
		lmt.style.left = x + "px";
		//lmt.style.top = y + "px";
		
		// adjust quad
		
	}
	if (lmt!=null){
		lmt.style.visibility = 'visible';
	}

}

function addevent(obj,evt,fn,capt){
	if(obj.addEventListener){
		obj.addEventListener(evt, fn, capt);
		return true;
	}else if(obj.attachEvent){
		obj.attachEvent('on'+evt, fn);
		return true;
	}
	else return false;
}

if (document.getElementById && document.getElementsByTagName)
{
	addevent(window, 'load', align, false);
	addevent(window, 'resize', align, false);
}
