function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+'yes'+',resizable'
//	alert("winprops= " + winprops);
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}
}
function PrintWindow(mypage, myname, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+'yes'+',menubar='+'yes'+',toolbar='+'yes'+',resizable' 
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { 
		win.window.focus(); 
	}
}

function closeAndRefresh() {
    window.opener.location.reload();
    close();
}
function SubmitFrm(FormName){
//var ThisFormName = eval("document.forms." + FormName);
	FormName.submit();
}
function ShowHideBlock(BlockToShow,blockstate){
if (blockstate == "none")
	{
	BlockToShow.style.display = 'none';
	}
else
	{
	BlockToShow.style.display = 'block';
	}
}
// var good;
function checkall(formname,checkname,thestate){
var el_collection=eval("document.forms."+formname+"."+checkname)
for (c=0;c<el_collection.length;c++)
el_collection[c].checked=thestate
}
/*
UncheckOthers is a function to uncheck all checkboxes with the passed field name if their VALUE is not the same as the passed value. Used to impose radio button behavior on checkboxes.
MLK 12/01/2004
usage: onclick="UncheckOthers('MainFrm','checkbox field name','checkbox_value')"
*/
function UncheckOthers(formname,checkname,checkedval)
{
var el_collection=eval("document.forms."+formname+"."+checkname)
for (c = 0; c < el_collection.length; c++)
	{
	if (el_collection[c].value != checkedval)
		{
	el_collection[c].checked = false;
		}
	}
}
// SetRadioState will CHECK the passed radio button with a value that matches the passed value
function SetRadioState(formname,TargetRadioField,ValToCompare,DesiredState)
{
var ThisRadioSet = eval("document.forms." + formname + "." + TargetRadioField);
for (i=0; i<ThisRadioSet.length;i++)
	{
	if (ThisRadioSet[i].value == ValToCompare)
		{
		ThisRadioSet[i].checked = DesiredState
		}
	}
}
/* 
checkEmailAddress will validate the passed form field value against the regular expression below. If it doesn't pass, it alerts with the passed msg if it is defined or the default error, focuses back on the calling document with the form field selected.
onblur="javascript:checkEmailAddress(FormName.FieldName,'Please enter a valid email address')"
*/
function checkEmailAddress(field,msg) 
{
// Note: The next expression must be all on one line...
//       allow no spaces, linefeeds, or carriage returns!
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (!goodEmail)
	{
	if (typeof(msg) != 'undefined')
		{
   alert('' + msg);
   		}
	else
		{
   alert('The email address you entered is not valid. Please enter a valid email address.');
		}
	self.focus();
	field.select();
	field.focus();
   }
}
//function to check if the fields given in an array have some value entered or not
// labels array is used to display the error message
function checkMandatoryFields(fieldsArr, labelsArr )
{
//alert("hello");
	var ErrorStr="";
	for(var i=0;i<fieldsArr.length;i++)
	{
		var type = eval("document.all."+fieldsArr[i]+".type")
//		type=type.toLowerCase();
alert("type=" + type);
		if(type=="text" ||type=="file" ||type=="textarea")
		{
			var len = eval("trim(document.all."+fieldsArr[i]+".value).length")
			if(!len)
			{
				ErrorStr=ErrorStr+"Please Enter "+labelsArr[i] +"\n";
			}
		}
/*
		else if(type=="select-one")
		{
			var len = eval("document.all."+fieldsArr[i]+".value")
			if(len==0)
			{
				ErrorStr=ErrorStr+"Please Select "+labelsArr[i] +"\n";
			}
		}
*/
		else if(type=="select-multiple")
		{
		var selectobj = eval("document.all."+fieldsArr[i]);
		if(selectobj.selectedIndex==-1)
			{
				ErrorStr=ErrorStr+"Please Select "+labelsArr[i] +"\n";
			}
		}
	}
	return 	ErrorStr;		
}
function selectFinal(formname, targ) {
 var finalObj = eval("document.forms."+formname+"."+targ);
	for (i=finalObj.length-1; i>=0; i--) {
finalObj.options[i].selected = true;
	}
}
function moveVals(n, formname, obj, targ) {
 var fromObj = eval("document.forms."+formname+"."+obj);
 var to = eval("document.forms."+formname+"."+targ);
	if (n == 1 || n == 2) {
		var indTo = to.length-1;
		for (i=fromObj.length-1; i>=0; i--) {
			if (n==1 || fromObj.options[i].selected) {
				indTo++;
				to.options[indTo] = new Option(fromObj.options[i].text, fromObj.options[i].value);
				fromObj.options[i] = null;
			}
		}
	} else if (n == 3 || n == 4) {
		var indFrom = fromObj.length-1;
		for (i=to.length-1; i>=0; i--) {
			if (n==4 || to.options[i].selected) {
				indFrom++;
				fromObj.options[indFrom] = new Option(to.options[i].text, to.options[i].value);
				to.options[i] = null;
			}
		}
	}
}



