var Dacia = {
    init: function () {
        $('#images').imageSlider();
        $('#images a').lightBox();

        $('.cms table').each(function () {
            if ($(this).hasClass('verticalstripe')) {
                size = $(this).find('tr:first td').size();
                $(this).find('tr').each(function() {
                    $(this).find('td').each(function(index, value) {
                        if (index > size - 3) {
                            $(this).addClass("tableLast");
                        }
                    });

                });
            } else {
                $(this).attr('border').replace('0', '1px');
                $('tbody tr:first', this).addClass("tableFirst");
                $('tbody tr:last', this).addClass("tableLast");
            }
        }
                )
                ;
        Dacia.fadeout_countdown();
        Dacia.printContent();
        //    Renault.banners.setup();
    },

    banners: {
        setup: function () {
            $('.cars').hide();
            $('#tabs li a').click(Dacia.banners.tab_click);
            $('#tabs li:first a').click();
        }
        ,

        tab_click: function () {
            var li = $(this).parent().get(0);
            var index = $("#tabs li").index(li);
            //      jQuery.each(jQuery.browser, function(i){
            //        if($.browser.msie){
            //          index = index-1;
            //        }
            //      });
            //      console.log("index "+index);
            $('#flash_keyvis-0').hide();
            $('#flash_keyvis-1').hide();
            $('#flash_keyvis-' + index).show();
            $(this).parent().siblings().removeClass('active');
            $(this).parent().addClass('active');
            var slug = $(this).parent().attr('id').replace('-menu', '');
            $('.cars').hide();
            $('#' + slug).show();
        }
    }
    ,

    printContent: function() {
        $(".print a").click(Dacia.print)
    }
    ,

    print: function() {
        window.print();
        return false;
    }
    ,

    fadein_countdown: function() {
        $(".countdown span .fade").fadeIn(2000, Dacia.fadeout_countdown);
    }
    ,
    fadeout_countdown: function() {
        $(".countdown span .fade").fadeOut(2000, Dacia.fadein_countdown);
    }
}
        ;

/* modal login window */
$().ready(function () {
    $('#footer').after('\n<div class="modal-window" id="win-login">Prosimo po�akajte ...</div>');
    var lang = $('html').attr('xml:lang');
    var action = 'uporabniki/prijava'
    $('#win-login').jqm({ajax:'/' + action, trigger: '.login-window'});
});

/* tooltip */
$('div.options-wrap span.switch').mouseover(function() {
    $(this).next().removeClass('hidden');
}).mouseout(function() {
    $(this).next().addClass('hidden');
});

$(document).ready(Dacia.init);
