/**
 * Catalog js
 *
 * Author - Mark Cullen - 26 Jan 2010
 *
 * Created to control the display of results
 * The function below check the users choice of view 
 * for the results list and displays accordingly. 
 * Note that the users selection is stored in a cooked called result_view
 *
 */


$(document).ready(function() {
	
	if($.cookie('result_view') == 'list')
	{	changeResultView('list');
	} else
	{	changeResultView('grid');
	}
	
	
	
	
});

/**
 * changeResultView
 *
 * Switch all styles necessary to control the style of the result list
 *
 * @Param format	This is either 'grid' or 'list'
 */

function changeResultView(format)
{	
	if(format == 'grid') {	
		$('div#product_results').attr("class", "result_grid");
		$('.rs_details_views_grid').addClass("current");
		$('.rs_details_views_list').removeClass("current");
		$('.rs_note_arrow').css("right","102px");
		$('.rs_note_text').text("Grid View. Click on the List View icon to view the items as a list. We’ll also remember your preference too!");
		$.cookie('result_view', 'grid', {expires: 365});
	} else {	
		$('div#product_results').attr("class", "result_list");
		$('.rs_details_views_list').addClass("current");
		$('.rs_details_views_grid').removeClass("current");
		$('.rs_note_arrow').css("right","28px");
		$('.rs_note_text').text("List View. Click on the Grid View icon to view the items as a grid. We’ll also remember your preference too!");
		$.cookie('result_view', 'list', {expires: 365});
	}
}
