// form prices updated for 2006 on 9/5/2006 by JM

var cW2=0, c1099=0, c1098=0, cT=0;


// VALUES BELOW ARE IN *CENTS* !!

var w2_dotMatrix_base = 700;    // each n forms
var w2_dotMatrix_chunkSize = 10; // order increment
var w2_laser = 3000;            // each n forms
var w2_laser_chunkSize = 50;    // order increment
var w2_gmsPrint_base = 6000;    // setup cost
var w2_gmsPrint_each = 25;      // per employee
var w2_magMedia_base = 12000;   // setup cost
var w2_magMedia_each = 25;      // per employee
var w2_magState_base = 12000;   // setup cost
var w2_magState_each = 25;      // per employee
var w2_magLocal_base = 12000;   // setup cost
var w2_magLocal_each = 25;      // per employee


var Form_1099_dotMatrix_base = 700;    // each n forms
var Form_1099_dotMatrix_chunkSize = 10; // order increment
var Form_1099_laser = 3000;            // each n forms
var Form_1099_laser_chunkSize = 50;    // order increment
var Form_1099_gmsPrint_base = 6000;    // setup cost
var Form_1099_gmsPrint_each = 25;      // per employee
var Form_1099_magMedia_base = 12000;   // setup cost
var Form_1099_magMedia_each = 25;      // per employee

var Form_1098_dotMatrix_base = 700;    // each n forms
var Form_1098_dotMatrix_chunkSize = 10; // order increment
var Form_1098_laser = 3000;            // each n forms
var Form_1098_laser_chunkSize = 75;    // order increment
var Form_1098_gmsPrint_base = 6000;    // setup cost
var Form_1098_gmsPrint_each = 25;      // per employee
var Form_1098_GMS_Prep_Mag_base = 12000; 	   // Setup cost
var Form_1098_GMS_Prep_Mag_each = 25;        // per employee   

function costToStr (n) {
	n = n.toString(); nl=n.length;
	ns = (n == "0") ? "0" : n.substr(0,nl-2) + "." + n.substr(nl-2,2);
	return ns;
}

function calcW2Cost () {
	var q = document.forms.order.W2_Quantity.value;
	with (document.forms.order) {
		if ( W2_Form_Type[0].checked || W2_Form_Type[1].checked ) {
			cW2 = w2_laser * Math.ceil(q/w2_laser_chunkSize);
		} else if ( W2_Form_Type[2].checked ) {
			cW2 = w2_dotMatrix_base * Math.ceil(q/w2_dotMatrix_chunkSize);
			
		} else { 
			cW2 = 0;
		}
		if ( W2_GMS_Print.checked && q > 0)  {
			cW2 = (w2_laser * Math.ceil(q/w2_laser_chunkSize)) + w2_gmsPrint_base + (w2_gmsPrint_each * q);
		}
		if ( W2_GMS_SSA_File.checked && q > 0 ) {
			cW2 += w2_magMedia_base + (w2_magMedia_each * q);
		}
		
		//BSD add per Liz@GMS
		if ( W2_GMS_Prep_State_Mag.checked && q > 0 ) {
			cW2 += w2_magState_base + (w2_magState_each * q);
		}
		//BSD add per Liz@GMS
		if ( W2_GMS_Prep_Local_Mag.checked && q > 0 ) {
			cW2 += w2_magLocal_base + (w2_magLocal_each * q);
		}
		
		
		W2_Cost.value = costToStr(cW2);
	}
	calcTotCost();
}

function calc1099Cost () {
	var q = document.forms.order.Form_1099_Quantity.value;
	with (document.forms.order) {
		if ( Form_1099_Form_Type[0].checked ) {
			c1099 = Form_1099_laser * Math.ceil(q/Form_1099_laser_chunkSize);
		} else if ( Form_1099_Form_Type[1].checked ) {
			c1099 = Form_1099_dotMatrix_base * Math.ceil(q/Form_1099_dotMatrix_chunkSize);
		} else {
			c1099 = 0;
		}
		if ( Form_1099_GMS_Print.checked && q > 0 ) {
			c1099 += Form_1099_gmsPrint_base + (Form_1099_gmsPrint_each * q);
		}
		if ( Form_1099_GMS_IRS_File.checked && q > 0 ) {
			c1099 += Form_1099_magMedia_base + (Form_1099_magMedia_each * q);
		}
		Form_1099_Cost.value = costToStr(c1099);
	}
	calcTotCost();
}

function calc1098Cost () {
	var q = document.forms.order.Form_1098_Quantity.value;
	with (document.forms.order) {
		if ( Form_1098_Form_Type[0].checked ) {
			c1098 = Form_1098_laser * Math.ceil(q/Form_1098_laser_chunkSize);
		} else if ( Form_1098_Form_Type[1].checked ) {
			
			c1098 = Form_1098_dotMatrix_base * Math.ceil(q/Form_1098_dotMatrix_chunkSize);
		} else {
			c1098 = 0;
		}
		if ( Form_1098_GMS_Print.checked && q > 0 ) {
			c1098 += Form_1098_gmsPrint_base + (Form_1098_gmsPrint_each * q);
		}
		
		if ( Form_1098_MagMedia.checked && q > 0 ) {
			c1098 += Form_1098_GMS_Prep_Mag_base + (Form_1098_GMS_Prep_Mag_each * q);
		}
		Form_1098_Cost.value = costToStr(c1098);
	}
	calcTotCost();
}

function calcTotCost () {
	cT = cW2 + c1099 + c1098;
	document.forms.order.Total_Estimated_Cost.value = costToStr(cT);
}
