﻿

$(document).ready(function () {

    $(".galerka").fancybox({
        'titleShow': false
    });

    //    $('body').nivoZoom({
    //        speed: 500,
    //        zoomHoverOpacity: 0.8,
    //        overlay: false,
    //        overlayColor: '#333',
    //        overlayOpacity: 0.5,
    //        captionOpacity: 0.8
    //    });

    function megaHoverOver() {
        $(this).find(".sub").stop().fadeTo('fast', 1).show();

        //Calculate width of all ul's
        (function ($) {
            jQuery.fn.calcSubWidth = function () {
                rowWidth = 0;
                //Calculate row
                $(this).find("ul").each(function () {
                    rowWidth += $(this).width();
                });
            };
        })(jQuery);

        if ($(this).find(".row").length > 0) { //If row exists...
            var biggestRow = 0;
            //Calculate each row
            $(this).find(".row").each(function () {
                $(this).calcSubWidth();
                //Find biggest row
                if (rowWidth > biggestRow) {
                    biggestRow = rowWidth;
                }
            });
            //Set width
            $(this).find(".sub").css({ 'width': biggestRow });
            $(this).find(".row:last").css({ 'margin': '0' });

        } else { //If row does not exist...

            $(this).calcSubWidth();
            //Set Width
            $(this).find(".sub").css({ 'width': rowWidth });

        }
    }

    function megaHoverOut() {
        $(this).find(".sub").stop().fadeTo('fast', 0, function () {
            $(this).hide();
        });
    }


    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
        interval: 5, // number = milliseconds for onMouseOver polling interval    
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
        timeout: 5, // number = milliseconds delay before onMouseOut    
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
    };

    $("ul#topnav li .sub").css({ 'opacity': '0' });
    $("ul#topnav li").hoverIntent(config);
  
    $("#txtHledat").focus(function () {
      //  $(this).css({ 'background-color': '#FFFFFF' });
      //  $(this).css({ 'color': '#000000' });
        //        this.value = $(this).attr('Text');

               // if (this.value == $(this).attr('Text')) {
        this.value = '';
      //  }

    });
    $("#txtHledat").focusout(function () {
       // $(this).css({ 'background-color': '#d2c3b3' });
       // $(this).css({ 'color': 'black' });
        this.value = $(this).attr('Text');


        this.value = 'Hledaný výraz...';

    });

    $("#slider1").easySlider({
        loop: true,                           // LoopingItemHlavniImg
        orientation: 'fade',                  // Fading
        autoplayDuration: 1000,               // Autoplay with 1 second intervals
        autogeneratePagination: false,         // Automatically generate pagination links
        restartDuration: 200,                // In case of user interaction, restart the autoplay after 2.5 seconds

        pauseable: true                       // Pause by hovering over the image!  Then restart after 2.5 seconds (see above)
    });

    //    $(".ChildItemHlavni").mouseover(function () {
    //        $(".ChildItemHlavniCena").animate({ 'left': '10px' }, "250");
    //    });
    //    $(".ChildItemHlavni").mouseleave(function () {
    //        $(".ChildItemHlavniCena").animate({ 'left': '0px' }, "250");ProduktHlavni
    //    });
    $('.ProduktHlavniHeadItem').mouseover(function () {
        $(this).cycle('pause');
        $('.ProduktHlavniHeadItem .OznacSipkouSmall').css({ 'background-image': 'url("../Images/System/SipkaOznac.png")' });
    });
    $('.ProduktHlavniHeadItem').mouseleave(function () {
        $(this).cycle('resume');
        $('.ProduktHlavniHeadItem .OznacSipkouSmall').css({ 'background-image': 'none' });
    });







    $('.KategoriePolozkyprodukt').mouseover(function () {
        $(this).find(".KategoriePolozkyPopisprodukt").css({ 'background-color': '#F5F5F5' });
    });
    $('.KategoriePolozkyprodukt').mouseleave(function () {
        $(this).find(".KategoriePolozkyPopisprodukt").css({ 'background-color': 'white' });
    });



    $('.ProduktHlavniHeadItem').cycle({
        fx: 'scrollLeft',
        timeout: 20000,
        delay: -2000,
        speed: 700,
        pager: '#nav'
    });


    $('#id1').cycle({
        fx: 'scrollLeft',
        timeout: 20000,
        delay: -2000,
        speed: 700,
        pager: '#nav2'
    });
    $('#id1').mouseover(function () {
        $('#id1 .OznacSipkouSmall').css({ 'background-image': 'url("../Images/System/SipkaOznac.png")' });
        $(this).cycle('pause');
    });
    $('#id1').mouseleave(function () {
        $('#id1 .OznacSipkouSmall').css({ 'background-image': 'none' });
        $(this).cycle('resume');
    });

    $('#id2').cycle({
        fx: 'scrollLeft',
        timeout: 20000,
        delay: -2000,
        speed: 700,
        pager: '#nav3'

    });
    $('#id2').mouseover(function () {
        $('#id2 .OznacSipkouSmall').css({ 'background-image': 'url("../Images/System/SipkaOznac.png")' });
        $(this).cycle('pause');
    });
    $('#id2').mouseleave(function () {
        $('#id2 .OznacSipkouSmall').css({ 'background-image': 'none' });
        $(this).cycle('resume');
    });

    $('#id3').cycle({
        fx: 'scrollLeft',
        timeout: 20000,
        delay: -2000,
        speed: 700,
        pager: '#nav4'

    });
    $('#id3').mouseover(function () {
        $('#id3 .OznacSipkouSmall').css({ 'background-image': 'url("../Images/System/SipkaOznac.png")' });
        $(this).cycle('pause');
    });
    $('#id3').mouseleave(function () {
        $('#id3 .OznacSipkouSmall').css({ 'background-image': 'none' });
        $(this).cycle('resume');
    });

    $('#id4').cycle({
        fx: 'scrollLeft',
        timeout: 20000,
        delay: -2000,
        speed: 700,
        pager: '#nav5'
    });
    $('#id4').mouseover(function () {
        $('#id4 .OznacSipkouSmall').css({ 'background-image': 'url("../Images/System/SipkaOznac.png")' });
        $(this).cycle('pause');
    });
    $('#id4').mouseleave(function () {
        $('#id4 .OznacSipkouSmall').css({ 'background-image': 'none' });
        $(this).cycle('resume');
    });

    $('#id5').cycle({
        fx: 'scrollLeft',
        timeout: 20000,
        delay: -2000,
        speed: 700,
        pager: '#nav6'
    });
    $('#id5').mouseover(function () {
        $('#id5 .OznacSipkouSmall').css({ 'background-image': 'url("../Images/System/SipkaOznac.png")' });
        $(this).cycle('pause');
    });
    $('#id5').mouseleave(function () {
        $('#id5 .OznacSipkouSmall').css({ 'background-image': 'none' });
        $(this).cycle('resume');
    });

    $('#id6').cycle({
        fx: 'scrollLeft',
        timeout: 20000,
        delay: -2000,
        speed: 700,
        pager: '#nav7'
    });
    $('#id6').mouseover(function () {
        $('#id6 .OznacSipkouSmall').css({ 'background-image': 'url("../Images/System/SipkaOznac.png")' });
        $(this).cycle('pause');
    });
    $('#id6').mouseleave(function () {
        $('#id6 .OznacSipkouSmall').css({ 'background-image': 'none' });
        $(this).cycle('resume');
    });




    $("ul.thumb li img").fadeTo('200', '0.5');

    $("ul.thumb li img").hover(function () { //On hover...
        $(this).fadeTo('200', '1');



    }, function () { //on hover out...
        $(this).fadeTo('200', '0.5');

    });









});

