var PrintObject = "";


function ValidateForm(FormName,Fields)
{
	for(var i=0;i<Fields.length;i++)
	{
		if(document.forms[FormName].elements[Fields[i]].value.length <= 0)
		{
			alert('Please make sure that all the required fields are filled before submitting form!');
			document.forms[FormName].elements[Fields[i]].focus();
			return false;
		}
	}
	return true;
}
	
function SubmitForm(FormName,Fields)
{
	if(Fields != null)
	{
		if(ValidateForm(FormName,Fields))
			document.forms[FormName].submit();
	}
	else
	{
			document.forms[FormName].submit();
	}
}

function ResetForm(FormName)
{
	if(confirm('Are you sure you wish to reset form?'))
		document.forms[FormName].reset();
}

function FocusField(fieldName,formName)
{
	document.forms[formName].elements[fieldName].focus();
}

function RemoveTopMenu()
{
	if(parent.window.frames.length > 1)
		parent.window.document.location.href = document.location.href;
}

function OpenHelpWindow(helpType)
{
	myWindow = window.open("help.asp?id=" + helpType, "HelpWindow", "toolbar=0,left=10,top=100,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width=500,height=400");
}

function OpenPopupWindow(width,height,url)
{
	myWindow = window.open(url, "Window"+width+height, "toolbar=0,left=100,top=100,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width="+width+",height="+height);
}

function CheckPasswordsMatch(formname,passfield1,passfield2)
{
	if(document.forms[formname].elements[passfield1].value != document.forms[formname].elements[passfield2].value){
		alert('Your passwords do not match!');
		return false;
	}
	return true;
}

function EnableDisableOnValue(val,formname,fieldname)
{
	if(val.length > 0)
		document.forms[formname].elements[fieldname].disabled = false;
	else
		document.forms[formname].elements[fieldname].disabled = true;
}

function CheckUncheckAll(formname,fieldname)
{
	for (i=0;i<document.forms[formname].elements[fieldname].length;i++)
		{
			if(document.forms[formname].elements[i].type = 'checkbox')
			{
				if (document.forms[formname].elements[i].checked == true)
					document.forms[formname].elements[i].checked = false;
				else
					document.forms[formname].elements[i].checked = true;
			}
		}
}

function ValidateCheckBox(formname,fieldname)
{	
	for (i=0;i<document.forms[formname].elements[fieldname].length;i++)
		{
			if(document.forms[formname].elements[i].type = 'checkbox')
			{
				if (document.forms[formname].elements[i].checked == true)
				{
					return true;
				}
			}
		}
		return false;
}

function StatusBarWrite(text)
{
	window.parent.window.status = text;
}

function Print(filename,width,height)
{
	PrintWindow = window.open(filename, "PrintWindow", "toolbar=0,left=100,top=100,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,copyhistory=0,width="+ width + ",height=" + height);
}

function checkEnter(e,formName){
	var characterCode;
	if(e && e.which)
	 characterCode = e.which
	else
	 characterCode = e.keyCode
	
	if (characterCode == 13){
	 eval("SubmitForm('LoginFrm',Array('username','password'))")
	 return false
	}
	return true
}