// Javascript Functions for OTIS Government Access Registration Website
// Developed by Abt Associates Inc.

// Created: July 9, 2000 by Michael Muller, www.abtassoc.com
// Last Updated: July 18, 2000 by Michael Muller, www.abtassoc.com

///////////////////////////////////
// Check IP Address
///////////////////////////////////

function yourIP(IP) {
 var clientIP = IP
 if (clientIP == "216.17.24.123")
  var feedback = "Your IP address is approved for access to OTIS."
 else
  var feedback = "Sorry, your IP address cannot be found in the database.  Access to OTIS cannot be given.  To sign up, please ..."
return feedback
}

function insertHTML(dummy) {
  var partIP = "hello"
return partIP 
}

// Preloading of images

if (navigator.appVersion.substring(0,1) >= 3) {

  showPreviousApplications1       = new Image (238,20);
  showPreviousApplications1.src   = "images/showPreviousApplications1.jpg";
  showPreviousApplications2       = new Image (238,20);
  showPreviousApplications2.src   = "images/showPreviousApplications2.jpg";
  
  fillOutApplication1       = new Image (114,20);
  fillOutApplication1.src   = "images/fillOutApplication1.jpg";
  fillOutApplication2       = new Image (114,20);
  fillOutApplication2.src   = "images/fillOutApplication2.jpg";
  
}

function checkFilters(frmName) {
 //make sure primary and secondary filters are different
 
 var prime = frmName.PrimaryFilterType.value;
 var secnd = frmName.SecondaryFilterType.value;
 var filter1 = frmName.PrimaryFilter.value;
 var filter2 = frmName.SecondaryFilter.value;
 
// Commented out by Michael Muller to allow for all records to be retrieved.
 if (prime == "None" && secnd == "None") {
  alert("You have not specified any search criteria.\nYou will retrieve ALL records in the EBiz database.");
  return true;
 } 
 else {
  if (prime == secnd) {
   alert("Your Primary and Secondary criterion are the same. Please change one of them.");
   return false;
  }  
 }
 if (prime == "None" && secnd != "None"){
  alert("Please select a Primary Criterion before selecting a Secondary  Criterion.");
  return false;
 }  
 if (prime != "None" && filter1 == ""){
  alert("Please specify a value for your Primary Criterion.")
  return false;
 } 
 if (secnd != "None" && filter2 == ""){
  alert("Please specify a value for your Secondary Criterion.")
  return false;
 }
 return true;
}// end the function


// Cancel button during editing, send them back

function oncancel()
{
 window.history.back();
}


///////////////////////////////////////////////////
// Switches a single image (with preloaded images)
///////////////////////////////////////////////////

function switchImage(imageName,newImage) {
  if (navigator.appVersion.substring(0,1) >= 3) {
    document.images[imageName].src = eval(newImage + ".src")
  }
}


/////////////////////////////////////////////////
// Switches 2 distinct images with mouse effect
////////////////////////////////////////////////

function switchIndexPair(imageID1,imageName1,imageID2,imageName2) { 
  if (navigator.appVersion.substring(0,1) >= 3) {
    document.images[imageID1].src = eval(imageName1 + ".src")
    document.images[imageID2].src = eval(imageName2 + ".src")
  }
}

/////////////////////////////////////////////////
// Switches 3 distinct images with mouse effect
////////////////////////////////////////////////

function switchTriplet(imageID1,imageName1,imageID2,imageName2,imageID3,imageName3) { 
  if (navigator.appVersion.substring(0,1) >= 3) {
    document.images[imageID1].src = eval(imageName1 + ".src")
    document.images[imageID2].src = eval(imageName2 + ".src")
    document.images[imageID3].src = eval(imageName3 + ".src")
  }
}

function checkIPformat(IP) {
 if (IP > 255) {
  alert("Please enter a number below 256.")
 } //end if
}


