var formName="";

/*	registration form functionality	*/
function validateForm(f) {
	var numberOfErrors = 0;
	var fe = document.getElementById(f).elements;
	for(var i=0;i<fe.length;i++) {
		if(fe[i].className.indexOf("required") > -1) {
			fe[i].className = fe[i].className.split(" error").join("");
			if(fe[i].value=="") {
				numberOfErrors++;
				fe[i].className += " error";
			}
		}
	}
	if(validateEmail(document.getElementById("email_address").value)==false) {
		numberOfErrors++;
		document.getElementById("email_address").className += " error";
	}
	if(numberOfErrors==0) {
		return true;
	} else {
		displayErrorMessage();
		return false;
	}
}

function validateEmail(v) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v)){
		return true;
	} else {
		return false;
	}
}

function displayErrorMessage() {
	document.getElementById("warning_panel").style.display="block";
	document.getElementById("additional_information").style.top = "265px";
}

function showPopupMessage(thing) {
	document.getElementById("additional_information").style.display="block";
	document.getElementById("factory_code_info").style.display="none";
	document.getElementById("privacy_info").style.display="none";
	document.getElementById(thing).style.display="block";
}
/*	registration form functionality	*/



/*	original design slideshow functionality	*/
var currentThumb = null;		//	the object
var currentThumbIndex = 0;		//	the number index
var currentSubThumb = null;		//	the object
var currentSubThumbIndex = 0;	//	the numeric index

function initSlideShow() {
	if(document.getElementById("thumbs")) {	//	if there is a primary slideshow to initialize...
		var t = document.getElementById("thumbs").getElementsByTagName("a");
		for(var i=0;i<t.length;i++) {
			t[i].onmouseover = function() {
				if(this.className=="thumbActive") return;
				this.childNodes[0].src = this.childNodes[0].src.split(".png").join("_hover.png");
			}
			t[i].onmouseout = function() {
				if(this.className=="thumbActive") return;
				this.childNodes[0].src = this.childNodes[0].src.split("_hover").join("");
			}
			t[i].onclick=function() {
				if(this.className=="thumbActive") return;
				this.className = "thumbActive";
				var s =  this.childNodes[0].src.split("tn_").join("gallery-").split("png").join("jpg").split("_hover").join("");
				document.getElementById("big_photo").src=s;
				if(currentThumb){
					currentThumb.className = "";
					currentThumb.childNodes[0].src = currentThumb.childNodes[0].src.split("_hover").join("");
				}
				currentThumb = this;
				currentThumbIndex = parseInt(this.id.split("_")[1]);
				return false;
			}
		}
		currentThumb = document.getElementById("thumbs").getElementsByTagName("a")[0];
		currentThumbIndex = 0;
	}
	if(document.getElementById("thumbSubNav")) initSubSlideShow(0);	//	if there is a secondary slideshow to initialize...
}

function initSubSlideShow() {
	currentSubThumbIndex = 0;
	var s = document.getElementById("thumbSubNav");
	var h = "";
	var a = "";
	var l = subSlides[currentThumbIndex].length;
	var xOff = 14;
	for(var i=0;i<l;i++) {
		if(i==0) {
			a = "active";
		} else {
			a = "button";
		}
		h += "<a style=\"right:"+((l*xOff)-(i*xOff))+"px;\" id=\"thumbSubButton_"+i+"\" class=\"" + a + "\" href=\"" + subSlides[currentThumbIndex][i] + "\" onclick=\"jumpToSubSlide(" + i + ");return false;\"></a>"
	}
	h += "<a id=\"thumbSubRight\" href=\"#\" onclick=\"advanceSubSlideShow(1);return false;\"></a>";	//	right nav
	h += "<a style=\"right:"+(l*xOff+xOff)+"px\" id=\"thumbSubLeft\" href=\"#\" onclick=\"advanceSubSlideShow(-1);return false;\"></a>";	//	left nav
	s.innerHTML = h;
	currentSubThumb = document.getElementById("thumbSubButton_"+currentSubThumbIndex);
}

function advanceSubSlideShow(direction) {
	var i = currentSubThumbIndex;
	i += direction;
	if(i<0) {i = subSlides[currentThumbIndex].length-1};
	if(i==subSlides[currentThumbIndex].length) {i = 0};
	jumpToSubSlide(i);
}
function jumpToSubSlide(index) {
	if(currentSubThumbIndex == index) return;
	if(currentSubThumb) currentSubThumb.className = "button";
	currentSubThumb = document.getElementById("thumbSubButton_"+index);
	currentSubThumb.className = "active";
	currentSubThumbIndex = index;
	document.getElementById("target_image").src = currentSubThumb.href;
}









/*	eliminate background image flicker in IE6	*/
try {document.execCommand('BackgroundImageCache', false, true);} catch(e) {}
/*	/eliminate background image flicker in IE6	*/


onload = initSlideShow;
/*	original stuff slideshow functionality	*/

