var timeOut = 300; 
var currentLayer = null; 
var currentitem = null; 
var currentLayerNum = 0; 
var noClose = 0; 
var closeTimer = null; 
var currentExpansion = null; 
 
/** 
 * Open menu for the specified menuId 
 */  
function menuOpen(menuId) 
{ 
    var menuContainer  = document.getElementById("menu_container_" + menuId); 
    var mm = document.getElementById("menu_button_" + menuId); 
	 
    if(menuContainer){ 
         
        menuCancelTimeout(); 
        menuContainer.style.visibility='visible'; 
 
        if(currentLayer && (currentLayerNum != menuId)) 
            currentLayer.style.visibility='hidden'; 
 
        currentLayer = menuContainer; 
        currentitem = mm; 
        currentLayerNum = menuId;			 
    }  
     
    else if(currentLayer) { 
        currentLayer.style.visibility='hidden'; 
        currentLayerNum = 0; 
        currentitem = null; 
        currentLayer = null; 
	} 
} 
 
/** 
 * Open menu for the specified menuId 
 */  
function menu2Open(menuId) 
{ 
    var menuContainer  = document.getElementById("menu2_container_" + menuId); 
    var mm = document.getElementById("menu_button_" + menuId); 
	 
    if(menuContainer){ 
         
        menuCancelTimeout(); 
        menuContainer.style.visibility='visible'; 
 
        if(currentLayer && (currentLayerNum != menuId)) 
            currentLayer.style.visibility='hidden'; 
 
        currentLayer = menuContainer; 
        currentitem = mm; 
        currentLayerNum = menuId;			 
    }  
     
    else if(currentLayer) { 
        currentLayer.style.visibility='hidden'; 
        currentLayerNum = 0; 
        currentitem = null; 
        currentLayer = null; 
	} 
} 
 
/** 
 * Start the menu timeout - this will autoclose the menu 
 */  
function menuStartTimeout() { 
    closeTimer = window.setTimeout(menuClose, timeOut); 
} 
 
/** 
 * Cancel the menu from automatically closing. 
 */  
function menuCancelTimeout(){ 
     
    if(closeTimer){ 
        window.clearTimeout(closeTimer); 
        closeTimer = null; 
    } 
} 
 
/** 
 * Close the open menu 
 */  
function menuClose() 
{ 
    if(currentLayer && noClose!=1) { 
        currentLayer.style.visibility='hidden'; 
        currentLayerNum = 0; 
        currentLayer = null; 
        currentitem = null; 
    } 
    else { 
        noClose = 0; 
    } 
 
    currentLayer = null; 
    currentitem = null; 
} 
 
/** 
 * Selects a navigaton item 
 */  
function navSelect(category, link){ 
 
    if (document.getElementById) { 
 
        // Select category 
        var categoryId = document.getElementById('nav_' + category); 
        if(categoryId != null){ 
            categoryId.className = 'nav_selected'; 
        } 
 
        // Open selected category 
        var containerId = document.getElementById('nav_container_' + category); 
        if(containerId != null){ 
            containerId.className = 'nav_show'; 
        } 
         
        // Select subcategory 
        var subCategoryId = document.getElementById('nav_' + category +  '_' + link); 
        if(subCategoryId != null){ 
            subCategoryId.className = 'nav_submenu_selected'; 
        } 
         
    } 
} 
 


/** 
 * Form method to expand row 
 */  
function expandRow(){ 
 
    if (document.getElementById) { 
 
        var selection = document.getElementById('customer_service_for'); 
        var name = selection.options[selection.selectedIndex].id; 
                
        var selectionRow = document.getElementById(name + '_selections'); 
        if(selectionRow){ 
          selectionRow.className = 'row_expand'; 
        }        
         
        if(currentExpansion){ 
          currentExpansion.className = 'row_collapse'; 
        } 
        currentExpansion = selectionRow; 
    } 
} 
 
 
 
 
 
 /** 
 * Validates form data 
 */  
function submitCustomerServiceForm(form){ 
 
   
  with(form){ 
     
    if (validate(first_name, "Please enter your first name.")==false){ return false } 
    if (validate(last_name, "Please enter your last name.")==false){ return false } 
    if (validateEmail(email_address, "Please provide a valid email address.")==false){ return false } 
    if (validate(address_one, "Please enter your mailing address.")==false){ return false } 
    if (validate(state, "Please indicate your State.")==false){ return false } 
    if (validate(city, "Please enter your city.")==false){ return false } 
    if (validate(zip, "Please provide your zip code.")==false){ return false } 
    if (validate(primary_phone_one, "Please provide us with your primary telephone number.")==false){ return false } 
    if (validate(primary_phone_two, "Please provide us with your primary telephone number.")==false){ return false } 
    if (validate(primary_phone_three, "Please provide us with your primary telephone number.")==false){ return false } 
 
    var index = customer_service_for.selectedIndex; 
    if(index == 0){ 
      alert("Please indicate the type of customer service request."); 
      return false; 
    } 
     
     
    if(index == 1 || index == 5){ 
      to_email.value = "damon@tieronelandscape.com";
    } 
    else { 
      to_email.value = "jzellmer@frontiernet.net"; 
    } 
    
  } 
  
  return true; 
} 



 
/** 
 * Form validation for individual field 
 */  
function validate(field, alerttxt){ 
 
  with (field){ 
    if (value==null||value==""){ 
      alert(alerttxt); 
      return false; 
    } 
    else { 
      return true; 
    } 
  } 
} 
 
/** 
 * Validate email 
 */  
function validateEmail(field, alerttxt){ 
  with (field){ 
    apos=value.indexOf("@"); 
    dotpos=value.lastIndexOf("."); 
     if (apos<1||dotpos-apos<2){ 
       alert(alerttxt); 
       return false; 
    } 
    else {return true} 
  } 
} 
