﻿/* 

KM 14.04.2011
Fehlende Variablen werden in header.php in templates definiert (PHP ist dafür nötig)

*/

//Bild wechseln
function change_image (image_id, image_source) {
    document.getElementById(image_id).src = image_source;
}
//jQuery ausführen
$.ajaxSetup({
    contentType: "application/x-www-form-urlencoded;charset=utf-8"
  });

  //KM 27.06.2011 -> Gibt jQueryObject aus
function show_jQueryObject(jobject){
    alertString = "";
    jQuery.each(jobject, function(index, value) { 
        alertString += index + ': ' + value+"\n\n"; 
    });
    alert(alertString);
}
$(document).ready(function() {
    //Cluetip mit Title und Ajax
    $('a.cluetipTitle').cluetip({splitTitle: '|',cluetipClass: 'bg'});   
    $('a.cluetip').cluetip();  
    //Superfish
    $('ul.sf-menu').superfish({
        delay:       300,                            // one second delay on mouseout
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
        speed:       'fast',                          // faster animation speed
        autoArrows:  false,                           // disable generation of arrow mark-up
        dropShadows: false                            // disable drop shadows
    });
    //Languagebuttons verstecken
    $("#open").click(function (){
       $("#language").hide();
    });
    $("#close").click(function (){
       $("#language").delay(500).fadeIn();
    });
    //KM 12.04.2011 - Fadeinbuttons 
    if ( $.browser.msie != true) {
    $('div.new_buttons').each(function (){
        $link = $('a.standard_bg',this).attr("href");
        $html = $('span.buttonText',this).html();
        $(this).append('<a class="hover_bg" href="'+$link+'"><span class="buttonText">'+$html+'</span></a>');
        var $hover = $('a.hover_bg', this).css('opacity', 0);
        $(this).hover(function () {
            $('ul.sf-menu a.hover_bg').stop().fadeTo(300, 0); //Für Menü  
            $hover.stop().fadeTo(300, 1);
         }, function () {
            $hover.stop().fadeTo(300, 0);  
            //Für Menü
            $('ul.sf-menu li').each(function() {              
                $('a.hover_bg', this).stop().fadeTo(300, 0); 
                if($("ul", this).css('visibility') == "visible"){
                     $('a.hover_bg', this).stop().fadeTo(300, 1); 
                }
            }); 
            
        });
    });
    }

    //KM 31.05.2011 - Fadeinbuttons   SUBMIT
        if ( $.browser.msie != true) {
    $('div.new_submits').each(function (){
        $name = $('input.submitbutton',this).attr("name");
        $value = $('input.submitbutton',this).attr("value");
        $(this).append('<input type="submit" name="'+$name+'" class="submitbuttonHover" value="'+$value+'"/>');
        var $hover = $('input.submitbuttonHover', this).css('opacity', 0);
        $(this).hover(function () {
            $hover.stop().fadeTo(300, 1);
         }, function () {
            $hover.stop().fadeTo(300, 0);  
            
        });
    });}
    
    //Preloader
    var loader = "<img src=\"img/slider/loading.gif\" class=\"img_preload_load\" alt=\"L&auml;dt&hellip;\" style='display:block;' />";
    $('.img_preload').hide();
    $('.img_preload_frame').append(loader);
    $(window).load( function() {
        $('.img_preload_load').hide();
        $('.img_preload').fadeIn('slow');
    });
            
    
    //Für Menü
    $("ul.sf-menu li ul").hover(function(){}, function () {
       $('ul.sf-menu a.hover_bg').stop().fadeTo(300, 0);
    });


    //KM 14.04.2011 - Warenkorbdropdown
    $("#cart_link").mouseover(function(){
       $("#warenkorb_dropdown").slideDown("slow"); 
       $("#warenkorb_dropdown_new").hide();  
    })
    $("#bottom").mouseover(function(){
       $("#warenkorb_dropdown").slideUp(); 
       if(new_product == true){    
            $("#warenkorb_dropdown_new").slideUp();
       }  
    })
    if(new_product == true){
        $("#warenkorb_dropdown_new").slideDown("slow"); 
        $("#warenkorb_dropdown_new").delay(5000).slideUp();  
    }
    
    //KM 14.04.2011 HideShowContent
    $(".showhidequestion").click(function (){
        $(".showhideanswer").slideUp();
        $(".showhidearrow").attr("src","img/icon/icon_arrowleft.png");
        //Nicht das aktuelle Element, dann wirds nur geschlossen
        $currentStat = $(this).next().css("display");
        if($currentStat == "none"){
            $(".showhidearrow", this).attr("src","img/icon/icon_arrowdown.png");   
            $(this).next().slideDown();    
        }        
    });
    
    //Tooltips
    //KM 31.05.2011 ersetzt durch neuen Tooltip
    /*$("#tooltip_area img.tt").tooltip({
    
        // place tooltip on the right edge 
        position: "top center", 
     
        // a little tweaking of the position 
        offset: [-14, 140], 
     
        // use the built-in fadeIn/fadeOut effect 
        effect: "fade", 
     
        // custom opacity setting 
        opacity: 0.92 
    });
    $("#tooltip_area img.tt[title]").each(function(){
        $(this).tooltip({
    
            // place tooltip on the right edge 
            position: "top center", 
         
            // a little tweaking of the position 
            offset: [-14, 140], 
         
            // use the built-in fadeIn/fadeOut effect 
            effect: "fade", 
         
            // custom opacity setting 
            opacity: 0.92 
        });
    })
    $("#tooltip_area a.tt[title]").tooltip({
    
        // place tooltip on the right edge 
        position: "top center", 
     
        // a little tweaking of the position 
        offset: [-2, 10], 
     
        // use the built-in fadeIn/fadeOut effect 
        effect: "fade", 
     
        // custom opacity setting 
        opacity: 0.92 
    });
    // select all desired input fields and attach tooltips to them 
     $("#tooltip_area input.tt[title]").tooltip({ 
     
        // place tooltip on the right edge 
        position: "center right", 
     
        // a little tweaking of the position 
        offset: [-2, 10], 
     
        // use the built-in fadeIn/fadeOut effect 
        effect: "fade", 
     
        // custom opacity setting 
        opacity: 0.92
    });
             */  
    
    //Masonry
    $(function(){
      
      var $wall = $('.masonry');

      $wall.masonry({
        columnWidth: 100, 
        itemSelector: '.box:visible'
      });

    $wall.infinitescroll({
        navSelector  : '#masonry_nav',  // selector for the paged navigation 
        nextSelector : '#masonry_nav a',  // selector for the NEXT link (to page 2)
        itemSelector : '.box',     // selector for all items you'll retrieve
        loadingImg : 'templates/3.1/js/preloader/jq-preloader-load.gif',
        donetext  : 'Keine weiteren Kommentare vorhanden.',
        debug: false,
        errorCallback: function() { 
          // fade out the error message after 2 seconds
          $('#infscr-loading').animate({opacity: .8},2000).fadeOut('normal');   
        }
      },
        // call masonry as a callback.
        function( newElements ) { $(this).masonry({ appendedContent: $(newElements) }); }
      );

    });
}); 


