
function getPageSize() {
	        
	 var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;		
	} else if (document.scrollHeight > document.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
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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.clientWidth;
		windowHeight = document.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 = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	//alert (pageWidth + " " + pageHeight);
	return [pageWidth,pageHeight];
}


function getOverlay() {	
	var over = document.getElementById('overlay');
	var popup = document.getElementById('lightbox');
	
	var arrayPageSize = this.getPageSize();
	over.style.width = arrayPageSize[0] + 'px';
	over.style.height = arrayPageSize[1] + 'px';
	
	popup.style.display = 'block';
	
}

function closeOverlay(){

	var over = document.getElementById('overlay');
	var popup = document.getElementById('lightbox');
	
	var arrayPageSize = this.getPageSize();
	over.style.width = '0px';
	over.style.height = '0px';
	
	popup.style.display = 'none';	
}

function showHide(id) {
	e = document.getElementById(id);

	if (e.style.display == 'none') {
		e.style.display = 'block';
	} else if (e.style.display == 'block') {
		e.style.display = 'none';
	}	
}
//////////////////////////////////////////////////////////////////////////////
//updateDiv
//
//Desc: Calls a special version of updateContentArea just for use with
//run.php
//////////////////////////////////////////////////////////////////////////////
function updateDiv(divName,funct_name,param1,param2,param3,param4){
	
	var vars = "function_name="+funct_name+"&param1="+param1+"&param2="+param2+"&param3="+param3+"&param4="+param4;	
	updateContentArea(divName,vars,'run.php');
	
}//end function
//////////////////////////////////////////////////////////////////////////////
//setFormHeight
//
//
//Desc: Ta forms hack/fix for ht issues
//////////////////////////////////////////////////////////////////////////////
function setFormHeight(ht){

	//pae form height fix
	var obj = document.getElementById('taForm');	
	obj.style.height = ht;

}
//////////////////////////////////////////////////////////////////////////////
//scaleImg
//
//
//Desc: enforces a maximum width/height on an image.
//var img = an object passed in usally as this onload
//var max_size = size in pixels the height and width are not allowed to exceed 
//////////////////////////////////////////////////////////////////////////////
function scaleImg(img,max_size){
	
	if(img==null){
		alert("Could Not Scale Image!");
		return;
	}
	
	var height = img.height;
	var width = img.width;
	
	
	//Find the longest side and check to see if it exceeds that max
	if(height>=width){
		//perform stuff based on height
		
		//Is it too big?
		if(height>max_size){
			//yes, resize it with respect to the aspect ratio

			//find the ratio
			var ratio = width/height;
			
			//reset the height
			img.height=max_size;
			height=img.height;
			
			//reset the width
			img.width=(height*ratio);
			
		}//end if
		
	}else{
		//perform stuff based on width
		
		//Is it too big?
		if(width>max_size){
			//yes, resize it with respect to the aspect ratio
			
			//find the ratio
			var ratio = height/width;
			
			//reset width
			img.width=max_size;
			width=img.width;
			
			//reset height
			img.height = (width*ratio);
			
		}//end if
		
	}//end if

	
}//end function
//////////////////////////////////////////////////////////////////////////////
//changeMapCat
//
//
//Desc: This is used on the local living page to alter the google map to show
//whatever category is selected from the related pulldown.
//////////////////////////////////////////////////////////////////////////////
function changeMapCat(element){
	var newSRC = "inc.googlemap.php?Category_ID="+element.value;
	var iframe = document.getElementById("map");
	iframe.src = newSRC;
}//end function


function openMapWindow(homeID){
	window.open("http://www.chateauelan.net/modules/map/interface.php?homeID="+homeID, "map_window", "width=1026,height=700,toolbars=no,scrolling=no");
	}