//##############################################################################
function isValidEmail(email){
	invalidChars = " /;:,";
	for(i=0; i < invalidChars.length; i++){
		badChar = invalidChars.charAt(i)
		if(email.indexOf(badChar,0) > -1){
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if(atPos == -1){
		return false
	}
	if(email.indexOf("@",atPos+1) > -1){
		return false
	}
	periodPos = email.indexOf(".",1)
	if(periodPos == -1){
		return false
	}
	if(periodPos+3 > email.length){
		return false
	}
	return true;
}
//##############################################################################
function verifyForm() {
	var returnVal = true;
	if (returnVal == true) {
		if (!(isValidEmail(document.newsform.emailAddress.value))) {
			alert('Please enter a valid email address in the format\nuser@domain.com.');
			document.newsform.emailAddress.focus();
			returnVal = false;
		}
	}
	if (returnVal == true) {
		document.newsform.submit();
	}
	return false;
}
//##############################################################################
// CHANGE THE SRC OF AN IMAGE BASED ON ROLLOVER, ROLLOUT.
function imageChange(theimage,theimagename) {
	document [theimage].src = "/img/templates/" + theimagename + "";
}
//##############################################################################
function show(object,event,element) {
	var lefter = event.clientX;
	var leftoff = event.offsetX
	var r = element.getBoundingClientRect();
	xxx = r.left;
	xxx = xxx - 2 + 274;
	if (document.getElementById) {
    	document.getElementById(object).style.visibility = 'visible';
		document.getElementById(object).style.left = xxx;
	} else if (document.layers && document.layers[object]) {
    	document.layers[object].visibility = 'visible';
		document.layers[object].left = xxx;
	} else if (document.all) {
		document.all[object].style.visibility = 'visible';
		document.all[object].style.left = xxx;
	}
}
//##############################################################################
function hide(object) {	
	if (document.getElementById) {
		document.getElementById(object).style.visibility = 'hidden';
	} else if (document.layers && document.layers[object]) {
		document.layers[object].visibility = 'hidden';
	} else if (document.all) {
		document.all[object].style.visibility = 'hidden';
	}
}
//##############################################################################
function newWindow(sURL,w,h) {
	var args = "scrollbars=yes,toolbar=no,directories=no,menubar=no,resizeable=yes,status=no,width=" + w + ",height=" + h;
	var editorwindow = window.open(sURL,"",args);  
}
//##############################################################################
function clearNewsletter() {
            if (document.newsform.emailAddress.value == "enter your e-mail") {
                        document.newsform.emailAddress.value = "";
            }
}
//##############################################################################











//########################################################################################
// SET THE NUMBER OF MENUS
var numberofmenus;
numberofmenus = 7;
var whichvisible;
//########################################################################################
// HIDE ALL SUB MENUS
function hideallsubmenus(force){
	// HIDE ALL THE SUBMENUS
	for ( i=1; i<=numberofmenus; i++ ) {


if (force == "force") { whichvisible = "none"; }
checkwhichvisible = ("topmenu" + i);
//alert(checkwhichvisible);
if (whichvisible == checkwhichvisible) {
// NOTHING
} else {
		if (document.getElementById) {
			document.getElementById("topmenu"+i).style.visibility = 'hidden';
		} else if (document.layers && document.layers["topmenu"+i]) {
			document.layers["topmenu"+i].visibility = 'hidden';
		} else if (document.all) {
			document.all["topmenu"+i].style.visibility = 'hidden';
		}
}

 	}
}
//########################################################################################
// POSITION THE MENU
function position(element,event,whichmenu){	
	// HIDE ALL THE SUBMENUS
	hideallsubmenus();
	// SET THE LEFT POSITION OF THE MENU
	var therect = element.getBoundingClientRect();
	thexlocation = therect.left;
	theylocation = therect.top;
	
	document.getElementById(whichmenu).style.left = (thexlocation - 15) + "px";
	// SHOW THE MENU
	showhide(whichmenu,'show');
}
//########################################################################################
goahead = 0;
//########################################################################################
// SHOW/HIDE THE MENU
function showhide(object,action) {


	visibility = "visible";
	if (action == "hide") { visibility = "hidden"; }
if (action == "show") { 







if (object != whichvisible) {
hideallsubmenus('force');
}
}

whichvisible = object;

	if (goahead == 1) {
		if (document.getElementById(object).style.left) { 
			if (document.getElementById) {
				document.getElementById(object).style.visibility = visibility;
			} else if (document.layers && document.layers[object]) {
		    		document.layers[object].visibility = visibility;
			} else if (document.all) {
		    		document.all[object].style.visibility = visibility;
		  	}
		}
	}
}
//########################################################################################
// CHANGE THE LOOK OF TOP NAV PULLDOWN
function changelook(element,theaction,theclass) {
	switch(theaction) {
		case 'over':
			element.className = theclass + "_over";
   			break;
  		case 'out':
			element.className = theclass;
   			break;
	}
}
//########################################################################################