jQuery.noConflict();
		
jQuery(function(){

	removeOffenders();
	tweakImages();
	tweakLayouts();

});

function removeOffenders(){
	// get rid of strings of non-breaking spaces
	jQuery('body').each(function() {				
		var replacedText = "";
		replacedText = jQuery(this).html().replace(/\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;\&nbsp\;/g, "");
		jQuery(this).html(replacedText);
	});
	
	// remove unwanted <br> tags in thumbnail views
	jQuery('.thumbnail').each(function(){
		jQuery(this).find('table').addClass("loading");
		jQuery(this).find('br').remove();
	});
	
	// remove unwanted <br> tags in featured images
	jQuery('#featured').each(function(){
		jQuery(this).find('br').remove();
	});
	
	// remove 'l' separator between pagination links
	jQuery('.gallery_next_page_link_style').each(function(){
		jQuery(this).html(jQuery(this).html().replace(/>\s+l\s/g, "> "));
		//jQuery(this).html(jQuery(this).html().replace(/\s+l\s+<a/g, " <a"));
	});
	
	// get rid of spaces in pagination nav
	jQuery('.gallery_next_page_link_style a').each(function(){
		var replacedText = "";
		replacedText = jQuery(this).html().replace(/([0-9])\s{1,}/g, "$1");
		jQuery(this).html(replacedText);
	});
	
	// replace 'next' and 'prev' pagination link images
	jQuery('.gallery_next_page_link_style a img').each(function(){
		if ( jQuery(this).attr('title') == 'Prev. Page'){
			jQuery(this).replaceWith("\&lt\; Prev");
		} else if ( jQuery(this).attr('title') == 'Next Page'){
			jQuery(this).replaceWith("Next \&gt\;");
		}
	});
	
	// replace double-arrows in Quick Links dropdown
	jQuery('#category_listing_section select option').each(function(){
		var replacedText = "";
		replacedText = jQuery(this).html().replace(/»/g, "");
		jQuery(this).html(replacedText);
	});
	
	jQuery("img[alt='Calculate License Price']").parent().html('');
	jQuery("img[alt='Print Invoice']").parent().hide();
}

function tweakImages(){
	// replace preview toggle icon
	jQuery('#preview_media_toggle > img').attr({src: $self + "images/canvass/icon-toggle-preview.png"})
}

function tweakLayouts(){
	jQuery('#featured img').wrap("<div></div>");
}

var alreadyShownHomepage = false;
function showHomepage() {
	if (alreadyShownHomepage) return;
	alreadyShownHomepage = true;
	
	jQuery("#std-content").hide();
	jQuery(function() {
		jQuery("#custom-content").load($self + "canvass/index-content.php");
	});
}
