$(document).ready(function () {
   Cufon.replace('h1, h2, h3, p.summary, span.cta, a.cta, p#tel',{
     hover: true
   });
  
  if($('div#contour.fieldsofopportunity').length) {
		$('div#contour.fieldsofopportunity div.contourNavigation input').attr('value', '');
		$('div#contour.fieldsofopportunity div.textarea label').html('In no more than 500 words, tell us why the nomination should win your chosen category. Please include information relating to the category, what makes the holiday let a special place to stay and any examples of the farmer going above and beyond for holidaymakers.');
	}
	
	$('div#showterms').hide();
	$('div#terms a img.terms').toggle(function() {
		$('div#showterms').show();
		return false;
	}, function() {
		$('div#showterms').hide();
		return false;
	});
  
  //Animate main navigation
  // if($('div#top-nav ul li ul').length) {
    // $('div#top-nav ul li').hoverIntent({
      // over: showNav, 
      // timeout: 200, 
      // out: hideNav
    // });
  // }
    
});

// function showNav() {
  // if($(this).children('ul').length) {
    // $(this).addClass('hover-nav').children('ul').animate({
      // "height": "toggle", 
      // "opacity": "toggle"
    // }, 200);
  // }
// }
// function hideNav() {
  
  // $(this).children('ul').animate({
    // "height": "toggle", 
    // "opacity": "toggle"
  // }, 200).parent('li').removeClass('hover-nav');
// }

function slideSwitch() {
	var $active = $('#home-main-image img.active');
	if ( $active.length == 0 ) $active = $('#home-main-image img:last');
	var $next =  $active.next().length ? $active.next()
		: $('#home-main-image img:first');
	
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );

	$active.addClass('last-active');
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 2000, function() {
			$active.removeClass('active last-active');
		});
}

$(function() {
	setInterval( "slideSwitch()", 5500 );
});
