/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","button2up.png","button3up.png",
                      "button4up.png","button5up.png","button6up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png",
                        "button4over.png","button5over.png","button6over.png");
 
// SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS
subInfo = new Array();
subInfo[1] = new Array();
subInfo[2] = new Array();
subInfo[3] = new Array();
subInfo[4] = new Array();
subInfo[5] = new Array();
subInfo[6] = new Array();

//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//
subInfo[2][1] = new Array("Analytical Main","testing.html","");
subInfo[2][2] = new Array("Forensic Chemistry","test1.html","");
subInfo[2][3] = new Array("Environmental","test2.html","");
subInfo[2][4] = new Array("Industrial Hygiene","test3.html","");
subInfo[2][5] = new Array("Microbiology","test4.html","");
//subInfo[2][6] = new Array("Manufacturing","test6.html","");
//subInfo[2][7] = new Array("Food Quality","test7.html","");
//subInfo[2][8] = new Array("ID of 'Unknowns'","test8.html","");

subInfo[3][1] = new Array("Services Main","services.html","");
subInfo[3][2] = new Array("Litigation Support","ser0.html","");
subInfo[3][3] = new Array("Indoor Air Quality","ser1.html",""); 
subInfo[3][4] = new Array("Consultant Services","ser4.html","");
subInfo[3][5] = new Array("Waste Stream / Stormwater","ser2.html","");
subInfo[3][6] = new Array("Equipment Rental","equip.html","");
subInfo[3][7] = new Array("Sampling Media","media.html","");

subInfo[4][1] = new Array("Client Main","client.html","");
subInfo[4][2] = new Array("COC/Blank Forms","forms.html","");
subInfo[4][3] = new Array("Kid's Page","kids_form.php","");
subInfo[4][4] = new Array("Survey/Feedback","survey.php","");

subInfo[5][1] = new Array("About Us Main","us.html","");
subInfo[5][2] = new Array("Qualifications","qualif.html","");
subInfo[5][3] = new Array("Careers","careers.html","");
subInfo[5][4] = new Array("Links","links.html","");
subInfo[5][5] = new Array("Contact","contact.html","");


//subInfo[6][4] = new Array("Client Login'","logon.html","");

//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 0;
var ySubOffset = 25;

//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
totalButtons = upSources.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons; x++) {
    // SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
    if ( subInfo[x+1].length < 1 ) { 
        document.write('<div id="submenu' + (x+1) + '">');
    // SET DIV FOR BUTTONS WITH SUBMENU
    } else {
        document.write('<div id="submenu' + (x+1) + '" class="dropmenu" ');
        document.write('onMouseOver="overSub=true;');
        document.write('setOverImg(\'' + (x+1) + '\',\'\');"');
        document.write('onMouseOut="overSub=false;');
        document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);');
        document.write('setOutImg(\'' + (x+1) + '\',\'\');">');


        document.write('<ul>');
        for ( k=0; k<subInfo[x+1].length-1; k++ ) {
            document.write('<li>');
            document.write('<a href="' + subInfo[x+1][k+1][1] + '" ');
            document.write('target="' + subInfo[x+1][k+1][2] + '">');
            document.write( subInfo[x+1][k+1][0] + '</a>');
            document.write('</li>');
        }
        document.write('</ul>');
    }
    document.write('</div>');
}

//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
    for ( x=0; x<totalButtons; x++ ) {
        buttonUp = new Image();
        buttonUp.src = buttonFolder + upSources[x];
        buttonOver = new Image();
        buttonOver.src = buttonFolder + overSources[x];
    }
}

// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
   document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
   document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}

