// JavaScript Document

$(document).ready(function(){
	
	//instead of re-load a whole page, we simply call the inner content page and load it into the #content div
	
	$(".dummy").click(function(event){
		
		event.preventDefault();
		
		
		href	=	$(this).attr("href");
		href	=	href.substring(2);

		href	=	"/includes/page_loader_standalone.php?" + href;							  
		
		$("#content").fadeTo("fast", 0.01, function(){
											   
			$(this).load(href, "", function(){
												  
				//once the content has loaded we want the content div to gradually adjust
				//to the new height
				
				new_content_height	=	$("#content").height();
				$(this).fadeTo("fast", 1);
												   
												   
			});//end load								  
											   
											   
	   });//end slideUp

		
	})
	
	
	
});//end jquery

function shortlist(id, name, action){
	
	
	//work out the width of the usable are of #content
	var actual_space	=	$("#content").outerWidth(false) - 60; //60 is the padding (left and right combined)
	var url				=	"/includes/functions.inc.php?function=shortlist&";	
	var prams			= 	"prams[ID]=" + id + "&prams[First_name]=" + name + "&prams[action]=" + action + "&prams[actual_space]=" + actual_space;
	
	$("#message_box").load(url, prams, function(response){
							
		if (action == "add")	show_message(response, 2000);
		
	});//end load
	
}//end shortlist


function show_message(message, duration){
	
	opacity = 0.9;
	if (message == '') message = "No message";
	$("#message_box").html(message);
	$("#message_box").fadeTo(0, opacity).fadeIn("slow");
	
	//0 means infinate
	if (duration != 0)	setTimeout("$('#message_box').fadeOut('slow');", duration);
}
