// JavaScript Document

// find out if browser is ie
// 0 = not ie
function isIEVesion(){
	var ie=0;
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		ie = ieversion;
		/*
		if (ieversion>=8){
			alert("You're using IE8 or above");
		} else if (ieversion>=7){
			alert("You're using IE7.x");
		} else if (ieversion>=6){
			alert("You're using IE6.x");
		} else if (ieversion>=5) {
			alert("You're using IE5.x");
		} else {
			alert("n/a");
		}
		*/
	}
	
	return ie;
}



/**************************************************/
browserWidth = 0; 
browserHeight = 0;

function getBrowserSize() {
	browserWidth = 0; 
	browserHeight = 0;
  	
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
    	browserWidth = window.innerWidth;
    	browserHeight = window.innerHeight;
  	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    	//IE 6+ in 'standards compliant mode'
    	browserWidth = document.documentElement.clientWidth;
    	browserHeight = document.documentElement.clientHeight;
  	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    	//IE 4 compatible
    	browserWidth = document.body.clientWidth;
    	browserHeight = document.body.clientHeight;
  	}
}


function getScrollY() {
  scrollY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrollY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    //DOM compliant
   scrollY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
   	scrollY = document.documentElement.scrollTop;
  }
 
}



function setElementPositions(){
	document.getElementById("background").style.width= browserWidth + "px";
  	document.getElementById("background").style.height= browserHeight + "px";
		document.getElementById("inspir-top-spc").style.height = (document.getElementById("header").offsetHeight - 5) + "px";
		document.getElementById("inspir-middle").style.height = browserHeight - document.getElementById("header").offsetHeight - document.getElementById("footer").offsetHeight + 10 + "px";
	document.getElementById("footer").style.top = (browserHeight - document.getElementById("footer").offsetHeight) + "px";
	
}

function ie6(){
	document.getElementById("background").style.position = "absolute";
	document.getElementById("background").style.top = (scrollY) + "px";
	
	document.getElementById("header").style.position = "absolute";
	document.getElementById("header").style.top = (scrollY) + "px";
	document.getElementById("header").style.left = 0;
	
	document.getElementById("footer").style.position = "absolute";
	//document.getElementById("footer").style.top = (browserHeight + scrollY - 50) + "px";
	document.getElementById("footer").style.top = (browserHeight + scrollY - document.getElementById("footer").offsetHeight) + "px";
	document.getElementById("footer").style.left = 0;
}

/* ------------------------------------------------------------ */
function onBodyLoad(){
	
	getBrowserSize();
	getScrollY();
	setElementPositions();
	//backgroundimage(backgroundIMG, backgroundIMGDir);
	
	
	if(isIEVesion() == 6){
		//alert('is ie 6');
		ie6();
	}
	
}

function init() {
	if (!document.getElementById) return;
 
	if (!document.getElementsByTagName("body").length) {
		window.setTimeout("init();", 100);
		return;
	}
  
	// Document body is loaded. Proceed with the rest of the code
	 onBodyLoad();
}
  
init();
/* ------------------------------------------------------------ */
window.onresize = function(){
	getBrowserSize();
	getScrollY();
	setElementPositions();
	//backgroundimage(backgroundIMG, backgroundIMGDir);
	
	if(isIEVesion() == 6){
	
		ie6();
	}
}

window.onscroll = function(){
	getScrollY();
	setElementPositions();
	
	if(isIEVesion() == 6){
		ie6();
	}
}

/* ************************************************************ */

function backgroundimage(imgN, imgP){
	getBrowserSize();
	document.getElementById("background").innerHTML = '<img src="/image.php?pNum=' + imgN + '&pWidth=' + browserWidth + '&pHeight=' + browserHeight + '&pType=2&album=' + imgP + '" width="100%" height="100%" />';
	//document.write('<img src="/image.php?pNum=' + imgN + '&pWidth=' + browserWidth + '&pHeight=' + browserHeight + '&pType=2&album=' + imgP + '" />');
}

