// toolbox
function openPopup(theURL, winName, w, h, scrollbar, resizable, toolbar, statusbar, menubar)
{
	var left = ((window.screen.width - w) / 2);
	var top = ((window.screen.height - h) / 2);
	//
	toolbar_str = toolbar ? 'yes' : 'no';
	menubar_str = menubar ? 'yes' : 'no';
	statusbar_str = statusbar ? 'yes' : 'no';
	scrollbar_str = scrollbar ? 'yes' : 'no';
	resizable_str = resizable ? 'yes' : 'no';
	//
	window.open(theURL, winName, 'left='+left+',top='+top+',width='+w+',height='+h+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

//
//----------------------------------------------------------//
// scrolling management
//----------------------------------------------------------//
//

function getScrollPosY()
{
	if(window.pageYOffset != null){
		return window.pageYOffset;
	}else if(document.body.scrollTop != null){
		return document.body.scrollTop;
	}
	return 0;
}

function innerResizeTo(w, h)
{
	window.resizeTo(w, h);
	// get the current inner sizes
	winW = getInnerWidth();
	winH = getInnerHeight();
	// calculate the real value for the desired sizes
	realW = (w + (w - winW));
	realH = (h + (h - winH));
	window.resizeTo(realW, realH);
	//
	var left = ((window.screen.width - realW) / 2);
	var top = ((window.screen.height - realH) / 2);
	window.moveTo(left, top);
}

function getInnerWidth()
{
	if(parseInt(navigator.appVersion) > 3){
		winW = 0;
		if(navigator.appName == "Netscape"){
			winW = window.innerWidth;
		}
		if(navigator.appName.indexOf("Microsoft") != -1){
			winW = document.body.offsetWidth;
		}
	}
	return winW;
}

function getInnerHeight()
{
	if(parseInt(navigator.appVersion) > 3){
		winH = 0;
		if(navigator.appName == "Netscape"){
			winH = window.innerHeight;
		}
		if(navigator.appName.indexOf("Microsoft") != -1){
			winH = document.body.offsetHeight;
		}
	}
	return winH;
}

function setScrollHeight(h)
{
	document.spacerImage.height = h;
	if(navigator.appName == "Netscape"){
		innerResizeTo(getInnerWidth(), getInnerHeight(), false);
	}
	// BUG
	innerResizeTo((screen.width - 10), getInnerHeight(), false);
	window.moveTo(0, 0);
}

function setScrollWidth(w)
{
	document.spacerImage.width = w;
	if(navigator.appName == "Netscape"){
		innerResizeTo(getInnerWidth(), getInnerHeight(), false);
	}
}

/*
*******************************************************
** div controlling
*******************************************************
*/

function toogleDiv(divName)
{
	if (document.getElementById){
		obj = document.getElementById(divName);
		if(obj.style.display == "none"){
			showDiv(divName);
		} else {
			hideDiv(divName);
		}
	}
}

function hideDiv(divName)
{
	$(divName).style.display = "none";
}

function showDiv(divName)
{
	$(divName).style.display = "block";
}
