var now = new Date();
var cutoff = new Date(2009,9,3);   //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 = "Registration fee: $1795";

if (now < cutoff) {
var ff=ff-300;  	 //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 = "Registration Fee: <s>$1795</s><font color='#CC0000'><strong> $1495 Early bird price through Friday, October 2nd</strong></font>";
}


function testCreditCard () {
  myCardNo = document.getElementById('cc_number').value;
  myCardType = document.getElementById('cc_type').value;
  if (checkCreditCard (myCardNo,myCardType)) {
    alert ("Credit card has a valid format")
  } 
  else {alert (ccErrors[ccErrorNo])}
}

// Set the price (ff), the cutoff date (cutoff), the early bird discount (line 19), the bulk discount amount and number if needed (line 39 and line 47), and the cookie value (line 139)

var isNS4 = (navigator.appName=="Netscape")?1:0;


//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='';
			
			// SP 79707 [RC: 08/19/2009]			
			document.getElementById('part_position_'+i).value='';
			document.getElementById('part_badge_'+i).value='';
			if (i==1) {
				document.getElementById('CopyMe').style.display='none';
				document.getElementById('CopyMeRadio').checked=false;
			}	
		}	
	}
}


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) {
	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);
	var reqFields = new Array(form.FirstName,form.LastName,form.Position,form.Email,form.Phone,form.Company,form.MailingAddress1,form.City,form.State,form.Zip);
	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', 'securitization', 1, '/', '', '' )
		
		// Submit Form If No Errors
		return true;
	}
}

//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");

	}

}
