$(document).ready(function()
{
    $('#slides').cycle({
        fx: 'fade',
        pager:  '.slide-page-jump',
        activePagerClass: 'active',
        next: '.slide-trigger .next',
        prev: '.slide-trigger .prev',
        pagerAnchorBuilder: function(idx, slide) { 
            return '<li><a href="#">' + idx + '</a></li>';
        }
    });
    
    //  Animated the country flags
    $('#lang-switch li a').each(function(){
        $(this).hover(function(e){
           $(this).css({'bottom': '0'});
            $(this).animate({'bottom': '-4px'}, 200);
        }, function(){
            $(this).animate({'bottom': '0'}, 200);
        });
    });
    
    //  Animated the slide-trigger buttons
    $('.trigger-prev').hover(function(){
        $(this).css({'left': '0'});
        $(this).animate({'left': '-10px'}, 200);
    }, function(){
        $(this).animate({'left': '0'}, 200);
    });
    $('.trigger-next').hover(function(){
        $(this).css({'right': '0'});
        $(this).animate({'right': '-10px'}, 200);
    }, function(){
        $(this).animate({'right': '0'}, 200);
    });

    Shadowbox.init();
    
    $('a.cloud-zoom').bind('click', function(){
        $(this).CloudZoom();
        return false;
    });
    
    $('#search-mod h2').bind('click', function(){
        $(this).parent().find('fieldset').toggle();
        return false;
    })
    
    $('#tool-print a').popupWindow({ 
        height:730,
        width:960,
        scrollbars:1
    });
    $('#tool-cart').bind('click', function(){
        
    })

    selection_opened = false;
    $selection_table = $('#user-selection');
    $('#selection-toggle a').click(function(){
        $selection_table.slideToggle();

        if (selection_opened) {
            $(this).hide();
            $('a.show', $(this).parent()).show();
        } else {
            $(this).hide();
            $('a.hide', $(this).parent()).show();
        }
        selection_opened = !selection_opened;

        return false;
    })

    //***************************************************************
    //  PRODUCT PAGE
    if ($('body').hasClass('slider-collection')){
        if ($('#user-selection').css('display') == 'block') {
            selection_opened = true;
            $('#selection-toggle .show').hide();
            $('#selection-toggle .hide').show();
        }

        $('#product-tools a').hover(function(){
            $(this).css('border', 'none').animate({'width': 150});
        }, function(){
            $(this).animate({'width': 0}, function(){ $(this).css('border-left', '1px solid #DDD')});
        });
    }
});

