//Let's make sure console.log doesn't break EVERYTHING! 

var debugging = true; // or true
if(typeof console == "undefined")
{
	var console = { log: function() {}, dir: function() {} };
}else{
	if(!debugging || typeof console.log == "undefined") console.log = function() {};
	if(!debugging || typeof console.dir == "undefined") console.dir = function() {};
}

jQuery(document).ready(function($){
	
	
	$thePage = $('body').attr("class");
	
	if($thePage.indexOf('pageHome') != -1)
	{
		$('#headerNavHome').toggleClass('headerNavHomeCurrent');
	}else if($thePage.indexOf('pageAbout') != -1)
	{
		$('#headerNavAbout').toggleClass('headerNavAboutCurrent');
	}else if($thePage.indexOf('pageGalleries') != -1)
	{
		$('#headerNavGallery').toggleClass('headerNavGalleryCurrent');
	}else if(($thePage.indexOf('category-events') != -1) || ($('#tec-content').length != 0))
	{
		$('#headerNavCalendar').toggleClass('headerNavCalendarCurrent');
	}else if(($thePage.indexOf('pagePromotions') != -1) || ($thePage.indexOf('parent-pageid-82') != -1))
	{
		$('#headerNavPromotions').toggleClass('headerNavPromotionsCurrent');
	}else if($thePage.indexOf('pageHappyHours') != -1)
	{
		$('#headerNavHappyHours').toggleClass('headerNavHappyHoursCurrent');
	}else if(($thePage.indexOf('pageBars') != -1) || ($thePage.indexOf('parent-pageid-19') != -1))
	{
		$('#headerNavBars').toggleClass('headerNavBarsCurrent');
	}else if(($thePage.indexOf('blog') != -1) || ($thePage.indexOf('single-post') != -1))
	{
		$('#headerNavBlog').toggleClass('headerNavBlogCurrent');
	}else if((($thePage.indexOf('pageProducts') != -1) || ($thePage.indexOf('parent-pageid-69') != -1)) && ($('#tec-content').length == 0))
	{
		$('#headerNavProducts').toggleClass('headerNavProductsCurrent');
	}else if($thePage.indexOf('pageContact') != -1)
	{
		$('#headerNavContact').toggleClass('headerNavContactCurrent');
	}
	
	
	
	
	
	
	
	
});

$(window).load(function () {
  // BANDAID FUNCTION TO CENTER SHORT IMAGES!
	$(".galleryPic img, .barsBarPic img, #barPic img, .productsProductPic img, .productPic img, .promosPromoPic img, .promoPic img").each(function(i){
		$h = $(this).attr("height");
		
		if($h < 175)
		{
			$diff = 175 - $h;
			$diff = $diff / 2;
			
			$(this).css("margin", ($diff + "px 0 0 0"));
		}
		
	});
});



function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

function urldecode (str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // +      input by: Ratheous
    // +   improved by: Orlando
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +      bugfixed by: Rob
    // %        note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // %        note 2: Please be aware that this function expects to decode from UTF-8 encoded strings, as found on
    // %        note 2: pages served as UTF-8
    // *     example 1: urldecode('Kevin+van+Zonneveld%21');
    // *     returns 1: 'Kevin van Zonneveld!'
    // *     example 2: urldecode('http%3A%2F%2Fkevin.vanzonneveld.net%2F');
    // *     returns 2: 'http://kevin.vanzonneveld.net/'
    // *     example 3: urldecode('http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a');
    // *     returns 3: 'http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a'
    
    return decodeURIComponent(str.replace(/\+/g, '%20'));
}
