//DON'T FORGET TO SET YOUR COOKIE VALUE DOWN NEAR LINE 185

var now = new Date();
var cutoff = new Date(2008,1,2);  //IMPORTANT - the second value, month, is zero based. So january is 0, february is 1, etc.
var ff=995  	//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=1350  	 //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'>Bank &amp; Thrift program: <s>$2,195</s><font color='#CC0000'> $1,995 Early bird price through June 13</font></li><li class='bullets'>Insurance program: <s>$1,695</s><font color='#CC0000'> $1,495 Early bird price through June 13</font></li><li class='bullets'>Entire program: <s>$3,395</s><font color='#CC0000'> $3,095 Early bird price through June 13</font></li></ul><br />";
}


/*Rajes SP 54567 (10/24/2008)*/
function special_pricing() {
	var markCode = document.register.discountCode.value;
	if (markCode=="TS09") {		
		//alert("RS1004");
		ff=(495*1); //Discount of $100 off the regular price $995.00
		//fb=(695*1);
		calculateValues();
	} else if (markCode=="SNLSUF09") {		
		//alert("RS1004");
		ff=(750*1); //Discount of $100 off the regular price $995.00
		//fb=(695*1);
		calculateValues();
	} else {
		ff=(995*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')) {
		// this function comes from https://www.snl.com/exnet/utilmanda/2008/registration.asp where there is a discount on multiple (>1) participants
		var discount = 0;	
		
		pf=(document.register.participants_full.value*1);
		pb=0;
		pi=0;
		
		document.register.participants.value = pf+pb+pi;
		var q = document.register.participants.value;
		
		if (q > 9999) { //bulk discount number of full price registrants - 99999 means that there is no auto bulk discount
			discount = 100*(q-1);
		}
		
		tf=(pf*ff)-discount;
		tb=0;
		ti=0;
		
		//document.register.fee_full.value = tf;
		document.register.total.value = tf+tb+ti;
		
		//document.register.deposit_amt.value=0*1;
		//for (i=1;i<=q;i++) {
		//	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('disp_fee').innerHTML='$'+ff;
		document.getElementById('disp_total').innerHTML='$'+tf;
	}
}

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);
	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.value;
	if (r<1) { error+='\nPlease enter the number of participants.\n\n'; }
	// SP 71360 RC: 05/20/2009
	var partError='false';
	var message="";
	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=='' || 
		document.getElementById('part_badge_'+i).value=='') {
			partError='true';
			/*message += "Participant"+i+"\n";
			if(document.getElementById('part_first_'+i).value=='') {
				message += "First Name is required.\n";
			}			
			if(document.getElementById('part_last_'+i).value=='') {
				message += "Last Name is required.\n";
			}			
			if(document.getElementById('part_position_'+i).value=='') {
				message += "Position is required.\n";
			}			
			if(document.getElementById('part_badge_'+i).value=='') {
				message += "Name on Name Badge is required.\n"; // document.getElementById('part_badge_'+i).getAttribute('name');
			}
			if(document.getElementById('part_email_'+i).value=='') {
				message += "Email is required.\n";
			}
			message += "\n";*/
		}
	}
	if(partError=='true') 
	{ 
		error+='\nPlease enter all Participant Information.\n';		
		//error+= message;
	}
	// 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', 'ef09', 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>')
	//}
//}


/* SP 81474 [RC: 09/15/2009] */
/* Presentation Download page validation Form*/
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', 'SUF2009', 1, '/', '', '' )		
		// Submit Form If No Errors
		return true;
		//alert("eagh");
	}
}

function checkpassword() {
	var Password = document.register.Password.value;	
	if (Password=="SUF2009" && document.getElementById('ta').checked) {		
		document.register.Submit.disabled = false;
	} else {
		document.register.Submit.disabled = true;
	}
}