jQuery(document).ready(function(){
	//allow $ to be used within this set of functions
	var $ = jQuery.noConflict();
	
	
/* ========= equal heights ========== */
	function equalHeight(group) {
		var tallest = 0;
		group.each(function() {
			var thisHeight = $(this).outerHeight();
			if(thisHeight > tallest) 
			{
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}
	
	equalHeight($(".front-large"));


	$('#home .home_item:last-child').css('margin-right', 0);


	$('form#tell-a-friend').hide();
	$('a#tell-friend').click(function(){
		if ($.browser.msie)
		{
			$(this).parent().stop().find('form#tell-a-friend').addClass('active').slideToggle();
		}
		else
		{
			$(this).parents('ul').stop().find('form#tell-a-friend').addClass('active').slideToggle();
		}		
		return false;
	});
	
	
	
	
/* ===== book mark ===== */

	//webkit doesnt support this so remove button from view
	if ($.browser.webkit)
	{
		$("a#bookmark").parent('li').hide(); 
	}
	
	$("a#bookmark").click(function(){

		var bookmarkUrl = this.href;
		var bookmarkTitle = this.title;
	 
		if ($.browser.mozilla) // For Mozilla Firefox Bookmark
		{ 
			window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
		} 
		else if($.browser.msie || $.browser.webkit) // For IE Favorite
		{ 
			window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
		}
		else if($.browser.opera ) // For Opera Browsers
		{ 
			$("a#bookmark").attr("href",bookmarkUrl);
			$("a#bookmark").attr("title",bookmarkTitle);
			$("a#bookmark").attr("rel","sidebar");
			$("a#bookmark").click();
		} 
		else // for other browsers which does not support
		{ 
			 alert('Please hold CTRL+D and click the link to bookmark it in your browser.');
			 return false;
		}
		return false; 
	});
	

	
	

/* ===== user vacancy application ====== */

	//$('#application-content').hide();

	//$('a#application-trigger').click(function(){
		//$(this).addClass('round_top').next('#application-content').slideToggle();
		//return false;
	//});




/* === user cv confi ==== */
	
	$('a#toggle-conf').click(function(){
		$(this).toggleClass('active').toggleClass('round_top').parents('li').stop().next('li').slideToggle(500, function(){
																  
		});
		return false; 
	});
	
	$('#cancel-cv-delete').click(function(){
		$(this).parents('li#delete').stop().slideUp(500).end().parents('.user-cv-wrapper').stop().find('a#toggle-conf').removeClass('active');	
	});


/* ==== user login js === */
	if ($('#client-form').length)
	{
		$('#client-wrapper #client-form').hide();
		
		$('a#logged-in').click(function(){
										
			if($('#client-form').is(':visible'))
			{
				$('a#logged-in').removeClass('active').removeClass('round_top');
			}
			else
			{
				$('a#logged-in').addClass('active').addClass('round_top');
			}						
			
			$('#client-wrapper #client-form').slideToggle(350, function(){
				//if the form is visible move focus to the first input text element
				if($('#client-form').is(':visible'))
				{
					$('#client-form form#loginform ul#login_list li input#user_login').focus();
				}
			});
			
			return false;
		});
	}
	
	//get ride of link love completely, not just hide
	$('p.linklove').remove();


	$('.child-row .child:last-child').css('margin-right', '0');
	//$('.row .child:last-child').css('margin-right', '0');


	$('#content .input-wrap:odd').addClass('alt-colour');


	$('span.help-content').hide();
	$('a.help-trigger').click(function(){
		$(this).next('span.help-content').slideToggle(750);
		return false; 
	});
	
	$('ul#fish li:first-child a').addClass('round_left');
	$('ul#fish li:last-child a').addClass('round_right');
	
	$('ul.saved-meta').hide();
	$('a.saved-trigger').click(function(){
		$(this).next('ul.saved-meta').slideToggle().end().toggleClass('active');
		return false;
	});

	

	//for the item listing pages
	$('.item_content').hide();
	
	$("a.item_trigger").click(function()
	{
		$(this).parents('.item').find('.item_content').stop().slideToggle();
		$(this).toggleClass('active');
		return false;
	});
	
	//=============for the sidebar ===============//
	$('.sidebar_item_content').hide();
	
	$('.show').show().parents('.sidebar_item').find('a.sidebar_trigger').stop().addClass('active');
	$("a.sidebar_trigger").click(function()
	{
		$(this).parents('.sidebar_item').find('.sidebar_item_content').stop().slideToggle();
		$(this).toggleClass('active');
		return false;
	});
	
	//==============for the sidebar ==============//
	$('ul.additional').hide();
	
	$("a.additional_trigger").click(function()
	{
		$(this).parents('li').find('ul.additional').stop().slideToggle();
		$(this).toggleClass('active');
		return false;
	});
	
	
});
