
var newWindow;	


function populateCombo(inElement, selected, outElement) 
{
	var selectedArray = eval(selected + "Array");
	
	while (selectedArray.length < outElement.options.length) 
	{
		outElement.options[(outElement.options.length - 1)] = null;
	}
	for (var i=0; i < selectedArray.length; i++) 
	{
		eval("outElement.options[i]=" + "new Option" + selectedArray[i]);
	}
	if (inElement.options[0].value == '') 
	{
		inElement.options[0]= null;
		
		if ( navigator.appName == 'Netscape') 
		{
			if (parseInt(navigator.appVersion) < 4) 
			{
				window.history.go(0);
			}
			else 
			{   	
				if (navigator.platform == 'Win32' || navigator.platform == 'Win16') 
				{
					window.history.go(0);
            		}
         		}
      	}
   	}
}

function selectAddUpdate(cbo, txt, n)
{
	if(n == 1)
	{
		if(cbo.disabled == true)
			cbo.disabled = false;
		cbo.focus();
		txt.disabled = true;
	}
	else if(n == 2)
	{
		if(txt.disabled == true)
			txt.disabled = false;
		txt.focus();
		cbo.disabled = true;
	}
	else if(n == 3)
	{
		if(txt.disabled == true)
			txt.disabled = false;
		txt.focus();
		cbo.disabled = true;
	}
	else if(n == 4)
	{
		if(txt.disabled == true)
			txt.disabled = false;
		txt.focus();
		cbo.disabled = true;
	}


}

function goURL(cbo, mes)
{
	var cboValue = cbo.value;
	
	if(cboValue == "")
		alert("Please Select " + mes);
	else 
		location = cboValue;
}

function goURL2(cbo,hid, mes)
{
	var cboValue = cbo.value;
	hid.value = cbo.options[cbo.selectedIndex].text;
	if(cboValue == "")
		alert("Please Select " + mes);
	else 
		location = cboValue;
}

function goURLchangeHideValue(cbo,hid, mes)
{
	var cboValue = cbo.value;
		hid.value = cbo.options[cbo.selectedIndex].text;
	if(cboValue == "")
	{
		hid.value = "";
		alert("Please Select " + mes);
	}
	else 
		location = cboValue;
}


function openWindow(pageURL, targetWindow, w, h, scroll, tool, menu, s, resize)
{
	var wLeft = (screen.width-w)/2 ;
	var wTop = (screen.height-h)/2;
	
	var settings = 'width='+w+',';
	settings += 'height='+h+',';
	settings += 'top='+wTop+',';
	settings += 'left='+wLeft+',';
	settings += 'scrollbars='+scroll+',';
	settings += 'toolbar='+tool+',';
	settings += 'menubar='+menu+',';
	settings += 'status='+s+',';
	settings += 'resizable='+ resize;

	window.open(pageURL, targetWindow, settings);

/*	if (!newWindow || newWindow.closed)
	{
		newWindow = window.open(pageURL, targetWindow, settings);
		if(!newWindow.opener)
			newWindow.opener = window
	}
	else
	{
		newWindow.focus()
	}
*/
}

function updateText(cbo, txt, hid, mes)
{
	var selValue = cbo.options[cbo.selectedIndex].text;
	txt.value = selValue;
	hid.value = cbo.options[cbo.selectedIndex].value;
	txt.focus();

	if(cbo.value == "")
	{
		txt.value = "";
		alert ("Please Select " + mes);
	}
}


function updateText2(cbo, txt, hid,txt2, mes)
{
	var selValue = cbo.options[cbo.selectedIndex].text;
	txt.value = selValue;
	hid.value = cbo.options[cbo.selectedIndex].value;
	txt2.value = cbo.options[cbo.selectedIndex].value;
	txt.focus();

	if(cbo.value == "")
	{
		txt.value = "";
		txt2.value = "";
		alert ("Please Select " + mes);
	}
}

function selectOption(cbo, nextOpt, mes)
{
	var sItem = cbo.options[cbo.selectedIndex].value;

	if(sItem == "")
	{
		alert("Please Select " + mes);
		nextOpt.disabled = true;
		cbo.focus();
	}
	else
	{
		nextOpt.disabled = false;
		nextOpt.focus();
	}
}

function selectDate(cbo, day, month, year, n)
{
	if(n == 1)
	{
		if(cbo.disabled == true)
			cbo.disabled = false;
		cbo.focus();
		day.disabled = true;
		month.disabled = true;
		year.disabled = true;
	}
	else if(n == 2)
	{
		if(day.disabled == true && month.disabled == true && year.disabled == true)
		{
			day.disabled = false;
			month.disabled = false;
			year.disabled = false;
		}
		day.focus();
		cbo.disabled = true;
	}
}

function setFocus(el1, el2, mes)
{
	if(el1.value == "")
	{
		alert ("Please Select " + mes);
		el1.focus();
	}
	else
		el2.focus();
}

function selectAddUpdateDisable(cbo, txt, n)
{
	if(n == 1)
	{
		if(cbo.disabled == true)
			cbo.disabled = true;
		txt.disabled = true;
	}
	else if(n == 2)
	{
		if(txt.disabled == true)
			txt.disabled = false;
		txt.focus();
		cbo.disabled = true;
	}
}

function selectCheckBox(butt, che, n)
{
	var noChecks = che.length;

	if(n == 1)
	{
		for(var i = 0; i < noChecks; i++)
		{
			if(che[i].checked == false)
				che[i].checked = true;
		}
	}
	else if(n == 2)
	{
		for(var i = 0; i < noChecks; i++)
		{
			if(che[i].checked == false)
				che[i].checked = true;
			else
				che[i].checked = false;
		}
	}
	else if(n == 3)
	{
		for(var i = 0; i < noChecks; i++)
		{
			if(che[i].checked == true)
				che[i].checked = false;
		}
	}
}
