

function DrinksFinderInit(f) {
	DrinksFinderOnChange(f)
}

function DrinksFinderOnChange(f){

	var qs = DrinksFinderFormToQS(f)
	var sURL = "/products/AjaxDrinksFinder.asp?ScriptAction=ProductCount" + qs	
	AjaxProcessHTMLRequest(sURL,"DrinksFinderProductCountContainer","...")

}

function DrinksFinderValidate(f){

	var productCount = parseInt(document.getElementById("DrinksFinderProductCountContainer").innerText)

	if(productCount==0){
		alert("We can't find any products that exactly match your choices.\n\nChange your options to be less specific to find a close match \nto what you're looking for.")
		return false;
	}
	return true;

}


function DrinksFinderFormToQS(f){

	var qs = ""

	qs += "&type=" + escape(f.type[f.type.selectedIndex].value)
	qs += "&country=" + escape(f.country[f.country.selectedIndex].value)
	qs += "&maingrape=" + escape(f.maingrape[f.maingrape.selectedIndex].value)
	qs += "&flavour=" + escape(f.flavour[f.flavour.selectedIndex].value)
	
	qs += "&price=" + GetRadioValue(f.price)
	
	return qs
}

function GetRadioValue(elRadio) {
	if(elRadio.type = "radio") {
		if(elRadio.length) {
			for(var i = 0;i<elRadio.length;i++){
				if(elRadio[i].checked){
					return elRadio[i].value
				}
			}
			return undefined
		} 
	} else {
		return undefined
	}
}