var x = x || {};

x.hideOrderForm = function(element) {
    $('#zakaz').hide();
    return true;
}

x.showOrderForm = function(element) {
    var vehicles_type = $('#order_autofields input[name="vehicles_type"]').val();
    var vehicles_model = $('#order_autofields input[name="vehicles_model"]').val();
    if ((vehicles_type != undefined) && !$('#zakaz form input[name="vehicles_type"]').val().length) {
	$('#zakaz form input[name="vehicles_type"]').val(vehicles_type);
    }
    if ((vehicles_model != undefined) && !$('#zakaz form input[name="vehicles_model"]').val().length) {
	$('#zakaz form input[name="vehicles_model"]').val(vehicles_model);
    }
    if ((vehicles_type != undefined) && (vehicles_model != undefined) && !$('#zakaz form input[name="vehicles_count"]').val().length) {
	$('#zakaz form input[name="vehicles_count"]').val('1');
    }
    $('#zakaz').show();
    $('body').animate({
	scrollTop: 0
    }, 100);
    $('html').animate({
	scrollTop: 0
    }, 100);
    return true;
}

function initCarousel(id) {
    $('#' + id).jcarousel({
	auto: 3,
	scroll: 1,
	wrap: 'circular',
	animation: 'slow',
	initCallback: function(carousel) {
	    carousel.clip.hover(function() {
		carousel.stopAuto();
	    }, function() {
		carousel.startAuto();
	    });
	}
    });
}
