var now = new Date();
var cutoff = new Date(2010,8,2);   //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=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 = "Registration Fee: <s>$1795</s><font color='#ff0000'><strong> $1595 Early bird price through Wednesday, September 1, 2010</strong></font>";
}


function special_pricing() {
var markcode ="euf1010";
var markcodevalue = document.register.Discount_Code.value;
var markcodevalue1 = markcodevalue.toLowerCase();
if ( markcode == markcodevalue1 ) {
	//alert("check");
	//document.getElementById('pmt_tbl').style.display='none'
//ff=(1595*1)	;
//fb=(695*1)	;
ff=1595;
calculateValues();
}
else {
	//ff=2195;
	//document.getElementById('pmt_tbl').style.display='block'
	ff=ff	;
calculateValues();
}
}



function showParticipantRows() {
	
	if (document.getElementById('participant_table1')){ //to fix error after submit		
		/*document.getElementById('pricing_table1').style.display='block'*/
		
		var q = document.register.participants_full.value;
		
		if (q <= 6) {	
			for (i=1;i<=q;i++) {
				if (i==1) {
					document.getElementById('participant_table1').style.display='block'
					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 79728 [RC: 08/21/2009]
				document.getElementById('part_position_'+i).value='';
				document.getElementById('part_badge_'+i).value='';
				if (i==1) {
					document.getElementById('participant_table1').style.display='none'
					document.getElementById('CopyMe').style.display='none';
					document.getElementById('CopyMeRadio').checked=false;
				}	
			}		
		}else {
			alert("Please enter valid number for participants");
		}	
	}
}

function calculateValues() {
	//var MarketingCode = document.register.discountCode.value;
	//regular expression on script
	//var mcodeinsmall= MarketingCode.toLowerCase();	
	
	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;
		

	}
}


var dup = "false";
function duplicateEntry() {
	dup = "false";
	var q = document.register.participants_full.value;
	if(q > 1){
		//alert(q);
		for(i=2;i<=q;i++){
			for(j=q;j>=1;j--){
				if(j!= i){
			//alert(document.getElementById('part_first_'+i).id);
			var fname = document.getElementById('part_first_'+i).value;
			var lname =  document.getElementById('part_last_'+i).value;
			var fname2 = document.getElementById('part_first_'+[j]).value;
			var lname2= document.getElementById('part_last_'+[j]).value;
			var firsttest=fname +" " + lname;
			var secondtest=fname2 +" " + lname2;
			if ( firsttest == secondtest ) {
				dup = "true";
			alert("Duplicate entries");
			return dup;
				}
				
				}
			}
		}
	}
}



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); 
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';
}



duplicateEntry();
// Validate Participant Information
var r = document.register.participants_full.value;
if (r<1) { error+='\nPlease enter the number of participants.\n\n'; }
if (r>6) { error+='\nPlease enter valid number of participants.\n\n'; }
if (dup == "true") { error+='\nPlease avoid same names for 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 (document.getElementById('part_badge_'+i).value=='') {
		nametagError='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', 'euf10', 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 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])};
}






//function for manual pricing override

var overRiden = "false";

function superOverRide() {
	

	var newPrice = 0;
	var oldPrice = 0;
	var discountAmount = 0;
			
			
			var q = document.register.participants_full.value;
			
			
			for (i=1;i<=q;i++) {

				newPrice = newPrice + parseInt(document.getElementById('part_discount_'+i).value);
			}
			
			
			
			oldPrice = (q * 1595);
			discountAmount = (oldPrice - newPrice);
			
			// alert("old price is " + oldPrice);
			// alert("new price is " + newPrice);
			// alert("discount amoutn is " + discountAmount);
			

			document.register.discountAmount.value = discountAmount;
			document.register.total.value = newPrice;
			
			//document.getElementById('disp_fee').innerHTML = "*$" + Math.round(newPrice/q);
			document.getElementById('disp_total').innerHTML = newPrice;
			overRiden = "true";
		

	
}	
	
	
	
	
	
	
//Functions for triggerdate	
	
	var now = new Date();
	var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    var months = new Array('1','2','3','4','5','6','7','8','9','10','11','12');

	var date = now.getDate();



