var $j = jQuery.noConflict();

/**
 * Delay function
 *
 * @author James Padolsey
 * @link http://james.padolsey.com/javascript/jquery-delay-plugin/
 */
$j.fn.delay = function(time, callback){
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
}

/**
 * External attribute
 */
function lazyLoad() {
	$j('img').lazyload();
}

/**
 * External attribute
 */
function externalTarget() {
	$j( '.comment-author cite.fn a.url' ).removeClass( 'external' );
	$j( '.external' ).attr( 'target','_blank' );

}

/**
 * Sliding header links
 * @since 0.1.1
 */
function movingHeaderLinks() {
	//Moving footer links
	$j("#page-nav ul li a").hover(function(){
		$j(this).stop().animate({
			paddingLeft: "20px"
		}, 300);
		$j(this).parent('li').addClass('color');
	}, function(){
		$j(this).stop().animate({
			paddingLeft: "0px"
		}, 300);
		$j(this).parent('li').removeClass('color');
	});
}


/**
 * 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() {
		externalTarget();
		movingHeaderLinks();
		smoothScroll();
	}
);
