function doSubmit(url, form){
	form.action = url;
	form.submit();
}
//disable form validation for delete button
function confirmDelete(btn, message){
	if(confirm(message)){
		btn.form.onsubmit=null;
		return true;
	}
	return false;
}

function confirmThis(msg, url){
	if (confirm(msg)){
		window.location = url
	}
}

function displayStatusMsg(msgStr) {
  status=msgStr;
}

function toggleElement(name, hideSelects, closeByDefault, toggleImage, imagePath){
	var el = document.getElementById(name);
	var display = YAHOO.util.Dom.getStyle(el, 'display');
	//Safari bug - reports null for display when css set to "none"
	if(display && display!="none"){
		el.style.display="none";
		/*if(hideSelects){
			for (var i=0; i<document.all.length; i++) {
			 o = document.all(i)
			 if (o.type == 'select-one' || o.type == 'select-multiple') {
			  // todo: add check for select in div?
			  if (o.style) o.style.display = 'inline';
			 }
			}
		}*/
		if(toggleImage != undefined){
			document.getElementById(toggleImage).src = imagePath + "/show.gif";
		}
	}else{
		el.style.display="block";
		/*if(hideSelects){
			for (var i=0; i<document.all.length; i++) {
			 o = document.all(i)
			 if (o.type == 'select-one' || o.type == 'select-multiple') {
			  // todo: add check for select in div?
			  if (o.style) o.style.display = 'none';
			 }
			}
		}*/
		if(toggleImage != undefined){
			document.getElementById(toggleImage).src = imagePath + "/hide.gif";
		}
	}	
}

function TimStatus(message){
    status=message;
}
function showStatus(message){
    setTimeout('TimStatus("'+message+'")',1);
}

/* PRODUCT LISTING */
	function addToCart(url,id,quantity){
		if(canAddToCart(quantity)){
			url+="&productid=" + id + "&quantity=" + quantity.value;
			window.location=url;
		}
	}
	
	function canAddToCart(field){
		//form element quantity 'INTEGER' validation checks
		if(field.value <= 0){
			alert("Please enter a quantity greater than zero for this item.");
       return false;
		}
		return true;
	}
	
	var products = new Array();
	
	function toggleMultiple(item, type){
		var id = item.value;
		var fieldName = 'quantity' + id;
		if(type == "unit"){
			fieldName = "unit" + fieldName;
		}else if(type == "3pack"){
			fieldName = "3pack" + fieldName;
		}
		var quantField = document.getElementById(fieldName);
		var ob;
		if(item.checked){
			if(quantField.value == ""){
				quantField.value=1;
			}
			var quantity = quantField.value;	
			ob = {id:id,quantity:quantity,type:type};
			products[products.length] = ob;
		}else{
			var newproducts = new Array();
			for(var ii = 0; ii < products.length; ii++){
				if(products[ii].id != id){
					newproducts.push(products[ii]);
				}
			}
			products = newproducts;
		}
	}
	function checkMultipleQuantity(item,id,type){
		var quantity = parseFloat(item.value);
		var found = false;
		for(var ii = 0; ii < products.length; ii++){
			if(products[ii].id == id && products[ii].type == type){
				if(!quantity){
					quantity=1;
				}
				products[ii].quantity = quantity;
				found = true;
				break;
			}
		}
		if(!found){
			document.getElementById(type + 'product' + id).click();
		}
	}
	function submitMultiple(field){
		var items = "";
		for(var ii = 0; ii < products.length; ii++){
			if(ii > 0){
				items = items + ",";
			}
			items = items + products[ii].id + ":" + products[ii].quantity + ":" + products[ii].type;
		}
		field.value = items;
	}
	function checkQuantity(item,step){
		var value = item.value;
		if(value % step != 0){
			item.value = value - (value % step);
		}
		if(item.value > 99){
			item.value = 99;
		}
	}
	function increment(item,step){
		if(item.value == ""){
			item.value = parseFloat(step);
		}else{
			item.value = parseFloat(item.value) + parseFloat(step);
		}
		checkQuantity(item,step);
	}
	function decrement(item,step){
		if(parseFloat(item.value) > parseFloat(step))
			item.value = parseFloat(item.value) - parseFloat(step);
	}
	function MM_openBrWindow(theURL,winName,features) {
		window.open(theURL,winName,features);
	}