/**
 * Being Wicked Scripts
 * 
 * Requires the Prototype lib (prototypejs.org)
 * 
 * @author Gordon Clemmons
 */

function printObfuscatedEmail()
{
	document.write('<'+
		'a hre'+
		'f="mai'+
		'lto:jyma'+
		'rtin@r'+
		'an'+
		'domh'+
		'ouse.com"'+
		'>jymar'+
		'tin@ra'+
		'ndo'+
		'mhou'+
		'se.com<'+
		'/a>'
	);
}

function getViewportDimensions()
{
	var viewportDims	= {};
	if ( window.innerHeight != 'undefined' && window.innerHeight != 0 )
	{
		viewportDims	= {
			'height':	window.innerHeight,
			'width':	window.innerWidth
		};
	} else if ( document.body.clientHeight != 'undefined' && document.body.clientHeight != 0 ) {
		viewportDims	= {
			'height':	document.body.clientHeight,
			'width':	document.body.clientWidth
		};
	} else if ( document.documentElement.clientHeight != 'undefined' &&
		document.documentElement.clientHeight != 0 ) {
		viewportDims	= {
			'height':	document.documentElement.clientHeight,
			'width':	document.documentElement.clientWidth
		};
	} else {
		viewportDims	= {
			'height':	0,
			'width':	0
		};
	}
	return viewportDims;
}

var bgHeight	= 2000;
var backgrounds	= ['bg01', 'bg02', 'bg03'];
function updateBackground()
{
	var idx	= Math.floor( Math.random() * backgrounds.length );
	var bg = backgrounds[idx];
	document.body.style.background = '#fff url(images/' + bg + '.png) bottom center no-repeat';
	resizeBackground();
}

function resizeBackground()
{
	if ( document.body == null )
		return;

	var bs		= document.body.style;
	var dims	= getViewportDimensions();
	bs.backgroundAttachment = 'fixed';
	bs.backgroundPosition	= '50% ' + ( -bgHeight + dims['height'] ) + 'px';
}

window.onload = updateBackground;
window.onresize = resizeBackground;
