// JavaScript Document

var $j = jQuery.noConflict();

$j(function() {
		   // Set up the more courses button
		   if( $j( '.product_slide_inner' ).length > 3 ) {
			   $j( 'a.more_courses' ).click( function(e) {
													var l = parseInt( $j( '#product_scroller' ).css('left') );
													var w = parseInt( $j( '#product_scroller' ).css('width') );
													var ml = ( w - ( 220 * 3 ) ) *-1; // as far left as we can go
													
													if ( l == ml ) {
														l = 0;
													} else {
														l = l + ( 220 * -3 );
													}
													
													if ( l < ml ) l = ml;
																										
													$j( '#product_scroller' ).animate({ left:( l + 'px' ) });
													
													e.preventDefault();
													});
		   } else {
			   $j( 'a.more_courses' ).hide();
		   }
		   
		   // Set up the attendee information
		   $j( '#order-data-regfirstname' ).blur( function() { $j( '#firstname' ).val( $j( '#order-data-regfirstname' ).val() ); } );
		   $j( '#order-data-reglastname' ).blur( function() { $j( '#lastname' ).val( $j( '#order-data-reglastname' ).val() ); } );
		   $j( '#order-data-regphone' ).blur( function() { $j( '#phone' ).val( $j( '#order-data-regphone' ).val() ); } );
		   $j( '#order-data-regemail' ).blur( function() { $j( '#email' ).val( $j( '#order-data-regemail' ).val() ); } );
		   
		   // fix the other referal method
		   otherReferralMethod_Checked();
		   $j( 'input:radio','#checkout').click( otherReferralMethod_Checked );
		   
		   });

function otherReferralMethod_Checked() {
	
	var refmeth = $j( 'input:radio', '#checkout' ).length;
	if( $j( 'input:radio:eq(' + (refmeth - 1) + ')', '#checkout' ).attr( 'checked' ) ) {
	   $j( '#order-data-referralother' ).css( 'display','');
	} else {
	   $j( '#order-data-referralother' ).css( 'display','none');
	   $j( '#order-data-referralother' ).val('');
	}
}
