var now = new Date();
var cutoff = new Date(2009,5,27);   //IMPORTANT - the second value, month, is zero based. So january is 0, february is 1, etc.



var ff=3395  	//full session price
var fb=2195    	//bank and thrift session price
var fi=1695	//insurance session price


//use the following blurb if you want the pricing paragraph to change based on date
var pricingBlurb = "<ul><li class='bullets'>Bank session only: $2,195<li class='bullets'>Insurance session only: $1,695<li class='bullets'>Full program: $3,395</li></ul><br />";

if (now < cutoff) {
var ff=2995  	 //subtract the early bird discount amount
var fb=1795
var fi=1395


//use the following blurb if you want the pricing paragraph to change based on date
var pricingBlurb = "<ul><li class='bullets'>Bank &amp; Thrift program: <s>$2,195</s><font color='#CC0000'> $1,795 Early bird price through June 26</font></li><li class='bullets'>Insurance program: <s>$1,695</s><font color='#CC0000'> $1,395 Early bird price through June 26</font></li><li class='bullets'>Entire program: <s>$3,395</s><font color='#CC0000'> $2,995 Early bird price through June 26</font></li></ul><br />";
}







//function special_pricing() {
//if (document.register.Discount_Code.value=="NAREIT2008") {
	//alert("check");
//ff=(1595*1)	;
//fb=(695*1)	;
//calculateValues();
//}
//else {
//	ff=ff	;
//calculateValues();
//}
//}


//jenny added
//function fedstate() {
//if (document.register.Type.value=="fedstate_agency") {
	//alert("fedstate exec");
//ff=(1195*1)	;
//calculateValues();
//}
//else {
	//ff=(1195*1)	;
//calculateValues();
//}
//}

function showParticipantRows() {
	
	if (document.getElementById('participant_table1')){ //to fix error after submit
	
	document.getElementById('participant_table1').style.display='block'
	/*document.getElementById('pricing_table1').style.display='block'*/

	var q = document.register.participants_full.value;
	
	for (i=1;i<=q;i++) {
	if (i==1) {
		document.getElementById('CopyMe').style.display='block';
		}
		document.getElementById('part_'+i).style.display='block';
		}
		for (i=10;i>q;i--) {
			document.getElementById('part_'+i).style.display='none';
			document.getElementById('part_first_'+i).value='';
			document.getElementById('part_last_'+i).value='';
			document.getElementById('part_email_'+i).value='';
			document.getElementById('part_session_'+i).value='';
			}	
		}
	}





function calculateValues() {
	if (document.getElementById('participants_full')){
	var q = document.register.participants_full.value;

	var fullPricePayers = 0;
	var BandTPayers = 0;
	var InsurancePayers = 0;
	
	for (i=1;i<=q;i++) {
		if (document.getElementById('part_session_'+i).value=='Full Program'){
		fullPricePayers = fullPricePayers +1;
		//alert(fullPricePayers);
		}
		if (document.getElementById('part_session_'+i).value=='Bank and Thrift'){
		BandTPayers = BandTPayers +1;
		//alert(BandTPayers);
		}
		if (document.getElementById('part_session_'+i).value=='Insurance'){
		InsurancePayers = InsurancePayers +1;
		//alert(InsurancePayers);
		}
	}
	
var FinalPrice = (fullPricePayers*ff)+(BandTPayers*fb)+(InsurancePayers*fi);
	

	
//document.getElementById('disp_fee').innerHTML='$'+ff;
document.getElementById('disp_total').innerHTML='$'+FinalPrice;


	document.register.total.value = FinalPrice;

		}

}




