// Created by Marius Pop (www.vline.ro) on 02/28/2007, 08:56:12 PM. !!!

sfHover = function() {
   var sfEls = document.getElementById("nav").getElementsByTagName("LI");
   for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
         this.className+=" sfhover";
      }
      sfEls[i].onmouseout=function() {
         this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
      }
   }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function check_zip_code_field(cnt, zip){
var alert_str = '';
var c_code;

   if(!zip)
      return true;
   if(zip.value == "")
      return true;

   c_code = cnt ? cnt.options[cnt.selectedIndex].value : "US";

   if (c_code == "US") {
      if (zip.value.length!=5 || zip.value.search(/\D/) != -1)
         alert_str = 'Ensure that you have 5 digits in your zip code';
   } else if (c_code == "CA") {
      if (zip.value.length!=6 && zip.value.length!=7)
         alert_str = 'Ensure that you have 6 or 7 characters in your postal code';
   }

   if(alert_str.length > 0) {
      alert(alert_str);
      zip.focus();
      return false;
   }
   return true
}
function check_zip_code(){
   return check_zip_code_field(document.forms["registerform"].b_country, document.forms["registerform"].b_zipcode) && check_zip_code_field(document.forms["registerform"].s_country, document.forms["registerform"].s_zipcode); 
}

function default_check_zip_code(zip){
    return check_zip_code_field("", zip);
}

function FormValidation() {
   if(document.getElementById('product_avail'))
       if(document.getElementById('product_avail').value == 0) {
          alert("Out of stock");
         return false;
       }
    return true;
}

function show_more_info() { 
    zip = document.getElementById('zipcode');

    if (zip.value!="") {
        if (default_check_zip_code(zip)) {
            document.orderform.action = 'dealerlocator.php';
            document.orderform.submit();
        }
    } else {
      alert('Please enter your zipcode');
   }
}
/*** 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");


//*** NO MORE SETTINGS BEYOND THIS POINT ***//
totalButtons = upSources.length;



//*** 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];
}


//preload();
