function createCookie(name,value,expiration) {
	var date = new Date();
	date.setSeconds(date.getSeconds() + expiration);
	var expires = "; expires="+date.toGMTString();
	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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

var resolution = new function() {
	this.min_height = 900;
	this.phone_height = 480;
	this.element = "#footer";
	this.element2 = "#footer-copyright";
	
	this.setup = function() {
		var h = this.get_height();
		if (h <= this.phone_height) {
			//do nothing
		} else if (h < this.min_height) {
			//hide the footer
			jQuery(this.element).hide();
		} else {
			//dynamic footer
			var do_animation = true;
			var last_animation = readCookie('last_animation');
			if (last_animation) {
				do_animation = false;
			}
			if (do_animation) {
				var d = new Date();
				createCookie('last_animation',1,300);
			
				jQuery(this.element).delay(4000).animate({bottom:-130},1000);
				jQuery(this.element2).delay(4000).animate({top:57}, 1000);
			} else {
				jQuery(this.element).css({bottom:-130},1000);
				jQuery(this.element2).css({top:57}, 1000);				
			}
			
			jQuery(this.element).hover(function() {
				jQuery(this).stop().animate({bottom:0},200);
				jQuery(resolution.element2).stop().animate({top:95}, 200);
			}, function() {
				jQuery(this).stop().animate({bottom:-130},200);					
				jQuery(resolution.element2).stop().animate({top:57}, 200);
			})
		}
	};
	
	this.get_height = function() {
		return screen.height;
	};
};
jQuery(document).ready(function() { 
	resolution.setup();
});