function week_before(s) {
    // parse s for month, day, year
    var dateArray = s.split('/');
    sdate = new Date(dateArray[2],dateArray[0]-1,dateArray[1]);

// figure out day, month, year 7 days ago
    var odate = new Date(sdate.getTime());
//
function fourdigits(number)  {
      return (number < 1000) ? number + 1900 : number;
}

// return value

    //return (odate.getMonth()+1) + '/' + odate.getDate() + '/' + (fourdigits(odate.getYear()));
	return sdate;
}



var isNS4 = (navigator.appName=="Netscape")?1:0;


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}


function Validate_String(string, return_invalid_chars)
         {
         valid_chars = '1234567890-_.^~abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         invalid_chars = '';
         
         if(string == null || string == '')
            return(true);
         
         //For every character on the string.   
         for(index = 0; index < string.length; index++)
            {
            char = string.substr(index, 1);                        
            
            //Is it a valid character?
            if(valid_chars.indexOf(char) == -1)
              {
              //If not, is it already on the list of invalid characters?
              if(invalid_chars.indexOf(char) == -1)
                {
                //If it's not, add it.
                if(invalid_chars == '')
                   invalid_chars += char;
                else
                   invalid_chars += ', ' + char;
                }
              }
            }                     
            
         //If the string does not contain invalid characters, the function will return true.
         //If it does, it will either return false or a list of the invalid characters used
         //in the string, depending on the value of the second parameter.
         if(return_invalid_chars == true && invalid_chars != '')
           {
           last_comma = invalid_chars.lastIndexOf(',');
           
           if(last_comma != -1)
              invalid_chars = invalid_chars.substr(0, $last_comma) + 
              ' and ' + invalid_chars.substr(last_comma + 1, invalid_chars.length);
                      
           return(invalid_chars);
           }
         else
           return(invalid_chars == ''); 
         }


function Validate_Email_Address(email_address)
         {
		  email_address = trim(email_address);	 
         //Assumes that valid email addresses consist of user_name@domain.tld
         at = email_address.indexOf('@');
         dot = email_address.indexOf('.');
         
         if(at == -1 || 
            dot == -1 || 
            //dot <= at + 1 ||
            dot == 0 ||
            dot == email_address.length - 1)
            return(false);
            
         user_name = email_address.substr(0, at);
         domain_name = email_address.substr(at + 1, email_address.length);                  
         
         if(Validate_String(user_name) === false || 
            Validate_String(domain_name) === false)
            return(false);                     
         
         return(true);
         }





function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


// this fixes an issue with the old method, ambiguous values 
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}			



function clearField(g) {
if (document.getElementById(g).value == '') {
    document.getElementById('disc_invalid').style.display = 'none';
	}
}

function addressCopy() {
    document.register.BillingAddress1.value = document.register.MailingAddress1.value;
    document.register.BillingAddress2.value = document.register.MailingAddress2.value;
    document.register.BillingCity.value = document.register.City.value;
    document.register.BillingState.value = document.register.State.value;
    document.register.BillingZip.value = document.register.Zip.value;
}

function selectItem() {
if (document.getElementById('ta').checked) {
    document.register.Submit.disabled = false;
   } else {
    document.register.Submit.disabled = true;
   }
}

function divControl(e) {
    if (document.getElementById(e).style.display == 'none') {
        document.getElementById(e).style.display = 'block';
    } else {
        document.getElementById(e).style.display = 'none';
    }
}

function ccControl(e) {
    if (document.register.PaymentMethod.value == "Credit Card") {
        document.getElementById(e).style.display = 'block';
    } else {
        document.getElementById(e).style.display = 'none';
		document.register.deposit.value = 'false';
	    document.register.deposit.checked = false;
    }
}   

function noEnter(e) {
var pK = e ? e.which : window.event.keyCode;
return pK != 13;
}
document.onkeypress = noEnter;
if (document.layers) document.captureEvents(Event.KEYPRESS);  
 
function printpage() {
window.print();  
}

function submitform() {
  document.register.submit();
}

function resetform() {
  document.register.reset();
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  if (document.register.participants.value >= 3) {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
	}
}

function MM_showHide() { //v6.0
  var i,p,v,obj,args=MM_showHide.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function doNotEnter() {
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key>0||key<255)
          return false;
     else
          return true;
}





/*============================================================================*/

