$(document).ready(function() {
				
	// Fade accreditations in and out
	if ($('#accreditations-fade').length)
	{
		$('#accreditations-fade').innerfade({
			animationtype: 'fade',
			speed: 1000, 
			timeout: 3000,
			type: 'sequence'
		}); 
	}
	// Fade Banners in and out
	if ($('.banner-fade').length)
	{
		$('.banner-fade').innerfade({
			animationtype: 'fade',
			speed: 1500, 
			timeout: 4000,
			type: 'sequence'
		}); 
	}
	
	// Set background image for first property
	$bg_url = '/images/projects/thumbs/' + $('.splash-background-image:first').html();
	$('#splash').css('background-image', 'url("' + $bg_url + '")'); 

	$("#splash li.fill").hover(
	 
	 function () {
		$(this).animate({ width: "100%" }, 200);
		$(this).children('div').fadeIn(400);
		
		$bg_url = '/images/projects/thumbs/' + $(this).children('.splash-background-image').html();
		$('#splash').css('background-image', 'url("' + $bg_url + '")'); 
	  },
	  function () {
		$(this).animate({ width: "290px" }, 200);
		$(this).children('div').fadeOut(10);
		$(this).children('div').css('display', 'none');
	  }
	);
	
	
	$("#splash .btn").click( function (){
		
		$current_pos = $("#splash ul").position();
		
		if ( $(this).hasClass('up'))
		{
			if ($current_pos.top == 21)
			{
				$last = $("#splash ul li").last();
				$last.clone(true).prependTo('#splash ul');
				$last.remove();
				$new_pos = $current_pos.top;
			}
			else $new_pos = $current_pos.top + 90;
		}
		else if ( $(this).hasClass('down'))
		{
			if ($current_pos.top == 21)
			{
				$first = $("#splash ul li").first();
				$first.clone(true).appendTo('#splash ul');
				$first.remove();
				$new_pos = $current_pos.top;
			}
			else $new_pos = $current_pos.top - 90;
		}
		
		$("#splash ul").animate({ top: $new_pos + 'px' }, 100);
		
	});
	
	// Overlays
	//$(function() {
	//	$("img[rel]").overlay({mask: '#000', effect: 'apple'});
	//});

	// Clear contact form contents on click
	$('#contact-form input').click( function (){
		$(this).val('');									  
	});
	$('#contact-form textarea').click( function (){
		$(this).html('');									  
	});


$('#image-list a').lightBox({
	//fixedNavigation:true,
	overlayBgColor: '#FFF',
	overlayOpacity: 0.6,
	imageLoading: '/images/lightbox-ico-loading.gif',
	imageBtnClose: '/images/lightbox-btn-close.gif',
	imageBtnPrev: '/images/lightbox-btn-prev.gif',
	imageBtnNext: '/images/lightbox-btn-next.gif',
	containerResizeSpeed: 350
	});

});


	

// Submit contact form
function submit_form()
{
	$('#contact-form .msg').slideUp();
	$('#contact-form .submit').css('display', 'none');
	$('#contact-form .ajax-loader').css('display', 'block');
	
	$name = $('#form-name').val();
	$email = $('#form-email').val();
	$enquiry = $('#form-enquiry').val();
	
	// Check postcode with ajax
	$.post("/includes/ajax.php?q=submit_form", {name : $name, email : $email, enquiry : $enquiry}, function(data) 
	{
		if (data)
		{
			if (data == 1)
			{
				$msg = '<div class="success">Thank you for getting in touch - we will get back to you as soon as possible.</div>';
				$('#contact-form .submit').css('display', 'none');
				$('#form-name').val('');
				$('#form-email').val('');
				$('#form-enquiry').val('');

			}
			else
			{
				$msg = data;	
			}
			
			$('#contact-form .ajax-loader').css('display', 'none');
			if (data != 1) $('#contact-form .submit').css('display', 'block');
			$('.msg').html($msg);
			$('.msg').slideDown();
		}
		
	}, "json");
	
	
	
	return;
}

function show_hide ($id)
{								 
	$('.director p').slideUp(200).delay(300);
	$('.director .show_hide').fadeIn(100).delay(300);
	
	$('#director' + $id + ' p').fadeIn(300);
	$('#director' + $id + ' .show_hide').fadeOut(100);

}
