﻿$(function() {
    // If no JS CSS menu will still work
    $("#mainmenu").removeClass("cssonly");
    // Find subnav menus and slide them down
    $("#mainmenu li a").hover(function () {
        $(this).parent().find("div.submenu").animate({ opacity: 'toggle', height: "toggle" }, 200);
        $(this).parent().hover(function () {
        }, function () {
            // On hovering out slide subnav menus back up
            $(this).parent().find("div.submenu").slideUp(100);
        })
    });

    $("#menulogged").removeClass("cssonly");
    // Find subnav menus and slide them down
    $("#menulogged li a").hover(function () {
        $(this).parent().find("div.submenu").animate({ opacity: 'toggle', height: "toggle" }, 200);
        $(this).parent().hover(function () {
        }, function () {
            // On hovering out slide subnav menus back up
            $(this).parent().find("div.submenu").slideUp(100);
        })
    });
    $("#menuregister").removeClass("cssonly");
    // Find subnav menus and slide them down
    $("#menuregister li a").hover(function () {
        $(this).parent().find("div.submenu").animate({ opacity: 'toggle', height: "toggle" }, 200);
        $(this).parent().hover(function () {
        }, function () {
            // On hovering out slide subnav menus back up
            $(this).parent().find("div.submenu").slideUp(100);
        })
    });

    $("#menuside").removeClass("cssonly");
    // Find subnav menus and slide them down
    $("#menuside li a").hover(function() {
        $(this).parent().find("ul.submenu").animate({ opacity: 'toggle', height: "toggle" }, 200);
        $(this).parent().hover(function() {
        }, function() {
            // On hovering out slide subnav menus back up
        $(this).parent().find("ul.submenu").slideUp(100);
        })
    });

    $("#menufooter").removeClass("cssonly");
    // Find subnav menus and slide them down
    $("#menufooter li a").hover(function() {
        $(this).parent().find("ul.submenu").animate({ opacity: 'toggle', height: "toggle" }, 200);
        $(this).parent().hover(function() {
        }, function() {
            // On hovering out slide subnav menus back up
            $(this).parent().find("ul.submenu").slideUp(100);
        })
    });

    $("#slider-range").slider({
        range: true,
        min: 0,
        max: 205000,
        step: 5000,
        values: [0, 205000],
        slide: function(event, ui) {
            if (ui.values[1] === 205000) {
                $(".txtSearchPriceStart").val(ui.values[0]);
                $(".txtSearchPriceStop").val('Bez limitu');
            }
            else {
                $(".txtSearchPriceStart").val(ui.values[0]);
                $(".txtSearchPriceStop").val(ui.values[1]);
            }
        }
    });

    $(".txtSearchPriceStart").val($("#slider-range").slider("values", 0) );
    $(".txtSearchPriceStop").val('Bez limitu');

});

