od47(document).ready(function(){
	od47('a.more-info').click(function()
	{
		overlay();
		od47('#more-info').fadeIn(400).css('left' , offset.left+240 + 'px').css('top' , offset.top+240 + 'px');
	});

// basic validation 

	od47('#alphabetical-list input[type="submit"]').click(function()
		{
			var consultantLed = od47('#birth-guide-search select:nth(0)').val();
			var midwifeLed = od47('#birth-guide-search select:nth(1)').val();
			if(consultantLed<1 && midwifeLed<1)
				{
					overlay();
					od47('#alphabetical-list .error-message').show();
					return false;
				}
			
		});

	od47('#postcode-search input[type="submit"]').click(function()
		{
			var postcode = od47('#postcode-search input[type="text"]').val();
			postcodeLength = postcode.length;
			if(postcodeLength<3)
				{
					overlay();
					od47('#postcode-search .error-message').show();
					return false;
				}
			
			
		});

	od47('.error-message .close input').click(function()
	{
		od47(this).parent().parent().fadeOut(400);
		hideOverlay();
		return false;
	});
	
	od47('#postcode-search input[type="text"]').focus(function()
		{
			od47('#postcode-search em.error').removeAttr('style');
		});

	od47('#birth-guide-search select:nth(0)').change(function()
		{
			od47('#birth-guide-search select:nth(1) option:nth(0)').attr('selected' , 'selected');
		});
	od47('#birth-guide-search select:nth(1)').change(function()
		{
			od47('#birth-guide-search select:nth(0) option:nth(0)').attr('selected' , 'selected');
		});

od47('.image-container div').hide();
od47('.image-container div:first-child').show();
od47('.graph-container li').css("cursor" , "pointer").click(function() 
	{
		od47('.graph-container li').removeClass('current');
		od47(this).addClass('current');
		od47('.image-container div').hide();
		var thisGraph = od47('.graph-tabs li').index(this);
		od47('.image-container div:nth('+ thisGraph +')').fadeIn(300);
		return false;
    	});
    
od47('#page-navigation li:not(:last)').append('<img src="/images/content/info-icon-small.gif" alt="more information" />\n<div class="page-nav-loader"></div>');

od47('#page-navigation li a:not(:last)').toggle(function()
	{
		var href= od47(this).attr('href');
		od47(this).siblings('.page-nav-loader:hidden').show().load('' + href + ' #birth-guide-detail', 
		function(){
  			od47(this).css('background' , 'none');
  			}
  		);
		od47(this).parent().addClass('minimise');
		return false;
	}, function()
	{
		od47(this).siblings('.page-nav-loader:visible').slideUp(200);
		od47(this).parent().removeClass('minimise');
		return false;
	});

od47('.more-information').css('top' , '40%');

od47('#page-navigation li img').click(function()
	{
		overlay();
		var thisImg = od47('#page-navigation li img').index(this);
		var thisInfo = thisImg-1;
		od47('#more-info-container .more-information:nth('+ thisInfo +')').show();
	});

});

