function listSwitcher() {
var activeClass = 'switcher-active';
var gridClass = 'products-grid';
var listClass = 'products-list';
jQuery('.switchToList').click(function(){
if(!jQuery.cookie('products_page') || jQuery.cookie('products_page') == 'grid'){
switchToList();
}
});
jQuery('.switchToGrid').click(function(){
if(!jQuery.cookie('products_page') || jQuery.cookie('products_page') == 'list'){
switchToGrid();
}
});
function switchToList(){
jQuery('.switchToList').addClass(activeClass);
jQuery('.switchToGrid').removeClass(activeClass);
jQuery('.main-products-loop .products-loop').fadeOut(300,function(){
jQuery(this).removeClass(gridClass).addClass(listClass).fadeIn(300);
jQuery.cookie('products_page', 'list', { expires: 3, path: '/' });
});
}
function switchToGrid(){
jQuery('.switchToGrid').addClass(activeClass);
jQuery('.switchToList').removeClass(activeClass);
jQuery('.main-products-loop .products-loop').fadeOut(300,function(){
jQuery(this).removeClass(listClass).addClass(gridClass).fadeIn(300);
jQuery.cookie('products_page', 'grid', { expires: 3, path: '/' });
});
}
}