
function OpenWindow(inURL,inHeight,inWidth)
{
	features = "height=" + inHeight + ",width=" + inWidth + ",left=100,top=50,toolbar=no,status=no,resizable=yes,scrollbars=yes";
	window.open(inURL,"newWindow",features);
}

// method iterates through a html form and sets the focus
// for the first input or select element it finds
function SetFocus(){
	for(i=0; i<document.forms.length; i++){
		frm = document.forms[i];
		for(j=0; j<frm.elements.length; j++){
			var element = frm.elements[j];
			var sTag = element.tagName.toUpperCase();
			var sType = element.type.toUpperCase();
			if(!element.disabled){
				if((sTag == "INPUT" && (sType == "TEXT" || sType == "RADIO")) || sTag == "SELECT" || sTag == "TEXTAREA"){
					element.focus();
					return;
				}
			}
		}
	}
}

function AskQuestion(inQuestion,inURL){
	if(confirm(inQuestion)){
		document.location.assign(inURL);
	}
}

function EditEmployees(inURL)
{
	OpenWindow(inURL,400,505);
	//window.open(inURL,"myWindow","");
}

function GetDVUsers(inURL)
{
	OpenWindow(inURL,600,800);
}

function GetEmployeeList(inElement)
{
	list = eval(inElement);
	var lstUsers = new Array(list.length);
	for(i=0; i<list.length; i++){
		var lstVals = new Array(2);
		index1 = list.options[i].value.indexOf(":");
		lstVals[0] = list.options[i].value.substring(0,index1);
		lstVals[1] = list.options[i].text;
		lstUsers[i] = lstVals;
	}
	
	return lstUsers;
}

function RefreshEmployeeList(inElement,inUsers)
{
	list = eval(inElement);
	list.length = inUsers.length;
	for(i=0; i<inUsers.length; i++)
	{
		sName = inUsers[i][1];
		index1 = sName.indexOf(", ");
		firstName = sName.substring(index1+2);
		lastName = sName.substring(0,index1);
		list.options[i].value = inUsers[i][0] + ":" + firstName + ":" + lastName;
		list.options[i].text = inUsers[i][1];
		list.options[i].selected = true;
	}
}

// method iterates through a html form and disables
// all duplicate checkboxs
function InitCheckBoxes()
{
	for(i=0; i<document.forms.length; i++)
	{
		frm = document.forms[i];
		for(j=0; j<frm.elements.length; j++)
		{
			var element = frm.elements[j];
			var sTag = element.tagName.toUpperCase();
			var sType = element.type.toUpperCase();
			var sName = element.name.toUpperCase();
			if(!element.disabled)
			{
				if(sTag == "INPUT" && sType == "CHECKBOX" && sName.indexOf("TRUE") > 0)
				{
					element.disabled = true;
				}
			}
		}
	}
}

function CheckDuplicate(chkBox)
{
	dupName = "document.Form1." + chkBox.name.substring(0,chkBox.name.length-5) + "True";
	dupBox = eval(dupName);
	if(chkBox.checked)
	{
		dupBox.disabled = false;
	}
	else
	{
		dupBox.disabled = true;
	}
}


