/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var process = false;

$(document).ready(function(){

    $('.ajax a').click( function(){

        var href = $(this).attr('href');
        var first_explode = href.split('/');
        var second_explode = first_explode[1].split('.');

        var category = first_explode[0];
        var subcategory = second_explode[0];

        $('#ajaxContent div').fadeOut('slow', function(){

           $(this).remove();

           $('#ajaxContent').addClass('loader');

            if ( process == false ){

                $.ajax({
                      url: "ajax.php",
                      data: ({'category' : category, 'subcategory' : subcategory}),
                      dataType: "html",
                      beforeSend: function(){
                          process = true;
                      },
                      success: function( response ){
                         $('#ajaxContent').removeClass( 'loader' ).html( response );
                         $('#ajaxContent div').fadeOut(0, function(){
                             $(this).fadeIn('slow');
                         });
                         process = false;
                      }
                   });

            }

        });

        return false;
    } );

});