function handleError(){return true;}
window.onerror = handleError;

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;
}
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}
function setContent() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById('container');
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'relative';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}
function setContentWidth (percent, loc) {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		var windowWidth = getWindowWidth();
		if (windowWidth > 0){
			document.getElementById(loc).style.position = 'absolute';			
			document.getElementById(loc).style.left = ((windowWidth) / 100) * percent + 'px';
		}
		if (windowHeight > 0) {
			var contentElement = document.getElementById(loc);
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'absolute';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}
function setContentLoc(loc) {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById(loc);
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'relative';
				contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}



function setContentBackground() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentElement = document.getElementById('container');
			var contentHeight = contentElement.offsetHeight;
			if (windowHeight - contentHeight > 0) {
				contentElement.style.position = 'relative';
				document.body.style.backgroundPosition = 'center '+((windowHeight / 2) -330)+'px';
			}
			else {
				contentElement.style.position = 'static';
			}
		}
	}
}


function pagereq(url, loc)
// pagereq loads a php file into a html element and passes url variables to it.
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="components/"+url
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(loc) {
	return function() {
	
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading"){
		
		var newinnerhtml = document.getElementById(loc).innerHTML
		document.getElementById(loc).
	 	innerHTML="<p class=\"statusbox\"></p>"+newinnerhtml;
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 	
	 document.getElementById(loc).
	 innerHTML=xmlHttp.responseText;
	}
	};
}(loc);
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 


function pagereqMid(url, loc)
// pagereq loads a php file into a html element and passes url variables to it.
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="components/"+url
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function(loc) {
	return function() {
	
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading"){
		
		var newinnerhtml = document.getElementById(loc).innerHTML
		document.getElementById(loc).
	 	innerHTML="<p class=\"statusbox\"></p>"+newinnerhtml;
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 	
	 document.getElementById(loc).
	 innerHTML=xmlHttp.responseText;
	setContentLoc(loc);
	}
	};
}(loc);
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function pagereqsjax(url, loc)
// pagereq loads a php file into a html element and passes url variables to it.
// SYNCHRONOUS VERSION!
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 } 
var url="components/"+url
url=url+"&sid="+Math.random()
xmlHttp.open("GET",url,false)
xmlHttp.send(null)
document.getElementById(loc).
innerHTML=xmlHttp.responseText;
} 


function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}



function target_classname (loc, varswitch) {
	document.getElementById(loc).className=varswitch
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

