var navImagePrefix = "/assets/member/header/";

function navTabSwap(image,imgState){
	var onSrc = navImagePrefix + image.id + "_on.gif";
	
	if (imgState == "on"){
		image.src = onSrc;
	} else if (imgState == "over"){
		// Don't switch to over if currently "on"
		if (!new RegExp(onSrc).test(image.src))
			image.src = navImagePrefix + image.id + "_over.gif";
	}else{
		if (!new RegExp(onSrc).test(image.src))
			image.src = navImagePrefix + image.id + ".gif";
	}
}

function init_tabs() {
	document.getElementById("tab1").className = "leftNav";
	document.getElementById("tab2").className = "leftNav";
	document.getElementById("tab3").className = "leftNav";
	document.getElementById("tab4").className = "leftNav";
}

var prev = "";
function makeTop(curr,tabNum) {

        init_tabs();
        document.getElementById(curr).style.display = "block";
		
        document.getElementById(tabNum.id).className = "leftNavSelected";
	   
	    
        if (prev != "" && prev != curr) {
        	document.getElementById(prev).style.display = "none";
        }
        prev = curr;
}

function selectCountry(countryCode){
	countryCode = countryCode.substring(0,2);
	var ii = document.getElementById('country');
	for (i=0; i < ii.options.length; i++){
		if (ii.options[i].value == countryCode){
			ii.selectedIndex=i;
		}
	}
}
function showStatesForCountry(countryCode){
	//go thru the option list, find the country code and hide the ones not belonging to this country.

	var ii = document.getElementById('state');

	for (i=0; i < ii.options.length; i++){

		if (ii.options[i].value.substring(0,2) != countryCode){
			ii.options[i].style.display = "none";
		}
		else {
			ii.options[i].style.display = "block";
		}
	}
	ii.options.selectedIndex=0;

}

//IE7 and earlier do not support setting display to table-row.  Use block instead
var trDisplay = "table-row";

IE4 = (navigator.appVersion.indexOf("MSIE 4.")==-1)? false : true;
IE5 = (navigator.appVersion.indexOf("MSIE 5.")==-1) ? false : true;
IE6 = (navigator.appVersion.indexOf("MSIE 6.")==-1) ? false : true;
IE7 = (navigator.appVersion.indexOf("MSIE 7.")==-1) ? false : true;
if (IE4 || IE5 || IE6 || IE7) {
	trDisplay = "block";
}

function validateEmailAddress(address) {
	var pattern=/.+@.+\..+/;
	return pattern.test(address);
}

function submitLogin() {
	if (!validateEmailAddress(document.f.username.value)) {
		document.getElementById('emailError').style.display=trDisplay; 
		return false;
	}
	return true;
}
