    $(document).ready(function() {

    var menuItem = $(".menu-item");
    var submenuItems = $(".submenu-items");
    menuItem.mouseover(function() {
        menuItem.removeClass('active-over');
        submenuItems.css("left", "-10000px");
        $(this).addClass('active-over');
        $(this).find(".submenu-items").css("left", "0");
    });

    $("a.active").next(".submenu-items").css("left", "0");

    var drop = $(".drop");

    drop.live('click', function() {
        $('.dropUL').hide();
        var obj = $(this);
        obj.next().toggle();
        return false;
    });

    $('#mark a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=model&cID=' + obj.attr('title'),
            success : function(html) {
                $("#model").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
        $('#model a').parent().parent().prev().text('Модель');
        $('#year a').parent().parent().prev().text('Год выпуска');
    });

    $('#model a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=year&cID=' + obj.attr('title'),
            success : function(html) {
                $("#year").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
        obj.attr('name', 'active');
        $('#year a').parent().parent().prev().text('Год выпуска');
    });

    $('#year a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        var cid = obj.attr('title');
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=body&cID=' + cid,
            success : function(html) {
                $("#body").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
        obj.attr('name', 'active');
    });

    $('#body a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=engine&cID=' + obj.attr('title'),
            success : function(html) {
                $("#engine").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
    });

    $('#engine a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=volume&cID=' + obj.attr('title'),
            success : function(html) {
                $("#volume").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
    });

    $('#volume a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=gearbox&cID=' + obj.attr('title'),
            success : function(html) {
                $("#gearbox").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
    });

    $('#gearbox a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=gear&cID=' + obj.attr('title'),
            success : function(html) {
                $("#gear").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
    });

    $('#gear a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        $.ajax({
            url : 'http://yoshida.ru/services/request.php',
            cache : false,
            data : 'id=steering&cID=' + obj.attr('title'),
            success : function(html) {
                $("#steering").html(html);
            }
        });
        obj.parent().parent().prev().text(val);
    });

    $('#steering a').live('click', function() {
        var obj = $(this);
        var val = obj.text();
        obj.parent().parent().prev().text(val);
    });


    $('*').live('click', function() {
        drop.next().hide()
    });


    $("#brokMap").click(function() {
        var obj = $(this);
        obj.next().css("display", "none");
        obj.next().toggle();
        return false;
    });

    var calcParam = "id=calculate";
    $("#calculate, .submit").click(function() {
        $("#popup-cont").html("загрузка данных ...");
        var cid = $("#year a[name=active]").attr('title');
        if (( cid == '') || ( cid == null)) {
            $("#popup-cont").html("<h2>Необходимо выбрать хотя бы 3 первых поля!</h2>");
            $("#popup").toggle();
        }
        else {
            $.ajax({
                url : 'http://yoshida.ru/services/request.php',
                cache : false,
                data : calcParam + '&cID=' + cid,
                success : function(html) {
                    $("#popup-cont").html(html);
                }
            });
            $("#popup").toggle();
            calcParam = "id=calculate";
        }
    });

    $("#popup-x, .dropUL, .drop").click(function() {
        $("#popup").hide();
    });


    $('.rounded, #inside-left, #inside-left div, #submenu-wrap, #popup').corner('10px');
    $('.head').corner('top 10px');
    $('.csc-firstHeader').corner('top 10px');
    $('#inside-menu li:last a').css("border", "none");

    $('#submenu-wrap, #submenu-wrap2, #submenu-wrap3').corner('10px');
    
    $("#addinp").live('click', function(){
        $('<div class="corporatmodel"><div class="modelcorp">    <label >Модель автомобиля</label>    <p><input name="models[]" class="modelscar" type="text" /></p></div><div class="modelcorp">    <label >Кол-во(шт)</label>    <p><input name="counts[]" class="counts" type="text" /></p></div><div class="modelcorp">    <label>возраст (от-до)</label>    <p><input name="oldfrom[]" class="old" type="text" /><input name="oldto[]" class="old"  type="text" /></p></div><a href="#" class="delete" onclick="return false;"><i>удалить</i></a></div>').appendTo("#inputsmodel");
    })
    $(".delete").live('click', function(){
        $(this).parent().remove();
    })
    

})
        ;
        
        
function screenSize() {
    var w, h; 
    w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
    h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
    return {w:w, h:h}; 
    }
