/************************************** Splendid *************************************
* Created By:		Steve Doggett
* Creation Date:	24th July 2009
* Edited ----------------------------------------------------------------------------
*      By: Prism        On: 6th August 2009 (to support reselection of appropriate card upon failed form submit
*      By:              On:
* Description -----------------------------------------------------------------------
*      This file handles the evoucher functionality
*      Uses JQuery.
*      Example:
*           29_e-vouchers.html
*
* Functions -------------------------------------------------------------------------
*       addOverlayToAllImages()     // Adds the overlay opacity to all the images
*       initImages()                // Run the first time so that the first image is selected by default when the page is loaded.
*
* Event Handlers --------------------------------------------------------------------
*       pTag_onClick()              // Handles the click event on the p tag around the image
*       radioBtn_onClick()          // Handles the click event on the radio button underneath an image
*
**************************************************************************************/

/********************************** Global Variables *********************************/
$(document).ready(function() {
    $('.stepOne p').click(function() {
        pTag_onClick(this);
    });

    $('.stepOne input').click(function() {
        radioBtn_onClick(this);
    });
});


/************************************** Functions *************************************/
/****
 * Adds the overlay opacity to all the images
 ****/
function addOverlayToAllImages() {
    $('.stepOne p img').addClass("overlay");
}

/*********************************** Event Handlers ***********************************/
/****
 * Handles the click event on the p tag around the image
 ****/
function pTag_onClick(which) {
    addOverlayToAllImages();
    $("img", which).removeClass("overlay");
    $('input', which).attr('checked', 'checked');
}

/****
 * Handles the click event on the radio button underneath an image
 ****/
function radioBtn_onClick(which) {
    addOverlayToAllImages();
	var thisSelect = which.id.substring(8);
    $('#olay'+thisSelect).removeClass("overlay");
}
