

function goBack() 
{
   history.go(-1);
}

function setWindowLocation(location)
{
    window.location = location;
}

function enable(field)
{
    document.forms[0].field.disabled = false;
}

function disable(field)
{
    document.forms[0].field.disabled = true;
}

function openWindow(windowToOpen)
{
    window.open(windowToOpen, "Window", "status, width=600, height=600");
}

function openWindow2(windowToOpen)
{
    window.open(windowToOpen, "Window", "scrollbars=yes,resizable=yes,status, width=720, height=600");
}

function openWindow3(windowToOpen)
{
    window.open(windowToOpen, "Window", "scrollbars=no,resizable=no,status, width=925, height=605");
}



// This function validates an HTML field passed in checking for non Alpha characters and
// spaces.  If either is true an alert is posted, focus is set on the
// field and a false is returned.
function validateRequired(field, name)
{
   if (field.value == "")
   {
   	 alert(name + " is required!");
   	 field.focus();
   	 return false;
   }
   else
     return true;
}

function validateAlphaRequired(field, name)
{
   charTest  = /[^a-z]/i;
   if (charTest.test(field.value))
   {
     alert(name + " can only contain alpha characters!");
     field.focus();
     return false;
   }
   else if (field.value == "")
   {
   	 alert(name + " is required!");
   	 field.focus();
   	 return false;
   }
   else
     return true;
}

function validateAlphaOrSpaceRequired(field, name)
{
   charTest  = /[^a-z ]/i;
   if (charTest.test(field.value))
   {
     alert(name + " can only contain alpha characters or spaces!");
     field.focus();
     return false;
   }
   else if (field.value == "")
   {
   	 alert(name + " is required!");
   	 field.focus();
   	 return false;
   }
   else
     return true;
}

function validateAlphaNumericRequired(field, name)
{
   charTest  = /[^a-z0-9]/i;
   if (charTest.test(field.value))
   {
     alert(name + " can only contain alphanumeric characters!");
     field.focus();
     return false;
   }
   else if (field.value == "")
   {
   	 alert(name + " is required!");
   	 field.focus();
   	 return false;
   }
   else
     return true;
}

// This function validates an HTML field passed in checking for non AlphaNumeric characters.
// If this is true an alert is posted, focus is set on the field and a false is returned.
function validateAlphaNumeric(field, name)
{
   charTest  = /[^a-z0-9]/i;
   if (charTest.test(field.value))
   {
     alert(name + " can only contain alpha numeric characters!");
     field.focus();
     return false;
   }
   else
     return true;
}

// This function validates an HTML field passed in checking for non Numeric characters and
// spaces.  If either is true an alert is posted, focus is set on the
// field and a false is returned.
function validateNumericRequired(field, name)
{
   numTest  = /[^0-9]/;

   if (numTest.test(field.value))
   {   	  
       alert(name + " can only contain numeric characters!");
       field.focus();
       return false;   	  
   } 
   else if (field.value == "")
   {
   	 alert(name + " is required!");
   	 field.focus();
   	 return false;
   }
   else
     return true;
}


function validatePhoneRequired(field, name)
{
   phoneTest  = /([0-9][0-9][0-9])[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]/;

   if (!phoneTest.test(field.value))
   {   	  
       alert(name + " must be (###)###-#### format");
       field.focus();
       return false;   	  
   } 
   else if (field.value == "")
   {
   	 alert(name + " is required!");
   	 field.focus();
   	 return false;
   }
   else
     return true;
}

function validatePhone(field, name)
{
   phoneTest  = /\([0-9][0-9][0-9]\)[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]/;

   if (field.value != "" && !phoneTest.test(field.value))
   {   	  
       alert(name + " must be (###)###-#### format");
       field.focus();
       return false;   	  
   } 
   else
     return true;
}


// This function validates an HTML field passed in checking for non Numeric characters.
// An exception value is allowed so it will not fail on a specific value.
// If this is true an alert is posted, focus is set on the field and a false is returned.
function validateNumeric(field)
{
   numTest  = /[^0-9]/;

   if (numTest.test(field.value))
   {
   	    alert("Field can only contain numeric characters!");
        field.focus();
        return false;
   }
 
   return true;
}

function validatePercentage(field)
{
   Test  = /[0-9][0-9].*[0-9]*/;

   if ((field.value != "") && (!Test.test(field.value)))
   {
   	    alert("ffFormat should be ###.#### for percentage!");
        field.focus();
        return false;
   }
 
   return true;
}

function validateCurrency(field)
{
   Test  = /[^0-9].[^0-9]/;

   if (Test.test(field.value))
   {
   	    alert("Format should be valid currency!");
        field.focus();
        return false;
   }
 
   return true;
}

function validateFareClass(field)
{
   hyphenTest  = /^-/;
   charTest  = /[^a-z0-9]/i;
   
   if (hyphenTest.test(field.value))
   {
   	   if (charTest.test(field.value.substring(1)))
   	   {
   	      alert("Alpha numeric only allowing for - in first position!");
          field.focus();
          return false;
   	   }
   }
   else if (charTest.test(field.value))
   {
      alert("Alpha numeric only allowing for - in first position!");
      field.focus();
      return false;
   }
   
   return true;
}

function clearTextValues(form)
{
   for (i = 0; i< form.elements.length; i++)
   {
   	   if(form.elements[i].type == "text")
   	   {
   	   	   form.elements[i].value = "";
   	   } 	
   }
}

function validateEmailRequired2(str) 
{
var at="@";
var dot=".";
var lat=str.indexOf(at);
var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		if(str.value == "")
		{
		   alert("E-mail address required");
		   str.focus();
		   return false;
		}
		
		
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid E-mail address");
		   str.focus();
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail address");
		   str.focus();
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail address");
		    str.focus();
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		    alert("Invalid E-mail address");
		    str.focus();
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid E-mail address");
		    str.focus();
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid E-mail address");
		    str.focus();
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid E-mail address");
		    str.focus();
		    return false;
		 }

 		 return true					
	}

function validateEmailRequired(str) 
{
    var emailFilter=/^.+@.+\..{2,3}$/;
    
    if(str.value == "")
	{
	   alert("E-mail address required");
	   str.focus();
	   return false;
	}
    else if (!(emailFilter.test(str.value))) 
    { 
       alert("Invalid E-mail address");
	   str.focus();
	   return false;
    }
    else
    {
       return true;
    }
}