var PageGetProducts = (new function(){
    this.index = function(category_url,gender,subcategory,size,color,heel,brand,page,sort){
        $.post('/get-products.html', {category_url: category_url,gender:gender,subcategory:subcategory,size:size,color:color,heel:heel,brand:brand,page:page,sort:sort}, function(data){
            $('#products-container').html(data);
            $('.showLoader').removeClass('show').addClass('hide');
        },'text');
    }
    this.search = function(){
         $('input[name="search"]').live('change', function(){             
             $(this).parent().submit();             
         });
    }
    this.searchFilter = function(search,gender,subcategory,size,color,heel,brand,page,sort){        
        $.post('/get-products-search-filter.html', {search:search,gender:gender,subcategory:subcategory,size:size,color:color,heel:heel,brand:brand,page:page,sort:sort}, function(data){            
            $('#products-container').html(data);            
            $('.showLoader').removeClass('show').addClass('hide');
        },'text');
    }
    this.change = function(){
        var current = $('.image-gallery :first-child').attr('class');
        var next = current*1 + 1;
        if ($(".sections > ."+ next).length){
            next = next;
        } else {
            next = $('.sections :first-child').attr('class');
        }
        if ($('.sections > .'+next).length){
            $('.image-gallery').prepend($('.sections .' + next).attr('style','opacity:0.9'));
            $('.image-gallery .'+ current).fadeOut(3000,function(){
                $('.sections').append($('.image-gallery .'+current));
                $('.image-gallery .'+ current).remove();
            });
            $('.sections .'+next).remove();
        }
        Cufon.refresh();
    };
});

