function popwin(url, winwidth, winheight)
{
	window.open(url,'kooltools','height=' + winheight + ',width=' + winwidth + ',status=yes,toolbar=no,menubar=no,location=no,top=10,left=10');
}

function verifyOption(formname,price1,price2,price3,productname)
{
	var Shipping_Option = 0;
	var arrFormElements = document.getElementsByTagName("form");
	var theForm = null;
	var i = 0;
	
	for (; i < arrFormElements.length; i++) {
		if (arrFormElements[i].name == formname) {
			theForm = arrFormElements[i];
			break;
		}
	}
	
	if (theForm) {
		var arrSelectElements = theForm.getElementsByTagName("select");
		var arrInputElements = theForm.getElementsByTagName("input");
		var theDropDown = null;
		var priceEle = null;
		var productEle = null;

		for (i = 0; i < arrSelectElements.length; i++) {
			if (arrSelectElements[i].name == "dock") {
				theDropDown = arrSelectElements[i];
				break;
			}
		}
		
		for (i = 0; i < arrInputElements.length; i++) {
			if (arrInputElements[i].name == "price") {
				priceEle = arrInputElements[i];
			} else if (arrInputElements[i].name == "product") {
				productEle = arrInputElements[i];
			}
		}
		
		if (theDropDown) {
			Shipping_Option = theDropDown.value;

			switch(Shipping_Option) {
				case '0':
					alert('Please select a Delivery Type');
					return false;
					break;
				case '1':
					priceEle.value = price1;
					productEle.value = productname + " (Loading Dock Available)";
					break;
				case '2':
					priceEle.value = price2;
					productEle.value = productname + " (No Loading Dock)";
					break;
				case '3':
					priceEle.value = price3;
					productEle.value = productname + " (Residential Delivery)";
					break;
				default:
					return false;
					break;
			}
			
			return true;
		}
	}
	
	return false;
}

function setPrice(formname, itemcost, shippingcost)
{
	var ConfirmOrder;

	ConfirmOrder = window.confirm("You won't be able to alter the quantities for this item on order pages. Please verify the quantity you are ordering.\nPress OK to Continue -or- Cancel to change the quantity.");

	if(ConfirmOrder){
		var Quantity, Price, Shipping;

		Quantity= eval('document.all.' + formname + '.ordqty.value');

		switch(Quantity)
		{
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
			case '10':
				Shipping = shippingcost;
				break;
			case '20':
				Shipping = shippingcost * 2;
				break;
			case '30':
				Shipping = shippingcost * 3;
				break;
			case '40':
				Shipping = shippingcost * 4;
				break;
			case '50':
				Shipping = shippingcost * 5;
				break;
			default:
				window.event.returnValue = false;
				break;
		}

		Price = ((Quantity * itemcost) + Shipping) / Quantity;

		eval('document.all.' + formname + '.qty.value = ' + Quantity);
		eval('document.all.' + formname + '.price.value =' + Price);
	}
	else{
		eval('document.all.' + formname + '.qty.value = 0');
		window.event.returnValue = false;
	}
}


/* Enlarge Image */

	function zoom(url)
	{
		var options = 'status=no,toolbar=no,menubar=no,location=no,top=10,left=10';
		var paramOptions = arguments[1];
		
		if (paramOptions && typeof paramOptions == "object") {
			for (i in paramOptions) {
				options += ',' + i + '=' + paramOptions[i];
			}
		}
		
		window.open(url,'zoom','height=' + 500 + ',width=' + 500 + ',' + options);
	}
