jQuery(document).ready(function($){	
//jQuery(function() {								
//$(function(){

	//Add 'selected' classes to menu and submenu items
	//var partnerpath = location.href.substring(location.href.lastIndexOf('/') + 1);//+location.hash;
	//	if ( partnerpath ) {
	//		$('#menu-container a[href$="' + partnerpath + '"]').parent('li').addClass('selected');
	//}
	
	
	//email spam protection - Example Markup: <span class="email">name[at]domain[dot]com</span>
	$('.email').each(function() {
		var $email = $(this);
		var address = $email.text()
		.replace(/\s*\[at\]\s*/, '@')
		.replace(/\s*\[dot\]\s*/g, '.');
		$email.html('<a href="mailto:' + address + '">'+ address +'</a>');
	});
	
	$('span.copy').each(function() {
		var $copy = $(this);
		var copyright = $copy.text()
		.replace(/\s*\[c\]\s*/g, '&copy;');
		$copy.html(''+ copyright +'');
	});
	
	$('sup.reg').each(function() {
		var $sup = $(this);
		var registered = $sup.text()
		.replace(/\s*\[r\]\s*/g, '&reg;');
		$sup.html(''+ registered +'');
	});
	
	$('span.deg').each(function() {
		var $deg = $(this);
		var degree = $deg.text()
		.replace(/\s*\[deg\]\s*/g, '&deg;');
		$deg.html(''+ degree +'');
	});
	
	$('span.tm').each(function() {
		var $tm = $(this);
		var trademark = $tm.text()
		.replace(/\s*\[tm\]\s*/g, '&trade;');
		$tm.html(''+ trademark +'');
	});

	//Update Discount Club (Right)
	var url = window.location.pathname;
	  if (url.indexOf("/discount") > -1) {
		$("div#button-discount").hide();
		$("div#button-partner").attr("id", "button-discount-app");
		$('#button-discount-app').load("/right-section/discount-right");
		return false;
		}

	  else if (url.indexOf("/trading-hours") > -1) {
		$("div#button-partner").show();
		$("div#button-partner").attr("id", "button-trading");  
		$("div#button-trading").load("/special-trading-hours");
		return false;
		}

	  else {
		$("div#button-partner").load("/right-section/btl-right");
		return false;
		}

		
	//Remove 'a' tag if there is no href
	$("a").each(function() {
		var hRefer = $(this).attr("href");
		if(hRefer != undefined && hRefer == '') { // or anything else you want to remove...
			$(this).removeAttr('href').removeAttr('target');//.remove();
		}
		if(hRefer != undefined && hRefer.indexOf('tag_') != -1) { // or anything else you want to remove...
			$(this).removeAttr('href').removeAttr('target');
		}
	});

	//Remove text {tag_website,_blank}
	var oDetails = $('.store-detail').find('.details');
	if ( $('.store-detail').find('.details:contains("{tag_website,_blank}")') ) {
		oDetails.html(oDetails.html().replace('{tag_website,_blank}',''));
	}

	
});
