function validateEmail2Form() {
	var email = document.getElementById('Email').value;
		
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
			document.getElementById('sendEmail2').value = "TRUE";
			document.frmEmail2.submit();
		}
		
	else {
		alert("Please enter a valid email address");
	}
}

function validateEmailForm() {
	var email = document.getElementById('Email').value;
	var qorc = document.getElementById('QORC').value;
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
		if (qorc != "" && qorc.length != 0) {
			document.getElementById('sendEmail').value = "TRUE";
			document.frmEmail.submit();
		}
		else {
			alert("You must enter a Question or a Comment to send");
		}
	}
	else {
		alert("Please enter a valid email address");
	}
}


function validateFormData() {
   var FName = document.getElementById('FName').value;
   var LName = document.getElementById('LName').value;
   var ADRS1 = document.getElementById('ADRS1').value;
   var City  = document.getElementById('City').value;
   var State = document.getElementById('State').value;
   var Zip   = document.getElementById('Zip').value;
   var Phone = document.getElementById('Phone').value;
   var Email = document.getElementById('Email').value;
   var PWord = document.getElementById('PWord').value;
   var RPWord = document.getElementById('RPword').value;

   if (FName == "" || LName == "" || ADRS1 == "" || City == "" || State == "" ||
       Zip == "" || Phone == "" || Email == "" || PWord == "" || RPWord == "" ) {
       alert("You must enter all the fields on the form");
	   var abort = true;
   }
   if (PWord.length < 6) {
      alert("Your Password must be at least 6 characters long");
	  var abort = true;
   }
   if (PWord != RPWord) {
      alert("The Passwords you Entered did not Match");
	  var abort = true;
   }
   if (!abort) { document.frmRegister.submit(); }
}
function checkCartAction(action) {
	if (action == 'shopping') {
		document.getElementById('isSHOPPING').value = 1;
		document.getElementById('isUPDATE').value = "";
		document.getElementById('isCHECKOUT').value = "";
	}
	else if (action == 'update') {
		document.getElementById('isSHOPPING').value = "";
		document.getElementById('isUPDATE').value = 1;
		document.getElementById('isCHECKOUT').value = "";
	}
	else if (action == 'checkout') {
		document.getElementById('isSHOPPING').value = "";
		document.getElementById('isUPDATE').value = "";
		document.getElementById('isCHECKOUT').value = 1;
	}
	document.frmViewCart.submit();
}
function changeImage(IMG) {
	document.getElementById('itemIMG').src = "_images/"+IMG;
}
function checkProductSelections(colorExists,sizeExists) {
	if (sizeExists == 'true') { var size = document.addProductToCart.itemSize.options[document.addProductToCart.itemSize.selectedIndex].value; }
	else { var size = 'NA'; }
	
	if (colorExists == 'true') { var color = document.addProductToCart.itemColor.options[document.addProductToCart.itemColor.selectedIndex].value; }
	else { var color = 'NA'; }

	if (color != "x" && size != "x") {
		document.addProductToCart.submit()
	}
	else {
		if (color == "x") {
			alert("Please Select a Color");
		}
		else {
			alert("Please Select a Size");
		}
	}
}
function viewBilling() {
  document.getElementById('showAccountBilling').style.display = "block";
}
function showCart(cartid) {
	var prevCart = document.getElementById('prevCart').value;
	if (prevCart != "x") {
		document.getElementById('showCart'+prevCart+'').style.visibility = "hidden";
	}
    document.getElementById('showCart'+cartid+'').style.visibility = "visible";
	document.getElementById('prevCart').value = cartid;
}
function hideCart(cartid) {
    document.getElementById('showCart'+cartid+'').style.visibility = "hidden";
}
function viewBilling() {
    document.getElementById('showPassword').style.visibility = "hidden";
    document.getElementById('showPassword').style.position = "absolute";
    document.getElementById('showBilling').style.visibility = "visible";
    document.getElementById('showBilling').style.position = "static";
    document.getElementById('showShipping').style.visibility = "hidden";
    document.getElementById('showShipping').style.position = "absolute";
}
function viewShipping() {
    document.getElementById('showPassword').style.visibility = "hidden";
    document.getElementById('showPassword').style.position = "absolute";
    document.getElementById('showBilling').style.visibility = "hidden";
    document.getElementById('showBilling').style.position = "absolute";
    document.getElementById('showShipping').style.visibility = "visible";
    document.getElementById('showShipping').style.position = "static";
}
function viewEmailPassword() {
    document.getElementById('showBilling').style.visibility = "hidden";
    document.getElementById('showBilling').style.position = "absolute";
    document.getElementById('showShipping').style.visibility = "hidden";
    document.getElementById('showShipping').style.position = "absolute";
    document.getElementById('showPassword').style.visibility = "visible";
    document.getElementById('showPassword').style.position = "static";
}
function modifyBilling() {
	document.getElementById('BILLING').value = 1;
	document.getElementById('SHIPPING').value = 0;
	document.getElementById('PASSWORD').value = 0;
	document.accountModifyForm.submit();
}
function modifyShipping() {
	document.getElementById('BILLING').value = 0;
	document.getElementById('SHIPPING').value = 1;
	document.getElementById('PASSWORD').value = 0;
	document.accountModifyForm.submit();
}
function modifyPassword() {
	var pass1 = document.getElementById('NewPass').value;
	var pass2 = document.getElementById('ConfirmPass').value;
	var cont = false;
	if (pass1 == pass2 && pass1.length >= 6) {
		document.getElementById('BILLING').value = 0;
		document.getElementById('SHIPPING').value = 0;
		document.getElementById('PASSWORD').value = 1;
		document.accountModifyForm.submit();
	}
	else {
		if (pass1 != pass2) {
			alert("The two passwords entered did not match");
		}
		else {
			alert("Your new password must be more than 6 characters long")
		}
	}
}
function toggleBillingShipping() {
	if (document.getElementById('altBillShip').checked) {
		document.getElementById('divShipping').style.visibility = "hidden";
		document.getElementById('spanBilling').innerHTML = "Billing/Shipping Information";
	}
	else {
		document.getElementById('divShipping').style.visibility = "visible";
		document.getElementById('spanBilling').innerHTML = "Billing Information";
	}
}
function prevSearch(start) {
	document.navigateSearchResults.txtStart.value = start;
	document.navigateSearchResults.submit();
}
function nextSearch(start) {
	document.navigateSearchResults.txtStart.value = start;
	document.navigateSearchResults.submit();
}
function sortSearch() {
	var sortType = document.navigateSearchResults.selOrderBy.options[document.navigateSearchResults.selOrderBy.selectedIndex].value;
	if (sortType != "x") {
		document.navigateSearchResults.txtOrderBy.value = sortType;
		document.navigateSearchResults.txtStart.value = 0;
		document.navigateSearchResults.submit();
	}
}

