<!-- meta http-equiv="cache-control" content="no-cache" -->
<!-- meta http-equiv="pragma" content="no-cache" / -->

/*
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'   File:	                Validate.js
'
'   Description:            Commonly used utility functions for Input Form Validation
'
'   Written by:             Imran khalid imranlink@hotmail.com
'
'	Language(s) Used:		JavaScript
'
'   Date Written:           Sept 18, 2001
'
'   Date Modify:            Oct 17 2001
'
'   Platform:               Microsoft Internet Explorer
'
'   Copyright:              © 2005 Imran Khalid
'                           All rights reserved
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
*/

function isNumber(vField) { 
str = vField.value;
isPrice = /^\d/;  
status= isPrice.test( str ); 
	if (status == "true" && str >0){
	 return false;
	 }
	else {
		vField.focus();
		alert(vField.name +" is Required. Please Fill numeric value");
		SetHighlight(vField, true);
		return true;
	}
} 
function isEmpty2(vField){

	if(vField.value.length!=0)
	{	
		SetHighlight(vField, false);
		return false;
	}
	else
	{

		vField.focus();
		alert(vField.name +" is Required. Please Fill in");
	
		SetHighlight(vField, true);
		return true;
	}
}

function isEmpty(vField){

	field_value = trim(vField.value);
	if(field_value.length!=0 && field_value !=0)
	{
		SetHighlight(vField, false);
		return false;
	}
	else
	{

		vField.focus();
		alert(vField.name+" is Required. Please Fill in");
	
		SetHighlight(vField, true);
		return true;
	}
}
//////////////////////////////////////////////////////////////////////////
function isEmpty3(vField, vField2){

	if(vField.value.length!=0 || vField2.value.length!=0)
	{	
		SetHighlight(vField, false);
		return false;
	}
	else
	{

		vField.focus();
		alert(vField.name.substring(3)+" is Required. Please Fill in");
	
		SetHighlight(vField, true);
		return true;
	}
}
////////////////////////////////////////////////////////////////////////

function SetHighlight(theElement, Highlight)
{
	if(Highlight)
	{
		theElement.focus();
		if(IsExplorer())
		{
			//theElement.style.borderStyle = "double";
			//theElement.style.borderWidth = 4;
		}
	}
	else
	{
		if(IsExplorer())
		{
			//theElement.style.borderStyle = "inset";
			//theElement.style.borderWidth = 2;
		}
	}
}

////////////////////////////////////////////////////////////////////////
function IsExplorer()
{
	var userAgent = navigator.userAgent;
	
	if(userAgent.indexOf("MSIE") >= 0)
		return true;
	else
		return false;
}
////////////////////////////////////////////////////////////////////////

function isEmailValid(varEMail)
{
	
	if(varEMail.value.indexOf("@")!=0)
		if(varEMail.value.indexOf(".")!=0)
			if(varEMail.value.lastIndexOf("@")!=(varEMail.value.length-1))
				if(varEMail.value.lastIndexOf(".")!=(varEMail.value.length-1))
					if(varEMail.value.lastIndexOf(".")!=-1)
						if(varEMail.value.lastIndexOf("@")!=-1)
							if(varEMail.value.indexOf(" ")<0)
								return true;
	alert("Invalid EMail Address");
	return false;
}
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
