var $ = jQuery.noConflict();

//Cufon

//Tips
$(document).ready(function(){
	$("nav li a").hover(function() {
		$(this).next("em").stop(true, true).animate({opacity: "show", top: "-45px"}, "slow");
		}, function() {
	$(this).next("em").animate({opacity: "hide", top: "-70px"}, "fast");
	});

});

//Pre and ap ends
jQuery(document).ready(function($){$("nav li em").prepend('<span></span>');});

//Scrolls
jQuery(document).ready(function($) {
	$('nav a[href*="#"]').click(function() {
	   var elementClicked = $(this).attr("href");
	   var destination = $(elementClicked).offset().top;
	   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 800 );
	   return false;
	});
});

//Line height fixes
jQuery(document).ready(function($)  {
    var lineHeight = parseInt($('body').css('line-height'));
    function balanceHeight(el) { 
        var h = $(el).outerHeight();
        var delta = h % lineHeight;
        if (delta != 0)
        {
            /* For images and objects, we want to align the bottom w/ the baseline, so we 
            * pad the top of the element. For other elements (text elements that have a
            * scrollbar), we pad the bottom, to keep the text within on the same baseline */
            var paddingDirection = ($(el).is('img') || $(el).is('object')) ? 
                                                    'padding-top' : 'padding-bottom';

            /* Adjust padding, because margin can get collapsed and cause uneven spacing */
            var currentPadding = parseInt($(el).css(paddingDirection));
            $(el).css(paddingDirection, currentPadding + lineHeight - delta);
        }
    }

    $('img, pre, object').each(function() {
        /* Only works if we're manipulating block objects */
        if ($(this).css('display') == 'inline')
        {
            $(this).css('display', 'block');
        }

        /* Images need to load before you get their height */
        if ($(this).is('img'))
        {
            $(this).load(function(){ balanceHeight(this); });
        }
        else
        {
            balanceHeight(this);
        }
    });
});

//Make ampersands lush
$(document).ready(function() {
    $("*:contains('&')", document.body)
        .contents()
        .each(
            function() {
                if( this.nodeType == 3 ) {
                    $(this)
                        .replaceWith( this
                            .nodeValue
                            .replace( /&/g, "<cite class='amp'>&</cite>" )
                        );
                }
            }
        );
});
  


/*

//Pre and ap ends
jQuery(document).ready(function($){
    $(".addclass")
        .prepend('add stuff');
});


//Add class
jQuery(document).ready(function($){
	$('').addClass("none");
});

//Fade in
jQuery(document).ready(function($){
	$('').fadeIn(2000);
});


//Open in external windows
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

//JQuery Plugin: "EqualHeights" by:	Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com) Copyright (c) 2008 Filament Group. Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
jQuery(document).ready(function($){ 	
	function equalHeight(group) {
		tallest = 0;
		group.each(function() {
			thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}

	equalHeight($ ( "add stuff" ) );
	
});

*/
