$(document).ready(function(){
	
	if($("a#all-link").length > 0) {
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    var vars = [], hash;
		for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
		if(hash[0] == 'showall' && hash[1] == 1) {
			$("a#all-link").click();
		}
		
    
	}
	
	//External Links open in a new tab/window
	$("a[href^=http://]").not("a[href^=http://albertaegg.cornerstone-cms.com]").attr("target", "blank");
	
	//Add Header for Printing
	$("body").prepend("<h5 class='print'>Alberta Egg Producers</h5>");
		//$("body").append("<h5 class='print'>Alberta Egg Producers</h5>");

//stripes for table															
	$("table.styled tr:nth-child(odd)").addClass("odd");
	
	// Add Class to last link in various callouts
	if($('table.home-callouts').length) {
		$('table.home-callouts td a:last-child').addClass('last');
	}
	$('table.callout td a:last-child').addClass('last');
	
// initialize nav

$("ul#nav_496071").supersubs({ 

minWidth:    12,   // minimum width of sub-menus in em units 
maxWidth:    27,   // maximum width of sub-menus in em units 
extraWidth:  1    // extra width can ensure lines don't sometimes turn over 
									// due to slight rounding differences and font-family 
}).superfish();  	// call supersubs first, then superfish, so that subs are 
									// not display:none when measuring. Call before initialising 
									// containing tabs for same reason. 

$('ul.#nav_496071 li:first').addClass('first');
$('ul.#nav_496071 li:first').mouseover(function(){$(this).addClass('first')});
$('ul.#nav_496071 li:first').mouseout(function(){$(this).addClass('first')});

$('#nav_496071 li li:last-child').children().addClass('last');

// initialize banner on home page
if($('#banner').length) {
	$('#pics').after('<div id="panel"><div id="pager" class="pager">').cycle({
		fx:     'fade',
		speed:  'slow',
		timeout: 6000,
		pager:  '#pager',
		before: function() { if (window.console) console.log(this.src); }
	});
}

		if($('#search_box').length) {
			$("#search_box #CAT_txtKeywords").DefaultValue("Search for Recipes");
		}


	
	/*$(".recipe").click(function(){
		window.location=$(this).find("a").attr("href"); return false;
	});*/




//email spam protection
	$('.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>');
	});
	

	

});