//create product array and product class
prodArray=new Array();
function prodObj(dText, bText, sku, qty, price, orig_price, category, subcateogry, whofor, packageof, sa_code, color, print_color, dTitle, bTitle, size, pic){
	this.dText=dText;
	this.bText=bText;
	this.sku=sku;
	this.qty=qty;
	this.price=price;
	this.orig_price=orig_price;
	this.category=category;
	this.subcateogry=subcateogry;
	this.whofor=whofor;
	this.packageof=packageof;
	this.sa_code=sa_code;
	this.color=color;
	this.print_color=print_color;
	this.dTitle=dTitle;
	this.bTitle=bTitle;
	this.size=size;
	this.pic=pic;
}

//validate form submission 
function validateSubmit(theForm){
	if(typeof(theForm.sku.selectedIndex)=='undefined') selectedSku=theForm.sku.value;
	else selectedSku=theForm.sku.options[theForm.sku.selectedIndex].value;
	quantityREString="[^0-9]";
	quantityRE=new RegExp(quantityREString);
	//see if qty entered is number
	if(quantityRE.test(theForm.qty.value)){
		alert("Please enter only numbers for the Quantity.");
		theForm.qty.focus();
		theForm.qty.select();
		return false;
	}
	//check if qty greater than onhand
	else if(prodArray[selectedSku].qty < theForm.qty.value){
		keepQty=confirm("There are currently "+prodArray[selectedSku].qty+" of these in stock. \nYou can still place this order, but we'll need a week or so to put this item into production again. If you want to stop and adjust your quantity, just click Cancel.");
		if(!keepQty){
			theForm.qty.focus();
			theForm.qty.select();
			return false;
		}
	}
	return true;
}

function changeSize(theForm){
	//prepare new data for selection
	if(typeof(theForm.sku.selectedIndex)=='undefined') selectedSku=theForm.sku.value;
	else selectedSku=theForm.sku.options[theForm.sku.selectedIndex].value;
	priceForChoice=formatCurrency(prodArray[selectedSku].price);
	origPriceForChoice=formatCurrency(prodArray[selectedSku].orig_price);
	//format new conent
	if(origPriceForChoice!=0 && origPriceForChoice!='' && origPriceForChoice!='0')newPriceTxt="<span style='font-weight:bold;'>Price:</span> <span style='color:red;'>$"+priceForChoice+"</span> &nbsp;<span style='text-decoration:line-through;'>$"+origPriceForChoice+"</span> &nbsp;Cdn (Click for <a href='googleexchange.php?cadAmount="+priceForChoice+"' target='_blank' onclick='return false;' rel='lightbox[itemCurrency 710 400]' title='Canadian Dollars into US'>currency conversion</a>)";
	else newPriceTxt="<span style='font-weight:bold;'>Price:</span> $"+priceForChoice+" &nbsp;Cdn (Click for <a href='googleexchange.php?cadAmount="+priceForChoice+"' target='_blank' onclick='return false;' rel='lightbox[itemCurrency 710 400]' title='Canadian Dollars into US'>currency conversion</a>)";
	newProdTxt="<span style='font-weight:bold;'>Product Description:</span> "+prodArray[selectedSku].dText;
	if(prodArray[selectedSku].bText != '')newProdTxt=newProdTxt+"<div style='margin-top:12px;'>"+prodArray[selectedSku].bText+"</div>"
	//replace content on screen
	document.getElementById('descDiv').innerHTML=newProdTxt;
	document.getElementById('priceDiv').innerHTML=newPriceTxt;
}
