//DON'T FORGET TO SET YOUR COOKIE VALUE DOWN NEAR LINE 185


var now = new Date();
var cutoff = new Date(2008,9,18);   //IMPORTANT - the second value, month, is zero based. So january is 0, february is 1, etc.



var ff=1795  	//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 = "";

 if (now < cutoff) {
var ff=1595  	 //subtract the early bird discount amount
//var fb=1995
//var fi=1495
//use the following blurb if you want the pricing paragraph to change based on date
var pricingBlurb = "<ul><li class='bullets'><s>$1,795</s><font color='#CC0000'> $1,595 Early bird price through Friday, October 17, 2008</font></li></ul><br />";
}



/*Rajes 
SP 54860 (10/23/2008)
SP 55067 (10/24/2008)
*/
function special_pricing() {
	var markCode = document.register.Discount_Code.value;
	if (markCode=="PG2016") {		
		//alert("PG2016");		
		ff=(1395*1); //Discount of $400 off the regular price of $1795.00
		//fb=(695*1);
		calculateValues();
	} else if (markCode=="PG2017") {
		//alert("PG2017");
		ff=(895*1); //Discount of $900 off the regular price $1795.00
		//fb=(695*1);
		calculateValues();
	} else {
		ff=(1795*1)	;
		//fb=(695*1)	;
		calculateValues();
	} 
}


//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')){
	
	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';
		document.getElementById('part_discount_'+i).style.display='none';
		}
	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_discount_'+i).value='';
		if (i==1) {
			document.getElementById('CopyMe').style.display='none';
			}		
		}
	}
}

function calculateValues() {
	if (document.getElementById('participants_full')){//to fix error after submit
	
	// 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';
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(partError=='true') {
error+='\nPlease enter all Participant Information.\n\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', 'rcd2008', 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';
  }
}

