var $j = jQuery.noConflict();
$j(document).ready(function() {
	//Sidebar height
	var bodyHeight = $j(document).height();
	var sidebarNewHeight = bodyHeight-116-25;
	$j('#main aside').css('height', sidebarNewHeight);
	
	//Fancybox settings
	$j("a:has(.size-medium)").fancybox();
	$j("a:has(.size-large)").fancybox();
	$j("a:has(.size-thumbnail)").fancybox();
	$j('a[rel^="fanxybox"]').fancybox();
	$j('a.fancybox').fancybox();
	$j("a:has(.size-full)").fancybox();
	
	//For icon plugin
	$j("p.aligned").vAlign();
	$j("div.paligned").vAlign("p").css("color","blue");
	
	// Add pdf icons to pdf links
	$j("a[href$='.pdf']").addClass("pdf");
	// Add txt icons to document links (doc, rtf, txt)
	$j("a[href$='.doc'], a[href$='.docx'], a[href$='.txt'], a[href$='.rft']").addClass("txt");
	// Add zip icons to Zip file links (zip, rar)
	$j("a[href$='.zip'], a[href$='.rar']").addClass("zip"); 
	
	/*
	// Add email icons to email links
	$j("a[href^='mailto:']").addClass("email");

	//Add external link icon to external links - 
	$j('a').filter(function() {
		//Compare the anchor tag's host name with location's host name
	    return this.hostname && this.hostname !== location.hostname;
	  }).addClass("external");
	*/

});

//Plugin to add icons for direct file links
(function ($) {
	$.fn.vAlign = function(container) {
		return this.each(function(i){
			if(container == null) {
				container = 'div';
			}
			$(this).html("<" + container + ">" + $(this).html() + "</" + container + ">");
			var el = $(this).children(container + ":first");
			var elh = $(el).height(); //new element height
			var ph = $(this).height(); //parent height
			var nh = (ph - elh) / 2; //new height to apply
			$(el).css('margin-top', nh);
		});
	};
})(jQuery);

