Functions= {};

$(document).ready(function () {
	Functions.setMainHeight();
	if($(".lightbox")) {
		$(".lightbox").lightbox();
	}
	Functions.initNewsletter();
});

$(window).bind('resize', function() {	
	Functions.setMainHeight();
});

Functions= {
	setMainHeight: function() {
		var height= Functions.getBrowserHeight();
		var main= $("#page .main");
		main.css("height", "auto");
		
		if(main.height()<(height-212)) {
			main.css("height", (height-212));
		}
	},
	getBrowserHeight: function() {
		return (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);
	},
	initNewsletter: function() {
		$("#newsletter_submit").click(function() {
			var email= $("#newsletter_email").val();
			if(email.length>5) {
				$.ajax({
					url: '/newsletter/subscribe.php',
					data: 'email='+encodeURIComponent(email),
					type: 'GET',
					dataType: 'html',
					timeout: 5000,
					success: function(html) {
						$("#newsletter").html(html);
					}
				});
			}
		});
	}
}
