/*
Created by : owenc/at/totalsales/dot/com
Date Created : 11/30/2005

Purpose : This script detects the browsers current height and resizes the div with id="map" to that height

Use : 
	window.onload=gMapSize
	window.onresize=gMapSize
*/

function findPosX(obj) {
	var curleft = 0;
	if(obj.offsetParent)
		while(1) {
			curleft += obj.offsetLeft;
			if(!obj.offsetParent)
				break;
			obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent)
		while(1) {
			curtop += obj.offsetTop;
			if(!obj.offsetParent)
				break;
			obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}

function getHeight() {
	var myHeight = 0;
	if( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
    	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientHeight || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientHeight || document.body.clientHeight ) ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

function gMapSize () {
	browserheight=getHeight();
	mymap=document.getElementById ? document.getElementById('map') : document.all.map;
	possibleResize =  parseInt(browserheight)-parseInt(findPosY(mymap));
	mymap.style.height = ( parseInt(gMapDefaultHeight) > possibleResize ) ? parseInt(gMapDefaultHeight) : mymap.style.height=possibleResize-5;
}
