function showImage(imageURL, imageAltTag, windowName, windowTitle, width, height)
{
	newWindow=window.open(imageURL,'windowName','width='+width+',height='+height+',toolbar=no,,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no');
	newWindow.document.write('<html><title>'+windowTitle+'<\/title><head><\/head><body style="margin:0;"><img src="'+imageURL+'" alt="'+imageAltTag+'"><\/body><\/html>');
	newWindow.focus();
}

function expandAll(view)
{
	$$('.toggle_cell').invoke(view);
}


/**
 * FIND YOUR GROUP FORM FUNCTIONS
 * These functions make ajax requests that returns a list of <option> elements
 * These elements are then inserted inside the relative <select> element
 * 
 * Requires jQuery
 */
/*
function ajax_load_towns(lea_area_div_id, town_div_id, group_div_id)
{
	var lea_area_div_id = typeof(lea_area_div_id) != 'undefined' ? lea_area_div_id : '#select-lea-area';
	var town_div_id = typeof(town_div_id) != 'undefined' ? town_div_id: '#select-town';
	// university_div_id & group_div_id are not strictly required, only so Town, School & Group can be cleared when Town choice changes.
	var university_div_id = typeof(university_div_id) != 'undefined' ? university_div_id: '#select-university';
	var group_div_id = typeof(group_div_id) != 'undefined' ? group_div_id: '#select-group';
	var area_id = jQuery(lea_area_div_id).val();

	jQuery.ajax({
		type: "GET",
		url: "/ajax.php",
		data: "action=booking_form&page=home&type=town&id="+area_id,
		success: function(new_html) {
			jQuery(town_div_id).html(new_html);
			jQuery(university_div_id+', '+group_div_id).empty();
		}
	});
}

function ajax_load_schools(town_div_id, university_div_id)
{
	var town_div_id = typeof(town_div_id) != 'undefined' ? town_div_id : '#select-town';
	var university_div_id  = typeof(university_div_id) != 'undefined' ? university_div_id : '#select-university';
	var group_div_id = typeof(group_div_id) != 'undefined' ? group_div_id: '#select-group';

	var town_id = jQuery(town_div_id).val();

	jQuery.ajax({
		type: "GET",
		url: "/ajax.php",
		data: "action=booking_form&page=home&type=school&id="+town_id,
		success: function(new_html) {
			jQuery(university_div_id).html(new_html);
			jQuery(group_div_id).empty();
		}
	});
}
*/

function ajax_load_groups()
{
	var area_id = jQuery('#select-lea-area').val();

	jQuery.ajax({
		type: "GET",
		url: "/ajax.php",
		data: "action=booking_form&page=home&type=groups&area="+area_id,
		success: function(new_html) {
			jQuery('#select-group').html(new_html);
		}
	});
}

/**
 * Redirect user to group homepage after selecting a group from drop down list on
 * 'find your group' form, or direct to event promoter page if user selected create own group
 *
 * Requires jQuery
 */
function redirect_to_group_page()
{
    group_name = jQuery('#select-group').val();
    window.location = (group_name == 'rep-apply') ? '/promote/apply/' : '/'+group_name;
}


/**
 * If rep application fails, this function hides the drop down boxes
 * to find your school, i.e. LEA area and town drop downs and just displays the
 * name of the last selected school
 */
function rep_application_failed_check_school()
{
	// hide the form
	jQuery('.choose_uni').hide();

	//show the name
	jQuery('#display_school_name').show();
}

/**
 * Hides the selected school name, clears the previously selected school and
 * shows the select your univerersity panel
 */
function rep_application_change_school()
{
	jQuery("#select-university option:selected").val('');
	jQuery('#display_school_name').fadeOut('slow', function() {
		jQuery('.choose_uni').fadeIn('slow');
	});
	return false;
}

// updates the accomodation hidden field on the booking form
function updateAccommodation()
{
    var accomm_name = jQuery("#select_accommodation option:selected").text();

    //Set the accommodation name
    if(accomm_name.indexOf("-") >= 0)
    {
	jQuery('#hidden_accom_name').val( accomm_name.substring(0, accomm_name.lastIndexOf('-')-1) );
    }
    else
    {
	jQuery('#hidden_accom_name').val( accomm_name );
    }
    
    //Extract the room/berth size from the Accommodation name
    var pos = accomm_name.lastIndexOf('-');
    // if accom has has limited number
    if(pos > 0)
    {
	    var room_size = accomm_name.substr(pos+2);
	    room_size = room_size.charAt(0);
	    if(isNaN(room_size)==true)
	    {
		    //Set a default room size.
		    room_size = 1;
	    }
    }
    else // if camping
    {
	// set default room size to 1
	room_size = 1;
	jQuery('#num_pax_row').show();
    }
    jQuery('#hidden_num_pax').val(room_size);

    // if accomm is camping
    if(accomm_name == 'Camping')
    {
	jQuery('#num_pax_row').show();
    }
    else {
	    jQuery('#num_pax_row').hide();
    }

}

function updatePaxNum()
{
    var pax_num = jQuery('#select_num_passengers option:selected').val();
    jQuery('#hidden_num_pax').val(pax_num);
}

function validateBookingForm()
{
    var accomm = jQuery('#hidden_accom_name').val()
    if(accomm == '' || accomm == 'Where you staying?...')
    {
        alert('Please select your accommodation');
        return false;
    }

    var num_pax = jQuery('#hidden_num_pax').val;
    if(parseInt(num_pax) == 0)
    {
	alert('Please select the number of passengers ');
	return false;
    }

    return true;
    
}