//------------------------------------------------//
	String.prototype.trim = function() {
	
	 // skip leading and trailing whitespace
	 // and return everything in between
	  var x=this;
	  x=x.replace(/^\s*(.*)/, "$1");
	  x=x.replace(/(.*?)\s*$/, "$1");
	  return x;
	}

//------------------------------------------------//
var chkDot = true;
 var usEmail = true;
   function validEmail( eAddr, message ) 
   { 
      var lenSuffix = (usEmail) ? 4 : 3;
      var result = false;
      var ndxAt = ndxDot =  0;
     
	  if( ( eAddr == "" ) || ( eAddr == message ) ) 
	  {
	  	alert( 'Please enter a valid Email Address' );
	  	return false;
	  }
	      
      ndxAt  = eAddr.indexOf("@");
      ndxDot = eAddr.indexOf(".") ;
      ndxDot2 = eAddr.lastIndexOf(".") ;
          
      if ((ndxDot < 0) || (ndxAt < 0))
         alert("email address lacks '.' or '@'.\n\nThe format is 'you@dom.suf'"); 
      else if (chkDot && (ndxDot < ndxAt) )
         chkDot = !( confirm("You entered a 'dot' before the '@'\nAre you sure that is right?") );
      else if ( (ndxDot2 - 3) <= ndxAt)
         alert("You may be missing your domain name.\n\nThe format is 'you@dom.suf'");
      else if (eAddr.length < ndxDot2 + lenSuffix) 
         usEmail = !(confirm("You have fewer than 3 characters as a domain suffix.\nAre you sure that is right?") );
      else 
           result=true; 
          
      return result; 
   } 
   
  /* ---------------------------------------- */
  
function validateZIP( field, whom ) 
{
	var valid = "0123456789-";
	var hyphencount = 0;
	
	if( field.length > 0 && field != whom ) 
	{
		if ( field.length != 5 && field.length != 10 ) 
		{
			alert("Please enter your 5 digit or 5 digit + 4 zip code.");
			return false;
		}
		for (var i = 0; i < field.length; i++ ) 
		{
			temp = "" + field.substring( i, i + 1 );
			if (temp == "-" ) hyphencount++;
			if (valid.indexOf( temp ) == "-1" ) 
			{
				alert("Invalid characters in your zip code.  Please try again.");
				return false;
			}
			if ( ( hyphencount > 1 ) || ( ( field.length == 10 ) && ""+ field.charAt(5) != "-") ) 
			{
				alert("The hyphen character should be used with a properly formatted 5 digit + four zip code, example '12345-6789'.   Please try again.");
				return false;
		   }
		}		
	}
	else
	{
			alert("Please enter a Zip code");
			return false;
	}	
	return true;
}


  /* ---------------------------------------- */
  function chkINPUT( value, message, output, isLimited, maxLength )
  {
  	if (value == message || value == "")	{
		//alert( output );
		return false;
	}
	if ( isLimited ) {
		if ( maxLength < value.length  )	{
			alert('Maximum length of field is less than ' + maxLength +  ' characters ');
			return false;
		}
	}	
		return true; 
  }
  
  /* ---------------------------------------- */
  
function checkForm() 
{
	//var bool = true;		
	
		if (!chkINPUT( document.forms[0].lname.value.trim(),"Enter Last Name Here", "Please enter your Last Name",true,50 )	)	
		{		
			alert( "Please enter your Last Name" );	
			document.forms[0].lname.focus();
			return false;
		}
		if(!chkINPUT( document.forms[0].fname.value.trim(),"Enter First Name Here","Please enter your First Name",true,50 ) )
		{	
			alert( "Please enter your First Name" );			
			document.forms[0].fname.focus();
			return false;
		}
		if(!chkINPUT( document.forms[0].field.value.trim(),"Enter Field Here","Please enter a Field",true,50 ) )
		{	
			alert( "Please enter a Field" );		
			document.forms[0].field.focus();
			return false;
		}
		if( document.forms[0].campus.value.trim() == "" )
		{	
			alert( "Please select a Campus" );		
			document.forms[0].campus.focus();
			return false;
		}
		if( document.forms[0].status.value.trim() == "" )
		{
			alert("Please select a Status");
			document.forms[0].status.focus();
			return false;
		}
		if( document.forms[0].role.value.trim() == "" )
		{
			alert("Please select a Role");
			document.forms[0].role.focus();
			return false;
		}
		
		return true;
		//return bool;
}


 /* ---------------------------------------- */
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()-. ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

 /* ---------------------------------------- */
 
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

 /* ---------------------------------------- */
