//*************************************** 
//The guts of the email list app.
//***************************************
var email_list_lite_version="1.0f";
var message1="Receive great deals.......";
var message2="Join mother may i newsletter today !.......";

var theserver="http://"+self.location.hostname+"/xm/email_list_lite/validate.php";
//The Form Itself
theform="<form method=\"POST\" name=\"FF\" action=\"" +theserver+ "\" target=\"e2afWin\">";
theform=theform + "<div style=\"font: 11px Verdana,Arial,Helvetica,Sans-Serif; color: #FFF; background-color: #000;\"><p>Enter your email address:</p><p><input type=\"text\" name=\"email_addr\" size=\"22\" onfocus=\"email_addr_onfocus()\" style=\"width: 250px; border: 1px solid #fff; color: #FFF; background: #000; padding: 5px; height: 30px; \"></p><p>How did you hear about us </p><p><select name=\"wom\" style=\"width: 250px; padding: 2px;\" ONChange=\"set_action()\"><option selected value=\"ads\">Ads</option><option value=\"myspace\">MySpace</option><option value=\"internet\">Internet</option><option value=\"stickers_poster_flyers\">stickers/posters/flyers</option><option value=\"events\">Events</option><option value=\"Other\">Other</option></select></p>";
//Forms Info 
theform=theform + "<p><select name=\"action\" style=\"width: 250px; padding: 2px;\" ONChange=\"set_action()\"><option selected value=\"1\">Join Mother May I Newsletter.</option><option value=\"0\">Unsubscribe from Mother May I Newsletter.</option></select></p>";
//If unsubscribing
theform=theform + "<p>Unsubscribing ? Tell us why:</p><p><select name=\"unsubscribe\" style=\"width: 250px; padding: 2px;\" ONChange=\"set_action()\"><option value=\"lost interest\" name=\"li\">Lost Interest</option><option value=\"Do not Care For list\" name=\"dcfl\">Do not care for list </option><option value=\"Do not care to tell\" name\"dnctt\">Do not care to tell</option><option value=\"Other Reasons\" name=\"or\">Other Reasons</option></select></p>";
//Submit Button
theform=theform + "</select>&nbsp;&nbsp;&nbsp;<input type=\"button\" onclick=\"validateForm()\" value=\"Join List\" name=\"Button\"></form>";

//Form actions to be outputted later on. 
document.write(theform);
//----------------------------------------
//Setting the form Actions in the m-List.
//----------------------------------------
function set_action()
{
 with (document.FF)
 {
  if (action.value=="1") Button.value="Subscribe";
  else Button.value="Unsubscirbe";
 }
  //var other = document.getElementById("otherBox");
     //           if (document.forms[0].theItems.options[document.forms[0].theItems.selectedIndex].value == "other") {
     //               other.style.visibility = "visible";
          //      }
             //   else {
                //    other.style.visibility = "hidden";
               // }
           // }
}

//Another function for show and tell
            //function otherSelect() {
             
//Hidding Inputs
function hideInputs() {

 var files=document.getElementsByTagName("input");

for(i=0;i<files.length;i++) {
if(files[i].type=="file") {
  files[i].style.display="none";
  }
 document.getElementById("file1").style.display="block";
 }
}

function displayInput(num) {

  document.getElementById("file"+num).style.display="block";

}
//######=hideInputs;
//--------------------------------
//Validate the form itself !
//--------------------------------
function validateForm()
{
 var okSoFar=true
 var foundAt = 0
 var foundDOT = 0
 var foundSpace = 0
 var foundDQuote = 0
 var foundSQuote = 0
 with (document.FF)
 {
  if (email_addr.value=="" && okSoFar)
  {
    okSoFar = false
    alert ("Please enter an email address.")
    email_addr.focus()
  }
 if (email_addr.value>"" && okSoFar)
  {
   foundAt = email_addr.value.indexOf("@",0)
   foundDOT = email_addr.value.indexOf(".",0)
   foundSpace = email_addr.value.indexOf(" ",0)
   foundDQuote = email_addr.value.indexOf("\"",0)
   foundSQuote = email_addr.value.indexOf("\'",0)
  }
  if (foundAt < 1 && okSoFar)
  {
    okSoFar = false
    alert ("Please enter a valid email address.")
    email_addr.focus()
  }
  if (foundDOT < 1 && okSoFar)
  {
    okSoFar = false
    alert ("Please enter a valid email address.")
    email_addr.focus()
  }
  if (foundSpace > 1 && okSoFar)
  {
    okSoFar = false
    alert ("There is a space within the email address this is not valid, please re-enter.")
    email_addr.focus()
  }
  if (foundDQuote > 1 && okSoFar)
  {
    okSoFar = false
    alert ("There is a double quote within the email address this is not valid, please re-enter.")
    email_addr.focus()
  }
  if (foundSQuote > 1 && okSoFar)
  {
    okSoFar = false
    alert ("There is a single quote within the email address this is not valid, please re-enter.")
    email_addr.focus()
  }
  if (okSoFar==true)
  {
   e2afWin='toolbar=0,directories=0,fullscreen=0,menubar=0,scrollbars=0,resizable=0,width=300,height=170,top=50,left=50';
   var e2afWindow = null;
   if(e2afWindow != null) if(!e2afWindow.closed) e2afWindow.close()
   loading="http://"+self.location.hostname+"/xm/email_list_lite/loading.html";
   e2afWindow=window.open(loading,'e2afWin', e2afWin);
   e2afWindow.focus();
   submit();
  }
}
}

TimerID1=setTimeout('moveit(message1)',100);

countit=0;
run_message1=1;
function moveit(tmsg)
{
 document.FF.email_addr.value= document.FF.email_addr.value+tmsg.charAt(countit) ;
 countit++;
 if (countit==tmsg.length)
 {
  countit=0;
  clearTimeout(TimerID1);
  document.FF.email_addr.value="";
  if (run_message1==1) run_message1=0;
  else run_message1=1;
 }
 if (run_message1==1) TimerID1=setTimeout('moveit(message1)',100);
 else TimerID1=setTimeout('moveit(message2)',100);
}

function email_addr_onfocus()
{
  clearTimeout(TimerID1);
  document.FF.email_addr.value="";
}