function displayItems() {
    $("#mycarousel img").css("display","block");    
}

function companyGroupClick(){
    $(".company-group ul").slideToggle("fast");
    return false;
}

$(document).ready(function() {
   // Live
  
   if ($('.nav').html() != null) {
        // Navausklappen / Cluetip ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/superfish.js',
            success: function() {              
                $(".nav").superfish({
                            animation : { opacity:"show",height:"show"}
                           });
                $("#main-nav li>ul").parent("li").addClass("sub-active");
                $("#main-nav li.first-row").removeClass();
              },
            dataType: 'script',
            cache: true
        });
    }




   if ($('#left-nav').html() != null) {
        // left Navigation / Treeview ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery.treeview.pack.js',
            success: function() {
                $("#left-nav ul").treeview({
                    collapsed: true
                });
                $("#left-nav .selected:last").addClass("bold");
                $("#left-nav.treeview.selected: first-child").each(function() {
                    $(this).addClass("selected-sub-item");
                });
                $("#left-nav.treeview li: last-child").each(function() {
                    $(this).addClass("last");
                });
                $("#left-nav.treeview li: first-child").each(function() {
                    $(this).addClass("first");
                });
                $('#left-nav .treeview li.all').hover(function() {
                    $(this).addClass("all-hover");
                },
                function() {
                    $(this).removeClass("all-hover");
                });
                $('#left-nav .treeview  li').hover(function() {
                    $(this).addClass("hover");
                },
                function() {
                    $(this).removeClass("hover");
                });
            },
            dataType: 'script',
            cache: true
        });
    }

    if ($('.history-content').html() != null) {
        // History / Cluetip ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery.cluetip.js',
            success: function() {
                $(".history").css("visibility","visible");
                
                $('.history-content .inner').cluetip({
                    positionBy: 'mouse',
                    sticky: 'true',
                    splitTitle: '|',
                    showTitle: true,
                    arrows: true,
                    closePosition: 'title',
                    closeText: '',
                    mouseOutClose: 'true',
                     topOffset: 10,
                     leftOffset: 50,
                     width: 225,
                    fx: {             
                           open: 'fadeIn'
                       },
                    hoverIntent: {    
                        interval: 500
                      }                     
                });
            },
            dataType: 'script',
            cache: true
        });
    }

    if ($('a.load-local').html() != null) {
        // History / Cluetip ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery.cluetip.js',
            success: function() {
    $("a.load-local").cluetip({
        local:true,
        cursor: 'pointer',
        positionBy: 'fixed',
        sticky: 'true',
        dropShadowSteps: 3,
        cluetipClass: 'finder',
        closeText: '',
        arrows: true,
        closePosition: 'title',
        mouseOutClose: 'true',
         topOffset: 2,
         leftOffset: 20,
         width: 200,
        fx: {             
               open: 'fadeIn'
           },
           hoverIntent: {    
            interval: 100
        }
     });

            },
            dataType: 'script',
            cache: true
        });
    }




    if ($('#mycarousel').html() != null) {
        // jcarousel ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery.jcarousel.pack.js',
            success: function() {
                $("#mycarousel").jcarousel({
                    scroll: 1,  
                    initCallback: displayItems
                    //itemLoadCallback: mycarousel_itemLoadCallback
                 });
            },
            dataType: 'script',
            cache: true
        });
        $('.jcarousel-skin-tango .jcarousel-item').show();

    }

   if ($('#slider').html() != null) {
        // slider ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery.cycle.all.pack.js',
            success: function() {
                $("#slider-first-item").css("display", "");
                $('#pause').click(function() {
                    $('#slider').cycle('pause');
                    $('#play').removeClass("active");
                    $('#pause').addClass("active");
                    return false;
                });
                $('#play').click(function() {
                    $('#slider').cycle('resume');
                    $('#play').addClass("active");
                    $('#pause').removeClass("active");
                    return false;
                });
                $('#slider').hover(
                function()
                {
                    if ($('#play').hasClass("active"))
                    {
                        $('#slider').cycle('pause');
                    }
                },
                function()
                {
                    if ($('#play').hasClass("active"))
                    {
                        $('#slider').cycle('resume');
                    }
                }
                );

                $('#slider').cycle({
                    fx: 'fade',
                    speed: 400,
                    timeout: 5000,
                    next: '#next',
                    prev: '#prev',
                    pager:  '#nav', 
                    pagerAnchorBuilder: function(idx, slide) {
                        // return selector string for existing anchor 
                        return '#nav li:eq(' + idx + ') a'; 
                    }
                });
$('#slider').hover(
    function () {
        $(this).cycle('pause');
    },
    function () {
        $(this).cycle('resume');
    }
);

            },
            dataType: 'script',
            cache: true
        });
    }



   if (
       $('.fancybox-taf').html() != null || 
       $('.fancybox_big').html() != null || 
       $('.fancybox_ugrp').html() != null || 
        $('.fancybox').html() != null ||
        $('.fancybox_start').html() != null ||
       $('.fancybox_video_16_9').html() != null ||
       $('.fancybox_video_4_3').html() != null
      )  
     {
        // fancybox ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery.fancybox.js',
            success: function() {
            
                if ($('.fancybox-taf').html() != null) {
                    $(".fancybox-taf").fancybox({
                    'frameWidth': 350,
                    //'frameHeight': 470,
                    'padding':0,
                    'centerOnScroll': false,
                    'hideOnContentClick': false,
                    'itemArray' : false});
                }
                if ($('.fancybox_big').html() != null) {
                    $(".fancybox_big").fancybox({
                    'frameWidth': 280,
                    'frameHeight': 300,
                    'padding':0,
                    'centerOnScroll': false,
                    'hideOnContentClick': false});
                }
                if ($('.fancybox_ugrp').html() != null) {
                    $(".fancybox_ugrp").fancybox({
                    'frameWidth': 800,
                    'frameHeight': 600,
                    'padding':0,
                    'centerOnScroll': false,
                    'hideOnContentClick': false});
                }
                
                if ($('.fancybox').html() != null) {
                    $(".fancybox").fancybox({
                    'frameWidth': 350,
                    'frameHeight': 400,
                    'padding':0,
                    'centerOnScroll': false,
                    'hideOnContentClick': false});
                }
                if ($('.fancybox_start').html() != null) {
                    $(".fancybox_start").fancybox({
                    'frameWidth': 450,
                    'frameHeight': 506,
                    'padding':0,
                    'centerOnScroll': false,
                    'hideOnContentClick': false});
                }
                
                if ($('.fancybox_video_16_9').html() != null) {
                    $(".fancybox_video_16_9").fancybox({
                    'frameWidth': 470,
                    'frameHeight': 270,
                    'padding':0,
                    'centerOnScroll': false,
                    'hideOnContentClick': false});
                }
                if ($('.fancybox_video_4_3').html() != null) {
                    $(".fancybox_video_4_3").fancybox({
                    'frameWidth': 470,
                    'frameHeight': 345,
                    'padding':0,
                    'centerOnScroll': false,
                    'hideOnContentClick': false});
                }
            },
            dataType: 'script',
            cache: true
        });
    }


    if ($('.faq').html() != null) {
        // FAQ ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery.faq.js',
            success: function() {
                $('.faq').makeFAQ({
                indexTitle: "",
                displayIndex: false,
                faqHeader: "h2"
            });            
            },
            dataType: 'script',
            cache: true
        });
    }



    if ($('.alpha-nav').html() != null) {     
        // Schuh ABC ----------------------------------------
        $.ajax({
            type: 'GET',
            url: '/site/da/js/jquery_quicksearch.js',
            success: function() {
                $.fn.clearForm = function() {
                    return this.each(function() {
                    var type = this.type, tag = this.tagName.toLowerCase();
                    if (tag == 'form')
                        return $(':input',this).clearForm();
                    if (type == 'text' || type == 'password' || tag == 'textarea')
                        this.value = '';        
                    else if (type == 'checkbox' || type == 'radio')
                        this.checked = false;        
                    else if (tag == 'select')
                        this.selectedIndex = -1;
                    });
                };
                $("ul.alpha-nav li a").click(function() {
                    $(this).parent().addClass("active");
                    $(this).parent().siblings().removeClass("active");
                    var getID = $(this).attr("rel");
                    if (getID != 'a-z') {
                        $("ul.list." + getID).show();
                        $("ul.list." + getID).siblings().hide();
                        return false;
                    } else {
                        $('ul.list').show();
                        return false;
                    };
                });
            
                $('ul.list li').quicksearch({
                    position: 'prepend',
                    attached: '.quick-form',
                    loaderImg: null,
                    labelText: 'Suchbegriff:',
                    loaderText: '',
                    delay: 100
                });
            
                //reset form
                $('#delete').click(function() {
                    $('.qs_input').clearForm();
                    $('ul.list li').show();
                    return false;
                });
    
                $("a.load-local").cluetip({
                    local:true,
                    cursor: 'pointer',
                    positionBy: 'fixed',
                    sticky: 'true',
                    dropShadowSteps: 3,
                    cluetipClass: 'finder',
                    closeText: '',
                    arrows: true,
                    closePosition: 'title',
                    mouseOutClose: 'true',
                    topOffset: 2,
                    leftOffset: 20,
                    width: 200,
                    fx: {             
                        open: 'fadeIn'
                    },
                    hoverIntent: {    
                        interval: 100
                    }
                });
            },
            dataType: 'script',
            cache: true
        });
    }
});

function open_catalog(catalog) {
  width=920;
  height = 625;
  pdw=open("http://www.deichmann.de/catalog/index.php?lang=lang" + catalog.substring(0, 6) + "&cat=" + catalog,"pdw","width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,copyhistory=no,menubar=no");
}

function popup(pname, width, height, scrollbars) {
  msg=open(pname,"pname","width=" + width + ",height=" + height + ",toolbar=no,location=no,directories=no,status=no,scrollbars=" + scrollbars + ",resizeable=no,menubar=no");
}

function open_product(artnumber) {
  window.location="?artnumber="+artnumber;
}

function open_category(categoryid) {
  window.location="?category="+categoryid;
}