
jQuery.noConflict();


/*
  
  Set active state of subnav dynamically.

*/
jQuery(document).ready(function($){
	
	if(!$("#nav").length) return;
	
	$("#nav a").each(function(){
		var linkurl = $(this).attr('href');
		var currenturl = document.location.href;		
		if (currenturl.indexOf(linkurl) != -1) {
			$(this).addClass("active");
		}
	});

});


/*
  
  Clear email field when clicked in.

*/
jQuery(document).ready(function($){
	
	if(!$("#form-signup #email").length) return;
	
	var defText = $("#form-signup #email").val();
	
	$("#form-signup #email").focus(function(){
		if($(this).val()==defText) $(this).val(""); 
	});
	
	$("#form-signup #email").blur(function(){
		if($(this).val()=="") $(this).val(defText);
	});
	
});


/*
  
  Home page - hero image rotation

  requires jquery.innerfade.js
  
  Preload and add images dynamically instead of innerfade's default method
  of using elements in the markup to avoid excessive home page load time.

*/
jQuery(window).load(function(){
	
	if(!jQuery("#hero").length) return;

	var images = new Array(
		'images/home-hero-2.jpg', 
	    'images/home-hero-3.jpg',
		'images/home-hero-4.jpg'
	);
				
	for(var i = 0; i<images.length; i++){
		var img = jQuery("<img>").attr("src", images[i]);
		jQuery('#hero').append(img);
	}

	jQuery("#hero").innerfade({
		speed: 2000,
		timeout: 4000,
		type: 'sequence',
		containerheight: '370px'
	});
});