

/***************************************************************************
// INIT
***************************************************************************/

		
// jquery ready event
$(document).ready(
	function() {
		initRegistration();
	}
);

function initRegistration(){
	var checksExist = exists( "input.check" );
	//console.log( "Checks Exists : " + checksExist );
	if( exists( "input.check" ) ) {
		// hide all of the children
		$( '.checklist' ).hide();
		
		//setup allow checkboxes to show / hide children
		$('input.check').each(function(index) {
			checkChange( $( this ) );
		  });
	}
}

function checkChange( checkBox, fields ){
	//check for initial check?
	var checked = $( checkBox ).attr('checked');
	toggleCheckBox( checkBox );
	
	$( checkBox ).change(
		function()
		{
			toggleCheckBox( $( this ) );
		}
	);
}

function toggleCheckBox( checkBox ){
	var children = $(checkBox).parent().next();
	var checked = $(checkBox).attr('checked');
	//console.log( "checked : " + checked );
	if( checked ){
		children.show();
		}else{
		children.hide();
	}
}





/***************************************************************************
// HELPERS
***************************************************************************/

/* 	@param		string		#element */
function exists( e ){
return $(e).length > 0;
}

