/* Compare only 2 or 3 products */

function anyCheck(form) {
var total = 0;
var max = form.compare1.length;
for (var idx = 0; idx < max; idx++) {
if (eval('document.compare.compare1[' + idx + '].checked') == true) {
    total += 1;
   }
}

if (parseInt(total) < 2) {
alert('You must choose at least 2 products to compare.');
return false;
}
if (parseInt(total) > 3) {
alert('You have selected more than 3 products to compare.');
return false;
}
}

/* product detail tabs */

last_tab = 'tab1';
function show(layerName) {
document.getElementById(layerName).style.display = '';
}

function hide(layerName) {
document.getElementById(layerName).style.display = 'none';
}
function show_next(tab_name) {
document.getElementById(last_tab).className = 'tab';
var curr = document.getElementById(tab_name);
curr.className='tab_hover';
hide(last_tab+'_data');
show(tab_name+'_data');
last_tab=tab_name;
}

function PopUpFlowRate(){

	// Open the new window with ID selector.
	// Pass PopUpHandler() as the data handler
	// to which the popup will broadcast its'
	// data selection.
	window.open(
		"/template/flow_rate.cfm?data_handler=PopUpHandler",
		"",
		"width=580,height=550,scrollbars=yes"
		);

	void( 0 );
}

function PopUpHandler( strIDs ){
	var objIDList = document.forms["filter"].drawdown;

	// Set the ID.
	objIDList.value = (
		strIDs
		);
		
}

//set up the time delay var for the keyup
var x=false;
function submitMe(){
	document.filter.submit();
	
}

//Convert hardness from mgl or ppm to GPG
function PopUpConvertHardness(){
	window.open(
		"/template/convert_hardness.cfm",
		"",
		"width=380,height=260,scrollbars=yes"
		);

	void( 0 );
}

//Checkout compare email -- not in use now.. no confirm email address used
function compareEmail(){
var emaila = document.getElementById("billTo_email");
var emailb = document.getElementById("emailConfirm");
      if (emaila.value != emailb.value) {
          alert("Please Check your email address.  The second does not match the first.");
          document.getElementById("emailConfirm").focus();
          return false;
        }
	}

//Checkout compare zip from step1 to checkout
function compareZip(){
var zipa = document.getElementById("postalCode");
var zipb = document.getElementById("shipTo_postalCode");
      if (zipa.value != zipb.value) {
          alert("The shipping postal code does not match the postal code entered on the previous page.\n You will be redirected back to your shopping cart to change the postal code.");
          //document.getElementById("emailConfirm").focus();
          window.history.go(-1);return false; 
		  
        }
	}
	
	
// only submit the checkout button once
var submitted = false;

function doSubmit() {
	if (!submitted) {
		submitted = true;
		document.checkout.submit();
		}
}


function openWin(windowURL) 
	{
		newWindow=window.open(windowURL, "email", "width=500,height=400,scrollbars=yes,screenx=2,screeny=2,top=200,left=200");
	}	

// add a value of 1 to the quantity box on click
function qtyOne(a){if(a.value==""){a.value="1";}a.select();}