//Setup ajax
function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function selectSubCategory(theCategorySelection, theSubSelection) {
	showProdURL = "?parentid=" + theCategorySelection.value + "&browseby=style";
	showProdURL = showProdURL + "&subid=" + theSubSelection.options[theSubSelection.selectedIndex].value;
	
	if (showProdURL != "") {
		window.location.href = showProdURL;
	}
}

function selectCountry(theCategorySelection, theCountry) {
	showProdURL = "?parentid=" + theCategorySelection.value + "&browseby=country";
	showProdURL = showProdURL + "&country=" + theCountry.options[theCountry.selectedIndex].value;
	
	if (showProdURL != "") {
		window.location.href = showProdURL;
	}
}

function selectCountryRegion(theCategorySelection, theCountry, theRegion) {
	showProdURL = "?parentid=" + theCategorySelection.value + "&browseby=country";
	showProdURL = showProdURL + "&country=" + theCountry.options[theCountry.selectedIndex].value;
	showProdURL = showProdURL + "&region=" + theRegion.options[theRegion.selectedIndex].value;
	
	if (showProdURL != "") {
		window.location.href = showProdURL;
	}
}

function selectGrape(theCategorySelection, theGrape) {
	showProdURL = "?parentid=" + theCategorySelection.value + "&browseby=grape";
	showProdURL = showProdURL + "&grape=" + theGrape.options[theGrape.selectedIndex].value;
	
	if (showProdURL != "") {
		window.location.href = showProdURL;
	}
}

//Check whether something is a number only
function isNumeric(theText) {

   var ValidChars = "0123456789";
   var IsNumber = true;
   var Char;

 
	for (charCounter = 0; charCounter < theText.length && IsNumber == true; charCounter++) { 
		Char = theText.charAt(charCounter); 
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	
	return IsNumber;	
}


// Trim leading/trailing whitespace off string
function trim(str) {
  return str.replace(/^\s+|\s+$/g, '');
}
