jQuery(function(){
	$('#nav-wrap li a').animate({backgroundColor: '#015193'});
	$('#nav-wrap li a').animate({backgroundColor: '#000000'})

	//popup links
    $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
	 
	//email spam protection
    $('.email').each(function() {
		var $email = $(this);
		var address = $email.text()
        .replace(/\s*\[at\]\s*/, '@')
        .replace(/\s*\[dot\]\s*/g, '.');
		$email.html('<a href="mailto:' + address + '">'
        + address +'</a>');
    });
	
	$('#nav-wrap li a').hover(function() {
        $(this).animate({backgroundColor: '#015193'});
      }, 
      function () {
        $(this).animate({backgroundColor: '#000000'})
      }
    );
	var aa=$('#nav_426185 li')[6];
	var aaa=$(aa).children('a');
	$(aaa).addClass('last-item');	
	
	
	//Rotate testimonials on the homepage.	
	var counter = 0;
	while(counter < $('#testimonialPanel .testimonial').length){
		console.log(counter)
		
		$('#testimonialPanel .testimonial.selected').removeClass('selected');
		$('#testimonialPanel .testimonial:eq(' + counter + ')').addClass('selected');
		
		$('#testimonialPanel .testimonial:eq()').fadeIn(700).delay(2000).fadeOut(700);
		/*if(counter == ($('#testimonialPanel .testimonial').length - 1)){
			counter=0;
		}*/
		

		counter++;
	}
	
	//Rotate testimonials on the homepage (using the cycle plugin)
	$('#testimonialList').cycle({ 
    fx:     'fade', 
    speed:   1000, 
    timeout: 5500, 
    //next:   '#s3', 
    pause:   1 
});
		
});
