// Helper function to load content into our content IFrame
function load( url ) {
	var iFrame = $('contentIFrame');
	if (iFrame)
	{
		iFrame.src = url;
	}
}

// Browser compatibility function
function $(id) {
	if (document.getElementById)
		return document.getElementById( id );
	if (document.all)
		return document.all[id];
	return null;
}

// Fetch the computed CSS property value for the given object reference
function getStyle( ref, styleProp ) {
	ref = (typeof(ref) == 'object') ? ref : _el( ref );
	if (ref.currentStyle)
		return ref.currentStyle[styleProp];
	else if (window.getComputedStyle)
		return document.defaultView.getComputedStyle(ref, null).getPropertyValue( styleProp );
	return null;
}

// Magic IE PNG fix
function makeIEHandlePng() {
	if (! window.attachEvent || window.opera)
		return;

	var images = document.getElementsByTagName( 'img' );
	for (var i = 0; i < images.length; i++)
	{
		var img = images[i];
		if (img.src.match(/\.png$/i) && img.src.indexOf('spacer') == -1)
		{
			// It's a png, replace some stuff
			var span = document.createElement( 'span' );
			span.style.display = 'inline-block';
			span.style.width   = img.clientWidth + 'px';
			span.style.height  = img.clientHeight + 'px';
			span.style.margin  = getStyle( img, 'margin' );
			// Build the filter value for IE
			var filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(" +
				"src='" + img.src + "', sizingMethod='scale')"
			span.style.filter  = filter;

			// Replace the image with the wrapper span
			var parent = img.parentNode;
			    parent.replaceChild( span, img );

			// Wrap the image in the span
			span.appendChild( img );

			// Change the image to a spacer
			img.src = 'spacer.png';
			img.style.margin = '';
			img.style.height = '16px';
			img.style.width  = '16px';
		}
	}
}

function reSize() {
	var iFrame = $('contentIFrame');
	if (iFrame)
	{
		var oBody = document.body;
		iFrame.style.height = (oBody.clientHeight - 98) + "px";
	}

}
// Application initialization
function init() {
	makeIEHandlePng();
	reSize();
	load('home.html');
}

window.onload = init;
window.onresize = reSize;
