$(document).ready(function(){
	

	tosLinkUpdate();

	$("#pinForm").validate({
		rules: {
			firstname: {
				required: true
			},
			lastname: {
				required: true
			},
			email: {
				required: true,
				email: true
			},
			client: {
				required: true,
				digits: true,
				minlength: 14,
				maxlength: 14
			},
			event: {
				required: true
			},
			tos: {
				required: true
			}
			
		}
	});
	
	$('#event').change(function(){
		tosLinkUpdate();
	});
	
});



function tosLinkUpdate(){

	// read the TOS URL from the rel attribute
	var toslink=$('#event option:selected').attr('rel');
	
	if(toslink){
		// populate the TOS link holder span
		$('#tosLink').html('Yes, I agree with the <a href="'+toslink+'" target="_new_window">Terms of Service</a>');
		$('#tosContainer').show();	
		$('#formSubmit').show();
	} else {
		$('#tosLink').html('');				
		$('#tosContainer').hide();
		$('#formSubmit').hide();
	}

	// since the TOS has changed, unset the tick box if it was previously set
	//$('#tos').attr('checked',false);		

	// the bosses want the box pre-checked ... lame but true
	$('#tos').attr('checked',true);		
	

}
