// JavaScript Document

//CALCULATION OF FEES
function CalcPrice(TB) {
			if (isNaN(TB.value))
				TB.value = 0;
			
			var N;
			var Price;
			var NOP1;
			var NOP2;
			var NOP3;
			var NOP4;
			var NOP5;
			var NOP6;
			var NOP7;
			TBID = TB.id;
			var Letter = TBID.substr(0, 1)
			if (Letter == 'S')  //Spectrum
				{
				NOP1 = parseInt(document.getElementById("SNOP1").value);
				NOP2 = parseInt(document.getElementById("SNOP2").value);
				NOP3 = parseInt(document.getElementById("SNOP3").value);
				NOP4 = parseInt(document.getElementById("SNOP4").value);
				NOP5 = parseInt(document.getElementById("SNOP5").value);
				NOP6 = parseInt(document.getElementById("SNOP6").value);
				NOP7 = parseInt(document.getElementById("SNOP7").value);
				if (isNaN(NOP1))
						NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				if (isNaN(NOP4))
				    NOP4 = 0;
				if (isNaN(NOP5))
				    NOP5 = 0;
				if (isNaN(NOP6))
				    NOP6 = 0;
				if (isNaN(NOP7))
				    NOP7 = 0;
				N = NOP1 + NOP2 + NOP3 + NOP4 + NOP5 + NOP6 + NOP7;
				switch (N)
					{
					case 0:
						Price = 1000;
						break;
					case 1:
						Price = 1000;
						break;
					case 2:
						Price = 750;
						break;
					default:
						Price = 500;
					}
				}
			else  if (Letter == 'E')      //Electric Truck 4 day
				{
				NOP1 = parseInt(document.getElementById("ENOP1").value);
				NOP2 = parseInt(document.getElementById("ENOP2").value);
				NOP3 = parseInt(document.getElementById("ENOP3").value);
				NOP4 = parseInt(document.getElementById("ENOP4").value);
				NOP5 = parseInt(document.getElementById("ENOP5").value);
				NOP6 = parseInt(document.getElementById("ENOP6").value);
				NOP7 = parseInt(document.getElementById("ENOP7").value);
				if (isNaN(NOP1))
					NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				if (isNaN(NOP4))
				    NOP4 = 0;
				if (isNaN(NOP5))
						NOP5 = 0;
				if (isNaN(NOP6))
				    NOP6 = 0;
				if (isNaN(NOP7))
				    NOP7 = 0;
				N = NOP1 + NOP2 + NOP3 + NOP4 + NOP5 + NOP6 + NOP7;
				switch (N)
					{
					case 0:
						Price = 1500;
						break;
					case 1:
						Price = 1500;
						break;
					case 2:
						Price = 1250;
						break;
					default:
						Price = 1000;
					}
				}
			else if (Letter == 'T')         //Electric Truck 2 day
				{
				    NOP1 = parseInt(document.getElementById("TNOP1").value);
				    NOP2 = parseInt(document.getElementById("TNOP2").value);
				    NOP3 = parseInt(document.getElementById("TNOP3").value);
				    NOP4 = parseInt(document.getElementById("TNOP4").value);
				    if (isNaN(NOP1))
				        NOP1 = 0;
				    if (isNaN(NOP2))
				        NOP2 = 0;
				    if (isNaN(NOP3))
				        NOP3 = 0;
				    if (isNaN(NOP4))
				        NOP4 = 0;
				    N = NOP1 + NOP2 + NOP3 + NOP4;
				switch (N)
					{
					case 0:
						Price = 1000;
						break;
					case 1:
						Price = 1000;
						break;
					case 2:
						Price = 750;
						break;
					default:
						Price = 500;
					}
				}
				else  if (Letter == 'P')      //Parts Professional Session 1-3
				{
				NOP1 = parseInt(document.getElementById("PNOP1").value);
				NOP2 = parseInt(document.getElementById("PNOP2").value);
				NOP3 = parseInt(document.getElementById("PNOP3").value);
				NOP4 = parseInt(document.getElementById("PNOP4").value);
				NOP5 = parseInt(document.getElementById("PNOP5").value);
				NOP6 = parseInt(document.getElementById("PNOP6").value);
				if (isNaN(NOP1))
				    NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				if (isNaN(NOP4))
				    NOP4 = 0;
				if (isNaN(NOP5))
				    NOP5 = 0;
				if (isNaN(NOP6))
				    NOP6 = 0;
				N = NOP1 + NOP2 + NOP3 + NOP4 + NOP5 + NOP6;
				switch (N)
					{
					case 0:
						Price = 550;
						break;
					case 1:
						Price = 550;
						break;
					case 2:
						Price = 500;
						break;
					default:
						Price = 350;
					}
				}
				else  if (Letter == 'Q')      //Parts Professional Session 1 and 2
				{
				NOP1 = parseInt(document.getElementById("QNOP1").value);
				NOP2 = parseInt(document.getElementById("QNOP2").value);
				NOP3 = parseInt(document.getElementById("QNOP3").value);
				if (isNaN(NOP1))
				    NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				N = NOP1 + NOP2 + NOP3;
				switch (N)
					{
					case 0:
						Price = 450;
						break;
					case 1:
						Price = 450;
						break;
					case 2:
						Price = 400;
						break;
					default:
						Price = 300;
					}
				}
				else  if (Letter == 'R')      //Parts Professional Session 1-3
				{
				NOP1 = parseInt(document.getElementById("RNOP1").value);
				NOP2 = parseInt(document.getElementById("RNOP2").value);
				NOP3 = parseInt(document.getElementById("RNOP3").value);
				if (isNaN(NOP1))
				    NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				N = NOP1 + NOP2 + NOP3;
				switch (N)
					{
					case 0:
						Price = 350;
						break;
					case 1:
						Price = 350;
						break;
					case 2:
						Price = 300;
						break;
					default:
						Price = 250;
					}
				}
				else  if (Letter == 'B')      //Basic Hydraulic
				{
				NOP1 = parseInt(document.getElementById("BHOP1").value);
				NOP2 = parseInt(document.getElementById("BHOP2").value);
				if (isNaN(NOP1))
				    NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				N = NOP1 + NOP2;
				switch (N)
					{
					case 0:
						Price = 1000;
						break;
					case 1:
						Price = 1000;
						break;
					case 2:
						Price = 750;
						break;
					default:
						Price = 500;
					}
				}
				
				
				
			if (Letter != 'F') {
			    
				document.getElementById(Letter + 'Price1').innerHTML = Price;
				document.getElementById(Letter + 'Price2').innerHTML = Price;
				if (document.getElementById(Letter + 'Price3'))
				    document.getElementById(Letter + 'Price3').innerHTML = Price;
				if (document.getElementById(Letter + 'Price4'))
				    document.getElementById(Letter + 'Price4').innerHTML = Price;
				if (document.getElementById(Letter + 'Price5'))
				    document.getElementById(Letter + 'Price5').innerHTML = Price;
				if (document.getElementById(Letter + 'Price6'))
				    document.getElementById(Letter + 'Price6').innerHTML = Price;
				if (document.getElementById(Letter + 'Price7'))
				    document.getElementById(Letter + 'Price7').innerHTML = Price;
				document.getElementById(Letter + 'Total1').innerHTML = NOP1 * Price;
				document.getElementById(Letter + 'Total2').innerHTML = NOP2 * Price;
				if (document.getElementById(Letter + 'Total3'))
				    document.getElementById(Letter + 'Total3').innerHTML = NOP3 * Price;
				if (document.getElementById(Letter + 'Total4'))
				    document.getElementById(Letter + 'Total4').innerHTML = NOP4 * Price;
				if (document.getElementById(Letter + 'Total5'))
				    document.getElementById(Letter + 'Total5').innerHTML = NOP5 * Price;
				if (document.getElementById(Letter + 'Total6'))
				    document.getElementById(Letter + 'Total6').innerHTML = NOP6 * Price;
				if (document.getElementById(Letter + 'Total7'))
				    document.getElementById(Letter + 'Total7').innerHTML = NOP7 * Price;
				CalcTotal();
                }
            
			}
		function CalcTotal()
			{
			var S1, S2, S3, S4, S5, S6, S7, E1, E2, E3, E4, P1, P2, P3, P4 , P5, P6, B1, B2
			S1 = document.getElementById('STotal1').innerHTML;
			S2 = document.getElementById('STotal2').innerHTML;
			S3 = document.getElementById('STotal3').innerHTML;
			S4 = document.getElementById('STotal4').innerHTML;
			S5 = document.getElementById('STotal5').innerHTML;
			S6 = document.getElementById('STotal6').innerHTML;
			S7 = document.getElementById('STotal7').innerHTML;

			E1 = document.getElementById('ETotal1').innerHTML;
			E2 = document.getElementById('ETotal2').innerHTML;
			E3 = document.getElementById('ETotal3').innerHTML;
			E4 = document.getElementById('ETotal4').innerHTML;
			E5 = document.getElementById('ETotal5').innerHTML;
			E6 = document.getElementById('ETotal6').innerHTML;
			E7 = document.getElementById('ETotal7').innerHTML;
			
			P1 = document.getElementById('PTotal1').innerHTML;
			P2 = document.getElementById('PTotal2').innerHTML;
			P3 = document.getElementById('PTotal3').innerHTML;
			P4 = document.getElementById('PTotal4').innerHTML;
			P5 = document.getElementById('PTotal5').innerHTML;
			P6 = document.getElementById('PTotal6').innerHTML;
			
			B1 = document.getElementById('BTotal1').innerHTML;
			B2 = document.getElementById('BTotal2').innerHTML;

			
			document.getElementById('GT').innerHTML = (parseInt(S1) + parseInt(S2) + parseInt(S3) + parseInt(S4) + parseInt(S5) + parseInt(S6) + parseInt(S7) + parseInt(E1) + parseInt(E2) + parseInt(E3) + parseInt(E4) + parseInt(E5) + parseInt(E6) + parseInt(E7) + parseInt(P1) + parseInt(P2) + parseInt(P3) + parseInt(P4) + parseInt(P5) + parseInt(P6) + parseInt(B1) + parseInt(B2))

			//document.getElementById('GT').innerHTML = (parseInt(T1) + parseInt(T2) + parseInt(T3) + parseInt(T4) + parseInt(T5) + parseInt(T6) + parseInt(T7) + parseInt(T8) + parseInt(T9) + parseInt(T10) + parseInt(T11) + parseInt(T12) + parseInt(T13) + parseInt(T14) + parseInt(T15) + parseInt(T16) + parseInt(T17) + parseInt(T18) + parseInt(T19) + parseInt(T20));
			}
		
