function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
	    (key==9) || (key==13) || (key==27) )
	   return true;
	else if (((".0123456789").indexOf(keychar) > -1))
	   return true;
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
	   return false;
}


function calc_sqft(myPrice,QTYField){
	
	var ratio, constrain, myWidth, myHeight, totalSqft, totalPrice;
	ratio = document.getElementById("ratio").value;
	myConstraint = document.getElementById("constrain");
	myHeight = document.getElementById("screen_height").value;
	myWidth = document.getElementById("screen_width").value;
	totalSqft = document.getElementById("sqft_total");
	totalPrice = document.getElementById("price_total");
	NEW_HEIGHT = document.getElementById("TEXTBOX___591___"+ QTYField +"___36");
	NEW_WIDTH = document.getElementById("TEXTBOX___592___"+ QTYField +"___37");
	NEWQTY = document.getElementById("QTY."+ QTYField);
	
	if(myWidth==""){
		alert("Please Enter a Width");
		return;
	}
	 
	switch (ratio) {
		case "custom":
			if(myHeight==""){
				alert("Please Enter a Height");
				return;
			}
			mysqft = Math.ceil((myWidth * myHeight)/144);
			break;
		case "wide":
			calcwidth = 16;
			calcHeight = 9;
			myHeight = Math.ceil((myWidth * calcHeight)/calcwidth);
			document.getElementById("screen_height").value = Math.ceil(myHeight);
			mysqft = (Math.ceil(myWidth * myHeight)/144);
			break;
		case "normal":
			calcwidth = 4;
			calcHeight = 3;
			myHeight = Math.ceil((myWidth * calcHeight)/calcwidth);
			document.getElementById("screen_height").value = Math.ceil(myHeight);
			mysqft = (Math.ceil(myWidth * myHeight)/144);
			break;
	}
	
	NEW_HEIGHT.value= myHeight;
	NEW_WIDTH.value = myWidth;
	NEWQTY.value = Math.ceil(mysqft);
	totalSqft.value = Math.ceil(mysqft);
	totalPrice.value = (mysqft * myPrice).toFixed(2);
	
}