var ie=document.all&&document.getElementById;

// function to hide objects
function hideObject(object) {
	if (object != null) {
		object.style.visibility="hidden";
		object.style.display="none";
		object.style.left=0+'px';
		object.style.top=0+'px';
	}
}

// function to show objects
function showObject(object)	{
	if (object != null) {
		object.style.display = 'block';			
		object.style.visibility="visible";
	}
}

// function to hide objects
function hideObjectById(objectid) {
	object = document.getElementById(objectid);
	if (object != null) {
		object.style.visibility="hidden";
		object.style.display="none";
		object.style.left=0+'px';
		object.style.top=0+'px';
	}
}

// function to show objects
function showObjectById(object)	{
	object = document.getElementById(objectid);
	if (object != null) {
		object.style.display = 'block';			
		object.style.visibility="visible";
	}
}

function getXCoords(e) {
	xCoords = ie? document.documentElement.scrollLeft+event.clientX-5+'px' : window.pageXOffset+e.clientX+'px';
	return xCoords;
}

function getYCoords(e) {
	yCoords = ie? document.documentElement.scrollTop+event.clientY-5+'px' : window.pageYOffset+e.clientY+'px';
	return yCoords;
}

// Strip newlines
function stripNewLines(stringValue) {
	return stringValue.replace(new RegExp( "\\n", "g" ),"");
}

//set the opacity for a given object, crossbrowser solution
function setOpacity(obj, value){
	if(document.all){
		obj.style.filter = 'alpha(opacity=' + value + ')';
	}
	else {
		obj.style.opacity = (value/100); 
	}	
}

// show a helpdiv
function showHelpDiv(event,id) {
	var helpdiv = document.getElementById(id);
	showObject(helpdiv);
	var xCoords = getXCoords(event);
	xCoords = xCoords.substr(0,xCoords.length-2);
	xCoords = parseInt(xCoords)+10;
	var yCoords = getYCoords(event);
	yCoords = yCoords.substr(0,yCoords.length-2)
	yCoords = parseInt(yCoords)+10;
	helpdiv.style.left = xCoords+'px';
	helpdiv.style.top = yCoords+'px';
}

// hide a helpdiv
function hideHelpDiv(id) {
	var helpdiv = document.getElementById(id);
	hideObject(helpdiv);
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){	
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function doResize() {
	var temp = new Array();
	temp = getPageSize();
	var height = temp[1]+'px';
	if(ie) {
		height = temp[1];
	}
	document.getElementById('sitecontainer').style.height = height;
}