// PRODUCT TAB CONTROLS
var currentPanel = 0; // The default banner
function ShowProductInfo( num ) {
	if ( num == 0 ) {
		getObj( "producttab"+currentPanel ).className = "producttab";
		getObj( "productinfo"+currentPanel ).style.display = "none";
		
		getObj( "productinfo0" ).style.display = "";
		currentPanel = num;
	} else if ( currentPanel != num ) {
		// Highlight the newly clicked tab and product
		getObj( "producttab"+num ).className = "producttab_focus";
		getObj( "productinfo"+num ).style.display = "block";
		getObj( "fullimage"+num ).style.display = "";
		
		// Restore the old tab and product to the original styles
		if ( currentPanel != 0 ) { 
			getObj( "producttab"+currentPanel ).className = "producttab";
			getObj( "productinfo"+currentPanel ).style.display = "none";
			getObj( "fullimage"+currentPanel ).style.display = "none";
		}
		
		getObj( "productinfo0" ).style.display = "none";
		
		// Set the new number as the active product
		currentPanel = num;
	}
}

function getObj( id ) {
	if ( document.getElementById ) {
		return document.getElementById(id);
	} else if ( document.all ) {
		return document.all[id];
	} else if ( document.layers ) {
		if ( document.layers[id] ) {
			return document.layers[id];
		} else {
			return null;
		}
	}
}

// Removes the instructional text from the email address box for newsletter signups
function removeInstructionalText(e) {
	if ( e.value.toLowerCase() == "e-mail address" ) { e.value = ""; }
}

function removeInstructionalTextFR(e) {
	if ( e.value.toLowerCase() == "courriel" ) { e.value = ""; }
}

function checkEmail(strVar) {
    var emailReg = /^(\w){1}[^\*\$\^\&\!\#\%\(\)\+\`\~\,\/\?\:\;\\\"\|\[\]\{\}\@]+\@(\w){1}(\w|-|\.)+\.[a-z]{2,4}$/i;
    var emOK = true;
    if(strVar.length > 1){
		if(!emailReg.test(strVar)){
			emOK = false;
		}
	} 
    return emOK;
}

function validateEmail() {
	if ((document.emailForm.EMAIL.value != "") && (document.emailForm.EMAIL.value != document.emailForm.EMAIL.defaultValue)) {
		if (!checkEmail(document.emailForm.EMAIL.value)) {
			alert("Invalid email address");
			return false;
		} // end if
	} else { //email is blank
		alert("Invalid email address");
		return false;
	}
	return true;
} // end function

function validateEmailFR() {
	if ((document.emailForm.EMAIL.value != "") && (document.emailForm.EMAIL.value != document.emailForm.EMAIL.defaultValue)) {
		if (!checkEmail(document.emailForm.EMAIL.value)) {
			alert("Adresse de courriel erron&eacute;e");
			return false;
		} // end if
	} else { //email is blank
		alert("Adresse de courriel erron&eacute;e");
		return false;
	}
	return true;
} // end function 

var sval = "Search:";
function clearSearch(el){
	if ( el.value == sval ) el.value = '';
}

function restoreSearch(el){
	if ( el.value == '' ) el.value = sval;
}

function update_full( idnum, imgname ) {
	image_path = "images/";
	getObj( 'fullimage'+idnum ).src = image_path+imgname+".jpg";
}