function validateForm(form) {
	//alert("eagh");
error = '';
// Validate Contact Information Fields
var reqFields = new Array(form.FirstName,form.LastName,form.Position,form.Email,form.Phone,form.Company,form.MailingAddress1,form.City,form.State,form.Zip,form.Referral);
for(i=0;i<reqFields.length;i++) {
	if(reqFields[i].value=='') {
		error+=reqFields[i].name+' is a required field.\n';
		}
	}

// Confirm Email Address
if(form.Email.value!=form.cEmail.value || form.cEmail.value=='') {
error+='\nPlease confirm your Email address.\n';	
}

if (Validate_Email_Address(form.Email.value)==false) {
	error+='A valid email address is required\n';
}

// Validate Participant Information
var r = document.register.participants_full.value;
if (r<1) { error+='\nPlease enter the number of participants.\n\n'; }

partError='false';
SessionpartError='false';
nametagError='false';

for (i=1;i<=r;i++) {
if (document.getElementById('part_first_'+i).value=='' || document.getElementById('part_last_'+i).value=='' || document.getElementById('part_position_'+i).value=='' || document.getElementById('part_email_'+i).value=='') {
partError='true';
	}
	//alert(document.getElementById('part_session_'+i).value);
if (document.getElementById('part_session_'+i).value=='') {
SessionpartError='true';
	}

if (document.getElementById('part_badge_'+i).value=='') {
nametagError='true';
	}

}
if(partError=='true') {
error+='\nPlease enter all Participant Information.\n\n';	
}

if(nametagError=='true') {
error+='\nPlease enter a name for each participant\'s name badge.\n';	
}

if(SessionpartError=='true') {
error+='\nPlease select a session for each participant.\n\n';	
}


// Validate Payment Options







// the following checks for empty fields when credit card has been selected as payment method

if(form.PaymentMethod.value=='Credit Card') {
if(!form.cc_type[0].checked&&!form.cc_type[1].checked&&!form.cc_type[2].checked) {error+='Credit Card type is required.\n'}
else {
	
		//the following checks the cc number and type to make sure it has been entered correctly
	myCardNo = document.getElementById('cc_number').value;
	
	var cc_type_val = 0;
	
	for( i = 0; i < document.register.cc_type.length; i++ )
	{
	if( document.register.cc_type[i].checked == true )
	cc_type_val = document.register.cc_type[i].value;
	}
	//alert( "val = " + cc_type_val );


	myCardType = cc_type_val;
	  //alert(myCardType);
	if (checkCreditCard (myCardNo,myCardType)) {
		//alert ("Credit card has a valid format")
	} 
	else {error+='\nPlease enter a valid credit card number.\n\n';	
	};

}
if(form.cc_name.value=='') {error+='Name on Credit Card is required.\n'}
if(form.cc_number.value=='') {error+='Credit Card Number is required.\n'}
if(form.cc_exp_month.value=='' || form.cc_exp_year.value=='') {error+='Credit Card Expiration Date is required.\n'}
}


//server side Captcha validation
var uword = hex_md5(document.getElementById('uword').value);

if (uword!==cword[anum-1]) {
error+='\n Enter the word as it is shown.';
//document.getElementById('uword').focus(); 
//return false;
}


// Validation Alert
if(error!='') {
error=error.replace(error,'The following errors occurred with your submission:\n\n'+error);
error=error.replace('\n\n\n','\n\n');
alert(error);
return false;

} else {
	//Set a cookie that the page checks for before processing form
	Set_Cookie( 'cfe', 'analtrain09', 1, '/', '', '' )
	
// Submit Form If No Errors
return true;
//alert("eagh");
	}
}

//function feesBlurb() {
//if (now < cutoff) {
//document.write('<B>Register now and receive an Early-Bird discount!</b><P>')
//document.write('<B>Conference Fee:  <span style="font-weight: bold; text-decoration: line-through;">$2,750</span>&nbsp;<span style="color: #FF0000">$1,550</span></B><p>')
//document.write('<span style="color: #FF0000"><B><i>Act Now!</i> Early-Bird discount ends at midnight on January 25, 2008!</b></span>')
//	}
//if (now >= cutoff) {
//document.write('<B>Conference Fee: $2,750</B><p>')
//	}
//}



function alertControl(e) {
  if (document.register.participants_full.value >= 3) {
        document.getElementById(e).style.display = 'block';
		//alert("Discounted rates are available for groups of three of more.  Please contact Tara Twibell at 434-951-6963 or by email at <!-- ENCODED EMAIL LINK --><a href=&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#116;t&#119;&#0105;&#98;&#101;&#0108;&#0108;&#064;&#115;&#110;&#0108;&#046;&#99;&#111;&#109;>&#116;t&#119;&#0105;&#098;&#0101;&#0108;&#0108;&#064;&#0115;&#0110;&#108;&#046;&#099;&#111;&#109;</a><!-- END OF ENCODED LINK --> for more information.")
    } else {
        document.getElementById(e).style.display = 'none';
  }
}
