function checkDecimals(fieldName, fieldValue) {

decallowed = 0;  // how many decimals are allowed?
if (isNaN(fieldValue) || fieldValue == "") {
alert("Oops!  That does not appear to be a valid number.  Please try again.");
fieldName.select();
fieldName.focus();
}
else {
if (fieldValue.indexOf('.') == -1) fieldValue += ".";
dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);

if (dectext.length > decallowed)
{
alert ("Oops!  Please enter a number with no decimal places.  Please try again.");
fieldName.select();
fieldName.focus();
      }
else {
// alert ("That number validated successfully.");
      }
   }
}

//checkboxes
function CheckChoice(whichbox)
	{
		with (whichbox.form)
		{
			//Handle differently, depending on type of input box.
			if (whichbox.type == "radio")
			{
				//First, back out the prior radio selection's price from the total:
				hiddentotal.value = eval(hiddentotal.value) - eval(hiddenpriorradio.value);
				//Then, save the current radio selection's price:
				hiddenpriorradio.value = eval(whichbox.price);
				//Now, apply the current radio selection's price to the total:
				hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price);
			}
			else
			{
				//If box was checked, accumulate the checkbox value as the form total,
				//Otherwise, reduce the form total by the checkbox value:
				if (whichbox.checked == false)
					{ hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.value); }
				else 	{ hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.value); }
			}

			//Ensure the total never goes negative (some browsers allow radiobutton to be deselected):
			if (hiddentotal.value < 0)
				{
				InitForm();
				}

			//Now, return with formatted total:
			return(formatCurrency(hiddentotal.value)) ;
		}
	}

	//Define function to format a value as currency:
	function formatCurrency(num)
	{
	   // Courtesy of http://www7.brinkster.com/cyanide7/
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		   num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		    cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		    num = num.substring(0,num.length-(4*i+3))+','+
		          num.substring(num.length-(4*i+3));
  	   // return (((sign)?'':'-') + '$' + num + '.' + cents);
		 return (((sign)?'':'-') + num + '.' + cents);
	}

	//Define function to init the form on reload:
	function InitForm()
		{
		//Reset the displayed total on form:
		document.myform.total.value='0';
		document.myform.hiddentotal.value=0;
		//document.myform.hiddenpriorradio.value=0;
		document.myform2.total.value='0';
		document.myform2.hiddentotal.value=0;
		//document.myform2.hiddenpriorradio.value=0;
		//document.myform2.hiddenpriorradio.value=0;

		//Set all checkboxes and radio buttons on form-1 to unchecked:
		for (xx=0; xx < document.myform.elements.length; xx++)
		{
		   if (document.myform.elements[xx].type == 'checkbox' | document.myform.elements[xx].type == 'radio')
			{
			document.myform.elements[xx].checked = false;
			}
		}
		//Set all checkboxes and radio buttons on form-2 to unchecked:
		for (xx=0; xx < document.myform2.elements.length; xx++)
		{
		   if (document.myform2.elements[xx].type == 'checkbox' | document.myform2.elements[xx].type == 'radio')
			{
			document.myform2.elements[xx].checked = false;
			}
		}

	}
	
	function DoSilk(x){ 
var productbase = document.forms.formjunk.productbase.value;
var ssextraf = document.forms.myform.sscolorfront.value;
var ssextrab = document.forms.myform.sscolorback.value;
var ssextrar = document.forms.myform.sscolorright.value;
var ssextral = document.forms.myform.sscolorleft.value;
var ssextra = (ssextraf) - (-ssextrab) - (-ssextrar) - (-ssextral);
if (1<=x && x<=20) y=((0.0524*x*x)-(2.1391*x)+(32.04575)+((5.017*Math.pow(x, -0.364))*(ssextra-1)))-(-productbase);
if (20<x && x<=50) y=(39.779 * Math.pow(x, -0.4532)+((5.017*Math.pow(x, -0.364))*ssextra))-(-productbase);
if (50<x && x<=288) y=((10.4835 * Math.pow(x, -0.121635))+.2+((5.017*Math.pow(x, -0.364))*ssextra))-(-productbase);
if (288<x && x<=4200) y=((10.4835 * Math.pow(x, -0.121635))+.2+((5.017*Math.pow(x, -0.364))*ssextra))-(-productbase);
if (4200<x) y=(4+((5.017*Math.pow(x, -0.364))*ssextra))-(-productbase);

if (document.forms.myform.sscolorfront) document.forms.orderform_16180.colorside1.value = 'Front - ' + document.forms.myform.sscolorfront.value + '  Colors';
if (document.forms.myform.sscolorback) document.forms.orderform_16180.colorside2.value = 'Back - ' + document.forms.myform.sscolorback.value + '  Colors';
if (document.forms.myform.sscolorright) document.forms.orderform_16180.colorside3.value = 'Right - ' + document.forms.myform.sscolorright.value + '  Colors';
if (document.forms.myform.sscolorleft) document.forms.orderform_16180.colorside4.value = 'Left - ' + document.forms.myform.sscolorleft.value + '  Colors';
} 

