/**
 * Clay Shooting Masters Protx Payment Integration
 *
 * JavaScript
 *
 * @author		Clear Media UK Ltd Dev Team
 * @copyright	Copyright (c) 2008 Clear Media UK Ltd.
 * @license		MIT
 * @link		http://clearmediawebsites.co.uk
 * @since		Version 1.0
 * @package		Clay Shooting Masters
 */

	/**
	 * @integer number of participant fieldsets
	 */
	var total_participants = 5;

	//-------------------------------
	 
	/**
	 * Sets up form so that participant details are hidden by default
	 * enables the form to work without CSS support
	 *
	 * @param void
	 * @return void
	 * @package Clay Shooting Masters 
	 */
	function initialise()
	{
		// loop through all the participant fields and hide them
		for(var i = total_participants; i >= 1; i--) {
		
			document.getElementById('participant' + i).style.display = 'none';
			
		}	
		
		document.getElementById('squad_size').value = 0;
	} 

	//-------------------------------
	 
	/**
	 * Loops through specified fieldsets setting them to display:inline
	 * via css.
	 *
	 * @param int
	 * @package Clay Shooting Masters
	 */
	function show_details(participants)
	{
		// loop through all the participant fields and hide them
		for(var i = total_participants; i >= 1; i--) {
		
			document.getElementById('participant' + i).style.display = 'none';
			
		}

		// Show the participant fields that we want
		for(var i = participants; i >= 1; i--) {
		
			document.getElementById('participant' + i).style.display = 'block';
			
		}
	}

	//-------------------------------
	
	/**
	 * Simply generates an error message if any required fields are incomplete
	 *
	 * @param void
	 * @return bool
	 * @package Clay Shooting Masters
	 */	
	function validate()
	{
		var surname = document.getElementById('surname').value;
		var first_name = document.getElementById('first_name').value;
		var address = document.getElementById('address').value;
		var city = document.getElementById('city').value;
		var postcode = document.getElementById('postcode').value;
		var email = document.getElementById('email').value;
		
		if((surname == '') || (first_name == '') || (address == '') || (city == '') || (postcode == '') || (email == '')) {
			alert('Please complete all required details!');
			return false;
		} else {
			return true;
		}
	}