/////////////////////////////////////

function checkAddToBasket() {
	var formRef = document.buy;
	var errorFlag = 0;
	var errorAlert = "You have not entered all the details for your purchase. Please complete the following:\n";
	var itemAlert;
	var itemFlag;
	var itemName;
	
	var noBuyItems = formRef.NoItems.value;
	
	var nullCount = 0;
	for (i=0; i<noBuyItems; i++) {
		itemFlag = 0;
		//Evaluate Quantity, Colour and if there is a select size, the selected index, same for colour
		quantity = eval("formRef.Quantity_" + i + ".value")
		
		if (eval("formRef.Colour_" + i)) {
			colour = eval("formRef.Colour_" + i + ".selectedIndex")
		}
		
		if (eval("formRef.SKUID_" + i)) {
			itemref = eval("formRef.SKUID_" + i + ".selectedIndex")
		}
		
		//alert("Quantity = " + quantity + "\nColour = " + colour + "\nSize = " + itemref)
		
		if (!((quantity == "") && ((colour == 0) || (!colour)) && ((itemref == 0) || (!itemref))))  {
			//Get name of item
			itemName = eval("formRef.SKUName_" + i + ".value");
			
			itemAlert = "\n- " + itemName + "  /";

			if (quantity == "") {
				itemAlert += " quantity /";
				itemFlag = 1;
				errorFlag = 1;
			}

			if (isNaN(quantity)) {
				itemAlert += " numerical quantity /";
				itemFlag = 1;
				errorFlag = 1;
			}

			if (colour == 0) {
				itemAlert += " colour /";
				itemFlag = 1;
				errorFlag = 1;
			}

			if (eval("formRef.SKUID_" + i)) {
				if (itemref == 0) {
					itemAlert += " size /";
					itemFlag = 1;
					errorFlag = 1;
				}
			}

			if (itemFlag == 1) {
				errorAlert += itemAlert
			}
		} else {
			nullCount += 1
		}
	
	}
	
	errorAlert += "\n\nAlternatively, click the 'Clear form' button and re-enter your purchasing details.";
	errorAlert += "\nNow click OK to return to the form and correct your purchasing details.";
	
	if (errorFlag == 1) {
		alert(errorAlert);
		return false;
	} else if (nullCount == noBuyItems) {
		alert("You have not selected any items");
		return false;
	}
	
	return true;
}

/////////////////////////////////////

function openWin(theURL, theName, theAtt) {
	var winName, winAtt, winURL;
	
	winURL = theURL;
	
	if (theName) {
		winName = theName;
	} else {
		winName = "popup";
	}
	
	if (theAtt) {
		winAtt = theAtt;
	} else {
		winAtt = "width=755,height=600,menubar=yes,resizable=yes,scrollbars=yes,status=yes";
	}
	
	window.open(winURL,winName,winAtt);
}

/////////////////////////////////////

function resizeForms() {
	var resizeValue = 1.6;
	var bType = navigator.appName;

	if (bType != 'Netscape') {
		for (x=0;x<document.forms.length;x++) {
			for (y=0;y<document.forms[x].elements.length;y++) {
				var formControl = document.forms[x].elements[y];
				if ((formControl.type.toLowerCase() == "text") || (formControl.type.toLowerCase() == "password") || (formControl.type.toLowerCase() == "file")) {
					formControl.size = (formControl.size * resizeValue);
				} else if (formControl.type == "textarea") {
					formControl.cols = (formControl.cols * (resizeValue * 0.9));
				}
			}
		}
	}
}

/////////////////////////////////////

function checkTax() {
	if (document.taxInfo.selectTax.selectedIndex == 0) {
		alert("Please choose a region before proceeding");
		return false;
	}
	
	return true;
}


////////////////////////////////////////

function busNav() {
	var page = document.form1.selectyourbusiness.options[document.form1.selectyourbusiness.selectedIndex].value;
	if (page != "") {
		document.location.href = page;
	}
}

/////////////////////////////////////