function chkRADIO( obj )
{
	var myOption = -1;
	for (i=obj.length-1; i > -1; i--) {
		if (obj[i].checked) {
			myOption = i;
		}
	}
	if (myOption == -1) return false;	
	else return true;
}

function chkCHECKBOX( obj )
{
	var myOption = -1;
	for (i=obj.length-1; i > -1; i--) {
		if (obj[i].checked) {
			myOption = i;
		}
	}
	if (myOption == -1) return false;	
	else return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone)
{
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length == minDigitsInIPhoneNumber);
}

function ValidatePhone( Phone, whom )
{	
	if ((Phone == null)||(Phone == whom)){
		alert("Please Enter your Phone Number with area code")		
		return false
	}
	if (checkInternationalPhone(Phone)==false){
		alert("Please Enter a Valid Phone Number with area code")			
		return false
	}
	return true
 }
 
 
  /* ---------------------------------------- */
  
 function Clear( obj, message ) 
{
	if ( obj.type == "textarea" ) {	
		if ( obj.value.trim() == message ) {			
			obj.value = '';	
			obj.focus();
		}
	} 
	else {	
		if ( obj.value == message )
			obj.value = '';
			obj.focus();
	}
}
 /* ---------------------------------------- */
 
function ChechObj( obj, message )
{
	if ( obj.type == "textarea" ) {
		if ( obj.value.trim() == "" ) 
			obj.value = message;
	} 
	else {	
		if ( obj.value == "")
			obj.value = message;
	}
}

/* ---------------------------------------- */
//------------------------------------------------//
function ShowMe( obj )
	
	// Function that will swap the display/no display for
	
	{
		if ( obj.checked )
			var whom = 'YES';
		else whom = 'NO';
		
		if (document.getElementById)
		{ // DOM3 = IE5, NS6 
			
			if ( whom == 'YES' )//DISPLAY WHAT REPORT DIV
			{					
				document.getElementById('otherInfo').style.visibility = 'visible';
			}
			else
			{				
				document.getElementById('otherInfo').style.visibility = 'hidden';				
			}			
		}
		else 
		{ 		
			if (document.layers)
			{ // netscape 4 
				if ( whom == 'YES' )
				{
					document.otherInfo.style.visibility = 'visible';						
				}
				else 
				{	
					document.otherInfo.style.visibility = 'hidden';					
				}				
			} 
			else 
			{ // IE 4 
				if ( whom == 'YES' )
				{
					document.otherInfo.visibility = 'visible';					
				}
				else 
				{
					document.otherInfo.visibility = 'hidden';						
				}
			} 
		} 
		
	}
//------------------------------------------------//
function ChechOther()
{
	if( document.forms[0].Other.checked )
	{		
		if (document.getElementById)
		{ // DOM3 = IE5, NS6
			document.getElementById('otherInfo').style.visibility = 'visible';				
		}
		else 
		{ 		
			if (document.layers)
			{ // netscape 4 				
				document.otherInfo.style.visibility = 'visible';							
			} 
			else 
			{ // IE 4 
				document.otherInfo.visibility = 'visible';
			} 		
		}
		UnCheckNone( document.forms[0].Other );
	}
	else
	{		
		if (document.getElementById)
		{ // DOM3 = IE5, NS6
			document.getElementById('otherInfo').style.visibility = 'hidden';				
		}
		else 
		{ 		
			if (document.layers)
			{ // netscape 4 				
				document.otherInfo.style.visibility = 'hidden';							
			} 
			else 
			{ // IE 4 
				document.otherInfo.visibility = 'hidden';
			} 		
		}
	
	}
	
}
//------------------------------------------//

function NoneClicked( obj )
{
	if ( obj.checked ) {
		var Audiovisual = document.forms[0].Audiovisual;	
		for ( i=1; i < Audiovisual.length; i++ ) {
			Audiovisual[i].checked = false;
		}		
		ChechOther();			
		document.forms[0].request.value = "Enter Audio-Visual Requests Here";		
	}	
}

//------------------------------------------//

function UnCheckNone( obj )
{
	if ( obj.checked ) {
		var Audiovisual = document.forms[0].Audiovisual;		
		Audiovisual[0].checked = false;		
	}	
}