$('document').ready(function() {
	$('.logo').hover(function() { // IN
		$(this).stop().animate({
          opacity: 0
		}, 250);
	},
	function() { // OUT
		$(this).stop().animate({
          opacity: 1
		}, 2000);
	});
	// sent data to the module
	$('#login').click(function() {
		var url = '/';
		var post = $('#loginForm').serialize();
		$.post(url,
			   post,
			   function(data) {
					if (!data)
						showAlert( loginFault1 );
					else
						location.reload();
			   });
	});
	$('#logout').click(function() {
		var url = '/?logout';
		$.get(url,
			   function(data) {
					location.reload();
			   });
	});
	$('#captcha').click(function() {
		var url = '/';
		var post = $('#captchaForm').serialize();
		$.post(url, 
			   post,
			   function(data) {
					location.reload();
			   });
	});
	checkCookie();
});

function checkCookie() {
	var cookieEnabled = (navigator.cookieEnabled)?true:false;
    if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){ 
        document.cookie="w5test";
        cookieEnabled=(document.cookie.indexOf("w5test")!=-1)?true:false;
    }
    if (!cookieEnabled) {
		showAlert(cookieDisabled);
	}
}
function showAlert( message ) {
	$('#loginFormAlert').stop().html( message ).delay(3000).slideDown(500);
}
