function navHooks() { // add IDs to the navigation based on it's text
	$('#sidebar li').each(function() {
		$(this).attr('id', 'nav_' + $(this).find('a').text().toLowerCase() );
	});
}

$.fn.externalLink = function() {
	return this.each(function() {
		$(this).addClass('external').attr('target', '_blank');
	});
}

$.fn.comma2dots = function() {
	return this.each(function() {
		var str = $(this).text();
		str = str.replace(/,/ig, ".");
		$(this).text(str);
	});
}

$(function() {
	navHooks();
	$('.email').defuscate();
	$('a[rel*="external"]').externalLink();
	$('.shop-main h4 a').add('.shop-product-small h5 a').add('.productItem h2').comma2dots();

	$(window).bind('load resize', function() {
		console.log($(window).width());
		// hide advert on narrow screen (covers text otherwise)
		if ( $(window).width() < 1040 ) {
			$('.ad').hide();
		} else {
			$('.ad').show();
		}
	});
});