// SET MOUSEOVER BUTTON 2
function setOImg(But, ID) {
   document.getElementById('button' + "14" + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON 2
function setTImg(But, ID) {
   document.getElementById('button' + "14" + ID).src = buttonFolder + upSources[13];
}

//*** SUB MENU FUNCTIONS ***//
// GET ELEMENT ID MULTI BROWSER
function getElement(id) {
    return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
}

// GET X COORDINATE
function getRealLeft(id) { 
    var el = getElement(id);
    if (el) { 
        xPos = el.offsetLeft;
        tempEl = el.offsetParent;
        while (tempEl != null) {
            xPos += tempEl.offsetLeft;
            tempEl = tempEl.offsetParent;
        } 
        return xPos;
    } 
} 

// GET Y COORDINATE
function getRealTop(id) {
    var el = getElement(id);
    if (el) { 
        yPos = el.offsetTop;
        tempEl = el.offsetParent;
        while (tempEl != null) {
            yPos += tempEl.offsetTop;
            tempEl = tempEl.offsetParent;
        }
        return yPos;
    }
}

// MOVE OBJECT TO COORDINATE
function moveObjectTo(objectID,x,y) {
    var el = getElement(objectID);
    el.style.left = x;
    el.style.top = y;
}

// MOVE SUBMENU TO CORRESPONDING BUTTON
function showSubMenu(subID, buttonID) {
    hideAllSubMenus();
    butX = getRealLeft(buttonID);
    butY = getRealTop(buttonID);
    moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset);
}

// HIDE ALL SUB MENUS
function hideAllSubMenus() {
    for ( x=0; x<totalButtons; x++) { moveObjectTo("submenu" + (x+1) + "",-500, -500 );  }
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
    if ( overSub == false ) {
        moveObjectTo(subID,-500, -500);
    }
}

preload();


//
// My Functions
//
var user;
var domain;
var suffix;
var namz;
function jemail(user, domain, suffix)
{  document.write('<a href="'+'mailto:'+user+'@'+domain+'.'+suffix+'"');
   document.write(' target="_blank">'+user+'@'+domain+'.'+suffix+'</a>');
}
function jmail(namz,user, domain, suffix)
{  document.write('<a href="'+'mailto:'+user+'@'+domain+'.'+suffix+'"');
   document.write(' target="_blank">'+namz+'</a>');
}

/*   XML Display */
var sName;
var xmlDoc;
var btype;
var tblNo; // media - 1 equip - 2



function readXML(sName,tblNum) 
{  tblNo=tblNum; //Media is 1; Equip is 2
   if (document.implementation && document.implementation.createDocument) 
   { btype = 1; 
     xmlDoc = document.implementation.createDocument('','', null);
     xmlDoc.load(sName);
     xmlDoc.onload = createTable;
     //alert('Got passed -- 1.');
    } 
   else if (window.ActiveXObject) 
     {  btype = 2; 
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  //alert('Got passed -- 2.');
        xmlDoc.onreadystatechange = function () 
          {  if (xmlDoc.readyState == 4) createTable() }; //    alert('Got passed --- 3.');
             xmlDoc.load(sName);  } 
   else { alert('Your browser can not display this script.');
            return; }  //  alert('Got passed with the above validation.');
}

function createTable() //Find all course elements
{  if (tblNo==1){var ele = xmlDoc.getElementsByTagName('Media')};
   if (tblNo==2){var ele = xmlDoc.getElementsByTagName('items')};
   //Create the table
   var newTable = document.createElement('TABLE');
   newTable.setAttribute('cellPadding',5);
   var newTableBody = document.createElement('TBODY');
   newTable.appendChild(newTableBody);
   //Each subelement name is a table header
   var row = document.createElement("tr");   
   for (j=0; j<ele[0].childNodes.length; j++) 
      {  //Only display the element nodes
         if (ele[0].childNodes[j].nodeType != 1) continue ;
         var header= document.createElement("th");
         var data = document.createTextNode(ele[0].childNodes[j].nodeName);         
         header.appendChild(data);
         //XML formating  tblNo is which xml tabl being used
         if(btype==1) // Start of Firefox & Opera
            {  if((j==1)&&(tblNo==1)) header.setAttribute('width',320); 
               if((j==3)&&(tblNo==1)) header.setAttribute('width','15%');
               if((j==5)&&(tblNo==1)) header.setAttribute('width','15%');   
               if((j==1)&&(tblNo==2)) header.setAttribute('width',320); 
               if((j==3)&&(tblNo==2)) header.setAttribute('width','15%');
               if((j==5)&&(tblNo==2)) header.setAttribute('width','15%');
               //alert('btype1');                  
            }
            else {
         if(btype==2) // Start of IE 
            {  if((j==0)&&(tblNo==1)) header.setAttribute('width',320); 
               if((j==1)&&(tblNo==1)) header.setAttribute('width','15%'); 
               if((j==2)&&(tblNo==1)) header.setAttribute('width','10%');   
               if((j==0)&&(tblNo==2)) header.setAttribute('width',240); 
               if((j==1)&&(tblNo==2)) header.setAttribute('width',55);
               if((j==2)&&(tblNo==2)) header.setAttribute('width',59); 
               //alert('btype2');                 
            }    } 
         if(btype>2) alert('Browser Not Supported');      
         row.appendChild(header);
   }  
   newTableBody.appendChild(row);
   //Each course element is a row
   for (var i=0; i<ele.length; i++) 
      {  row = document.createElement("tr");
         //Each subelement is a column
         for (j=0; j<ele[i].childNodes.length; j++) 
            {  //Only display the element nodes
               if (ele[0].childNodes[j].nodeType != 1) continue;
                  var column = document.createElement("td");
                  var data = document.createTextNode(ele[i].childNodes[j].firstChild.nodeValue);                    
                  column.appendChild(data);                              
                  row.appendChild(column);         
               if ((i%2)==0)
                  {  //  alert('odd');
                     if(btype==2){column.setAttribute('className','odd');}
                     else{column.setAttribute('class','odd');}            
                  }        
               else 
                  {  //  alert('even'); 
                     if(btype==2){column.setAttribute('className','even'); } 
                     else{column.setAttribute('class','even');}                         
                  }
            }
      newTableBody.appendChild(row);
      }
      document.getElementById("theList").appendChild(newTable);
}

/*   Summary Paragraphs */
var pName;
function postText(pName){ 
   if (pName=="legal") {
   document.write('<em>Legal</em><br/><br/>');
   document.write('Please read these <a href="legal.html" target="_self">terms</a> carefully before using this site.<br/>&nbsp;');
   document.write('<br/><em>Summary</em><br />&nbsp;<br />');
   document.write('The materials on this Web site (the "Site") are provided by <em>Armstrong Forensic Laboratory, Inc.</em>');
   document.write(' (<em>Armstrong</em>) as a service to its customers and may be used only for the purpose of conducting business with those customers. &nbsp;');
   document.write('Single copies of the information may be downloaded subject to the provisions below: &nbsp;');
   document.write('By downloading any materials from this site, you agree to Armstrong&#39;s terms of use. &nbsp;<br/><hr/>');
   }
   if (pName=="Accredit") {
   document.write('<em>Armstrong</em> has maintained its Industrial Hygiene Laboratory Accreditation (AIHA) since 1988, ');
   document.write('adding AIHA Environmental Lead (ELLAP) accreditation in 1995.&nbsp; ');
   document.write('A full list of Armstrong&#39;s accreditations, licenses and certifications ');
   document.write('is available on the <a href="qualif.html">"Qualifications"</a> page.<br/><br/>');
   document.write('<a href="http://www.aiha.org/" target="_blank"><img class="ad2" src="images/cert-ih.png" alt=""/></a><br />');
   document.write('<a href="http://www.aiha.org/" target="_blank"><img class="ad2" src="images/cert-el.png" alt=""/></a><br /><hr />');
   }
   if (pName=="WBE") {
   document.write('<em>Armstrong</em> is a Nationally Recognized Woman-owned Business Enterprise (WBE), ');
   document.write('certified by Woman`s Business Enterprise National Council (WBENC) and the State of ');
   document.write('Texas as a Historically Underutilized Business (HUB). &nbsp;<em>Armstrong</em> is a Prime ');
   document.write('Contractor for on-going Metroplex, State and Federal projects.<br />  <hr />');
   }
   if (pName=="ascld") {
   document.write('<em>Armstrong</em> has received Accreditation from ASCLD/Lab-<span class="it">International</span> in June of 2007, ');
   document.write('&nbsp;Accredited Disciplines include Controlled Substances and Trace Evidence.  &nbsp;Specific categories are Controlled Substances Analysis, Analysis of Unknowns and Fire Debris.');
   document.write('&nbsp;  A full list of Armstrong&#39;s accreditations, licenses and certifications ');
   document.write('is available on the <a href="qualif.html">"Qualifications"</a> page.<br/><br/>');
   document.write('<a href="http://www.ascld-lab.org/" target="_blank"><img class="ad" src="images/ascld1.png" alt=""/></a><br />  <hr />');
   }   
   if (pName=="external") {
   document.write('<u><em>External Accreditation</em></u><br /><br />');      
   document.write('External accreditation is a hallmark of a laboratory you can trust. &nbsp;The periodic review of the laboratory by an');
   document.write('out side organization is to ensure ongoing quality of your sample analysis. &nbsp;The routine ');
   document.write('analysis of blind samples is used to continuously monitor laboratory quality control procedures. &nbsp;All');
   document.write(' laboratories accredited by AIHA are in compliance with International Standard ISO/IEC ');
   document.write('17025, general requirements for the competence of testing and calibration laboratories.<hr />');
   }
   if (pName=="scope") {
   document.write('<em>Armstrongs</em> 2008 AIHA<br/>Scope of Accreditation<br/>is  <a href="/pdf/AIHAApproval.pdf">Available Here</a>.<br/><br/>');
   }   
   if (pName=="weekend") {
   document.write('<em>Routine Analysis <br />with 2 shifts, 5 days a week.</em><br /> <br />');
   document.write('<em>Weekend &amp; Emergency <br />Services Available</em> <br />  <hr />');
   }
   if (pName=="places") {
   document.write('Some of the places around the world, <em>Armstrong</em> has provided services.<br /><br />');
   document.write('<table ><tr><td class="tel">USA   </td><td class="tel">Mexico        </td></tr>');
   document.write('<tr><td class="tel">Diego Garcia </td><td class="tel"> United Kingdom</td></tr>');
   document.write('<tr><td class="tel">Puerto Rico   </td><td class="tel">Ireland    </td></tr>');
   document.write('<tr><td class="tel">Peru          </td><td class="tel">Taiwan     </td></tr>');
   document.write('<tr><td class="tel">Colombia      </td><td class="tel">Belize     </td></tr>');
   document.write('<tr><td class="tel">Jamaica        </td><td class="tel">Japan      </td></tr>');
   document.write('<tr><td class="tel">Canada        </td><td class="tel">Netherlands</td></tr>');
   document.write('<tr><td class="tel">Chile         </td><td class="tel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>');
   }  
   if (pName=="Student") {
   document.write('<a href="testing.html" target="_self"><em>Students</em></a>');
   document.write('<br/>In Use Instrumentation Information Here.<br/>');   
   }
   if (pName=="kids") {
   document.write('<br /><a href="kids.html" target="_self"><em>Students</em></a>');
   document.write('<br/>Test Your Knowledge Here.<br/><br/>');   
   }   
   if (pName=="work") {
   document.write('<br/><hr/><b>Laboratory Work Areas</b><br/>');
   document.write('<a href="test10.html">GCs</a><br/><a href="test11.html">HPLC</a><br/>');
   document.write('<a href="test12.html">ICs</a><br/><a href="test13.html">GC/MS, MS/MS</a><br/>');
   document.write('<a href="test14.html">UV/Vis</a><br/><a href="test15.html">ICP</a><br/>');
   document.write('<a href="test16.html">AAS &amp; GFAAS</a><br/><a href="test17.html">XRD</a><br/>');
   document.write('<a href="test18.html">FTIR-ATR</a><br/><br/>');
   }  
   if (pName=="answers") {
   document.write('<b>Summary Sheets <br/>for Laboratory Services:</b><br/>');
   document.write('<a href="./select/product.html" target="_self">CPSC Lead &amp; Phthalates</a><br/>');
   document.write('<a href="./select/crime.html" target="_self">Crime Lab</a><br/>');
   document.write('<a href="./select/environmental.html" target="_self">Environmental</a><br/>');
   document.write('<a href="./select/fire.html" target="_self">Arson Analysis</a><br/>');
   document.write('<a href="./select/healthcare.html" target="_self">Healthcare Support</a><br/>');   
   document.write('<a href="./select/rain.html" target="_self">Stormwater Collection</a><br/>');
   document.write('<a href="./select/mold.html" target="_self">Mold Analysis</a><br/>');
   }    
   if (pName=="cpsc") {
   document.write('<h3 color="yellow">Childrens Products ');
   document.write('CPSIA Testing:</h3>');   
   document.write(' <a href="./select/cpsc.html" target="_self">CPSC Requirements</a>');
   document.write('<br/><a href="ser5.html" target="_self">Laboratory Services</a><br/>');
   }
   if (pName=="drywall") {
   document.write('<h3 color="yellow">"Chinese" Drywall: <br/>');
   document.write('High-Sulfur <br/>Drywall Analysis</h3>');   
   document.write('<img  src="./images/arrow.png" alt="arrow"></img> <a href="./select/drywall.html" target="_self">Analysis Information</a>');
   document.write('<br/>');
   } 
   if (pName=="footer") {
   document.write('All products mentioned are registered trademarks of their respective companies.<br />&nbsp;');
   document.write(' | <a href="privacy.html" target="_self"><b>Privacy Page</b></a> |');
   document.write(' Last Updated: 5/22/2009 | <a href="legal.html" target="_self"><b>Legal Page</b></a> |');
   document.write('<br/>Questions or problems regarding this web site should be directed to ');
   jemail("website", "aflab", "com"); 
   document.write('.<br />Copyright &copy; 1999-2009 Armstrong Forensic Laboratory, Inc. &nbsp;All rights reserved.');
   }      
}
function submitIt(theform) {
    if (theform.fname.value=="") {
        alert("You must enter a name here!")
        theform.fname.focus()
        return false    }
    if (theform.q1.value=="") {
        alert("You must enter an answer here!")
        theform.q1.focus()
        return false  }
    if (theform.q2.value=="") {
        alert("You must enter an answer here!")
        theform.q2.focus()
        return false  }
    if (theform.q3.value=="") {
        alert("You must enter an answer here!")
        theform.q3.focus()
        return false  }
    if (theform.q4.value=="") {
        alert("You must enter an answer here!")
        theform.q4.focus()
        return false  }
    if (theform.q5.value=="") {
        alert("You must enter an answer here!")
        theform.q5.focus()
        return false  }
    return true
}
function isRequired(e,len) 
   { var entryReq= /./;
      if (entryReq.test(e.value) && e.value.length>=len) return true;
      return false;
   }
function isValidEmail(e) 
   { var validEmail = /^[^@]+@[^@.]+\.[^@]*\w\w$/
      if (validEmail.test(e.value)) return true;
      return false;
   }
function isValidPass(e) 
   { var validPass = /^.{8,12}$/;
      if (validPass.test(e.value)) return true;
      return false;
   }
function isNumeric(e) 
   { var v = parseFloat(e.value);
      if (isNaN(v)) return true;
      return false;
   }
function isAllNumeric(e) 
   { var numericExp=/^\d+$/;
      if (numericExp.test(e.value)) return true;
      return false;
   }
function isValidZip(e) 
   { var numericExp=/^\d+$/;
      var v = parseFloat(e.value);
      if (numericExp.test(e.value)) 
         { if(v>=601 && v<=99950)
            {if(e.value.length == 5) return true; }
         }
      return false;
   }
function isValidPhone(e)
   { var phonePattern = /^\d{10}$/;
      if (phonePattern.test(e.value)) return true;
      return false;
   }
function validate(f) 
   { var msg = "";
      for (var i=0; i<f.length; i++)
      { var e = f.elements[i];
        if (e.style.backgroundColor) e.style.backgroundColor="white";

        var numeric = e.getAttribute("numeric");
         if (numeric) 
            { if (!isNumeric(e)) 
               { msg += generateErrorMessage(e, " must be numbers.");
                  continue;
               }
            }
        var allNumeric = e.getAttribute("allNumeric");
         if (allNumeric) 
            { if (!isAllNumeric(e)) 
               { msg += generateErrorMessage(e, " must be all numbers.");
                  continue;
               }
            }
        var required = e.getAttribute("required");
        var len = e.getAttribute("len");
         if (required) 
            { if (!isRequired(e,len)) 
               { msg += generateErrorMessage(e, " must be entered.");
                  continue;
               }
             }
        var validZip = e.getAttribute("validZip");
         if (validZip) 
            { if (!isValidZip(e)) 
               { msg += generateErrorMessage(e, " does not appear to be a valid zip code.");
                  continue;
               }
            }             
        var validPhone = e.getAttribute("validPhone");
         if (validPhone) 
            { if (!isValidPhone(e)) 
               { msg += generateErrorMessage(e, " does not appear to be a valid phone number.");
                  continue;
               }
            }
        var validEmail = e.getAttribute("validEmail");
         if (validEmail) 
            { if (!isValidEmail(e)) 
               { msg += generateErrorMessage(e, " does not appear to be a valid e-mail address.");
                  continue;
               }
            }
        var validPass = e.getAttribute("validPass");
         if (validPass) 
            { if (!isValidPass(e)) 
               { msg += generateErrorMessage(e, " must be between 8 and 12 characters.");
                  continue;
               }
            }
   }
   if (!msg) return true;
   return msg;
}

function generateErrorMessage(e, str) {
   e.style.backgroundColor = "orange";
   return ("* " + e.name + str + "<br />");
}

function startForm() { document.RegistrationForm.invoice.focus();    }

function doQuiz(f) {
   document.getElementById("invoice").setAttribute("required", "true");
   document.getElementById("rptdate").setAttribute("required", "true");
   document.getElementById("lname").setAttribute("len", "2");
   document.getElementById("q1").setAttribute("required", "true");
   document.getElementById("q1").setAttribute("len", "2");
   document.getElementById("q2").setAttribute("required", "true");
   document.getElementById("q3").setAttribute("len", "2");
   document.getElementById("q4").setAttribute("validZip", "true");
   document.getElementById("q5").setAttribute("validPhone", "true");
   document.getElementById("q6").setAttribute("required", "true");
   var result = validate(f);
   if (result==true) 
   {  parent.frames( "mainFrame").document.write( "<h1>Thank You!</h1>"+
      "<p><a href='main.html' target='_self'>Home</a></p>");
      return true;
   }
   document.getElementById("Error").innerHTML = result;
   return false;
}
