/*
	Closures are used for each function so we lessen the memory footprint and increase speed by not polluting the global namespace.
	
	To create a new closure:
	(function() {
		// code here, variables won't pollute the global namespace
		var privateVariable = "private!";
		var privateFunction = function() { return "private"; };
		
		this.publicVariable = "public!";
		this.publicFunction = function() { return "public"; };
	});
	
	Adding () before the semi-colon will call it immediately. You can save it to a variable and call the function closure later.
	Adding $(); around the closure will call it on jQuery ready. Useful for making sure DOM is loaded before proceeding with script
*/

/*
	Immediate execution code
*/
(function() {
	/*
		Strings for Localization
			- these are strings added through JS
			- this should provide a centralized place for modifying those strings to provide for translation
			- all other strings, unless noted, will be present in the HTML
	*/
	
	(function($) {
		$.localize = {
			turnEffectsOn: "Turn Effects On", // link in footer, when effects have been turned off
			turnEffectsOff: "Turn Effects Off"
		};

	})(jQuery);
})();


/*
	This is the main function
		- called on jQuery's ready event
*/
$((function() {
	
	var $pageurl = window.location;
	var $lang = $pageurl.toString().indexOf("fr") != -1 ? "fr" : "en";
	
	//$.log($lang);

	
	var $loginBox = $("#site-login").login({loginSuccessPage:"/" + $lang + "/my-ziploc/myziploc-profile.aspx"});



	
	/*
		Tips section
	*/
	if (document.body.id.indexOf("tips") != -1) {
		(function() {
			$.fn.textCounting.defaults.countDirection = "up";
			$(":input[type=textarea]").textCounting();
			
			return false;
		})();
	}
	
	/*
		Promos section
	*/
	if (document.body.id.indexOf("promos") != -1) {
		(function() {
			$('#coupons').innerfade({
																animationtype: 'fade', //fade or slide
																speed: 'slow', //ms or keyword
																timeout: 5000, //ms
																type: 'random_start', //sequence, random, random_start
																containerheight: '306px' });
			
			return false;
		})();
	}
	
	/*
		Recipes section
	*/
	if (document.body.id.indexOf("recipes") != -1) {
		(function() {
			$("#finder-menu").recipefilter();
			$("#comment-section").comments();
			
			return false;
		})();
	}
	
	/*
		Blog section
	*/
	if (document.body.id.indexOf("blog") != -1) {
		(function() {
			$("#comment-section").comments();
			
			return false;
		})();
	}
	
}));