//These functions for the rotating scroll bar effect
function MsgRotator() {
  msg = new InitArray(4);
  msg[0]="You are at the localhost.";
  msg[1]="This is the place for web development.";
  msg[2]="Dave, stay focused.";
  msg[3]="But above all, have a great day!";
  window.defaultStatus = msg[currentmsg];
  if (currentmsg > msg.length - 1) {
    currentmsg = 0;
    setTimeout("MsgRotator()", MsgEndTime);
  }
  else {
    currentmsg = currentmsg + 1;
    setTimeout("MsgRotator()", MsgTime);
  }
}

function InitArray(n) {
  this.length = n;
  for (var i =1; i <= n; i++) {
    this[i] = ' ';
  }
}

//This function controls onMouse events for image rollovers

function MouseMove(imagename,direction) {
  if (direction == "down") {
    switch (imagename) {
    case "login":
      document.images.login.src="images/ma_login2.gif";
      break;
    case "dir":
      document.images.dir.src="images/usa4.gif";
      break;
    case "tour":
      document.images.tour.src="images/usa4.gif";
      break;
    }
  }
  else {
    switch(imagename) {
      case "login":
        document.images.login.src="images/ma_login1.gif";
        break;
      case "dir":
          document.images.dir.src="images/usa3.gif";
          break;
      case "tour":
          document.images.tour.src="images/usa3.gif";
          break;
      }
    }
}

/*These functions placed in the public domain by Affordable Production Tools
  April 27, 1998
  Web site: http://www.aptools.com
  December 2, 1998 -- Modified to allow specification of
  character to be trimmed.
  This function trims spaces (default) or the specified
  character from the left of a string or form field.
*/

function LeftTrim(String,TrimChar){
  String += "";         // Force argument to string.
  TrimChar += "";       // Force argument to string.
  if((TrimChar == "") || (!(TrimChar.length == 1))) {
   TrimChar = " ";
  }
  if(String.length == 0) {
    return(String);
  }
  var Count = 0;
  for(Count = 0;Count < String.length;Count++) {
    if(!(String.charAt(Count) == TrimChar)) {
      return(String.substring(Count,String.length));
    }
  }
  return("");
}

/* This function trims spaces (default) or the specified
   character from the right of a string or form field.
*/

function RightTrim(String,TrimChar){
  String += "";        // Force argument to string.
  TrimChar += "";      // Force argument to string.
  if((TrimChar == "") || (!(TrimChar.length == 1))){
   TrimChar = " ";
  }
  if(String.length == 0){
    return(String);
  }
  var Count = 0;
  for(Count = String.length -1;Count >= 0;Count--){
    if(!(String.charAt(Count) == TrimChar)){
      return(String.substring(0,Count + 1));
    }
  }  
  return("")
}

/* This function trims spaces (default) or the specified
   character from the left and the right of a string or form field.
   Note that this functions uses two other library functions,
  TrimLeft() and TrimRight().
*/

function AllTrim(String,TrimChar){
  String += "";        // Force argument to string.
  TrimChar += "";      // Force argument to string.
  if((TrimChar == "") || (!(TrimChar.length == 1))){
    TrimChar = " ";
  }
  return(RightTrim(LeftTrim(String,TrimChar),TrimChar));
}

function SubmitForm(thefield){
  if (AllTrim(thefield.value) == "") {
    alert('You did not enter a value!');
    return false;
  }
}

//Function used with click-drop-go menu bar
function Redirect(url){
  location.href=url;
  return true;
}

//Format the local date
function SetTheDate() {
  thedate = new Date();
  themonth = thedate.getMonth();
  theday = thedate.getDate();
  theyear = thedate.getYear();
  theyear =+ theyear+1900;
  month = ConvertMonth(themonth);
  todaysdate = month + " " + theday + ", " + theyear;
  var monthindex = themonth;
  var yearindex = todaysdate.substring((todaysdate.length-1), todaysdate.length);
  var dayindex = --theday;
}

