var now = new Date();
var cutoff = new Date(2009,8,1);   //IMPORTANT - the second value, month, is zero based
// Jan - 0
// Feb - 1
// Mar - 2
// Apr - 3
// May - 4
// Jun - 5
// Jul - 6
// Aug - 7
// Sep - 8
// Oct - 9
// Nov - 10
// Dec - 11


var ff=1350  	//full session price
var fb=995    	//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 = "Registration Fee: $1350";

if (now < cutoff) {
var ff=1350  	 //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 = "Registration Fee: $1350 <br />State and Federal Regulatory Commissions: $995";
}







//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() {
var is_checked = document.register.fed.checked
if (is_checked == true) {
	//alert("the box is checked");
ff=fb	;
calculateValues();
}
else {
	if (ff==995){
		ff=1350;
		 if (now < cutoff) {
		ff=1350; 	 //subtract the early bird discount amount
}
		}	;
	//alert("the box is not checked");
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')){
	
	// this function is custom for this page 3.24.08- ajh
	var q = document.register.participants_full.value;
	//alert(q);

	var fullPricePayers = 0;
	var BandTPayers = 0;
	var InsurancePayers = 0;
	
	
//the below code can be used when the conference has different sessions with different prices.//
	//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);

//the above code can be used when the conference has different sessions with different prices.//	


var FinalPrice = q*ff; // number of participants times the full price

//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', 'util09', 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';
  }
}



function Presentation_validateForm(form) {
	error = '';
	// Validate Contact Information Fields
	var reqFields = new Array(form.FirstName,form.LastName,form.Company,form.Password);
	for(i=0;i<reqFields.length;i++) {
		if(reqFields[i].value=='') {
			error+=reqFields[i].name+' is a required field.\n';
		}
	}
	// 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_Presentation', 'RCD09', 1, '/', '', '' )
		// Submit Form If No Errors
		return true;
		//alert("eagh");
	}
}