function theRotator() {
	//Set the opacity of all images to 0
	$('div.partners ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.partners ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div.partners ul li.show')?  $('div.partners ul li.show') : $('div.partners ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.partners ul li:first') :current.next()) : $('div.partners ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$(document).ready(function(){

	$.addthis('ADA');
	Shadowbox.init();
	$(document).pngFix();
	theRotator();
		
	//Opens link in new window	
    $("a[rel*='external']").attr({ target: "_blank" });

	var volatile = $(".field input")
    volatile.focus(function(event){
        if ($(this).val() == $(this).attr("title") ){        
            $(this).val("");
        }}, volatile.blur(function(event){
            if ($(this).val() == "" ){        
                $(this).val($(this).attr("title"));
            }
        }
    ));
	
	$('input').customInput();

	$(".field select").sexyCombo({
	});

	Cufon.replace('h1', { fontFamily: 'NewsGothic'});
	Cufon.replace('#homeContent h2, #leftCol h2, #deepLinks .linkContainer .fr .tel, #nav a, #filter h3', { fontFamily: 'NewsGothic', hover: true });


//Toggle Element
    
//    var toggler =  $(".toggle")
//    var toggleElement = $(".linkContainer")
       
//    $(toggleElement).ready(function(event){ $(toggleElement).css('display', 'none'); });
         
//    $(toggler).click(function(){
//        toggleElement.slideToggle("slow");
//        toggler.toggleClass("close");
//    });


//Fade Toggle Element
       
	jQuery.fn.fadeToggle = function(speed, easing, callback) {
		return this.animate({opacity: 'toggle'}, speed, easing, callback);
	}; 	   
	   
	var fadeToggler = $(".filterToggler")
	var fadeElement = $(".filterOverlay")
	     
	$(fadeToggler).click(function(event){
	 	event.preventDefault();
		fadeElement.fadeToggle("normal");
	});
	
	//Validator	
	$.validator.setDefaults({});
		
	//Select forms to be validated
	$("#contactForm, #postCommentForm").validate();
	
	$('#interestRolesAll').click(function () {
		$(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);
	});

	
});


	