function toggleFormFieldsForImg(act) {
	if (act == 0) { val = 'hidden'; } else { val = 'visible'; }
	document.getElementById('itemColor').style.visibility = val;
	document.getElementById('itemSize').style.visibility = val;	
}
function imgOptions(act) {
	switch(act) {
		case 'showMax':  document.getElementById('divMax_title').style.display = "block"; break;
		case 'showMin':  document.getElementById('divMin_title').style.display = "block"; break;
		case 'hideMax':  document.getElementById('divMax_title').style.display = "none";  break;
		case 'hideMin':  document.getElementById('divMin_title').style.display = "none";  break;
		case 'expand':   toggleFormFieldsForImg(0); document.getElementById('divMax_image').style.display = "block"; break;
		case 'collapse': toggleFormFieldsForImg(1); document.getElementById('divMax_image').style.display = "none";  break;
	}	
}
function printCoupon() {
	var left = parseInt((screen.availWidth/2)-240);
	var top  = parseInt((screen.availHeight/2)-260);
	var winProps = 'status=0,menubar=yes,toolbar=0,resizeable=0,scrollbars=1,height=600,width=800,left='+left+',top='+top+',screenX='+left+',screenY='+top;
	var win = window.open('winCoupon.htm', 'winCoupon', winProps);
	win.focus();
}