var $j = jQuery.noConflict();

function deployFunctions() {
	
	/**************************************************
		SLIDER
	**************************************************/
	
	$j(".sliderMask, .jScrollPaneContainer").height($j(window).height());
	$j('.sliderMask').jScrollPane();
	
	/**************************************************
		GOOGLE MAPS
	**************************************************/
	
	if ($j.browser.msie && $j.browser.version=="6.0") {
		$j("#background div.gradient .right, #background div.gradient .left").height($j(window).height());
	}
	
}

/**
 * Scroll the site
 *
 * @since 0.1
 */
function smoothScroll(){
	$j('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $j(this.hash);
			$target = $target.length && $target || $j('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$j('html,body').animate({scrollTop: targetOffset}, 1200);
				return false;
				}
			}
	});
}

$j(document).ready(function() {

	deployFunctions();
	
	/**************************************************
		NAVIGATION
	**************************************************/
	
	$j('#page-nav .menu li a').hover(function() {
		$j(this).animate({paddingLeft: '20px'}, {queue:false, duration: 100});
	},
	function(){
		$j(this).animate({paddingLeft: '10px'}, {queue:false, duration: 100});
	});
	
	/**************************************************
		SEARCH
	**************************************************/
	
	$j('.menu .search').hover(function(){
		$j(this).animate({left: '0px'}, {queue:false, duration: 100});
	},
	function(){
		$j(this).animate({left: '-150px'}, {queue:false, duration: 100});
	});
	
	/**************************************************
		SLIDER
	**************************************************/
	
	$j('.sliderMask .sliderContent img').load(function() {
		$j(".sliderMask, .jScrollPaneContainer").height($j(window).height());
		$j('.sliderMask').jScrollPane();
	});
	
	/**************************************************
		PRIMARY
	**************************************************/
	$j('#primary').css({opacity: '0.4'});
	
	$j('#primary').hover(function(){
		$j(this).animate({opacity: '1.0'}, {queue:false, duration: 350});
	},
	function(){
		$j(this).animate({opacity: '0.4'}, {queue:false, duration: 700});
	});
	
	/**************************************************
		BACKGROUND
	**************************************************/
	
    $j('#background img').load(function() {
		$j(this).css({
			top: ($j(window).height() - $j(this).height()) / 2,
			display: 'block'
		});
    });
	
});

window.onresize = function() {

	deployFunctions();
	
	/**************************************************
		BACKGROUND
	**************************************************/
	
	$j('#background img').css('top', ($j(window).height() - $j('#background img').height()) / 2);
}