// JavaScript Document
function autohideMenu() {
		var i=1
		for (i=1; i<=4; i=i+1) 
		{
			hide('menu'+i);
		}

}

function refreshCounter() {
	clearTimeout(window.showTimeout);
	showTimeout = window.setTimeout("autohideMenu();",3000);
}


function showhide(id){
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == "none"){
	obj.style.display = "";
} else {
obj.style.display = "none";
}
}
} 

function show(id,fade){
if (document.getElementById){
	obj = document.getElementById(id);
	if (obj.style.display == "none"){
		
		/*
		if (fade == 1){
			obj.style.display = "";
			fadeIn(id);
		}
		
		else {
			obj.style.display = "";
		}
		*/
		obj.style.display = "";
		showTimeout = window.setTimeout("autohideMenu();",3000);
	} 
}
} 

function hide(id){
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == ""){
obj.style.display = "none";
}
}
} 

function showMenu(id,subid){
if (document.getElementById){
	if (subid == 0) {
		var i=1
		for (i=1; i<=4; i=i+1) 
	{
		if (i != id) {
			hide('menu'+i);
		}
		else {
			show('menu'+i,1);
		}
	}
	}
	else {
		var i=1
		var SubCount=0 
		//SubCount is the amount of menu items on that branch
		//Set the values in the switch below.
		
		switch(id)
			{
			case 1:
			SubCount=9
			}
		
		for (i=1; i<=SubCount; i=i+1) 
			{
				if (i != subid) {
					hide('menu'+id+'_'+i);
				}
				else {
					show('menu'+id+'_'+i);
				}
			}		
	}
}
}


//fades layer in
/*
ie5  = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
opac = 0;

function fadeIn(id) {
    if(opac != 100){
        opac+=1;
        if(ie5) document.getElementById('menu1').filters.alpha.opacity = opac;
        if(ns6) document.getElementById('menu1').style.MozOpacity = opac/100;
        setTimeout('fadeIn()', 20);
    }
}
*/
function showContent(id){
if (document.getElementById){
	/*hide('Intro');
	hide('Features');
	hide('Specs');*/
	hide('pageContent');
	hide('Photos');
	hide('BuyOnline');
	hide('EmailPage');
	show(id);
}
}

function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}

function printpage(searchURL){
	if (window.print != null) {
		window.print();
	} else {
		alert("Sorry, your browser does not support this functionality.  Please select \"Print\" from the \"File\" menu at the top of your browser.");
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//****************************************************************************************
/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