function DoHeat(x){ 
var productbase = document.forms.formjunk.productbase.value;
var htextra = document.forms.myform.total.value;
if (1<=x && x<=100) y=((10.87*Math.pow(x,-.17))+1.12-(-htextra))-(-productbase); 
if (100<x) y=(6-(-htextra))-(-productbase); 

if (document.forms.myform.htfront.checked) {
document.forms.orderform_16180.colorside1.value = 'Print on Front';
}
else {
document.forms.orderform_16180.colorside1.value = 'Nothing on Front';
}
if (document.forms.myform.htback.checked) {
document.forms.orderform_16180.colorside2.value = 'Print on Back';
}
else {
document.forms.orderform_16180.colorside2.value = 'Nothing on Back';
}
if (document.forms.myform.htrsleeve.checked) {
document.forms.orderform_16180.colorside3.value = 'Print on R. Sleeve';
}
else {
document.forms.orderform_16180.colorside3.value = 'Nothing on R. Sleeve';
}
if (document.forms.myform.htlsleeve.checked) {
document.forms.orderform_16180.colorside4.value = 'Print on L. Sleeve';
}
else {
document.forms.orderform_16180.colorside4.value = 'Nothing on L. Sleeve';
}
} 

function Radio(obj){ 

var productbase = document.forms.formjunk.productbase.value;
var finalqty = 0;
var fields = document.forms["formjunk"].elements;
for (var i=0;i<fields.length;i++) {
  if (fields[i].name.indexOf("product_options_amount") == 0) {
    finalqty += new Number(fields[i].value);
  }
}
document.forms.orderform_16180.amount.value = finalqty;

var subject=document.forms.orderform_16180;
var subject1 = document.forms.imagestuff;
var total = document.forms.formjunk.product_options_amount1.value;
var htextra = document.forms.myform.total.value;
var ssextraf = document.forms.myform.sscolorfront.value;
var ssextrab = document.forms.myform.sscolorback.value;
var ssextrar = document.forms.myform.sscolorright.value;
var ssextral = document.forms.myform.sscolorleft.value;
var ssextra = (ssextraf) - (-ssextrab) - (-ssextrar) - (-ssextral);
var items =  '(' + (document.forms.formjunk.product_options_amount1.value) + ')' + ' - ' + (document.forms.formjunk.product_options_Size1.value) + ' - ' + (document.forms.formjunk.product_options_color1.value);
var printstyle = "None Selected";

if (subject1.yihorwone[0].checked) {var yi1 ="Height"};
if (subject1.yihorwone[1].checked) {var yi1 ="Width"};
if (subject1.yihorwtwo[0].checked) {var yi2 ="Height"};
if (subject1.yihorwtwo[1].checked) {var yi2 ="Width"};
if (subject1.yihorwthree[0].checked) {var yi3 ="Height"};
if (subject1.yihorwthree[1].checked) {var yi3 ="Width"};
if (subject1.yihorwfour[0].checked) {var yi4 ="Height"};
if (subject1.yihorwfour[1].checked) {var yi4 ="Width"};

if (subject1.rmhorwone[0].checked) {var rm1 ="Height"};
if (subject1.rmhorwone[1].checked) {var rm1 ="Width"};
if (subject1.rmhorwtwo[0].checked) {var rm2 ="Height"};
if (subject1.rmhorwtwo[1].checked) {var rm2 ="Width"};
if (subject1.rmhorwthree[0].checked) {var rm3 ="Height"};
if (subject1.rmhorwthree[1].checked) {var rm3 ="Width"};
if (subject1.rmhorwfour[0].checked) {var rm4 ="Height"};
if (subject1.rmhorwfour[1].checked) {var rm4 ="Width"};

if (subject1.alignGroup1[0].checked) {var txt1 ="Left"};
if (subject1.alignGroup1[1].checked) {var txt1 ="Center"};
if (subject1.alignGroup1[2].checked) {var txt1 ="Right"};
if (subject1.alignGroup2[0].checked) {var txt2 ="Left"};
if (subject1.alignGroup2[1].checked) {var txt2 ="Center"};
if (subject1.alignGroup2[2].checked) {var txt2 ="Right"};
if (subject1.alignGroup3[0].checked) {var txt3 ="Left"};
if (subject1.alignGroup3[1].checked) {var txt3 ="Center"};
if (subject1.alignGroup3[2].checked) {var txt3 ="Right"};
if (subject1.alignGroup4[0].checked) {var txt4 ="Left"};
if (subject1.alignGroup4[1].checked) {var txt4 ="Center"};
if (subject1.alignGroup4[2].checked) {var txt4 ="Right"};

if (subject1.blank.checked) {subject.imagearea.value = "Blank - There should be no printing or image specifications." + "\n" + "\n";}
else { 
subject.imagearea.value = "";
}
if (subject1.idea.checked) {subject.imagearea.value = subject.imagearea.value + ' (Idea - ' + subject1.ideaboxone.value + ') ' +   ' (Uploaded File - ' + subject1.FileUpload5.value + ')' + "\n" + "\n"};
if (subject1.text1.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Text - ' + subject1.texttextone.value + ') ' +  ' (Aligned: ' + txt1 +') (Font - ' + subject1.textfontone.value + ') ' +   ' (Size - ' + subject1.textsizeone.value + ' inches) ' +   ' (Color - ' + subject1.textcolorone.value + ') ' +   ' (Position - ' + subject1.textposone.value + ')' +"\n" + "\n"};
if (subject1.text2.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Text2 - ' + subject1.texttexttwo.value + ') ' +  ' (Aligned: ' + txt2 +') (Font2 - ' + subject1.textfonttwo.value + ') ' +   ' (Size2 - ' + subject1.textsizetwo.value + ' inches) ' +   ' (Color2 - ' + subject1.textcolortwo.value + ') ' +   ' (Position2 - ' + subject1.textpostwo.value + ')' +"\n" + "\n"};
if (subject1.text3.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Text3 - ' + subject1.texttextthree.value + ') ' +  ' (Aligned: ' + txt3 +') (Font3 - ' + subject1.textfontthree.value + ') ' +   ' (Size3 - ' + subject1.textsizethree.value + ' inches) ' +   ' (Color3 - ' + subject1.textcolorthree.value + ') ' +   ' (Position3 - ' + subject1.textposthree.value + ')' +"\n" + "\n"};
if (subject1.text4.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Text4 - ' + subject1.texttextfour.value + ') ' +  ' (Aligned: ' + txt4 +') (Font4 - ' + subject1.textfontfour.value + ') ' +   ' (Size4 - ' + subject1.textsizefour.value + ' inches) ' +   ' (Color4 - ' + subject1.textcolorfour.value + ') ' +   ' (Position4 - ' + subject1.textposfour.value + ')' +"\n" + "\n"};
	
if (subject1.youri1.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Uploaded File - ' + subject1.FileUpload1.value  + ') ' +   ' (Your Image Size - ' + subject1.yisizeone.value  + ' inches)' +  '(' + yi1 + ') ' + ' (Your Image Position - ' + subject1.yiposone.value + ')' +"\n" + "\n"};
if (subject1.youri2.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Uploaded File2 - ' + subject1.FileUpload2.value  + ') ' +   ' (Your Image Size2 - ' + subject1.yisizetwo.value  + ' inches)' +  '(' + yi2  + ') ' + ' (Your Image Position2 - ' + subject1.yipostwo.value + ')' +"\n" + "\n"};
if (subject1.youri3.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Uploaded File3 - ' + subject1.FileUpload3.value  + ') ' +   ' (Your Image Size3 - ' + subject1.yisizethree.value  + ' inches)' +  '(' + yi3  + ') ' + ' (Your Image Position3 - ' + subject1.yiposthree.value + ')' +"\n" + "\n"};
if (subject1.youri4.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Uploaded File4 - ' + subject1.FileUpload4.value  + ') ' +   ' (Your Image Size4 - ' + subject1.yisizefour.value  + ' inches)' +  '(' + yi4  + ') ' + ' (Your Image Position4 - ' + subject1.yiposfour.value + ')' +"\n" + "\n"};
	
if (subject1.rm1.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Ready Made Image Name - ' + subject1.rmnameone.value  + ') ' +   ' (Ready Made Image Size - ' + subject1.rmsizeone.value  + ')' +  '(' + rm1  + ') ' + ' (Ready Made Image Position - ' + subject1.rmposone.value + ')' +"\n" + "\n"};
if (subject1.rm2.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Ready Made Image Name2 - ' + subject1.rmnametwo.value  + ') ' +   ' (Ready Made Image Size2 - ' + subject1.rmsizetwo.value  + ')' +  '(' + rm2  + ') ' + ' (Ready Made Image Position2 - ' + subject1.rmpostwo.value + ')' +"\n" + "\n"};
if (subject1.rm3.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Ready Made Image Name3 - ' + subject1.rmnamethree.value  + ') ' +   ' (Ready Made Image Size3 - ' + subject1.rmsizethree.value  + ')' +  '(' + rm3  + ') ' + ' (Ready Made Image Position3 - ' + subject1.rmposthree.value + ')' +"\n" + "\n"};
if (subject1.rm4.checked) {
	subject.imagearea.value = subject.imagearea.value + ' (Ready Made Image Name4 - ' + subject1.rmnamefour.value  + ') ' +   ' (Ready Made Image Size4 - ' + subject1.rmsizefour.value  + ')' +  '(' + rm4  + ') ' + ' (Ready Made Image Position4 - ' + subject1.rmposfour.value + ')' +"\n" + "\n"};

 y='?'; 
 x=document.forms.orderform_16180.amount.value;

 
 rbs=obj.getElementsByTagName('INPUT'); 
 if (rbs[0].checked){ 
   y=(3.5)-(-productbase); 
   var printstyle = "Blank" + "\n" + "\n";
   document.forms.orderform_16180.colorside1.value = 'Blank';
document.forms.orderform_16180.colorside2.value = 'Blank';
document.forms.orderform_16180.colorside3.value = 'Blank';
document.forms.orderform_16180.colorside4.value = 'Blank';
 } 
 if (rbs[1].checked){ 
  DoHeat(x); 
  var printstyle = "Heat Transfer" + "\n" + "\n";
 } 
 if (rbs[2].checked){ 
  DoSilk(x);
  var printstyle = "Silk Screen Printing" + "\n" + "\n";
 } 
document.getElementById('baseprice').value=((Math.round(y *100)/100).toFixed(2)); 
document.forms.orderform_16180.subtotal.value = ((Math.round((document.forms.orderform_16180.baseprice.value*document.forms.orderform_16180.amount.value)*100)/100).toFixed(2));


   var qtytotal = 0, whites = 0, large = 0; 
  var fields = document.forms["formjunk"].elements; 
  for (var i=0;i<fields.length;i++) { 
    if (fields[i].name.indexOf("product_options_amount") == 0) { 
      qtytotal += new Number(fields[i].value); 
      // This assumes that the select element comes right after the text box 
      if (fields[i+1].selectedIndex == 0) { 
        whites += new Number(fields[i].value);
		}
		if (fields[i+2].selectedIndex == 0) { 
        large += new Number(fields[i].value); 
		
      } 
	  var of16180 = document.forms.orderform_16180;
	  var fj = document.forms.formjunk;
	  if (of16180.items0)  of16180.items0.value = '(' + (fj.product_options_amount1.value) + ')' + ' - ' + (fj.product_options_Size1.value) + ' - ' + (fj.product_options_color1.value);
	  if (of16180.items1)  of16180.items1.value = '(' + (fj.product_options_amount2.value) + ')' + ' - ' + (fj.product_options_Size2.value) + ' - ' + (fj.product_options_color2.value);
	  if (of16180.items2)  of16180.items2.value = '(' + (fj.product_options_amount3.value) + ')' + ' - ' + (fj.product_options_Size3.value) + ' - ' + (fj.product_options_color3.value);
	  if (of16180.items3)  of16180.items3.value = '(' + (fj.product_options_amount4.value) + ')' + ' - ' + (fj.product_options_Size4.value) + ' - ' + (fj.product_options_color4.value);
	  if (of16180.items4)  of16180.items4.value = '(' + (fj.product_options_amount5.value) + ')' + ' - ' + (fj.product_options_Size5.value) + ' - ' + (fj.product_options_color5.value);
	  if (of16180.items5)  of16180.items5.value = '(' + (fj.product_options_amount6.value) + ')' + ' - ' + (fj.product_options_Size6.value) + ' - ' + (fj.product_options_color6.value);
	  if (of16180.items6)  of16180.items6.value = '(' + (fj.product_options_amount7.value) + ')' + ' - ' + (fj.product_options_Size7.value) + ' - ' + (fj.product_options_color7.value);
	  if (of16180.items7)  of16180.items7.value = '(' + (fj.product_options_amount8.value) + ')' + ' - ' + (fj.product_options_Size8.value) + ' - ' + (fj.product_options_color8.value);
	  if (of16180.items8)  of16180.items8.value = '(' + (fj.product_options_amount9.value) + ')' + ' - ' + (fj.product_options_Size9.value) + ' - ' + (fj.product_options_color9.value);
	  if (of16180.items9)  of16180.items9.value = '(' + (fj.product_options_amount10.value) + ')' + ' - ' + (fj.product_options_Size10.value) + ' - ' + (fj.product_options_color10.value);
	  if (of16180.items10)  of16180.items10.value = '(' + (fj.product_options_amount11.value) + ')' + ' - ' + (fj.product_options_Size11.value) + ' - ' + (fj.product_options_color11.value);
	  if (of16180.items11)  of16180.items11.value = '(' + (fj.product_options_amount12.value) + ')' + ' - ' + (fj.product_options_Size12.value) + ' - ' + (fj.product_options_color12.value);
	  if (of16180.items12)  of16180.items12.value = '(' + (fj.product_options_amount13.value) + ')' + ' - ' + (fj.product_options_Size13.value) + ' - ' + (fj.product_options_color13.value);
	  if (of16180.items13)  of16180.items13.value = '(' + (fj.product_options_amount14.value) + ')' + ' - ' + (fj.product_options_Size14.value) + ' - ' + (fj.product_options_color14.value);
	  if (of16180.items14)  of16180.items14.value = '(' + (fj.product_options_amount15.value) + ')' + ' - ' + (fj.product_options_Size15.value) + ' - ' + (fj.product_options_color15.value);
	  if (of16180.items15)  of16180.items15.value = '(' + (fj.product_options_amount16.value) + ')' + ' - ' + (fj.product_options_Size16.value) + ' - ' + (fj.product_options_color16.value);
	  if (of16180.items16)  of16180.items16.value = '(' + (fj.product_options_amount17.value) + ')' + ' - ' + (fj.product_options_Size17.value) + ' - ' + (fj.product_options_color17.value);
	  if (of16180.items17)  of16180.items17.value = '(' + (fj.product_options_amount18.value) + ')' + ' - ' + (fj.product_options_Size18.value) + ' - ' + (fj.product_options_color18.value);
	  if (of16180.items18)  of16180.items18.value = '(' + (fj.product_options_amount19.value) + ')' + ' - ' + (fj.product_options_Size19.value) + ' - ' + (fj.product_options_color19.value);
	  if (of16180.items19)  of16180.items19.value = '(' + (fj.product_options_amount20.value) + ')' + ' - ' + (fj.product_options_Size20.value) + ' - ' + (fj.product_options_color20.value);
	  if (of16180.items20)  of16180.items20.value = '(' + (fj.product_options_amount21.value) + ')' + ' - ' + (fj.product_options_Size21.value) + ' - ' + (fj.product_options_color21.value);
	  if (of16180.items21)  of16180.items21.value = '(' + (fj.product_options_amount22.value) + ')' + ' - ' + (fj.product_options_Size22.value) + ' - ' + (fj.product_options_color22.value);
	  if (of16180.items22)  of16180.items22.value = '(' + (fj.product_options_amount23.value) + ')' + ' - ' + (fj.product_options_Size23.value) + ' - ' + (fj.product_options_color23.value);
	  if (of16180.items23)  of16180.items23.value = '(' + (fj.product_options_amount24.value) + ')' + ' - ' + (fj.product_options_Size24.value) + ' - ' + (fj.product_options_color24.value);
	  if (of16180.items24)  of16180.items24.value = '(' + (fj.product_options_amount25.value) + ')' + ' - ' + (fj.product_options_Size25.value) + ' - ' + (fj.product_options_color25.value);
    } 
  } 
  document.forms.orderform_16180.amount.value = qtytotal; 
  document.forms.orderform_16180.lightshirts.value = whites; 
  document.forms.orderform_16180.bigshirts.value = large;


subject.hiddencost.value = ((Math.round((subject.subtotal.value - subject.lightshirts.value - (subject.bigshirts.value * -1))*100)/100).toFixed(2));

document.forms.orderform_16180.price.value = ((Math.round((subject.hiddencost.value/document.forms.orderform_16180.amount.value) *100)/100).toFixed(2));
document.forms.orderform_16180.totalcost.value = ((Math.round((document.forms.orderform_16180.amount.value*document.forms.orderform_16180.price.value) *100)/100).toFixed(2));

document.forms.orderform_16180.printtype.value = printstyle;
} 

//to = setTimeout('checkfunc()',2500);

//function checkfunc() {
//  document.getElementById('htfront').checked = true;
//}