//Converts the month date object number to a name (see SetTheDate)
function ConvertMonth(number) {
  switch(number) {
    case 0:
      month = "January";
      break;
    case 1:
      month = "February";
      break;
    case 2:
      month = "March";
      break;
    case 3:
      month = "April";
      break;
    case 4:
      month = "May";
      break;
    case 5:
      month = "June";
      break;
    case 6:
      month = "July";
      break;
    case 7:
      month = "August";
      break;
    case 8:
      month = "September";
      break;
    case 9:
      month = "October";
      break;
    case 10:
      month = "November";
      break;
    case 11:
      month = "December";
      break;
  }
  return month;
}

//Checks for proper credit card numbers and length
function CheckCC(str,cc) {
  var msg = "";
  str=str.slice(0,3);
  str=str.toLowerCase();
  cc=cc.replace(/[^0-9]/g, "")
  cclen=cc.length;
  ccid=cc.charAt(0);

  switch (str) {
    case "vis":
      if (ccid != 4) {
	msg = "Credit card number " + cc + " is not a valid Visa.\n";
      }
      if (cclen != 16) {
	msg += "You have " + cclen + " digits in your credit card.  16 digits are required.\n";
      }
      break;
    case "mas":
      if (ccid != 5) {
        msg = "Credit card number " + cc + " is not a valid MasterCard.\n";
      }
      if (cclen != 16) {
        msg += "You have " + cclen + " digits in your credit card.  16 digits are required.\n";
      }
      break;
    case "dis":
        if (ccid != 6) {
          msg = "Credit card number " + cc + " is not a valid Discover.\n";
	}
	if (cclen != 16) {
	  msg += "You have " + cclen + " digits in your credit card.  16 digits are required.\n";
	}
	break;
    case "ame":
      if (ccid != 3) {
      msg = "Credit card number " + cc + " is not a valid American Express.\n";
      }
      if (cclen != 15) {
        msg += "You have " + cclen + " digits in your credit card.  15 digit are required.\n";
      } 
      break;
    default:
      return false;
      break;
  }
  if (msg != "") {
    alert(msg);
    return false;
  }
}

function SetLock(name,str) {
  str = "?ba=" + name + "&ul=" + str;
  php_self = str;
  return php_self;
}

function EchoCheck(ra) {
  ra = ra.substring(0,6);
  switch (ra) {
    case "127001":
      str = prompt("Please enter today's password");
      if (str != "hali") {
        alert ("Bad password!");
        location.href = location.href + '/index.php';
        return location.href;
      }
      else {
        alert('good pass');
        location.href = location.href + '/index.php?ba=admin';
        return location.href;
      }
      break;
    default:
      break;
    }
  return; 
}
    
//Function for pop-up window that is centered for each monitored
//Window features will affect the horizontal placement though, the more features, the further down the screen the window appears
function openURL(newURL) {
  aw=window.screen.availWidth;
  ah=window.screen.availHeight;
  ww=Math.floor(aw * .66);
  wh=Math.floor(ah * .66);
  wx=Math.floor((aw - ww)/2);
  wy=Math.floor(((ah - wh)/2)-25);
  var remote = open(newURL,"remotewin",'width='+ww+',height='+wh+',left='+wx+',top='+wy+',status=no,location=no,directories=no,menubar=yes,resizable=yes,toolbar=no,scrollbars=yes');
  remote.focus();
}

function right(e) { 
	var msg = "These images are protected. Please contact the webmaster for assistance.";
	if (navigator.appName == 'Netscape' && e.which == 3) { 
		alert(msg); 
		return false; 
	} 
	if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2) { 
		alert(msg); 
		return false; 
	} 
	else 
		return true; 
	}  
	
function trap() { 
	if(document.images) { 
		for(i=0;i<document.images.length;i++) {
			document.images[i].onmousedown = right; 
		}
	}
} 

		
