$(function(){
    $("#navigation>ul>li").each(function () {
        $(this).hoverIntent({
            over: function () {
                $(this).addClass("hover");
            },
            timeout: 300,
            out: function () {
                $(this).removeClass("hover");
            }
        });
    });
});


$(function(){
    $('#slider').nivoSlider( {
        effect: 'fade',
        pauseTime: 5000,
        animSpeed: 200,
        captionOpacity:1
    }); 
    if (!$('.nivo-controlNav a:eq(1)').length) {
        $('.nivo-controlNav').hide();
        $('#slider').data('nivoslider').stop();
    }
});


// suchvorschlaege
$(function(){    
    $("input.searchsuggest").autocomplete("/_comp/wquadrat/php/suche_autocomplete.php", {
        limit: 1000,
        width: 140,
        selectFirst: false,
        minChars: 2
    });
// tooltip
    $("img.tooltipTrigger[title]").tooltip({position: "top right", opacity: 0.8});
    
});

function toggleReclamationFields(){
  if ($('#anliegen').val() == "Reklamation"){
    $('#reclamationFields').fadeIn(1000).show();
  }else{
    $('#reclamationFields').fadeOut(1000);
  }
}
$(document).ready(function() {
  $('#anliegen').bind('change', function(event) {
    toggleReclamationFields();
  });
  toggleReclamationFields();
});
toggleReclamationFields();

$(function(){  
    if ($('#anliegen').val() == "Reklamation"){
        if ($('input#produktbezeichnung').val() != "") {
            if ($('input#bestBefore').val() == "" || $('input#chargen-Nr').val() == "") {
                $('p#hintProdukt').fadeIn(1000).show();
            }
        }   
    }
    $('input#produktbezeichnung').focus(function() {
        $('p#hintProdukt').fadeIn(1000).show();
    });
    $('input#produktbezeichnung').blur(function() {
        if ($(this).val() == "") {
            $('p#hintProdukt').fadeOut(1000).show();
        }
    });
});
