
/**
 * Return true if this page has power45 related elements
 */
function has_power45() {
	return ( $('input.power45_type_regular').size() > 0 );
}

/**
 * Show or hide the powerball. It gets hidden when Power45 is selected.
 */
function show_hide_powerball(show) {
	// set1 is the powerball set
	$('.numb_field.set1').each(function(){
		// Hide or show the number input field
		$(this).toggle(show);
		// Show or hide the Power45 text
		$('+ .power45text',this).toggle(!show);
	});

	// Swap in the correct available count drop down select
	// Have to tweak the name so when a submit happens it uses the correct one..
	$('#regular_count_choices').toggle(show ).find('select').attr('name', ( show ? 'new_count' : 'other_new_count' ));
	$('#power45_count_choices').toggle(!show).find('select').attr('name', (!show ? 'new_count' : 'other_new_count' ));

	// The second table in picker is the powerball picker
	$('#picker table:eq(1)').toggle(show);

	// Do this to refresh the triangle shaped arrow position. See play_picker.js
	select_game(current.game,null,true);

	// Swap the set counts
	var temp = set_counts;
	set_counts = other_set_counts;
	other_set_counts = temp;
}


/**
 * Setup Power45 related behaviours
 */
function power45_setup() {
	if (has_power45()) {

		// Get a container element for the Power45 radio buttons
		//var $container = $('input[name=game_offer_id]:radio:first').closest('table');


		// Apply some behaviour to the Regular/Power45 radio buttons
		//$container.find('input[name=game_offer_id]:radio').click(function(){
		//	show_hide_powerball($container.find('input[name=game_offer_id]:radio:checked').hasClass('power45_type_regular'));
		//});
	}
}

$(document).ready(power45_setup);


