//
// JQUERY
//

jQuery(document).ready(function() {
	// hodinky
	var options2 = {
		format: '%A, %d. %b. %Y | %H:%M:%S' // 24-hour
	}
	$('#jclock2').jclock(options2); 
	// lightbox
	$("a.lightbox").fancybox({
		'padding' 	: '0',
		'margin' 	: '0',
		'titlePosition' 	: 'over',
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
	});
	// login
	$("#user").fancybox({
		'scrolling' : 'no',	
		'titleShow'	: false,
		'modal'			: true,
		'onClosed'	: function() {
		    $("#login_error").hide();
		}
	});
	    
	$("#login_form").bind("submit", function() {
	
		if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) {
			$("#login_error").show();
			$.fancybox.resize();
			return false;
		}
		
		$.fancybox.showActivity();
		
		$.ajax({
			type	: "POST",
			cache	: false,
			url		: "/login.php",
			data	: $(this).serializeArray(),
			success: function(data) {
				switch(data){
					case "1":
						(function() {window.location.reload();})();break;
					case "0":
						$("#login_error").show();
						$.fancybox.hideActivity();break;
				}
			}
		});
	
		return false;
	});
});


//
// ODOSLANIE FORMULARU
//

function move(target){
	document.getElementById('multiple_form').action = target;
	document.getElementById('multiple_form').submit();
}

