jQuery('document').ready(function($){
    /* List decoration */
    $('ul li:first-child').addClass('first');
    $('ul li:last-child').addClass('last');
    
    /* Tabs */
    $('.tabs-content').each(function(){
        $(this).children().hide();
        $(this).children(':first').show();
    });
    $('.tabs-list').each(function(){
        $(this).children(':first').addClass('active');
    })
    $('.tabs-list li').hover(
        function(){
            $(this).addClass('over');
        },
        function(){
            $(this).removeClass('over');
        }
    );
    $('.tabs-list li').click(function(){
        var parent = $(this).parent();
        
        parent.children('.active').removeClass('active');
        $(this).addClass('active');
        
        $('.tabs-content > div', parent.parent().parent().get(0)).hide();
        $('div.' + $(this).attr('id')).show();
    });

    /* Drop down menu */
    $('#menu-bar li').each(function(){
        if ($(this).children('ul').length) $(this).addClass('parent');
    })
    
    $('.parent').hover(
        function(){
            $(this).addClass('hover').children('ul').show();
        },
        function(){
            $(this).removeClass('hover').children('ul').hide();
        }
    )
})

/* Table decoration */
function decorateTable(table){
    if ($('#' + table).length > 0) {
        var bodyRows = $('#' + table + ' > tbody > tr')
        var headRows = $('#' + table + ' > thead > tr')
        var footRows = $('#' + table + ' > tfoot > tr')
        
        if (headRows.length) {
            $(headRows[0]).addClass('first');
            $(headRows[headRows.length-1]).addClass('last');
        }
        
        if (headRows.length) {
            $(footRows[0]).addClass('first');
            $(footRows[footRows.length-1]).addClass('last');
        }
        
        if (bodyRows.length) {
            var cols;
            
            $(bodyRows[0]).addClass('first');
            $(bodyRows[bodyRows.length-1]).addClass('last');
            
            bodyRows.each(function(i){
                $(this).addClass(i % 2 == 0 ? 'even' : 'odd');
                
                cols = $(bodyRows[i]).children('td');
                
                $(cols[0]).addClass('first')
                $(cols[cols.length-1]).addClass('last');
            })
        }
    }
}
/* Hide-Show CVV-Help */
function toggleCvv(){
    if ($('.helpCvv').length)
        $('.helpCvv').remove();
    else
        $('body').append('<div class="helpCvv">'+
        'Enter numbers from yor credit card<a class="Cvv-close" href="#" onclick = "toggleCvv()"></a>'+
        '</div>');  
}
