// portfolio slides
$(document).ready(function() {
 
			$(".container img:first-child").addClass('last');
 
			$(".container img").click(function() {
				$(this).fadeOut('normal', function() {
 
					if ( $(this).hasClass('last') ) {
						$("img", $(this).parent()).css('z-index', 10);
 
					} else {
						$(this).css('z-index', 9)
					}
 
					$(this).show();	
				});
			});
 	
		});

// jquery aminated scrolling
$(document).ready(function(){
  $('a[href*=#]').click(function() {
 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
 && location.hostname == this.hostname) {
   var $target = $(this.hash);
   $target = $target.length && $target
   || $('[name=' + this.hash.slice(1) +']');
   if ($target.length) {
  var targetOffset = $target.offset().top;
  $('html,body')
  .animate({scrollTop: targetOffset}, 1000);
    return false;
   }
 }
  });
});

// focus effect
$(document).ready(function() {
	$('input[type="text"], input[type="email"], input[type="number"], input[type="password"], textarea[name="message"]').addClass("idleField");
	$('input[type="text"], input[type="email"], input[type="number"], input[type="password"], textarea[name="message"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
	    if (this.value == this.defaultValue){ 
	    	this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"], input[type="email"], input[type="number"], input[type="password"], textarea[name="message"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
	    if ($.trim(this.value) == ''){
	    	this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
});

// header slider 
$(function(){
	$('#carousel').infiniteCarousel({
		displayTime: 6000,
		textholderHeight : .25,	
		displayProgressBar : 0,
		displayThumbnailBackground: 0
	});
});

//matt homepage slider
$('#homeimages').cycle({
		fx:     'fade',
		speed:  600,
		timeout: 4500,
		prev: "#homeimgNav .prev",
		next: "#homeimgNav .next"
	});

// cufon font - menu navigation
Cufon.replace('.navi h3', {
    fontFamily: 'molengo-reg',
	hover: true
});