// FORM VALIDATION
function fnSubmit ( )
	{
    valid = true;
    var strError = ""

    if (trim(document.smhuenrollment.txtcompanyname.value) == "" )
    {
        strError += "Please enter your Company Name\n";
        valid = false;
    }
	
	   if (trim(document.smhuenrollment.txtmailadd.value) == "" )
    {
        strError += "Please enter your Mailing Address\n";
        valid = false;
    }
	
	    if (trim(document.smhuenrollment.txtcity.value) == "" )
    {
        strError += "Please enter your City\n";
        valid = false;
    }
	
	   if (trim(document.smhuenrollment.txtstate.value) == "" )
    {
        strError += "Please enter your State\n";
        valid = false;
    }
	
	    if (trim(document.smhuenrollment.txtzip.value) == "" )
    {
        strError += "Please enter your Zip Code\n";
        valid = false;
    }
	
	   if (trim(document.smhuenrollment.txtcontactname.value) == "" )
    {
        strError += "Please enter your Contact Name\n";
        valid = false;
    }
	
	    if (trim(document.smhuenrollment.txttitle.value) == "" )
    {
        strError += "Please enter your Contact Title\n";
        valid = false;
    }
	
	   if (trim(document.smhuenrollment.txtemail.value) == "" )
    {
        strError += "Please enter your E-Mail Address\n";
        valid = false;
    }
	
	  //  if (trim(document.smhuenrollment.txtphone.value) == "" )
    //{
    //    strError += "Please enter your Telephone Number\n";
    //    valid = false;
    //}
	
	   if (trim(document.smhuenrollment.txtfax.value) == "" & trim(document.smhuenrollment.txtphone.value) == "" )
    {
        strError += "Please enter your Phone or Fax Number\n";
        valid = false;
    }
    
    	
    var NOP1, NOP2, NOP3, NOP4, NOP5, NOP6, NOP7, N;
    N = 0;
        NOP1 = parseInt(document.getElementById("SNOP1").value);
				NOP2 = parseInt(document.getElementById("SNOP2").value);
				NOP3 = parseInt(document.getElementById("SNOP3").value);
				NOP4 = parseInt(document.getElementById("SNOP4").value);
				NOP5 = parseInt(document.getElementById("SNOP5").value);
				NOP6 = parseInt(document.getElementById("SNOP6").value);
				NOP7 = parseInt(document.getElementById("SNOP7").value);
				if (isNaN(NOP1))
					NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				if (isNaN(NOP4))
				    NOP4 = 0;
				if (isNaN(NOP5))
				    NOP5 = 0;
				if (isNaN(NOP6))
				    NOP6 = 0;
				if (isNaN(NOP7))
				    NOP7 = 0;
				N += NOP1 + NOP2 + NOP3 + NOP4 + NOP5 + NOP6 + NOP7;

				NOP1 = parseInt(document.getElementById("ENOP1").value);
				NOP2 = parseInt(document.getElementById("ENOP2").value);
				NOP3 = parseInt(document.getElementById("ENOP3").value);
				NOP4 = parseInt(document.getElementById("ENOP4").value);
				NOP5 = parseInt(document.getElementById("ENOP5").value);
				NOP6 = parseInt(document.getElementById("ENOP6").value);
				NOP7 = parseInt(document.getElementById("ENOP7").value);
				if (isNaN(NOP1))
					NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				if (isNaN(NOP4))
				    NOP4 = 0;
				if (isNaN(NOP5))
				    NOP5 = 0;
				if (isNaN(NOP6))
				    NOP6 = 0;
				if (isNaN(NOP7))
				    NOP7 = 0;
				N += NOP1 + NOP2 + NOP3 + NOP4 + NOP5 + NOP6 + NOP7;

				NOP1 = parseInt(document.getElementById("PNOP1").value);
				NOP2 = parseInt(document.getElementById("PNOP2").value);
				NOP3 = parseInt(document.getElementById("PNOP3").value);
				NOP4 = parseInt(document.getElementById("PNOP4").value);
				NOP5 = parseInt(document.getElementById("PNOP5").value);
				NOP6 = parseInt(document.getElementById("PNOP6").value);
				if (isNaN(NOP1))
				    NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				if (isNaN(NOP3))
				    NOP3 = 0;
				if (isNaN(NOP4))
				    NOP4 = 0;
				if (isNaN(NOP5))
				    NOP5 = 0;
				if (isNaN(NOP6))
				    NOP5 = 0;
				N += NOP1 + NOP2 + NOP3 + NOP4 + NOP5 + NOP6;
				
				NOP1 = parseInt(document.getElementById("F1").value);
				NOP2 = parseInt(document.getElementById("F2").value);
				NOP3 = parseInt(document.getElementById("F3").value);
				if (isNaN(NOP1))
					NOP1 = 0;
				if (isNaN(NOP2))
				  NOP2 = 0;
				if (isNaN(NOP3))
					NOP3 = 0;
				N += NOP1 + NOP2 + NOP3 ;
				    
				NOP1 = parseInt(document.getElementById("BHOP1").value);
				NOP2 = parseInt(document.getElementById("BHOP2").value);
				if (isNaN(NOP1))
				    NOP1 = 0;
				if (isNaN(NOP2))
				    NOP2 = 0;
				N += NOP1 + NOP2;
	
				if (N < 1) {
					strError += "Please Enter a Participant for at least one class\n";
        	valid = false;
				}

    if (!valid)
        window.alert(strError);
	
    return valid;
}		

function trim (str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

function checkNum(tb) {
	if (isNaN(tb.value))
			tb.value = 0;
}

