// JavaScript Document
function update(form, product){
	var input=1;
	var price=0;
	input=document.forms[0].fldQty.value;
	document.forms[0].quantity.value=input;
	price=get_price(product, document.forms[0].quantity.value);
	document.forms[0].amount.value=price;
}
function addHandlers() {
	myCorrals = new Array("thumbCorral", "thumbCorral2");
	for (var j=0; j<myCorrals.length; j++) {
		var myThumbs = document.getElementById(myCorrals[j]);
		var myImages = myThumbs.getElementsByTagName("img");
		for (var i=0; i<myImages.length; i++) {
			myImages[i].onmouseover = swapPic;
			myImages[i].onmouseout = swapOut;
		}
	}
}
function swapPic() {
	var myAttr = this.parentNode.attributes;
	myPath = new String(this.src);
	myPath = myPath.replace("thumbnails", myAttr.getNamedItem("mySize").value);
	document.getElementById(myAttr.getNamedItem("mySpot").value).src = myPath;
}
function swapOut() {
//	var myAttr = this.parentNode.attributes;
//	myPath = new String(this.src);
//	myPath = myPath.replace("medium", myAttr.getNamedItem("mySize").value);
//	document.getElementById(myAttr.getNamedItem("mySpot").value).src = myPath;
}
function preloader() {	    
	imageObj = new Image();
	// start preloading     
	for(var i=0; i<curImages.length; i++) {          
		imageObj.src=curImages[i];
	}
} 
function get_price(product, qty) {
	switch (product) {
		case "clock":
			price = "$249.00";
			break;
		case "bowl":
			price = "$99.00";
			break;
		case "customcribbage":
			price = "$350.00";
			break;
		case "icechest":
			price = "$599.00";
			break;
		case "rack":
			price = "$99.00";
			break;
		case "cribbageboard":
			price = "$149.00";
			break;
		case "lazysusan":
			price = "$129.00";
			break;
		case "lazysusan_handles":
			price = "$149.00";
			break;
		case "tray":
			price = "$149.00";
			break;
		case "holder":
			price = "$100.00";
			break;
		case "rockerholder":
			price = "$100.00";
			break;
		case "winerack":
			price = "$499.00";
			break;
		case "chair":
			if (qty>1) {
				price = "$150.00";
			} else {
				price = "$175.00";
			}
			break;
		case "stool":
			if (qty>1) {
				price = "$250.00";
			} else {
				price = "$275.00";
			}
			break;
		case "candleholder":
			if (qty>9) {
				price = "$20.00";
			} else {
				price = "$24.00";
			}
			break;
		case "candleholder_glass":
			if (qty>9) {
				price = "$25.00";
			} else {
				price = "$29.00";
			}
			break;
		case "balancer":
			if (qty>9) {
				price = "$10.00";
			} else {
				price = "$14.00";
			}
			break;
		case "balancer2":
			if (qty>9) {
				price = "$10.00";
			} else {
				price = "$14.00";
			}
			break;
		case ("pub_table"):
			price = "$235.00";
			break;
		case ("end_table"):
			price = "$225.00";
			break;
		case ("basket"):
			price = "$175.00";
			break;
		case ("platter"):
			price = "$125.00";
			break;
		case ("bottle_carrier"):
			price = "$125.00";
			break;
		default: 
			price = "$0.00";
	} // end switch statement
	return price;
}
function formatPhone(fieldObject){
	var num = fieldObject.value;
	if (num.length == 10) {
		var newNum;
		newNum = '(' + num.substring(0,3) + ')' + num.substring(3,6) + '-' + num.substring(6,10);
		fieldObject.value = newNum;
	} else if (num.length == 0) {
		return;
	} else {
		alert("Please enter a 10 digit number without punctuation or spaces.");
		fieldObject.focus();
		fieldObject.select();
	}
}