function checkLen255(fldLen) {
 var len = fldLen.length;
 if (len > 255) {
  extra = len - 255;
  alert ("The entry you just types is too long.\n You have exceeded the maximum number of characters (255) by " + extra);
 } //end if
} //end  function checkLen255


function validChargecode(gfield) {
 //check the charge code
 
 var fldValue = gfield.value;

 var delim1 = fldValue.indexOf("-");
 var $alerttext = "Please enter the full charge code in the format: ####-###";
 if (delim1 == -1) {
  //no delimeter typed, check for 7 digits
  if (fldValue.length == 7) {
   //all there so add the -
   var first = fldValue.substr(0,4);
   var second = fldValue.substr(4);
   window.document.frmProject.ChargeCode.value = first + "-" + second;
  }
  else {
   //not enough digits
   alert($alerttext);
  }  
 }
 else {
  //delimeter there, are there 8 digits with the dash in the right place
  if (fldValue.length != 8 || delim1 != 4) {
   alert($alerttext)
  }
 }
}//end function  

function checkForm(cancel) {
 //check for at least a title
 
 var title = window.document.frmProject.RequestID.value; 
 
 if (title == "" && cancel == "") {
  alert("Please provide a title for the project.");
  return false;
 }
 else {
  return true;
 }
} 

/////////////////////////////////////////////////////////
// Retains and writes the correct URL to the web page.
/////////////////////////////////////////////////////////

function pageURL(URL,pageName) {
  var hostRef = unescape(URL.substring(0,(URL.lastIndexOf("/")) + 1))
  var pageRef = hostRef + pageName + ".html"
return pageRef
}


// VARIABLES USED IN PAGE CREATION

  var leftSideHeader = "<img src=\"images/abt_logo.gif\">";
  // leftSideHeader = leftSideHeader & 

  // var leftSideBody = "<table></table>";
  var mainHeader = "<img src=\"images/ebiz_database_banner.jpg\">";

  var updatedInfo = "Developed and maintained by <a href='http://www.abtassoc.com'>Abt Associates Inc</a>.<br>";
      updatedInfo = updatedInfo + "Last updated: February 20, 2000";
    
  var menuChoices = "";
  
  menuChoices = menuChoices + "<p><a href='index.html' onMouseOver=\"switchImagePair('introduction','images/introduction3.gif', 'main_clip', 'images/introduction_clip.jpg'); return true\" onMouseOut=\"switchImagePair('introduction','images/introduction1.gif', 'main_clip', 'images/main_clip.jpg'); return true\"><img border=0 src='images/introduction1.gif' name='introduction' width=67 height=14></a></p>";
  menuChoices = menuChoices + "<p><a href='searchProjects.asp' onMouseOver=\"switchImagePair('search_database','images/search_database3.gif', 'main_clip', 'images/search_database_clip.jpg'); return true\" onMouseOut=\"switchImagePair('search_database','images/search_database1.gif', 'main_clip', 'images/main_clip.jpg'); return true\"><img border=0 src='images/search_database1.gif' name='search_database' width=97 height=14></a></p>";
  menuChoices = menuChoices + "<p><a href='addProjectInfo.asp' onMouseOver=\"switchImagePair('add_record','images/add_record3.gif', 'main_clip', 'images/add_record_clip.jpg'); return true\" onMouseOut=\"switchImagePair('add_record','images/add_record1.gif', 'main_clip', 'images/main_clip.jpg'); return true\"><img border=0 src='images/add_record1.gif' name='add_record' width=65 height=14></a></p>";
  menuChoices = menuChoices + "<p><a href='guide.html' onMouseOver=\"switchImagePair('guide','images/view_guide3.gif', 'main_clip', 'images/view_guide_clip.jpg'); return true\" onMouseOut=\"switchImagePair('guide','images/view_guide1.gif', 'main_clip', 'images/main_clip.jpg'); return true\"><img border=0 src='images/view_guide1.gif' name='guide' width=65 height=14></a></p>";
  menuChoices = menuChoices + "<img SRC='images/main_clip.jpg' name='main_clip' width=120 height=130>";
       
      