jQuery(document).ready(function($){

    //Rotate logo
    setTimeout("rotateLogo()", 6500);

    //slider
    $('#slider').superBanner({width: '981',
                              height: '413',
                              speed: '5000',
                              autoplayDelay: '2000',
                              dotPagination: false,
                              numberPagination: false,
                              pauseable: false});

    //Img viewer plugin
    //$('#image-gallery').imageViewer();

    //Img gallery
    $('.ad-gallery').adGallery({effect:'fade'});


    //Image section
    /*var countThumb = $('.thumbnail > ul > li').size();
    var iThumb     = 1;
    var next       = iThumb+1
    var back       = 

    $('.thumbnail > ul > li').each(function(i){
        if(i >= 5)
        {
            $(this).hide();
        }
    });

    $('.right-arrow').click(function(){
        $('.thumbnail > ul > li').each(function(i){
            if(i < 5)
            {
                $(this).hide();
            }

            if(i >= 5)
            {
                $(this).show();
            }
        });
    });*/

    /**
     * ADMIN AREA
     */

    // Nice even rows highlighting for the Admin Area's results sets.
    $('.admin-resultset tr:nth-child(odd)').addClass('highlighted');

    // Modal dialogs to confirm deletions.
    $("#admin-deletion-dialog").dialog({
      autoOpen: false,
      modal: true
    });

    // Bind this routine on the click event of the delete buttons.
    $('.admin-delete-button').click(function(event) {
      event.preventDefault();

      $('#admin-deletion-dialog').dialog({
        buttons : {
          'Confirm' : function() {
            $(event.target).parent().submit();
            $(this).dialog("close");
          },
          'Cancel' : function() {
            $(this).dialog("close");
          }
        }
      })
      .dialog('open');
    });

});

function rotateLogo()
{
    $('#logo > a > img').fadeOut(1000, function(){
        if($(this).attr('src')=='/images/logo1.png')
            $(this).attr('src', '/images/logo2.png');
        else
            $(this).attr('src', '/images/logo1.png');

        $(this).fadeIn(1000, function(){
            setTimeout("rotateLogo()", 3500);
        });
    });
}
