<!--
//Contains scripts throughout site

//this script checks the members signup form
//found in pages/members_subpages/team_subpages/default.php
function check_member_signup(fname,lname,password,con_pass,gender,mobile,email)
{
	err_msg = "Please check you have filled in ";
	filled_in = true
	//make sure gender is selected
	if (gender[0].checked == false && gender[1].checked == false)
	{
		gender_checked = false;
	} else
	{
		gender_checked = true;
	}
	//check all required inputs and create an error message and change the filled_in variable if required
	if (fname == "" || fname == " ")
	{
		err_msg += "your first name, ";
		filled_in = false;
	}
	if (lname == "" || lname == " ")
	{
		err_msg += "your last name, ";
		filled_in = false;
	}
	if (password == "" || password == " ")
	{
		err_msg += "your password, ";
		filled_in = false;
	}
	if (gender_checked == false)
	{
		err_msg += "your gender, ";
		filled_in = false;
	}
	if (mobile == "" || mobile == " ")
	{
		err_msg += "your mobile number, ";
		filled_in = false;
	}
	if (email == "" || email == " ")
	{
		err_msg += "your email address, ";
		filled_in = false;
	}
	err_msg += "and click submit again.";
	
	if (filled_in == false)
	{
		alert(err_msg);
	}else if (password != con_pass)
	{
		alert("Your password did not match the confirmed password. Please fill in the password and confirm password fields again.");
		filled_in = false
	}
	
	return filled_in;
}

//this script changes the source of an image on the home page to the one clicked on
//found in pages/home.php
function change_main_img(img_name,photo_id,gal_thumb_id,total_thumbs)
{
	//change the main image
	document[img_name].src = "includes/show_photo.php?photo_id="+photo_id+"&type=main";
	//change the thumbnail to grey
	document.getElementById(gal_thumb_id).className = "gal_thum_grey";
	//change all other thumbnails to normal
	var i=0;
	while (i < total_thumbs)
	{
		if ("gal_thumb_"+i != gal_thumb_id)
		{
			document.getElementById("gal_thumb_"+i).className = "gal_thum_normal";
		}
		i++;
	}
}

//-----------------------------------------------------------------------------
//------------------From here on is all jquery script--------------------------
//-----------------------------------------------------------------------------

var total_cols;
var curr_col;
var goto_col;
var img_box_high;
var imgs_high;


$(function()
{
	// Menu Information & effects (.hover(fn,fn2) did not work well)
	$("#mullex_home").click(menuClicked).mouseover(function(){$(this).fadeTo(500,1);}).mouseout(function(){$(this).fadeTo("fast",.7)});
	$("#mullex_members").click(menuClicked).mouseover(function(){$(this).fadeTo(500,1);}).mouseout(function(){$(this).fadeTo("fast",.7)});
	$("#mullex_restaurant").click(menuClicked).mouseover(function(){$(this).fadeTo(500,1);}).mouseout(function(){$(this).fadeTo("fast",.7)});
	$("#mullex_functions").click(menuClicked).mouseover(function(){$(this).fadeTo(500,1);}).mouseout(function(){$(this).fadeTo("fast",.7)});
	$("#mullex_whats_on").click(menuClicked).mouseover(function(){$(this).fadeTo(500,1);}).mouseout(function(){$(this).fadeTo("fast",.7)});
	$("#mullex_contact_us").click(menuClicked).mouseover(function(){$(this).fadeTo(500,1);}).mouseout(function(){$(this).fadeTo("fast",.7)});
	
	// Gallery Information
	total_cols = $("#total_cols").text();
	curr_col = $("#curr_col").text();
	goto_col = $("#goto_col").text();
	img_box_high = $("#img_box_high").text();
	imgs_high = $("#imgs_high").text();
	
	//whats on admin
	$("#event_type").change(function(){event_type_changed();});
	
	for( i=1; i<=total_cols;i++ ) {
		if( i > imgs_high )
		{
			$("#gal_div"+i).hide();
		}
	}
	$("#gal_bottom").hide();
	
	if ( parseInt(imgs_high) >= parseInt(total_cols) )
	{
		$("#gal_top").hide();
	}
	$("#gal_top").click(clickUp);
	$("#gal_bottom").click(clickDown);
	
	//move to current location if needed
	if (goto_col > 1)
	{
		$i=1;
		while ($i < goto_col-1)
		{
			clickUp();
			$i++;
		}
	}
});

function menuClicked() {
	var href = ($(this).find("a").attr("href"));
	window.location=href;
}

function clickDown() {
	var right_column_name = "#gal_div" + (curr_col+parseInt(imgs_high-1)); // get the name for the right column
	$(right_column_name).fadeOut(500); //hide right col
	curr_col--; //move to next col
	//loop until to end col
	curr_move_col = curr_col+1; // which column to move
	curr_pos_pix = parseInt(img_box_high);
	curr_pos_img = 2;
	while ( curr_pos_img <= imgs_high )
	{
		var move_column_name = "#gal_div"+curr_move_col;
		$(move_column_name).animate({ top:curr_pos_pix+"px"}, 500); //move next col right
		curr_move_col++;
		curr_pos_img++;
		curr_pos_pix += parseInt(img_box_high);
	}
	$("#gal_div"+curr_col).fadeIn(500);//show the next col on the left
	//check to see wether left/right arrows need to be shown/hidden
	if (curr_col == 1)
	{
		$("#gal_bottom").fadeOut(500);
	}
	if (curr_col == (total_cols-imgs_high))
	{
		$("#gal_top").fadeIn(500);
	}
}

function clickUp() {
	$("#gal_div"+curr_col).fadeOut(500); //hide left col
	curr_col++; //move to next col
	//loop until to end col
	curr_move_col = curr_col
	curr_pos_pix = 0;
	curr_pos_img = 1;
	while ( curr_pos_img < imgs_high )
	{
		$("#gal_div"+curr_move_col).animate({ top:curr_pos_pix+"px"}, 500); //move next col left
		curr_move_col++;
		curr_pos_img++;
		curr_pos_pix += parseInt(img_box_high);
	}
	
	$("#gal_div"+(curr_col+parseInt(imgs_high-1))).fadeIn(500);//show the next col on the right
	//check to see wether left/right arrows need to be shown/hidden
	if(curr_col == 2)
	{
		$("#gal_bottom").fadeIn(500);
	}
	if (curr_col == (total_cols-imgs_high+1))
	{
		$("#gal_top").fadeOut(500);
	}
}

function event_type_changed()
{
	var curr_item = $("#item_id").text();
	
	if($("#event_type").val() == "none")
	{
		$("#event_form").html("");
	} else
	{
		if($("#event_type").val() == "attraction")
		{
			$("#event_form")
				.html("loading...")
				.load("pages/admin_subpages/whats_on/attraction_form.php", {'item_id':curr_item});
		} else if($("#event_type").val() == "entertainment")
		{
			$("#event_form")
				.html("loading...")
				.load("pages/admin_subpages/whats_on/entertainment_form.php", {'item_id':curr_item});
		}
	}
}
-->