var browser=new Browser();
function getInnerWinWidth(){
	return browser.is_ie ? document.body.clientWidth : browser.is_nav ? window.innerWidth : null; 
}
function getInnerWinHeight(){
	return browser.is_ie ? document.body.clientHeight : browser.is_nav ? window.innerHeight : null; 
}

function getElement(id) { 
	return document.getElementById ? document.getElementById(id) : 
	document.all ? document.all(id) : null; 
} 
function getRealLeft(id) { 
	var el = getElement(id); 
	if (el) { 
		xPos = el.offsetLeft; 
		tempEl = el.offsetParent; 
		while (tempEl != null) { 
		xPos += tempEl.offsetLeft; 
		tempEl = tempEl.offsetParent; 
	} 
	return xPos; 
} 
} 
function getRealTop(id) { 
	var el = getElement(id); 
	if (el) { 
		yPos = el.offsetTop; 
		tempEl = el.offsetParent; 
		while (tempEl != null) { 
			yPos += tempEl.offsetTop; 
			tempEl = tempEl.offsetParent; 
		} 
	return yPos; 
	} 
} 
function getRealRight(id) { 
	return getRealLeft(id) + getElement(id).offsetWidth; 
} 
function getRealBottom(id) { 
	return getRealTop(id) + getElement(id).offsetHeight; 
} 
function autoResizeWindowTo(refElementId,reposition,mapwindow_resized){
	if(reposition==0) return;
	var width = getRealRight(refElementId);
	var height = getRealBottom(refElementId);
    if (width==0) return;
	if (width==0) width=800;
	if (height==0) height=600;
	

	if(browser.is_ie){
		if(reposition==1 && mapwindow_resized)self.moveTo(0,0);
		window.resizeBy(width-document.body.clientWidth,height-document.body.clientHeight);
	}
	if(browser.is_nav){
		window.innerHeight = height;
		window.innerWidth = width;
	}
	if (getElement("mapdescHeight")) getElement("mapdescHeight").value=getElement("MapDesc").offsetHeight;
	if (getElement("legendWidth")) getElement("legendWidth").value=getElement("htmlLegend").offsetWidth;
	if (getElement("availHeight")) getElement("availHeight").value=window.screen.availHeight;
	if (getElement("availWidth")) getElement("availWidth").value=window.screen.availWidth;
    if(reposition==1&& mapwindow_resized) self.moveTo((window.screen.availWidth-width)/2-5,(window.screen.availHeight-height)/2-18);
//    if(reposition==2) self.moveTo((window.screen.availWidth-width)-50,(window.screen.availHeight-height)/2-20);
    if(reposition==2) //for legend
		self.moveTo(50,window.screen.availHeight-height-200);
}

