/*

Problem:
	We need a script that can take the value of an option and the value of any selected checkbox and combine them to make a url.
	1. Determine if any checkboxes are selected.
	2. Determine which checkboxes are selected.
	3. Add the value of the selected checkboxes onto the end of the url from the value of the selected option.
	
	define variables
	get the url of the selected option
	while there's a selected checkbox
		get the value of the checkbox
		save the value of the checkbox
	end while
	print the url of the selected option + the value of the checkbox
	
	variables:
		checkedBoxes
		urlBase	
*/


/* ONE DROPDOWN WITH CHECKBOXES */
function multiOptionsExtras() {
	var checkedBoxes = new Array();
	if (document.purchase.extraOptions.length > 0 ) {
		for (i=0; i < document.purchase.extraOptions.length; i++) {
			if (document.purchase.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase.extraOptions[i].value);
			}
		}
	} else {
		if (document.purchase.extraOptions.checked) {
			checkedBoxes.push(document.purchase.extraOptions.value);
		}
	}
	
	var extras = checkedBoxes.join("&");
	var urlBase = document.purchase.LinkUP.options[document.purchase.LinkUP.selectedIndex].value;
	var	productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function multiOptionsExtras1() {
	var checkedBoxes = new Array();
	if (document.purchase1.extraOptions.length > 0 ) {
		for (i=0; i < document.purchase1.extraOptions.length; i++) {
			if (document.purchase1.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase1.extraOptions[i].value);
			}
		}
	} else {
		if (document.purchase1.extraOptions.checked) {
			checkedBoxes.push(document.purchase1.extraOptions.value);
		}
	}
	
	var extras = checkedBoxes.join("&");
	var urlBase = document.purchase1.LinkUP.options[document.purchase1.LinkUP.selectedIndex].value;
	var	productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function multiOptionsExtras2() {
	var checkedBoxes = new Array();
	if (document.purchase2.extraOptions.length > 0 ) {
		for (i=0; i < document.purchase2.extraOptions.length; i++) {
			if (document.purchase2.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase2.extraOptions[i].value);
			}
		}
	} else {
		if (document.purchase2.extraOptions.checked) {
			checkedBoxes.push(document.purchase2.extraOptions.value);
		}
	}
	
	var extras = checkedBoxes.join("&");
	var urlBase = document.purchase2.LinkUP.options[document.purchase2.LinkUP.selectedIndex].value;
	var	productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function multiOptionsExtras3() {
	var checkedBoxes = new Array();
	if (document.purchase3.extraOptions.length > 0 ) {
		for (i=0; i < document.purchase3.extraOptions.length; i++) {
			if (document.purchase3.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase3.extraOptions[i].value);
			}
		}
	} else {
		if (document.purchase3.extraOptions.checked) {
			checkedBoxes.push(document.purchase3.extraOptions.value);
		}
	}
	
	var extras = checkedBoxes.join("&");
	var urlBase = document.purchase3.LinkUP.options[document.purchase3.LinkUP.selectedIndex].value;
	var	productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function multiOptionsExtras4() {
	var checkedBoxes = new Array();
	if (document.purchase4.extraOptions.length > 0 ) {
		for (i=0; i < document.purchase4.extraOptions.length; i++) {
			if (document.purchase4.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase4.extraOptions[i].value);
			}
		}
	} else {
		if (document.purchase4.extraOptions.checked) {
			checkedBoxes.push(document.purchase4.extraOptions.value);
		}
	}
	
	var extras = checkedBoxes.join("&");
	var urlBase = document.purchase4.LinkUP.options[document.purchase4.LinkUP.selectedIndex].value;
	var	productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}




/* ONE DROPDOWN */
function multiOptions() {
	window.location.href= document.purchase.LinkUP.options[document.purchase.LinkUP.selectedIndex].value;
}

function multiOptions1() {
	window.location.href =document.purchase1.LinkUP.options[document.purchase1.LinkUP.selectedIndex].value;
}

function multiOptions2() {
	window.location.href =document.purchase2.LinkUP.options[document.purchase2.LinkUP.selectedIndex].value;
}

function multiOptions3() {
	window.location.href =document.purchase3.LinkUP.options[document.purchase3.LinkUP.selectedIndex].value;
}

function multiOptions4() {
	window.location.href =document.purchase4.LinkUP.options[document.purchase4.LinkUP.selectedIndex].value;
}

function multiOptions5() {
	window.location.href =document.purchase5.LinkUP.options[document.purchase4.LinkUP.selectedIndex].value;
}

