var $nb = jQuery.noConflict();

$nb(document).ready(function(){
	
	//add tooltips to map
    $nb('.our_care_map a[title]').qtip({
		style: { classes: 'ui-tooltip-dark ui-tooltip-shadow',
			tip: { corner: true}
		},
		position: { my: 'top right'}
	});
	
	
	// add extra padding to the sub menu
	$nb('.sub-menu').prepend('<li class="no_hover"><a href="#" onclick="return false;"></a></li>');
	$nb('.sub-menu').append('<li class="no_hover"><a href="#" onclick="return false;"></a></li>');
	
	
	//our homes pages, the effects in the 'slider' area
	$nb('.our_other_homes').click(function() {
		$nb('.map_popout').fadeIn(1000, function() { 
			//$nb('.map_enclosure').show('slide', {direction: "right"}, 1500 ); 
			$nb('.map_popout').css('overflow', 'hidden');			
			$nb('.map_enclosure').css('position', 'relative');
			$nb('.map_enclosure').css('right', '-150px');
			$nb('.map_enclosure').animate({
				opacity: 'toggle', 
				right: 0
			}, 650, 'easeOutSine');
			
			
		});
		return false;
	});
	$nb('.close_map').click(function() {
		$nb('.map_enclosure').animate({
			opacity: 'toggle', 
			right: '-150'
		}, 650, 'easeOutSine', 
			function() {
				$nb('.map_popout').fadeOut(500); 
			}
		);
		return false;
	});
	
	
	//expanding boxes on about us
	$nb(".expand_content").hide();
	$nb(".trigger").click(function(){
		$nb(this).toggleClass("trigg_down");
		$nb(this).next(".expand_content").slideToggle("fast");
		return false;
	});
	
	//expanding boxes on careers
	$nb(".post-type-archive-careers .trigger").click(function(){
		$nb("#all-latest-vacancies .entry-content").hide().toggleClass("trigg_down");
		$nb("#all-positions-available .entry-content").hide().toggleClass("trigg_down");															  
		$nb(this).next(".entry-content").slideToggle("fast").toggleClass("trigg_down");
		return false;
	});
	
	//when clicking on a link in the left column, jump to the corresponding job and open expandy box
	$nb('#job-vacancies-list li a').click(function() {
		$nb("#all-latest-vacancies .entry-content").hide().removeClass("trigg_down");
		var link_id = $nb(this).attr('href');
		$nb(link_id + " .entry-content").show();
		$nb('#all-latest-vacancies').show();
	});
	
	$nb('#positions-list li a').click(function() {
		$nb("#all-positions-available .entry-content").hide().removeClass("trigg_down");
		var link_id = $nb(this).attr('href');
		$nb(link_id + " .entry-content").show();
		$nb('#all-positions-available').show();
	});

	// external links
	$nb("a[rel='external']").addClass("external").attr('title', function() { return this.title + ' (Opens in New Window)' }).click(function() { window.open(this.href); return false; });

	
	// remove margin on last item
	$nb(".blog_feed li:last-child").addClass("noMargin");
		
});
