$j(document).ready(function(){
	$j("ul#nav li").first().addClass('first');
	$j("ul#nav li").last().addClass('last');
	$j(".page-template-homepage-php #content_text p").first().attr('id', 'intro_par');
	
	// Sort out the margins for images which immediately follow a page heading
	if ($j('#main h1').next().children(':first-child').is('img')) {
		var img = $j('#main h1').next().children(':first-child');
		img.css('margin', '0 0 25px 0');
	}
	
	// Sort out the margins for images at the top of a sidebar
	if ($j('#sidebar').children(':first-child').is('p')) {
		var p = $j('#sidebar').children(':first-child');
		if (p.children(':first-child').is('img')) {
			var img = p.children(':first-child');
			p.css('margin-top', '44px');
			img.css('margin', '-44px 0 15px 0');
		} else {
			p.css('margin-top', '-5px');
		}
	}
	
	// Link highlighting for the specialists page
	if ($j('#sidebar ul li:first').text() == 'Meet the specialists') {
		//alert($j('#sidebar ul li:first').text());
		var page = 	window.location.pathname;
		$j('#sidebar ul li a').each(function(){
			if($j(this).attr('href') == 'http://www.vermilion.co.uk'+page) {
				$j(this).parent().addClass('current_page_item');
			}
		});
	}
	
	//Extra spacing for pages with video clips
	if ($j('div.clip').length > 0) {
		$j('#maintext').css('padding-bottom', '48px');
	}
	
	// Scroll to top of page when form has been submitted
	$j('input.wpcf7-submit').click(function(){
		$j("html, body").animate({ scrollTop: 0 }, "fast");
	});
});
