$(function() {
//read the cookie
	var cookieValue = readCookie('animationstopper');
	var override = 0;
	console.log(cookieValue);
//	if the cookie doesn't exist or is marked as 0 or has the testing override passed to it, we'll add the animation trigger to the banner and make the cookie.
	if (cookieValue == 0||cookieValue == null|| override == 1)	{
			document.getElementById("banner").className += " animated ";
			document.getElementById("image-tile").className += " dim ";
			if (override != 1){
				createCookie('animationstopper','1','');
			} 
			
	}
//	if the cookie has already been set (returning in the same session) we add a class to make visible without animation.
	else if (cookieValue == 1){
		document.getElementById("banner").className += " instant ";
//		console.log ('Read cookie.');
		document.getElementById("image-tile").className += " dim ";
		
	}
//	Place for error fallback.
	else {
//		console.log ('Malformed cookie.');
	}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
});
