function getObj(targetDocument, name)
{
  if (targetDocument.getElementById)
  	return targetDocument.getElementById(name);
  else if (targetDocument.all)
	return targetDocument.all[name];
  else if (targetDocument.layers)
   	return targetDocument.layers[name];
}

function getSelectedIndex(listbox)
{
	return listbox.options.selectedIndex;
}

function getSelectedValue(listbox)
{
	if (getSelectedIndex(listbox) != -1)
		return listbox.options[getSelectedIndex(listbox)].value;
	return '';
}

function getSelectedName(listbox)
{
	if (getSelectedIndex(listbox) != -1)
		return listbox.options[getSelectedIndex(listbox)].text;
	return '';
}

function isDivVisible(targetDocument, divname)
{
	if (targetDocument.getElementById)
		return (targetDocument.getElementById(divname).style.display != "none")
	else if (targetDocument.all)
		return (targetDocument.all[name].style.display != "none")
	else if (targetDocument.layers)
		return (targetDocument.layers[divname].display != "none");
}


function setDivStatus(targetDocument, divname, isVisible)
{
	if (targetDocument.getElementById)
		targetDocument.getElementById(divname).style.display  = (isVisible) ? "block" : "none";
	else if (targetDocument.all)
		targetDocument.all[name].style.display  = (isVisible) ? "block" : "none";
	else if (targetDocument.layers)
		targetDocument.layers[divname].display  = (isVisible) ? "block" : "none";
}

function uncheckOthers(checkboxUsed, namePattern)
{
	var chkIndex = 0;
	var objCheck = getObj(document, namePattern + chkIndex);
	while (objCheck)
	{
		objCheck.checked = false;
		objCheck = getObj(document, namePattern + ++chkIndex);
	}
	if (checkboxUsed)
		checkboxUsed.checked = true;
}

function showModalPopup(url, name, width, height, isCentered)
{		
	var left = (screen.availWidth - width)/2;
	var top = (screen.availHeight - height)/2;
	var ID = name;
	if (!isCentered)
	{
		left=10;
		top=10
	}
	if (window.showModalDialog)
	{
		var dialogArguments = new Object();
		var _R = window.showModalDialog(url, dialogArguments, "dialogWidth="+width+"px;dialogHeight="+height+"px;scroll=no;status=no;");
		if ("undefined" != typeof(_R))
		{
			SetName(_R.strName);	
		}
	}		
	else	//NS			
	{  	
 		winHandle = window.open(url, ID, "modal,toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=no,resizable=no,left="+left+",top="+top+",width="+width+",height="+height);
		winHandle.focus();
	}
	return false;
}