var popupWin;
var aHelp = new Array();
var aHelp2 = new Array();

function helpBean(title, content)
{
	this.title = title;
	this.content = content;
}

function popup(url,name,w,h,s,t) {

	var left = ',left=' + ((screen.width/2) - w/2);
	var top = ",top=" + ((screen.height/2) - h/2);
	w = (w) ? 'width=' + w : '';
	h = (h) ? ',height=' + h : '';
	s = (s) ? ',scrollbars=' + s : '';
	t = (t) ? ',status=' + t : '';

	var args = w + h + s + t + left + top + ',menubar=0';
	if(navigator.userAgent.indexOf("MSIE") > -1 && navigator.userAgent.toUpperCase().indexOf("MAC")==-1)
	{
		if(popupWin != null)
		{
			//popupWin.close();
		}
	}

	popupWin = window.open(url,name,args);
	
	return false;
}

function maxSize(oControl, size)
{
	if(oControl.value.length > size)
		oControl.value = oControl.value.substring(0,size-1);
}

function showHelp(iHelpId, oElement)
{
	if(iHelpId > aHelp.length)
		alert("Help is currently unavailable for this item");
	else
	{
		document.getElementById("helpTitle").innerHTML = aHelp[iHelpId].title
		document.getElementById("helpContent").innerHTML = aHelp[iHelpId].content

		var oHelp = document.getElementById("idHelp")

		oHelp.style.top = window.event.clientY ;
		oHelp.style.left = window.event.clientX + 25;
		showHideCombo("hidden");
		oHelp.style.visibility = 'visible'
	}

	oElement.onmouseup = hideHelp;
}

function showHelp2(iHelpId, oElement)
{
	if(iHelpId > aHelp2.length)
		alert("Help is currently unavailable for this item");
	else
	{
		document.getElementById("helpTitle").innerHTML = aHelp2[iHelpId].title
		document.getElementById("helpContent").innerHTML = aHelp2[iHelpId].content

		var oHelp = document.getElementById("idHelp")

		oHelp.style.top = window.event.clientY ;
		oHelp.style.left = window.event.clientX + 25;
		showHideCombo("hidden");
		oHelp.style.visibility = 'visible'
	}

	oElement.onmouseup = hideHelp;
}


function showHideCombo(sHide)
{
	var oElements = document.getElementsByTagName("SELECT");
	for(i = 0; i < oElements.length; i ++)
		oElements[i].style.visibility = sHide;
}

function hideHelp()
{
	document.getElementById("idHelp").style.visibility = "hidden";
	showHideCombo("visible")
}
function switchEnvironment(selectedObj)
{
	alert('TODO');
}
function searchEntities()
{
	var theForm = document.forms[0];


	if (theForm.elements["mapper.id"].value == '-1')
	{
		alert('You must select a search option!');
		return false;
	}

	return theForm.submit();
}
function openPage(selectedObj)
{
	document.location.href=selectedObj.options[selectedObj.selectedIndex].value;
}