
$(document).ready(function(){
						   
	/* Case images */					   
	var case_images_string = "";
	$("#case_info .case_info h2 a").each(function(index) {
		//$(this).log(index + ': ' + $(this).text());
		//alert ($(this).attr("href"));
		case_images_string = case_images_string + '<a href="' + $(this).attr("href") + '"><img src="' + $(this).attr("rel") + '" alt="" width="960" height="250" class="photo" id="entry_98" /></a>'
	});

	$("#case_images").html(case_images_string);					   		   
	/* / Case images */						   
	
	/* rollover for case images > show more info */	
	$('#case_container').hoverIntent(
			  function () {
				  $('#more_info .inner').show().animate({marginTop:'0px',queue:false,opacity:1},250);
					
			  }, 
			  function () {
				$('#more_info .inner').animate({marginTop:'30px',queue:false,opacity:0},500);
					
			  }
	);


	$('#case_images').cycle({ 
	    fx:    'fade', 
		next: '#next',
		prev: '#prev',
		pause:  1,
		speed:    600, 
		timeout:  7000,
 		before:  prepare_swap,
    	after:   done_swap

		});
	

	function prepare_swap(curr,next,opts) { 
		var number = opts.currSlide+1;
		$("#case_info div:nth-child("+ number +")").fadeOut(500);

	}
	
	function done_swap(curr,next,opts) { 
		var number = opts.currSlide+1;
		$("#case_info div:nth-child("+ number +")").customFadeIn(500);
		$('#more_info .inner a').attr('href',this.href);
	}




	/* ********** FORM VALIDATION **********  */

  

	$("#newsletter_subscription").validate();
  
	// focus and blur: change background:
	$('input').focus(function() {	
		$(this).addClass("active");
	});
	$('input').blur(function() {
		$(this).removeClass("active")
	});	


});