// JavaScript Document


// vars and functions for the membership cost field
var memcost = 0;

function setmemcost()
{
if (document.form1.membership.checked==true)
     {memcost = 60;
	 document.form1.membership.value = 1;}
else
     {memcost = 0;
	 document.form1.membership.value = 0;}
document.form1.totala.value = "" + memcost;	 
}
function clearmemcost()
{
	document.form1.membership.checked=false; 
	memcost = 0;
	document.form1.totala.value = "" + memcost;
}

// for the master session costs
var mastcost = 0;
function setmastcost(thiscost)
{
    mastcost = thiscost;
	document.form1.totalb.value = "" + mastcost;	 
}
function clearmasters()
{
   mastcost = 0;
   document.form1.totalb.value = "" + mastcost;
   for( i = 0; i < document.form1.MasterClass1.length; i++ )
   {
     document.form1.MasterClass1[i].checked = "";  
   }
   for( i = 0; i < document.form1.MasterClass2.length; i++ )
   {
     document.form1.MasterClass2[i].checked = "";  
   }   
}

// for the various pre conferences

var yescost = 0;
var siocost = 0;
var procost = 0;
function subttlpreconf()
{
var subttlpc = (yescost + siocost + procost);
document.form1.totalc.value = "" + subttlpc;
}
function clearpreconfyes()
{
   yescost = 0;
   for( i = 0; i < document.form1.yes.length; i++ )
   {
   document.form1.yes[i].checked = "";  
   }
}
function clearpreconfsio()
{
   siocost = 0;
   for( i = 0; i < document.form1.sio.length; i++ )
   {
   document.form1.sio[i].checked = "";  
   }
}
function clearpreconfpro()
{
   procost = 0;
   for( i = 0; i < document.form1.pro.length; i++ )
   {
     document.form1.pro[i].checked = "";  
   }
}
function clearpreconf()
{
	clearpreconfyes();
	clearpreconfsio();
	// clearpreconfpro();
	var yescost = 0;
    var siocost = 0;
    var procost = 0;
	subttlpreconf();	
}

// for the full conference costs
var confcost = 0;
function setconfcost(thiscost)
{
    confcost = thiscost;
	document.form1.totald.value = "" + confcost;	 
}
function clearfullconf()
{
   confcost = 0;
   for( i = 0; i < document.form1.fullconf.length; i++ )
   {
   document.form1.fullconf[i].checked = "";  
   }
   setconfcost(confcost);
}

// for the one day costs
var oneday = 0;
function setoneday(thiscost)
{
    oneday = thiscost;
	document.form1.totale.value = "" + oneday;	 
}
function clearonedays()
{
   oneday = 0;
   document.form1.totale.value = "" + oneday;
   for( i = 0; i < document.form1.day.length; i++ )
   {
   document.form1.day[i].checked = "";  
   }
   for( i = 0; i < document.form1.oneday.length; i++ )
   {
   document.form1.oneday[i].checked = "";  
   }   
}

function clearallconf()
{
allcost = 0;
document.form1.allconf[0].checked = "";
document.form1.allconf[1].checked = "";
document.form1.allconf[2].checked = "";
}

function totaltix()
{
	var tixzero = 0; 
	var tixtotal = 0;
	if (isNaN(document.form1.fritickets.value) || document.form1.fritickets.value == "")
    {
		document.form1.fritickets.value = "" + tixzero;		
	}
	var frittl = 10 * parseFloat(document.form1.fritickets.value);	
	if (isNaN(document.form1.sattickets.value) || document.form1.sattickets.value == "")
    {
		document.form1.sattickets.value = "" + tixzero;		
	}
	var satttl = 15 * parseFloat(document.form1.sattickets.value);
    document.form1.totalf.value = "" + tixtotal;	
	if (isNaN(document.form1.suntickets.value) || document.form1.suntickets.value == "")
    {
		document.form1.suntickets.value = "" + tixzero;		
	}
	var sunttl = 15 * parseFloat(document.form1.suntickets.value);
	if (isNaN(document.form1.earlytixpkg.value) || document.form1.earlytixpkg.value == "")
    {
		document.form1.earlytixpkg.value = "" + tixzero;		
	}
	var earlypkg = 100 * parseFloat(document.form1.earlytixpkg.value);
	if (isNaN(document.form1.latetixpkg.value) || document.form1.latetixpkg.value == "")
    {
		document.form1.latetixpkg.value = "" + tixzero;		
	}
	var latepkg = 125 * parseFloat(document.form1.latetixpkg.value);
	if (earlypkg > 0 && latepkg > 0)
	{
		earlypkg = 0;
		document.form1.earlytixpkg.value = "" + tixzero;
	}
	tixtotal = frittl + satttl + sunttl + earlypkg + latepkg;	
    document.form1.totalf.value = "" + tixtotal;	
}

function setdoncost()
{
var tixzero = 0; 
	var dontotal = 0;
	if (isNaN(document.form1.donation.value) || document.form1.donation.value == "")
    {
		document.form1.donation.value = "" + dontotal;		
	}
	dontotal = parseFloat(document.form1.donation.value);
	document.form1.totalg.value = "" + dontotal;
}

// total the entire conference costs
function totalconf()
{
    var totalaint = parseFloat(document.form1.totala.value);
	var totalbint = parseFloat(document.form1.totalb.value);
	var totalcint = parseFloat(document.form1.totalc.value);
	var totaldint = parseFloat(document.form1.totald.value);
	var totaleint = parseFloat(document.form1.totale.value);
	var totalfint = parseFloat(document.form1.totalf.value);
	var totalgint = parseFloat(document.form1.totalg.value);
	var formttl = totalaint + totalbint + totalcint + totaldint + totaleint + totalfint + totalgint;
	document.form1.totalamount.value = "" + formttl;
}    

// check for missing fields
function checkFields() {
	missinginfo = "";
    if (document.form1.firstname.value == "") {
      missinginfo += "\n     -  First Name";
    }
    if(document.form1.lastname.value == "") {
      missinginfo += "\n     -  Last Name";
    }
    if(document.form1.address.value == "") {
      missinginfo += "\n     -  Address";
    }
    if(document.form1.city.value == "") {
      missinginfo += "\n     -  City";
    }
	if(document.form1.state.value == "") {
      missinginfo += "\n     -  State";
    }
    if(document.form1.zipcode.value == "") {
      missinginfo += "\n     -  Zip Code";
    }
    if(document.form1.phone.value == "") {
      missinginfo += "\n     -  Phone";
    }
	if(document.form1.email.value == "") {
      missinginfo += "\n     -  Email";
    } 
	if (missinginfo != "") 
    {
      missinginfo ="Required Fields Missing\n\nYou forgot to fill in your:" +
      missinginfo + "\n\nPlease complete the form and submit again!";
      alert(missinginfo);
	  return false;
    }
    else return true;    
}