/*******************************************************************************************************************
*  Global variables                                                                                                *
*******************************************************************************************************************/ 

$(document).ready(function() {
    
    /*******************************************************************************************************************
    *  jQuery tabs                                                                                                     *
    *******************************************************************************************************************/
    $('.tabs').tabs();
   
    
    /*******************************************************************************************************************
    *  CSS tweaks                                                                                                   *
    *******************************************************************************************************************/
    $('table tr:even').addClass('even');
    
    /*******************************************************************************************************************
    *  Help box                                                                                                        *
    *******************************************************************************************************************/
    $('body').append('<div id="helpBox"></div>');
    $('.infoIcon').hover(function() {
        $('#helpBox').html($(this).attr('title'));
        var offset = $(this).offset();
        posLeft = offset.left + 0;
        posTop = offset.top - $('#helpBox').outerHeight();
        $('#helpBox').css({'left': posLeft + 'px', 'top': posTop + "px"});
    }, function() {
        $('#helpBox').css({'left': '-9999px', 'top': '-9999px'});
    });
    
    /*******************************************************************************************************************
    *  Form elements focus                                                                                             *
    *******************************************************************************************************************/  
    $('input.focus').focus(function() {if (this.value == this.defaultValue){ this.value = ''; }});

    /*******************************************************************************************************************
    *  Product onClick                                                                                                 *
    *******************************************************************************************************************/
    $('.productsList li').click(function() {
        window.location.href = $(this).find('a').attr('href');
    });
    
    /*******************************************************************************************************************
    *  jCarousel                                                                                                       *
    *******************************************************************************************************************/
    $('#slider .jcarousel').jcarousel({
        scroll: 1,
        visible: 1,
        auto: 2,
        wrap: "both"
    });
    
    /*******************************************************************************************************************
    *  Show and hide content                                                                                           *
    *******************************************************************************************************************/
    $('a.showOrHideContent').click(function(a) {
        a.preventDefault();
        $($(this).attr('href')).toggle(200);          
    });    
    $('input.showOrHideContent').change(function() {
        $($(this).attr('rel')).toggle(0);     
        $(this).parent().parent().toggleClass('highlight');
    });  
    
});

$(window).load(function() {
    
    /*******************************************************************************************************************
    *  Set height in row (parentSelector, childSelector, itemsPerRow)                                                  *
    *******************************************************************************************************************/
    setHeight('.productsList', '.name', 5);
    
});
