/* navigation rollovers */

  $(function() {
    //Preserves the mouse-over on top-level menu elements when hovering over children
    $("#nav ul ul").each(function(i){
      $(this).hover(function(){
        $(this).parent().find("a").slice(0,1).addClass("active"); 
      },function(){ 
        $(this).parent().find("a").slice(0,1).removeClass("active"); 
      });
    });

    // IE6 Fix: Drop-down fix due to lack of support for :hover on list elements
    if($.browser.msie && ($.browser.version < 7)) {
      $("#nav").each(function(i){
        $(this).find("li").hover(function(){
          $(this).addClass("sfhover");
        },function(){ 
          $(this).removeClass("sfhover"); 
        });
      });
    }
  
  });
  
/* contact form checker */

	function checkIt() {      
	if(document.contactForm.fname.value == "") {       
		alert('Please enter your first name.');              
            return false;
	} 
	if(document.contactForm.lname.value == "") {       
		alert('Please enter your last name.');               
            return false;
	} 
	if(document.contactForm.dPhone1.value == "" || document.contactForm.dPhone2.value == "" || document.contactForm.dPhone3.value == "") {       
		alert('Please enter your phone number.');                
            return false;
	}
	if(document.contactForm.email.value == "") {       
		alert('Please enter your email address.');                
            return false;
	} 	
	if(document.contactForm.comment.value == "") {       
		alert('Please enter your comment or question.');               
            return false;
	}
	else {
		document.contactForm.submit()
		return true;
	}
}

/* show/hide pmzone */

function showItem(id) {
	thisDiv = 'item'+id;
	if(document.getElementById(thisDiv).style.display == 'none') {
		document.getElementById(thisDiv).style.display = 'block';
	}
	else {
		document.getElementById(thisDiv).style.display = 'none';
	}
}

function showItemOLD(id,tot) {
	for(i=1;i<=tot;i++) {
		thisDiv = 'item'+i;
		if(i == id) {
			if(document.getElementById(thisDiv).style.display == 'none') {
				document.getElementById(thisDiv).style.display = 'block';
			}
			else {
				document.getElementById(thisDiv).style.display = 'none';
			}
		}
		else {
			/* document.getElementById(thisDiv).style.display = 'none'; */
		}
	}
}

/* default PMZone form */

function clearText(thefield) {
	if (thefield.defaultValue==thefield.value) {
		thefield.value = " ";
	}
}

function resetText(thefield) {
	if (thefield.value == " " || thefield.value == "") {
		thefield.value = thefield.defaultValue;
	}
}


	
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