function KontrolaFormulare() {

//    var pass = document.formular.heslo_form.value;
//    var delka = pass.length;

//    var pass2 = document.formular.login_form.value;
//    var delka2 = pass2.length;

//    var email = document.formular.email.value;



    if (!document.ctl01.txtFirma.value) {
        document.ctl01.txtFirma.focus();
        alert("Není vyplněno FIRMA/JMÉNO !\nFormulář nemůže být odeslán.");
        return false;
    }


//    if (!document.formular.prijmeni.value) {
//        document.formular.prijmeni.focus();
//        alert("Není vyplněno PŘÍJMENÍ !\nFormulář nemůže být odeslán.");
//        return false;
//    }



//    if (!document.formular.mesto.value) {
//        document.formular.mesto.focus();
//        alert("Není vyplněno MĚSTO!\nFormulář nemůže být odeslán.");
//        return false;
//    }



//    if (!email) {
//        document.formular.email.focus();
//        alert("Není vyplněn E-MAIL!\nFormulář nemůže být odeslán.");
//        return false;
//    }






//    if (!document.formular.login_form.value) {
//        document.formular.login_form.focus();
//        alert("Není vyplněn Login!\nFormulář nemůže být odeslán.");
//        return false;
//    }


//    if ((delka2 < 5) || (delka2 > 12)) {
//        document.formular.login_form.focus();
//        alert("LOGIN musím mít minimálně 5 a maximálně 12 znaků!\nFormulář nemůže být odeslán.");
//        return false;
//    }



//    if (!document.formular.heslo_form.value) {
//        document.formular.heslo_form.focus();
//        alert("Není vyplněno HESLO!\nFormulář nemůže být odeslán.");
//        return false;
//    }

//    if ((document.formular.heslo_form.value) && ((delka < 6) || (delka > 15))) {
//        document.formular.heslo_form.focus();
//        alert("HESLO musí mít minimálně 6 a maximálně 15 znaků!\nFormulář nemůže být odeslán.");
//        return false;
//    }


//    if ((document.formular.heslo_form.value) && (!document.formular.heslo2.value)) {
//        document.formular.heslo2.focus();
//        alert("Není vyplněno POTVRZENÍ HESLA!\nFormulář nemůže být odeslán.");
//        return false;
//    }



//    if (document.formular.heslo2.value != document.formular.heslo_form.value) {
//        document.formular.heslo_form.focus();
//        alert("Zadaná hesla se musí shodovat!\nFormulář nemůže být odeslán.");
//        return false;
//    }






//    if (email.indexOf("@") == -1 | email.indexOf("@") == 0 | email.indexOf("@") == email.length - 1) {
//        document.formular.email.focus();
//        alert("Chybně zadaný E-MAIL!\nFormulář nemůže být odeslán.");
//        return false;
//    }

//    if (email.indexOf(".") == -1 | email.indexOf(".") == email.length - 1 | email.indexOf(".") == email.indexOf("@") + 1) {
//        document.formular.email.focus();
//        alert("Chybně zadaný E-MAIL!\nFormulář nemůže být odeslán.");
//        return false;
//    }


//    var znak = email.indexOf("@");
//    var cast1 = email.substring(0, znak);
//    var cast2 = email.substring(znak, email.length);
//    var konec = email.substring(email.length - 1, email.length);

//    if (konec == ".") {
//        document.formular.email.focus();
//        alert("Chybně zadaný E-MAIL!\nFormulář nemůže být odeslán.");
//        return false;
//    }

//    if (cast2.indexOf(".") == cast2.length - 4 | cast2.indexOf(".") == cast2.length - 3 | cast2.indexOf(".") == cast2.length - 6) {
//        return true;
//    } else {
//        document.formular.email.focus();
//        alert("Chybně zadaný E-MAIL!\nFormulář nemůže být odeslán.");
//        return false;
//    }



}  

