window.onresize = adjustBackgroundOffset;

var containerEle = null;

function site_init()
{
	containerEle = document.getElementById('container');

	// Adjust the background offset to match up with the site position
	adjustBackgroundOffset();
	
	// Adjust the sites height to match up with the background
	adjustHeight();
}


function adjustBackgroundOffset()
{	
	var siteWidth = 0;
	var windowWidth = document.documentElement.clientWidth;
	
	if(containerEle.style.width) {
		siteWidth = containerEle.style.height;
	}
	else if(containerEle.offsetWidth) {
		siteWidth = containerEle.offsetWidth;
	}
	else if(containerEle.style.pixelWidth) {
		siteWidth = containerEle.style.pixelWidth;
	}
	
	var margin = (windowWidth - siteWidth) / 2;

	var x = Math.floor(margin/26)*26;
	
	document.body.style.backgroundPosition = (margin-x)+'px 0px';
} // end func adjustBackgroundOffset



function adjustHeight() {
	
	var padding = 27;
	
	// Fetch the elements height
	if(containerEle.style.height) {
		eleHeight = containerEle.style.height;
	}
	else if(containerEle.offsetHeight) {
		eleHeight = containerEle.offsetHeight;
	}
	else if(containerEle.style.pixelHeight) {
		eleHeight = containerEle.style.pixelHeight;
	}
	
	
	// var newHeight = (Math.ceil((eleHeight) / 24) * 24) +'px'; - Doesn't work reliably without the padding
	var newHeight = (Math.ceil((eleHeight+padding) / 24) * 24) - padding +'px'; 
//	alert(newHeight);
	
	// Set the new height
	containerEle.style.height = newHeight;
}



function bookmark_us(url, title){
	// Mozilla Based
	if (window.sidebar) {
	    window.sidebar.addPanel(title, url, "");
	}
	
	else if(
		(window.opera && window.print) // Opera
		|| (navigator.userAgent.toLowerCase().indexOf('webkit') > -1) // Safari Win & Mac
	) {
		if(navigator.userAgent.toLowerCase().indexOf('mac') > -1) {
			alert('You need to press Command/Cmd + D to bookmark our site.');
		} else {
			alert('You need to press Ctrl + D to bookmark our site.');
		}
	}
	
	// Safari 1.0 & IE5 on Mac
	else if(!window.print || navigator.userAgent.toLowerCase().indexOf('mac')> -1) {
		alert('You need to press Command/Cmd + D to bookmark our site.');
	}
	
	// Konqueror
	else if(navigator.userAgent.toLowerCase().indexOf('konqueror') > -1) {
		alert('You need to press CTRL + B to bookmark our site.');
	}

	// Internet Explorer 4.0+
	else if(document.all) {
	    window.external.AddFavorite(url, title);
	}
}