
$(document).ready(function() {

	Cufon.replace('#topmenu, .cufon', { fontFamily: 'Trajan Pro' });
	$('#slider').coinslider({
		width: 922,
		height: 343,
		spw: 10,
		sph: 7,
		navigation: false,
		delay: 4000,
		sDelay: 10,
		links: false
	});

	jQuery('#glist').jcarousel({
		initCallback: mycarousel_initCallback,
		scroll: 4
	});
	
	/*$('.gallery a').click(function(e) {
		e.preventDefault();
	});*/

	$('#glist a').click(function(e) {
		e.preventDefault();
		$('.gallery a').hide();
		$('#'+$(this).attr('rel')).show();
	});
	
	$('#contactForm').submit(function(){
		$('#contactForm button').attr('disabled','disabled');
		$('#loading').show();
		$.post
		(
			$("#contactForm").attr('action'),
			$("#contactForm").serialize(),
			function(result){
				$('.error').hide();
				result = jQuery.parseJSON(result);
				for (error in result.errors){
					if(result.errors[error]){
						$('#'+error+'Error').show();
					}
				}
				if(result.status == 'error'){
					$('#sendingError').show();
				}
				if(result.status == 'success'){
					$('#sendingSuccess').show();
					$('#contactForm :input').val('');
				}
				$('#contactForm button').attr('disabled','');
				$('#loading').hide();
			}
		);
		return false;
	});
	
	$('#date').datepicker({ dateFormat: 'yy. mm. dd.', firstDay: 1 });

});

function mycarousel_initCallback(carousel) {
	jQuery('.gallery a').bind('click', function() {
		$('.gallery a').hide();
		if($('.gallery a.active').next().attr('id')){
			$('.gallery a.active').next().addClass('active').show();
			carousel.scroll(jQuery.jcarousel.intval(parseInt(jQuery(this).attr('rel'))+1));
		} else {
			$('.gallery a:first').addClass('active').show();
			carousel.scroll(jQuery.jcarousel.intval(1));
		}
		$(this).removeClass('active');
		return false;
	});
};

