// preload rollovers
//preload("Images/MNavOurProducts_o.jpg");

//populate the image array for random homepage image
//arImage = new Array();
//arImage[0] = "Images/HomeHero01.jpg";



// handle rollovers
function mOver(Image) {
	if(Image) {
		if(Image.src.indexOf("_o") == -1) {
   			Image.src = Image.src.replace(".jpg", "_o.jpg");
	    }
	 }
	 
	 if(lastImage) {
		lastImage.src = lastImage.src.replace("_o.jpg", ".jpg");
		}	
	lastImage = Image;
}

function mOverGif(Image) {
	if(Image) {
		if(Image.src.indexOf("_o") == -1) {
   			Image.src = Image.src.replace(".gif", "_o.gif");
	    }
	 }
	 
	 if(lastImage) {
		lastImage.src = lastImage.src.replace("_o.gif", ".gif");
		}	
	lastImage = Image;
}

var lastImage;


// simple preload function
function preload(sPath) {
	var o = new Image();
	o.src = sPath;
	return o;
}



function getWindowHeight() 
{
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') 
	{
		windowHeight=window.innerHeight;
	}
	else 
	{
		if (document.documentElement&& document.documentElement.clientHeight) 
		{
			windowHeight = document.documentElement.clientHeight;
		}
		else 
		{
			if (document.body&&document.body.clientHeight) 
			{
				windowHeight = document.body.clientHeight;
			}
		}
	}
	
	return windowHeight;
}


// determine height for <div> element 
function getDivSize(DivID) {	
	d= document.getElementById(DivID)
	var divHeight = 0
	
	
	
	if(d.offsetHeight)
		{ 
		 divHeight=d.offsetHeight; 
		} 
		else if(d.style.pixelHeight)
		{ 
		 divHeight=d.style.pixelHeight; 
		} 

		
	return divHeight;
	
}

function recalcContainerHeight(){

	
	var maxHeight= 800;
	//var maxHeight = Math.max(maxHeight, getDivSize("MainContent") + 183);
	var maxHeight = Math.max(maxHeight, getWindowHeight());
	var maxHeight = Math.max(maxHeight, (getDivSize("InnerTopContent")  + 80));
	//Debug(maxHeight);
	
	//document.getElementById("OuterContentContainer").style.visibility = "visible";
	document.getElementById("OuterContentContainer").style.height = maxHeight + "px";
	
	document.getElementById("Footer").style.top = (maxHeight - getDivSize("Footer")) + "px";
	document.getElementById("Footer").style.visibility = "visible";
}

function Debug(outputString){
	document.getElementById("DebugLayer").innerHTML = outputString;
}


window.onload = function() 
{

	recalcContainerHeight();
	
}
window.onresize = function() 
{
	recalcContainerHeight();
}

function SwapImageBackground(id, imagebackground) 
{
	var identity = document.getElementById(id);
	identity.style.backgroundImage = 'url( ' + imagebackground + ')';
}

function checkValue(obj, stringValue){
	if(obj.value == ""){
		obj.value = stringValue;
	}
}	

