Cufon.replace('#masthead p,h1, h2, #footer h3,li.cufon>a, #menu a.btn', {hover: true});
	
Shadowbox.init();

var $j = jQuery.noConflict();
$j(document).ready(function(){
	//alert($j(".clients blockquote").length);
	if($j(".clients blockquote").length > 1){
		$j('.clients blockquote').quovolver();
	}
	if($j(".testimonials blockquote").length > 1){
		$j('.testimonials blockquote').quovolver();
	}
	
	//Clear inputs on focus
	$j('input.clearFocus').focus(function() {
		if( this.value == this.defaultValue ) {
		this.value = "";
		}
		}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
/** Homepage menu slider **/
		/* position of the <li> that is currently shown */
		var current = 0;
			$j('li.bg1,li.bg2').mouseover(function(e){
				
				var $this = $j(this).find('.btn');
				/* if we hover the current one, then don't do anything */
				if($this.parent().index() == current)
					return;
				
				/* item is bg1 or bg2 or bg3, depending where we are hovering */
				var item = e.target.id;

				/*
				this is the sub menu overlay. Let's hide the current one
				if we hover the first <li> or if we come from the last one,
				then the overlay should move left -> right,
				otherwise right->left
				 */
				if(item == 'bg1' || current == 2)
					$j('#menu .sub'+parseInt(current+1)).stop().animate({backgroundPosition:"(-475px 0)"},300,function(){
						$j(this).find('li').hide();
					});
				else
					$j('#menu .sub'+parseInt(current+1)).stop().animate({backgroundPosition:"(475px 0)"},300,function(){
						$j(this).find('li').hide();
					});

				
				/* change the current element */
				current = $this.parent().index();
				/* let's make the overlay of the current one appear */
			   
				$j('#menu .sub'+parseInt(current+1)).stop().animate({backgroundPosition:"(0 0)"},300,function(){
					$j(this).find('li').fadeIn();
				});
			});			
/*
dir:1 - move left->right
dir:0 - move right->left
 */
function move(dir,item){
	if(dir){
		$j('#bg1').parent().stop().animate({backgroundPosition:"(0 0)"},200);
		$j('#bg2').parent().stop().animate({backgroundPosition:"(-475px 0)"},300);
		$j('#bg3').parent().stop().animate({backgroundPosition:"(-532px 0)"},400,function(){
			$j('#menuWrapper').removeClass('bg1 bg2 bg3').addClass(item);
		});
	}
	else{
		$j('#bg1').parent().stop().animate({backgroundPosition:"(0 0)"},400,function(){
			$j('#menuWrapper').removeClass('bg1 bg2 bg3').addClass(item);
		});
		$j('#bg2').parent().stop().animate({backgroundPosition:"(-266px 0)"},300);
		$j('#bg3').parent().stop().animate({backgroundPosition:"(-532px 0)"},200);
	}
}
});
