$(document).ready(function() {

    // Dropdown menus
	$('#nav li').hover(
		function(){
			$(this).find('ul').show();
		},
		function(){
			$(this).find('ul').hide();
		}
	);

	// Rotating testimonials
	$('#panel-testimonials .panel-testimonial-quote');
	setInterval(function(){
		$('#panel-testimonials .panel-testimonial-quote').filter(':visible').fadeOut(1000,function(){
			if($(this).next('.panel-testimonial-quote').size()){
				$(this).next().fadeIn(1000);
			}
			else{
				$('#panel-testimonials .panel-testimonial-quote').eq(0).fadeIn(1000);
			}
		});
	},10000);

	// News ticker - jquerynewsticker.com
	$('#latest-news-ticker').ticker({
		titleText: '',
		controls: false,
		displayType: 'reveal',
		pauseOnItems: 5000
	});

	// Compensation guide
	$('.compguide-link').click(function(e){
		e.preventDefault();
		
		//reset dots to orange
		$('#compguide-bodyparts img').attr('src','/images/site/dot-orange.png');
		//and hide all the popups
		$('#compguide-info div').hide();
		
		//change dot to blue for this click
		var infoid = $(this).attr('href');
		$('img',this).attr('src','/images/site/dot-blue.png');
		
		//Show this popup
		$(infoid).fadeIn();
		
	});
	
	// jQuery UI datepicker
	$('#accident_date').datepicker({
		maxDate: 0,
		dateFormat: "dd/mm/yy"
	});

	// Input placeholder text
	$('[placeholder]').focus(function() {
		var input = $(this);
	  	if (input.val() == input.attr('placeholder')) {
	    	input.val('');
	    	input.removeClass('placeholder');
	  	}
	}).blur(function() {
	  	var input = $(this);
	  	if (input.val() == '' || input.val() == input.attr('placeholder')) {
	    	input.addClass('placeholder');
	    	input.val(input.attr('placeholder'));
	  	}
	}).blur();

	$('[placeholder]').parents('form').submit(function() {
	  	$(this).find('[placeholder]').each(function() {
	    	var input = $(this);
	    	if (input.val() == input.attr('placeholder')) {
	      		input.val('');
	    	}
	  	})
	});

});
