$(function() {
	$('#navigation a').stop().animate({
		'marginLeft' : '60px'
	}, 1000);
	$('#navigation > li').hover(function() {
		$('a', $(this)).stop().animate({
			'marginLeft' : '0px'
		}, 200);
	}, function() {
		$('a', $(this)).stop().animate({
			'marginLeft' : '60px'
		}, 200);
	});
	$('#carousel').jcarousel({
		auto : 5,
		wrap : 'both',
		scroll : 1
	});
	$('div.note').css('opacity', '0.8');
	$('a[rel^="lightbox"]').lightBox();
});
$(document).ready(function() {
	$("a.galerie img").css('opacity', '0.6');
	$("a.galerie img").hover(function() {
		$(this).animate({
			opacity : 1.00
		}, 500, function() {
		});
	}, function() {
		$(this).animate({
			opacity : 0.6
		}, 500, function() {
		});
	});
	$("#dialog-form").dialog({
		autoOpen : false,
		height : 300,
		width : 450,
		modal : true,
		buttons : {
			'Odeslat' : function() {
				$.post('/index/sendcontactform', {
					'email' : $("#cform-email").val(),
					'phone' : $("#cform-phone").val(),
					'text' : $("#cform-text").val(),
					'code' : $("#cform-code").val()
				}, function(data) {
					if (data != '') {
						alert(data);
					} else {
						$(this).dialog('close');
						$("#dialog-success").dialog('open');
					}
				});
			},
			'Zavřít' : function() {
				$(this).dialog('close');
			}
		},
		close : function() {
		}
	});
	$('input#cform-submit').click(function() {
		$('#dialog-form').dialog('open');
		return false;
	});
	$("#dialog-success").dialog({
		autoOpen : false,
		height : 300,
		width : 450,
		modal : true,
		buttons : {
			Zavřít : function() {
				$(this).dialog('close');
				location.href = "";
			}
		},
		close : function() {
			allFields.val('').removeClass('ui-state-error');
		}
	});
	$("#dialog-fail").dialog({
		autoOpen : false,
		height : 300,
		width : 450,
		modal : true,
		buttons : {
			Zavřít : function() {
				$(this).dialog('close');
				location.href = "";
			}
		},
		close : function() {
			allFields.val('').removeClass('ui-state-error');
		}
	});
	var cformIsVisible = true;
	$("a#cFormLabel").click(function() {
		if (cformIsVisible == false) {
			$("#cform-wrap").show();
			$("#contactform").animate({
				width : '120px'
			}, 1000, function() {
				cformIsVisible = true;
			});
		} else {
			$("#contactform").animate({
				width : '0px'
			}, 1000, function() {
				cformIsVisible = false;
				$("#cform-wrap").hide();
			});
		}
		return false;
	});
	$("#designer").click(function() {
		location.href = "http://www.stopra.eu";
	});
	
	$("#homepage-wrap #realizace #katalogy div.kat img").click(function () {
		location.href = $(this).next().attr('href');
	});
});
