function validateAdvancedSearch(f) {

	if (isBlank(f.keyword.value)) {
		alert('Se ha de introducir una palabra clave');
		f.keyword.focus();
		return false;
	}

	/* 
	if ((!isBlank(f.priceLow.value)) && (!isNumber(f.priceLow.value))) {
		alert('The low price range value must be numeric');
    		f.priceLow.focus();
		return false;
	}

    	if ((!isBlank(f.priceHigh.value)) && (!isNumber(f.priceHigh.value))) {
    		alert('The high price range value must be numeric');
    		f.priceHigh.focus();
    		return false;
    	}
    	*/

}

function CompareProduct(c) {
	var intPos
	intPos = document.ProductCompare.ProductCodes.value.indexOf(c.value + "|")
	if (intPos > -1 ) {
		document.ProductCompare.ProductCodes.value = document.ProductCompare.ProductCodes.value.replace(c.value + "|","");
	} else {
		var arrProductCodes;
		arrProductCodes = document.ProductCompare.ProductCodes.value.split("|");
		if (arrProductCodes.length > 4) {
			alert("Solo se pueden comparar 4 productos a la vez.");
			c.checked = false;
		} else {
			document.ProductCompare.ProductCodes.value = document.ProductCompare.ProductCodes.value + c.value + "|"
		}
	}
}

function SubmitProductCompare() {
	var arrProductCodes;
	arrProductCodes = document.ProductCompare.ProductCodes.value.split("|");
	if (arrProductCodes.length <= 2) {
		alert("Por favor, escoja un mínimo de 2 productos para comparar.");
	} else {
		document.ProductCompare.submit();
	}
}

function validateSearch(f) {
	if (isBlank(f.keyword.value)) {
		alert('Se ha de introducir una palabra clave');
		f.keyword.focus();
		return false;
	}
}

function submitMultipleAddToBasket(f){
	var ProductCodeList = ""
	var QuantityList = ""
	
	if(f.quantity.length>1) {
		for (var i=0;i<f.quantity.length;i++) {
			if ((!isBlank(f.quantity[i].value)) && (isValidQty(f.quantity[i]))) { 
				QuantityList += f.quantity[i].value + ","
				ProductCodeList += f.productCode[i].value + ","
			}
		}
		if (isBlank(QuantityList)) {
			alert('Como mínimo se ha de introducir una cantidad valida.');
			return false;
		}
	}
	else {	
		if ((!isBlank(f.quantity.value)) && (isValidQty(f.quantity))) { 
			QuantityList += f.quantity.value + ","
			ProductCodeList += f.productCode.value + ","
		}
		else {
			alert('Por favor, introduzca una cantidad valida.');
			return false;
		}
	}
	
	// remove trailing comma
	if (ProductCodeList.length > 0) {
		ProductCodeList = ProductCodeList.substring(0,ProductCodeList.length-1)
		QuantityList = QuantityList.substring(0,QuantityList.length-1)
		f.ProductCodeList.value = ProductCodeList
		f.QuantityList.value = QuantityList
		return true;
	} 
	else {
		return false;
	}
}

function PageProductCompare(strUrl) {
	location.href = strUrl + '&ppc=' + document.ProductCompare.ProductCodes.value
	return false;
}
