	function formSubmit(location, name, width, height, resizable)
	{
		var option = "toolbar=no, width=" + width + ",height=" + height + ", resizable=" + resizable + ", location=no, directories=no, menubar=no, status=yes, dependent=yes, scrollbars=yes";
		window.open(location, name, option);
	}

	function isValidEmail(strEmail)
	{
		validRegExp = /^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,6}$/i;
		valid = true;

		emailArray = strEmail.split(";");
		for( var i = 0; i < emailArray.length && valid; i++)
		{
		    if (emailArray[i].length != 0 && emailArray[i].search(validRegExp) == -1) 
		 		valid = false;
		}
	    return valid;
	}

	function closeWindow(win)
	{
		win.close();
	}

	function isValidDigit(digit)
	{
		if (!isInt(digit))
		{
			return false;
		}
		else
		{
			var numberInteger = parseInt(digit);
			if (numberInteger < 1)
			{
				return false;
			}
			else
			{
				return true;
			}
		}
	}

	function isInt(digit)
	{
		if (isNaN(digit))
		{
			return false;
		}
		else
		{
			var numberFloat = parseFloat(digit);
			var numberInteger = parseInt(digit);
			if (numberFloat == numberInteger)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}

	function toggle(form)
	{
		with (form)
		{
			range[1].checked = true;
		}
	}

	function selectAll(form)
	{
		for (var i = 0; i < form.elements.length; i++)
		{
			if (form.elements[i].name == "recordNo")
				form.elements[i].checked = true;
		}
	}

	function unselectAll(form)
	{
		for (var i = 0; i < form.elements.length; i++)
		{
			if (form.elements[i].name == "recordNo")
				form.elements[i].checked = false;
		}
	}

	function checkForm(theForm, direction)
	{
		with (theForm)
		{
			var start;
			var page = parseInt(recordPerPage.value);
			if (direction == "jump")
			{
				if (!isValidDigit(startIndex.value))
				{
					alert("Invalid Record Number");
					return false;
				}
				if (parseInt(startIndex.value) > parseInt(maxLimit.value))
				{
					var msg = "Jump to record greater than total number of records or max record limit!!!\n";
					msg = msg + "Max limit number of records:" + maxLimit.value + "\n";
					msg = msg + "Number of record:" + numberOfRecord.value + "\n";
					msg = msg + "You have choosen jump to:" + startIndex.value + "\n";
					alert(msg);
					return false;
				}
				if (parseInt(startIndex.value) > parseInt(numberOfRecord.value))
				{
					alert("Jump To Record greater than Total number of records");
					return false;
				}
			}
			start = parseInt(startIndex.value);
			if (direction == "previous")
				start = start - page;
			else if (direction == "next")
				start = start + page;
			startIndex.value = start;
			submit();
		}
	}

	function checkExport(theForm)
	{
		var selected = false;
		with (theForm)
		{
			for (var i = 0; i < elements.length && !selected; i++)
			{
				if (elements[i].name == "recordNo" && elements[i].checked)
					selected = true;
			}
			if (selected)
			{
				formSubmit("", "exportWindow", 500, 320, "no");
				submit();
			}
			else
			{
				alert("Please select at least one record to export");
			}
		}
	}

	function checkQuickSearch(theForm)
	{
		with (theForm)
		{
			if (recordNo.value == '')
			{
				alert("Record ID cannot be empty");
				return false;
			}
			else if (!isInt(recordNo.value))
			{
				alert("Record ID must be integer");
				return false;
			}
			else
			{
				submit();
			}
		}
	}

	function checkMail(theForm)
	{
		with (theForm)
		{
			if (toAddress.value == "")
				alert("To Address is required");
			else
			{
				if (!isValidEmail(toAddress.value))
					alert("Invalid To address");
				else
					submit();
			}
		}
	}

	function invalidUserPassword()
	{
		alert("Invalid User Id or Password");
	}

	function noRecordFound()
	{
		alert("No Record Found");
	}

	function userExist()
	{
		alert("User already exist");
	}

	function checkPassword(theForm)
	{
		with (theForm)
		{
			if (password1.value != password2.value)
			{
				alert("Password not match");
				return false;
			}
			else
			{
				submit();
			}
		}
	}

	function  printExport()
	{
		parent.content.focus();
		parent.content.print();
		parent.content.focus();
	}

	function setField(theForm, formName, fieldName)
	{
		with (theForm)
		{
			if (choose.selectedIndex != -1)
			{
				var text = choose.options[choose.selectedIndex].text;
				eval("window.opener." + formName + "." + fieldName + ".value='" + text + "'");
			}
		}
		
	}
