<!--
/*
     To add a list to the drop down menu do the following:


     To the shownames Array add the Display Name of the List - as
     it should appear in the drop down menu

     To the RNames Array add the Real Name of the List - as
     it must appear in the subscription string.

     To link to this form for a specific List append the URL with
     the variable containing the Real Name of the list EG: "?list=MDOT-GEOPAK"
*/
//Array of display names for drop-down menu
var shownames = new Array(
  'MDOT-AERO-Airport Development Information',
  'MDOT-AERO-Commission News',
  'MDOT-AERO-General Aviation News and Events');

//Array of list name - must be exact name for command
//must be in same order as shownames
var Rnames = new Array(
  'MDOT-AERO-AIRPORT-DEVELOPMENT',
  'MDOT-AERO-COMMISSION-NEWS',
  'MDOT-AERO-NEWS-AND-EVENTS');


//-----------------------------------------------------------------------------
//DO NOT Edit below this line without talking to the webteam mdot-webservicesteam@michigan.gov
//-----------------------------------------------------------------------------

//Function for Email Validation
function echeck(str) {
   var at="@";
   var dot=".";
   var lat=str.indexOf(at);
   var lstr=str.length;
   var ldot=str.indexOf(dot);
   if ((str.indexOf(at)==-1)||
       (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)||
       (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)||
       (str.indexOf(at,(lat+1))!=-1)||
       (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)||
       (str.indexOf(dot,(lat+2))==-1)||
       (str.indexOf(" ")!=-1)){
      return false;
   }
   return true;
}

//Form validation Function
function checkform(form){
  if(!echeck(form.fpMailFromAddr.value)){
    alert("Must Enter Valid Email Address");
    form.fpEmail.focus();
    return false;
  }
  else if(document.LSform.ListName.selectedIndex == 0){
    alert("Must Select a List");
    document.LSform.ListName.focus();
    return false;
  }

  if(form.fpCommand[0].checked) form.doThis.value="SUBSCRIBE "+form.fpListName.value+" Anonymous";
  else form.doThis.value='SIGNOFF '+form.fpListName.value;

  //alert(document.listform.fpListName.value);
  //alert(document.listform.fpSubject.value);
  //alert(document.listform.fpMailFromAddr.value);
  //alert(document.listform.doThis.value);

  form.submit();
}

//Function for Extracting the URL variable
function delineate(str){
  ar_str = str.split("?");
  if(ar_str[1]){
    ar_str1 = ar_str[1].split("=");
    populateList(ar_str1[1]);
  }
  else populateList("all");
}

//Function for initially populating the list when the page loads
function init(){
  var locate = window.location;
  document.LSform.variables.value = locate;
  var text = document.LSform.variables.value;
  delineate(text);
  populateSubject();

 // if(form.fpCommand(0).checked) form.doThis.value="SUBSCRIBE "+form.fpListName.value+" Anonymous";
 // else form.doThis.value='SIGNOFF '+form.fpListName.value;
}

//Function for populating the fpListName field
function populateName(list){
  for(i=0;i<Rnames.length;i++){
    if(list==Rnames[i]){
      document.listform.fpListName.value = Rnames[i];
      return;
    }
  }
}

//Function for populating the fpSubject field
function populateSubject(){
  var LName = document.LSform.ListName;
  var list = LName.options[LName.selectedIndex].value;
  if (!list) return;
  document.listform.fpSubject.value = "subscribe "+list;
  populateName(list);
}


//Function for populating the Drop Down box
function populateList(name){
  if(name=="all"){
    for(i=0;i<Rnames.length;i++){
      document.LSform.ListName.options[i+1] = new Option(shownames[i],Rnames[i]);
    }
  }
  else{
    for(i=0;i<Rnames.length;i++){
      if(name==Rnames[i]){
        document.LSform.ListName.options[1] = new Option(shownames[i],Rnames[i]);
      }
    }
    document.LSform.ListName.selectedIndex = 1;
  }
}



-->
