		window.onload = initForm;
		window.onunload = function() {};
		
		function initForm() {
			document.getElementById("shape").onchange = checkShape;
			document.getElementById("size").onchange = checkSize;
			document.getElementById("clothColor").onchange = calculate;
			document.getElementById("seating").onchange = calculate;

			MM_preloadImages('images/navbar_mid06_pressevents_on.png','images/navbar_mid08_apparel_on.png','images/navbar_mid10_contact_on.png','images/navbar_mid08_about_on.png','images/navbar_mid02_tables_on.png','images/navbar_mid04_rental_on.png','images/navbar_mid06_apparel_on.png','images/cloth/cloth_Scarlet_120px.gif','images/cloth/cloth_Burgundy_120px.gif','images/cloth/cloth_TrumpCard_120px.gif','images/cloth/cloth_Imperial_120px.gif','images/cloth/cloth_Playboy_120px.gif','images/cloth/cloth_Hypnotic_120px.gif','images/cloth/cloth_Chocolate_120px.gif','images/cloth/cloth_DakotaGold_120px.gif','images/cloth/cloth_Bronze_120px.gif','images/cloth/cloth_Margarita_120px.gif','images/cloth/cloth_Kryptonite_120px.gif','images/cloth/cloth_PineGreen_120px.gif','images/cloth/cloth_BlackTeal_120px.gif','images/cloth/cloth_Moondust_120px.gif','images/cloth/cloth_NavyBlue_120px.gif','images/cloth/cloth_RoyalBlue_120px.gif','images/cloth/cloth_DakotaSky_120px.gif','images/cloth/cloth_Mercedes_120px.gif','images/cloth/cloth_Black_120px.gif','images/finish/finish_PickledOak_250px.gif','images/finish/finish_Natural_250px.gif','images/finish/finish_GoldenOak_250px.gif','images/finish/finish_PuritanPine_250px.gif','images/finish/finish_Fruitwood_250px.gif','images/finish/finish_IpswichPine_250px.gif','images/finish/finish_Driftwood_250px.gif','images/finish/finish_Cherry_250px.gif','images/finish/finish_ColonialMaple_250px.gif','images/finish/finish_Gunstock_250px.gif','images/finish/finish_EnglishChestnut_250px.gif','images/finish/finish_EarlyAmerican_250px.gif','images/finish/finish_Provincial_250px.gif','images/finish/finish_SpecialWalnut_250px.gif','images/finish/finish_RedChestnut_250px.gif','images/finish/finish_SedonaRed_250px.gif','images/finish/finish_RedOak_250px.gif','images/finish/finish_RedMahogany_250px.gif','images/finish/finish_DarkWalnut_250px.gif','images/finish/finish_Jacobean_250px.gif','images/finish/finish_Ebony_250px.gif')
		}
		
		function checkShape()
		{
			var oct = new Array("Four Foot"); 
			var ova = new Array("Six Foot", "Seven Foot +$20", "Eight Foot +$30");
			var octseats = new Array("Eight Player");
			var ovaseats = new Array("Eight Player", "Ten Player");
			var clothColors = new Array ("Standard Green", "Black +$40","Black/Teal +$40","Bronze +$40","Burgundy +$40","Chocolate +$40","Dakota Gold +$40","Dakota Sky +$40","Forest Green +$40","Hypnotic +$40","Imperial +$40","Kryptonite +$40","Margarita +$40","Mercedes +$40","Moondust +$40","Navy Blue +$40","Pine Green +$40","Playboy +$40","Royal Blue +$40","Scarlet +$40","Trump Card +$40");
		
			if (document.form1.shape.value=="Oval"){
				document.form1.size.options.length = 0;
				document.form1.seating.options.length = 0;
				for (var i=0; i < ova.length;++i){ 
					addOption(document.form1.size, ova[i], ova[i]);
				}
				for (var i=0; i < ovaseats.length;++i){
					addOption(document.form1.seating, ovaseats[i], ovaseats[i]);
				}				
			}
			if (document.form1.shape.value=="Octagon") {
				document.form1.size.options.length = 0;
				document.form1.seating.options.length = 0;				
				for (var i=0; i < oct.length;++i){
					addOption(document.form1.size, oct[i], oct[i]);
				}
				for (var i=0; i < octseats.length;++i){
					addOption(document.form1.seating, octseats[i], octseats[i]);
				}
			}
			document.form1.clothColor.options.length = 0;
			
			for (var i=0; i < clothColors.length;++i)
			{
					addOption(document.form1.clothColor, clothColors[i], clothColors[i]);
			}
		calculate();
		
		}
		function checkSize()
		{
			var sixfootseats = new Array("Eight Player");
			var otherseats = new Array ("Eight Player", "Ten Seats");
			if (document.form1.size.value=="Six Foot") {
				document.form1.seating.options.length = 0;	
				for (var i=0; i < sixfootseats.length;++i){
					addOption(document.form1.seating, sixfootseats[i], sixfootseats[i]);
				}
			} 
			else {
				document.form1.seating.options.length = 0;	
				for (var i=0; i < otherseats.length;++i){
					addOption(document.form1.seating, otherseats[i], otherseats[i]);
				}	
			}
			calculate();
		}
		function addOption(selectbox,text,value )
		{
			var optn = document.createElement("OPTION");
			optn.text = text;
			optn.value = value;
			selectbox.options.add(optn);
		}

  function calculate()
		{
			if (document.form1.shape.value=="Octagon") { var total= 400 } else { var total = 400; }
			var temp = new Array();
			temp=document.form1.size.value.split("$");	
			temp[1]=parseInt(temp[1]);
			if (isInt(temp[1])) { total = total + temp[1]; }
			temp=document.form1.clothColor.value.split("$");	
			temp[1]=parseInt(temp[1]);
			if (isInt(temp[1])) { total = total + temp[1]; }
			document.form1.totalprice.value=total;	
			
			// var x = document.getElementById("chip");
			// var src = x.getAttribute("src");
			halftotal = parseInt(total / 2);
			document.getElementById("downamount").innerHTML = "$" + halftotal;
			// x.setAttribute("src", "chip"+halftotal+".png");
 		}
				
 function isInt(x) {
   var y=parseInt(x);
   if (isNaN(y)) return false;
   return x==y && x.toString()==y.toString();
 } 
				
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
