$(document).ready(function(){
	$('div.summer_offer').children('div[class!="header"]').each(function(){
		var div = $(this);
        div.click(function(){
			if(div.children('.sel').css('display') == 'none') {
			  $('div.summer_offer').children('div[class!="header"]').children('.sel').css('display', 'none');
			  $('div[id^="main_vitrina"]').css('display', 'none');
			  $('#main_vitrina_'+div.attr('class')).css('display', 'block');
			  div.children('.sel').css('display', 'block');
			}  
        });
	});
	$('div.main_offer_arrow_next').hover(
			function(){
				$(this).css('background-position', '0px -60px');
			},
			function(){
				$(this).css('background-position', '0px 0px');
			}
		
	);
	$('div.main_offer_arrow_prev').hover(
			function(){
				$(this).css('background-position', '0px -60px');
			},
			function(){
				$(this).css('background-position', '0px 0px');
			}
		
	);
	
	$('div.main_offer_arrow_next').click(
			function(){
				var div = $(this);
				var type = this.id.replace('main_offer_arrow_next_', '');
				var current_page = $($('table[class="spec_items"][page^="'+type+'_"]').get(0)).attr('page').replace(type+'_', '');
				current_page++;
				if($('table[page^="'+type+'_'+current_page+'"]').length > 0) {
					$('table[page^="'+type+'_'+(current_page-1)+'"]').addClass('hidden');
					$('table[page^="'+type+'_'+current_page+'"]').removeClass('hidden');
					if($('table[page^="'+type+'_'+(current_page+1)+'"]').length == 0) $('#main_offer_arrow_next_'+type).css('display', 'none');
					$('#main_offer_arrow_prev_'+type).css('display', 'block');
				}
			}
    );
	
	$('div.main_offer_arrow_prev').click(
			function(){
				var div = $(this);
				var type = this.id.replace('main_offer_arrow_prev_', '');
				var current_page = $($('table[class="spec_items"][page^="'+type+'_"]').get(0)).attr('page').replace(type+'_', '');
				current_page--;
				if($('table[page^="'+type+'_'+current_page+'"]').length > 0) {
					$('table[page^="'+type+'_'+(current_page+1)+'"]').addClass('hidden');
					$('table[page^="'+type+'_'+current_page+'"]').removeClass('hidden');
					if($('table[page^="'+type+'_'+(current_page-1)+'"]').length == 0) $('#main_offer_arrow_prev_'+type).css('display', 'none');
					$('#main_offer_arrow_next_'+type).css('display', 'block');
				}
			}
    );
	
});