function multiOptions6() {
	window.location.href =document.purchase6.LinkUP.options[document.purchase4.LinkUP.selectedIndex].value;
}

function multiOptions7() {
	window.location.href =document.purchase7.LinkUP.options[document.purchase4.LinkUP.selectedIndex].value;
}

/*  TWO DROPDOWNS */
function multiOptionsExtraOptions() {
	var extras = document.purchase.extraLink1.options[document.purchase.extraLink1.selectedIndex].value;
	var moreExtras = document.purchase.extraLink2.options[document.purchase.extraLink2.selectedIndex].value;
	var urlBase = document.purchase.LinkUP.options[document.purchase.LinkUP.selectedIndex].value;
	var productLink = urlBase + "&" + extras + "&" + moreExtras;
	window.location.href = productLink;
}


/* JUST CHECKBOXES */
function makeCombo(mainSku) {
	var checkedBoxes = new Array();
	var j = 0;
	var extras;
	if (document.purchase.extraOptions.length) {
		for (i=0; i < document.purchase.extraOptions.length; i++) {
			if (document.purchase.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase.extraOptions[i].value);
			}
		}
		extras = checkedBoxes.join("&");
	} else {
		checkedBoxes = document.purchase.extraOptions.value;
		extras = checkedBoxes;
	};
	var urlBase = "https://store.baseballtips.com/ShoppingCart.asp?ProductCode=" + mainSku;
	var productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function makeCombo1(mainSku) {
	var checkedBoxes = new Array();
	var j = 0;
	var extras;
	if (document.purchase1.extraOptions.length) {
		for (i=0; i < document.purchase1.extraOptions.length; i++) {
			if (document.purchase1.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase1.extraOptions[i].value);
			}
		}
		extras = checkedBoxes.join("&");
	} else {
		checkedBoxes = document.purchase1.extraOptions.value;
		extras = checkedBoxes;
	};
	var urlBase = "https://store.baseballtips.com/ShoppingCart.asp?ProductCode=" + mainSku;
	var productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function makeCombo2(mainSku) {
	var checkedBoxes = new Array();
	var j = 0;
	var extras;
	if (document.purchase2.extraOptions.length) {
		for (i=0; i < document.purchase2.extraOptions.length; i++) {
			if (document.purchase2.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase2.extraOptions[i].value);
			}
		}
		extras = checkedBoxes.join("&");
	} else {
		checkedBoxes = document.purchase2.extraOptions.value;
		extras = checkedBoxes;
	};
	var urlBase = "https://store.baseballtips.com/ShoppingCart.asp?ProductCode=" + mainSku;
	var productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function makeCombo3(mainSku) {
	var checkedBoxes = new Array();
	var j = 0;
	var extras;
	if (document.purchase3.extraOptions.length) {
		for (i=0; i < document.purchase3.extraOptions.length; i++) {
			if (document.purchase3.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase3.extraOptions[i].value);
			}
		}
		extras = checkedBoxes.join("&");
	} else {
		checkedBoxes = document.purchase3.extraOptions.value;
		extras = checkedBoxes;
	};
	var urlBase = "https://store.baseballtips.com/ShoppingCart.asp?ProductCode=" + mainSku;
	var productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function makeCombo4(mainSku) {
	var checkedBoxes = new Array();
	var j = 0;
	var extras;
	if (document.purchase4.extraOptions.length) {
		for (i=0; i < document.purchase4.extraOptions.length; i++) {
			if (document.purchase4.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase4.extraOptions[i].value);
			}
		}
		extras = checkedBoxes.join("&");
	} else {
		checkedBoxes = document.purchase4.extraOptions.value;
		extras = checkedBoxes;
	};
	var urlBase = "https://store.baseballtips.com/ShoppingCart.asp?ProductCode=" + mainSku;
	var productLink = urlBase + "&" + extras;
	window.location.href = productLink;
}

function checkOutLine() {
	var checkedBoxes = new Array();
	var j = 0;
	var extras;
	if (document.purchase.extraOptions.length) {
		for (i=0; i < document.purchase.extraOptions.length; i++) {
			if (document.purchase.extraOptions[i].checked) {
				checkedBoxes.push(document.purchase.extraOptions[i].value);
			}
		}
		extras = checkedBoxes.join("&");
	} else {
		checkedBoxes = document.purchase.extraOptions.value;
		extras = checkedBoxes;
	};
	var productLink = "https://store.baseballtips.com/ShoppingCart.asp?" + extras;
	window.location.href = productLink;
}