function ValdFormDist(frm) {			//Validate Distributr Search Form
	if ((frm.txtZipCode.value == "") || (frm.txtZipCode.value == "enter zip code") || (frm.txtZipCode.value.length < 5)) {
		//showBlank("Zip Code ",frm.txtZipCode); return false;
		alert('Please enter a valid zip code and try again.');
		return false;
	}
	location.href = "/distributors-near-you/" + frm.txtZipCode.value;
	return false;
}
function showHide(sMenuName) {
	var sObject;
	if(document.layers){
		sObject = document.all.sMenuName.style;
	} else if(!document.all && document.getElementById){
		sObject = document.getElementById(sMenuName).style;
	} else {
		sObject = eval(sMenuName).style;
	}
	if (sObject.visibility =='visible')	{
		sObject.visibility='hidden';
	} else {
		sObject.visibility='visible';
	}
}
function JoinFormCheck1(frm) {			//Owners Area Form
	if (frm.owners_t1.value == "") { showBlank("Owners Name ",frm.owners_t1); return false; }
	if (frm.owners_t2.value == "") { showBlank("Owners Email ",frm.owners_t2); return false; }
	Email = frm.owners_t2.value;
	if (Email.length < 6) {
		alert("The Email Address you entered was found to be invalid.\nPlease enter a valid Email Address.");frm.owners_t2.select();frm.owners_t2.focus();return false;
	}
	if (Email.indexOf("@") == -1) {
		alert("The Email Address you entered was found to be invalid.\nPlease enter a valid Email Address.");frm.owners_t2.select();frm.owners_t2.focus();return false;
	}
	if (Email.indexOf(".") == -1) {
		alert("The Email Address you entered was found to be invalid.\nPlease enter a valid Email Address.");frm.owners_t2.select();frm.owners_t2.focus();return false;
	}
	if (!((frm.owners_t7[0].checked) || (frm.owners_t7[1].checked) || (frm.owners_t7[2].checked) || (frm.owners_t7[3].checked) || (frm.owners_t7[4].checked) || (frm.owners_t7[5].checked))) {
alert("You have missed one of the mandatory fields.\n Please select 'In Regards To'");
      frm.owners_t7[0].focus();
      return false;
	}


return true;
}
function JoinFormCheck2(frm) {			//Email Friend Form
	if (frm.email1.value == "") { showBlank("Email ",frm.email1); return false; }
	Email = frm.email1.value;
	if (Email.length < 6) {
		alert("The Email Address you entered was found to be invalid.\nPlease enter a valid Email Address.");frm.email1.select();frm.email1.focus();return false;
	}
	if (Email.indexOf("@") == -1) {
		alert("The Email Address you entered was found to be invalid.\nPlease enter a valid Email Address.");frm.email1.select();frm.email1.focus();return false;
	}
	if (Email.indexOf(".") == -1) {
		alert("The Email Address you entered was found to be invalid.\nPlease enter a valid Email Address.");frm.email1.select();frm.email1.focus();return false;
	}
	return true;
}

function showBlank(field, obj){msg = "You have missed one of the mandatory fields.\n" + field + " was left blank or not selected.\n";alert(msg);obj.focus();}
function showBlank1(field, obj){msg = "You have missed one of the mandatory fields.\n" + field + " is Invalid.\n";alert(msg);obj.focus();}

function addEvent() {
	var ni = document.getElementById('myDiv');
	var numi = document.getElementById('theValue');
	var num = (document.getElementById("theValue").value -1)+ 2;
	numi.value = num;
	var divIdName = "my"+num+"Div";
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	newdiv.innerHTML = "<input type='text' name='email" + num + "' value='Email Address' onblur=\"if(this.value=='') {this.value='Email Address';}\"  onfocus=\"if(this.value=='Email Address') {this.value='';}\" size='51' class='fi' /> <a href=\"javascript:;\" onclick=\"removeElement(\'"+divIdName+"\')\"><img src='/images/delete.png' width='16' height='16' alt='Delete' border='0' align='absmiddle' /></a>";
	ni.appendChild(newdiv);
}

function removeElement(divNum) {
	var d = document.getElementById('myDiv');
	var olddiv = document.getElementById(divNum);
	d.removeChild(olddiv);
}

/* tabs on product page */
function showProductTab(curObj, tabIdName, presetClassesNeeded) {
	//first reset the classes
	resetProductTabClasses();
	//change classes to show the "active" state for the selected tab
	var classList = 'active';
	//classList = classList + presetClassesNeeded;
	document.getElementById(curObj).className = classList;
	//next, hide all of the content blocks
	hideAllTabContents();
	//show selected content
	document.getElementById(tabIdName).style.display = "block";
	return true;
}
function resetProductTabClasses() {
	document.getElementById('tabLinkOverview').className='';
	document.getElementById('tabLinkUnit').className='';
	document.getElementById('tabLinkCloseUp').className='last';
}
function hideAllTabContents() {
	document.getElementById('tabOverview').style.display = "none";
	document.getElementById('tabUnit').style.display = "none";
	document.getElementById('tabCloseUp').style.display = "none";
}