// JavaScript Document


<!--

//
// Make sure page does not reside in another page's frame
//
if ( top.location != self.location ) {

     top.location = self.location 
}

// 
//    CONSTANTS     
//
var numDays     = 7;
var numMonths   = 12; 
var oneDay      = 24;
var numPageImg  = 3;
var numTopImgs  = 5;
var mDate;
var functionName;

//  
//   Function Definitions
//   

function CreateStringArray( size ) {

          this.length = size;  
          return this;
}

function CreateImageArray(size) 
{
          this.length = size
          for (var i = 0; i<size; i++) {
               this[i] = new Image()
          }
          return this
}         

var amonths  = new CreateStringArray( numMonths );
var days     = new CreateStringArray( numDays );


amonths[1]  = "January";    amonths[2]  = "February";  
amonths[3]  = "March";      amonths[4]  = "April";  
amonths[5]  = "May";        amonths[6]  = "June";
amonths[7]  = "July";       amonths[8]  = "August";  
amonths[9]  = "September";  amonths[10] = "October";  
amonths[11] = "November";   amonths[12] = "December"; 

days[1]  = "Sunday";    days[2]  = "Monday";  
days[3]  = "Tuesday";   days[4]  = "Wednesday";  
days[5]  = "Thursday";  days[6]  = "Friday";
days[7]  = "Saturday"; 


function setDivContent( obj )
{	
	var divText = "";

	if ( obj.selectedIndex == ( obj.options.length - 1 ) )
	{
		divText = "<input type='text' name='othersubject' value=''>";
	}
	writeToDiv( divText, 'othersubject' );

}

function writeToDiv( text, id )
{
//alert( id );
     if (document.getElementById)
     {
          x = document.getElementById(id);
          x.innerHTML = '';
          x.innerHTML = text;
     }
     else if (document.all)
     {
          x = document.all[id];
          x.innerHTML = text;
     }
     else if (document.layers)
     {
          x = document.layers[id];          
          x.document.open();
          x.document.write(text);
          x.document.close();
     }
}

function trim (str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function fieldIsBlank( field )
{
     return ( ( field.value.length == 0 ) || ( trim( field.value ).length == 0 ) )
}

function rand() {
      
     var rndNum = Math.floor( Math.random() * 10 );
     return rndNum
}

function showTime( ) 
{
  var now = new Date( );
  var hr  = now.getHours();
  var min = now.getMinutes();
  var sec = now.getSeconds();
  var ampm = ( hr >= 12 ) ? " PM" : " AM";

  hr = ( hr >= 13 ) ? hr - 12 : hr;
  hr = ( hr == 0 ) ? 12 : hr;

  sec = ( sec < 10 ) ? "0" + sec : sec;
  min = ( min < 10 ) ? "0" + min : min;

  writeToDiv( hr + ":" + min + ":" + sec + ampm, 'timediv' );
  setTimeout( "showTime( )", 1000 );
  mDate += 1000;
}
	 
function showDate( splitit ) {

  var  now = new Date( );
  var   localYear = now.getYear();
  var splitdate = ", ";

  if ( splitit == 1 ) { splitdate =  "<br>"; }


  localYear = ( localYear <= 1000 ) ? localYear + 1900 : localYear;

      writeToDiv(  days[now.getDay() + 1] + splitdate + amonths[now.getMonth() + 1] + " " + now.getDate() + 
	      ",  " + now.getFullYear() + " &nbsp; - &nbsp;", 'datediv' );

}  
	 
function  writeLocalDateTime( )
{
	showTime( );
	showDate( );		
}
  
/*****************************************************
* Ensure that the argument looks like an email address
*****************************************************/

function emailIsValid( email ) 
{
   if ( ( (email.value.indexOf('@') != -1) &&
        (email.value.indexOf('.') != -1) ) || 
        ( email.value.length == 0 ) )
  {    
  return true;
}

/********************************
* Address does not contain @ sign
********************************/
if (confirm("\nE-mail address may not be valid." +
	"\nDo you want to continue?"))
 	return true;
else {
	 //email.value = "";
	 email.focus();
	 email.select();
	 return false;
}
}
    
/*
 Check if a string is in valid email format.
 Input  : the string to check
 Output : true if the string is a valid email address, false otherwise.
 */
 function isEmail(str)
 {
	var regex = /^[-_.a-z0-9]+@(([-a-z0-9]+\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i;
	return regex.test(str);
}

 
function validateContactForm(form )
{
     var noemail;
     
     if ( fieldIsBlank( form.sender )  )
     {
	  alert( "Please enter sender's name." )
	  form.sender.focus();
	  return false;
     }

     if ( fieldIsBlank( form.from_email )  )
     {
	  noemail =  confirm( "You did not enter the sender's email address\nDo you wish to continue without it? Ok = Yes, Cancel = No." );
	  
	  if ( ! noemail ) {	  
	  	return false;
	  }
     }
     else {
     	if ( ! emailIsValid( form.from_email ) )
     		return false;
     }
	if ( fieldIsBlank( form.to_email )  )
     {
	  alert( "Please enter recipients's email address." )
	  form.to_email.focus();
	  return false;
     }
     //if ( src == 'S' && form._rcptID.selectedIndex == 0 ) {
     //		alert( "Please make a selection for receipient of email." )
	//	form._rcptID.focus();
	 // 	return false;
     //}

     //if (  src != 'F' && form.subject.selectedIndex == 0 ) {
	if ( form.subject.selectedIndex == 0 ) {
     		alert( "Please select subject of email." )
		form.subject.focus();
	  	return false;
     }
     
     if ( fieldIsBlank( form.emessage )  )
     {
	  alert( "Message is blank, please enter email message." )
	  form.emessage.focus();
	  return false;
     }
     
     return true;
}
//-->



