function display(view) {
	if (view == 'list') {
	    
		$('.product-grid').attr('class', 'product-list');
		
		$('.product-list li').each(function(index, element) {
		
			// Megnor Start
			html = '';
			
			
			html += '<div class="product-block pro' + $(element).find('#product_idhidden').val() + '" >';
			html += '<input type="hidden" name="product_idhidden" class="product_idhidden" id="product_idhidden" value="'+ $(element).find('#product_idhidden').val() +'"/>';
			html += '<input type="hidden" name="product_carrinho" class="product_carrinho" id="product_carrinho'+$(element).find('#product_idhidden').val()+'" value="'+ $(element).find('#product_carrinho'+$(element).find('#product_idhidden').val()).val() +'"/>';
			html += '<input type="hidden" name="parhidden" class="parhidden" id="parhidden" value="'+ $(element).find('#parhidden').val() +'"/>';
			html += '<input style="width:35px" type="hidden" name="quantity" id="htop'+ $(element).find('#parhidden').val() +'_' + $(element).find('#product_idhidden').val() + '" size="2" value="1" class="numeric" />';
			html += '<div class="product-block-inner" >'
			// Megnor End 

			html += '<div class="left" >';
			
			var image = $(element).find('.image').html();
			
			if (image != null) { 
				html += '<div class="image">' + image + '</div>';
			} 
			
			// Megnor product sale display Start
			var special = $(element).find('.saleblock').html();
			if (special != null) {
				html +=   '<div class="saleblock">' + special + '</div>'  ;
			}
			// Megnor product sale display End
		
		//HUGO ALTEREI PARA LISTAR OS PRODUTO CORRETO {style="margin-top:40px; !important"}
			html += '  <div class="name" style="margin-top:20px; !important">' + $(element).find('.name').html() + '</div>';
			html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
			
						
			html += '</div>'; // End left DIV
			// Megnor Start
			
			
			html += '<div class="right" >';
			
				
			var model = $(element).find('.modelo').html();
			
			if (model != null) {
				html += '<div class="modelo" style="color:#999;margin-top:10px;font-weight:600">' + model  + '</div>';
			}
			
			
			var price = $(element).find('.price').html();	
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
			
			/*html += '<div class="product-block-inner">';
			html += '<div class="base-produto-atacado" style="width:80px; float:left;">';
			html += '<input type="button" id="decrease_' + $(element).find('#product_idhidden').val() + '" value="-"  onclick="javascript:onAction(' + $(element).find('#product_idhidden').val() + ', -1, \''+ $(element).find('#parhidden').val() +'\');">';
			html += '<input class="base-produto-atacado" type="text" name="quantity" value="1" id="htop'+ $(element).find('#parhidden').val() +'_' + $(element).find('#product_idhidden').val() + '">';
			html += '<input type="button" id="increase_' + $(element).find('#product_idhidden').val() + '" value="+" onclick="javascript:onAction(' + $(element).find('#product_idhidden').val() + ', 1, \''+ $(element).find('#parhidden').val() +'\');">';
			html += '<input type="hidden" name="product_id" size="2" value="' + $(element).find('#product_idhidden').val() + '" />';
			html += '</div>';
			html += '<div class="cart" style="margin-top:55px;"><button name="button" onclick="addCarrinho(' + $(element).find('#product_idhidden').val() + ', \''+ $(element).find('#parhidden').val() +'\');"></button></div>';
			html += '</div>';
			html += '</div>';
			html += '</div>';*/
			
			
			html += '<div class="base-produto-atacado" style="width:84px; top:20px;">';
			html += '<div class="content-produto-atacado" style="width:80px; float:left;">';
			html += '<input type="button" id="decrease_' + $(element).find('#product_idhidden').val() + '" value="-"  onclick="javascript:onActionList(' + $(element).find('#product_idhidden').val() + ', -1, \''+ $(element).find('#parhidden').val() +'\');"/>';
			html += '<input type="text" name="quantity" class="input_qtd  numeric" value="1" id="htopList'+ $(element).find('#parhidden').val() +'_' + $(element).find('#product_idhidden').val() + '">';
			html += '<input type="button" id="increase_' + $(element).find('#product_idhidden').val() + '" value="+" onclick="javascript:onActionList(' + $(element).find('#product_idhidden').val() + ', 1, \''+ $(element).find('#parhidden').val() +'\');"/>';
			html += '<input type="hidden" name="product_id" size="2" value="' + $(element).find('#product_idhidden').val() + '" />';
			html += '</div>';
			html += '</br></br>';
			html += '<div class="cart">';
			html += '<button name="button" onclick="addCarrinholist(' + $(element).find('#product_idhidden').val() + ', \''+ $(element).find('#parhidden').val() +'\');"></button>';
			html += '</div>';
			html += '</div>';
			
			/*html += '<div style="width:88px; float:left; margin: 10px 0px 10px 22px;">';
			html += '<input type="button" id="decrease_' + $(element).find('#product_idhidden').val() + '" value="-"  onclick="javascript:onActionList(' + $(element).find('#product_idhidden').val() + ', -1, \''+ $(element).find('#parhidden').val() +'\');" style="width:20px; text-indent:0px;" />';
			html += '<input style="width:35px" type="text" name="quantity" id="htopList'+ $(element).find('#parhidden').val() +'_' + $(element).find('#product_idhidden').val() + '" size="2" value="1" class="numeric" />';
			html += '<input type="button" id="increase_' + $(element).find('#product_idhidden').val() + '" value="+" onclick="javascript:onActionList(' + $(element).find('#product_idhidden').val() + ', 1, \''+ $(element).find('#parhidden').val() +'\');" style="width:20px; text-indent:0px;"/>';
	        html += '<input type="hidden" name="product_id" size="2" value="' + $(element).find('#product_idhidden').val() + '" />';
			html += '</div>';			
		
			html += '<div class="cart"><button name="button" onclick="addCarrinholist(' + $(element).find('#product_idhidden').val() + ', \''+ $(element).find('#parhidden').val() +'\');"></button></div>';
			*/
			
			html += '</div>';	
			html += '</div>';
			html += '</div>';			
			
			// Megnor End
			// Megnor Start
			//$(".product-list").css('width', '100%'); 
			$(".product-list > li").css('width', '100%'); 
			$(".product-list > li").css('height', 'auto'); 
			$('.product-list .product-block').css('height', 'auto');
			$('.product-list .product-block').css('width', 'auto');
			// Megnor End
			
			$(element).html(html);
			
			//matheus - troca a cor da borda caso produto esteja no carrinho...
			if($(element).find('#product_carrinho'+ $(element).find('#product_idhidden').val()).val() ){
			   $('.pro' + $(element).find('#product_idhidden').val()).css('border-color', '#00A550');
            }
		});		
		
		$('.display').html('<span class="List">List</span><span class="Grid"><a onclick="display(\'grid\');">Grid</a></span>');
		
		$.totalStorage('display', 'list'); 
	} else {
	   
		$('.product-list').attr('class', 'product-grid');
		
		$('.product-grid li').each(function(index, element) {
			html = '';
			
			// Megnor Start
			html = '';                                                                                                  /*360px*/
			html += '<div class="product-block pro' + $(element).find('#product_idhidden').val() + '" style="min-height:400px;">';
			html += '<input type="hidden" name="product_idhidden" class="product_idhidden" id="product_idhidden" value="'+ $(element).find('#product_idhidden').val() +'"/>';
			html += '<input type="hidden" name="product_carrinho" class="product_carrinho" id="product_carrinho'+$(element).find('#product_idhidden').val()+'" value="'+ $(element).find('#product_carrinho'+$(element).find('#product_idhidden').val()).val() +'"/>';
			
			html += '<input type="hidden" name="parhidden" class="parhidden" id="parhidden" value="'+ $(element).find('#parhidden').val() +'"/>';

			var image = $(element).find('.image').html();
			
			if (image != null) {
				html += '<div class="image">' + image + '</div>';
			}
			
			// Megnor product sale display Start
			var special = $(element).find('.saleblock').html();
			if (special != null) {
				html +=   '<div class="saleblock">' + special + '</div>'  ;
			}
			// Megnor product sale display End
				
			
			html += '<div class="name">' + $(element).find('.name').html() + '</div>';
			html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			
			
			var model = $(element).find('.modelo').html();
			
			if (model != null) {
				html += '<div class="modelo">' + model  + '</div>';
			}
			
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
			
			
			
			
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
			
			
			html += '<div class="base-produto-atacado" style="width:180px;">';
			html += '<div class="content-produto-atacado" style="width:80px; float:left;">';
			html += '<input type="button" id="decrease_' + $(element).find('#product_idhidden').val() + '" value="-" onclick="javascript:onAction(' + $(element).find('#product_idhidden').val() + ', -1, \''+ $(element).find('#parhidden').val() +'\');">';
			html += '<input type="text" name="quantity" class="input_qtd  numeric" value="1" id="htop'+ $(element).find('#parhidden').val() +'_' + $(element).find('#product_idhidden').val() + '">';
			html += '<input type="button" id="increase_' + $(element).find('#product_idhidden').val() + '" value="+" onclick="javascript:onAction(' + $(element).find('#product_idhidden').val() + ', 1, \''+ $(element).find('#parhidden').val() +'\');">';
			html += '<input type="hidden" name="product_id" size="2" value="' + $(element).find('#product_idhidden').val() + '" />';
			html += '</div>';
			html += '<div class="cart">';
			html += '<button name="button" onclick="addCarrinho(' + $(element).find('#product_idhidden').val() + ', \''+ $(element).find('#parhidden').val() +'\');"></button>';
			html += '</div>';
			html += '</div>';
					
			//html += '<div class="cart"><input type="button" id="btn_desc' + $(element).find('#product_idhidden').val() + '" value="Informações" onclick="javascript:descprod(' + $(element).find('#product_idhidden').val() + ');" class="button" style="margin-top:10px;"/></div>';
			html += '<div id="desc_produto' + $(element).find('#product_idhidden').val() + '" style="display:none;">' + $(element).find('.description').html() + '</div>';


			//html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
		//	html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
		//	html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';

			// Megnor Start
			html += '</div>';
			html += '</div>';
			// Megnor End

			$(element).html(html);
			
			if($(element).find('#product_carrinho'+ $(element).find('#product_idhidden').val()).val()){
			   $('.pro' + $(element).find('#product_idhidden').val()).css('border-color', '#00A550');
			} 
		});	
					
		$('.display').html('<span class="List"><a onclick="display(\'list\');">List</a></span><span class="Grid">Grid</span>');

		// Megnor Start

		$(".product-grid > li").css('width', ''); 
		$(".product-grid > li").css('height', ''); 
		$('.product-grid .product-block').css('height', '');
		$('.product-grid .product-block').css('width', '');
		//matheus - troca a cor da borda caso produto esteja no carrinho...
			
		$('ul.product-grid').smartColumnsRows({
			defWidthClss : 'grid_default_width',
			subElement   : 'li',
			subClass     : 'product-block'
		});
		// Megnor End
		
		$.totalStorage('display', 'grid');
	}
	if($('input.numeric').length > 0) $('input.numeric').numeric();
}

view = $.totalStorage('display');

if (view) {
	display(view);
} else {
	display('grid');
}
// Megnor Start
function productGridAutoSet() { 
	$('ul.product-grid').smartColumnsRows({
		defWidthClss : 'grid_default_width',
		subElement   : 'li',
		subClass     : 'product-block'
	});
}
$(window).load(function(){productGridAutoSet();});
$(window).resize(function(){productGridAutoSet();});
// Megnor End

function hideListView(){
	if ($(window).width() < 768 )
	{	
	 display('grid');
	 $(".display").css('display','none');
	}else{
		$(".display").css('display','block');
	}
}
$(document).ready(function(){hideListView();});
$(window).resize(function(){hideListView();}); 