/*

This routine checks the credit card number. The following checks are made:

1. A number has been provided
2. The number is a right length for the card
3. The number has an appropriate prefix for the card
4. The number has a valid modulus 10 number check digit if required

If the validation fails an error is reported.

The structure of credit card formats was gleaned from a variety of sources on 
the web, although the best is probably on Wikepedia ("Credit card number"):

  http://en.wikipedia.org/wiki/Credit_card_number

Parameters:
            cardnumber           number on the card
            cardname             name of card as defined in the card list below

Author:     John Gardner
Date:       1st November 2003
Updated:    26th Feb. 2005      Additional cards added by request
Updated:    27th Nov. 2006      Additional cards added from Wikipedia
Updated:    18th Jan. 2008      Additional cards added from Wikipedia

*/

/*
   If a credit card number is invalid, an error reason is loaded into the 
   global ccErrorNo variable. This can be be used to index into the global error  
   string array to report the reason to the user if required:
   
   e.g. if (!checkCreditCard (number, name) alert (ccErrors(ccErrorNo);
*/

var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {
     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "Master Card", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "DinersClub", 
               length: "14,16", 
               prefixes: "300,301,302,303,304,305,36,38,55",
               checkdigit: true};
  cards [3] = {name: "CarteBlanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
  cards [4] = {name: "Amex", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011,650",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "15,16", 
               prefixes: "3,1800,2131",
               checkdigit: true};
  cards [7] = {name: "enRoute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
  cards [8] = {name: "Solo", 
               length: "16,18,19", 
               prefixes: "6334, 6767",
               checkdigit: true};
  cards [9] = {name: "Switch", 
               length: "16,18,19", 
               prefixes: "4903,4905,4911,4936,564182,633110,6333,6759",
               checkdigit: true};
  cards [10] = {name: "Maestro", 
               length: "16,18", 
               prefixes: "5020,6",
               checkdigit: true};
  cards [11] = {name: "VisaElectron", 
               length: "16", 
               prefixes: "417500,4917,4913",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardnumber = cardnumber.replace (/\s/g, "");
  
  // Check that the number is numeric
  var cardNo = cardnumber
  var cardexp = /^[0-9]{13,19}$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}

/*============================================================================*/

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 alertControl1(e) {
	if (!document.register.fedStateCommCheck.checked){
		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';
		}
	} else {
		document.getElementById(e).style.display = 'none';
		}
}


function addressCopyToParticipants() {
	
	if (document.forms[0].CopyMeRadio.checked){
    	document.register.part_first_1.value = document.register.FirstName.value;
	    document.register.part_last_1.value = document.register.LastName.value;
		document.register.part_position_1.value = document.register.Position.value;
		document.register.part_email_1.value = document.register.Email.value;
	} else {
    	document.register.part_first_1.value = '';
	    document.register.part_last_1.value = '';
		document.register.part_position_1.value = '';
		document.register.part_email_1.value = '';
		document.register.part_badge_1.value = '';				
	}
	
}

function checkmailbox() { 
	/*if (document.register.Email.value==document.register.cEmail.value)
	{
		document.getElementById('cem').innerHTML='Confirmed'
		document.getElementById('cem').style.color='green';
	} else {
		document.getElementById('cem').innerHTML=''
	}*/	
	var Emailobj = document.register.Email.value; //document.getElementById('Email');
	var cEmailobj = document.register.cEmail.value; //document.getElementById('cEmail');
	if ((Emailobj == cEmailobj) && cEmailobj != "")
	{
		document.getElementById('cem').innerHTML='Confirmed';
		//document.getElementById('cem').style.color='green';
	}
	else if ((Emailobj != cEmailobj) && cEmailobj != ""){
		 alert('Invalid Email Address!  Please re-enter.')
		// cEmailobj.select();
		//cEmailobj.focus();	
		 return false;
		 }
		 else if (Emailobj != cEmailobj){
		 alert('Invalid Email Address!  Please re-enter.')
		// cEmailobj.select();
		//cEmailobj.focus();	
		 return false;
		 }
	else{		
		document.getElementById('cem').innerHTML='';
		/*if (cEmailobj.value != Emailobj.value && cEmailobj.value != "" ) 
		{
			alert("Invalid Confirm Email Address! Please re-enter.");
			cEmailobj.select();
			cEmailobj.focus();			
		}*/
		//return false;  
	}
}
