$(function(){ 
$('ul.submenu').hide()
})
/* Le o cookie e aplica */
$(document).ready(function() {								 
	var bgStatus = $.cookie('bgStatus');
	var imagemactual = $.cookie('imagemactual');
	if (bgStatus != '' && bgStatus != 'imagem') {
    $('body').css("background-color",bgStatus);
  };
	if (bgStatus == 'imagem') {
    $('body').css("background-image","url(up/"+imagemactual+")");
		$('body').css("background-position","center top");
  };
});

/* cores fundo */
$(document).ready(function() {					
	$("div.cor a").click(
	 function()
	 {	
		ref = $(this);
		var num = ref.attr("id");
		var urlimg = ref.attr("class");
		if (num != 'imagem') {
			$('body').css("background-image","none");
			$('body').css("background-color",num);
			$.cookie('bgStatus', num);
		}else{
			$('body').css("background-image","url(up/"+urlimg+")");
			$('body').css("background-position","center top");
			$.cookie('bgStatus', num);
		}
	 }
	);
});


/* MENU */
$(document).ready(function(){
	$('a.mainlink').hover(function(){
		var ref = $(this);
		var choosed = ref.attr("id");
		var cor = ref.attr("rel");
		$('a#'+choosed).css('background-color',cor);
		$('a#'+choosed).css('color','white');
		$('ul.submenu').hide();		 
		$('ul#sub'+choosed).show();
		
		$('ul#sub'+choosed).hover(function(){
			$('a#'+choosed).css('background-color',cor);
			$('a#'+choosed).css('color','white');
			$('ul.submenu').hide();		 
			$('ul#sub'+choosed).show();											 
		},function(){
			$('a.mainlink').css('background-color','#969696');
			$('a.mainlink').css('color','#FFF');
			$('ul.submenu').hide();
		});
		
	},function(){
		$('a.mainlink').css('background-color','#969696');
		$('a.mainlink').css('color','#FFF');
		$('ul.submenu').hide();
	});
});





/* imagens */
$(document).ready(function() {
	$("div#right div a").fancybox({
		'hideOnContentClick': true,
		'overlayShow': true,
		'overlayOpacity': 0.8
	});
});

$(document).ready(function() {
	$("div.imgarea a").fancybox({
		'hideOnContentClick': true,
		'overlayShow': true,
		'overlayOpacity': 0.8
	});
});

$(document).ready(function() {
	$("div#imagensFundo div a").fancybox({
		'hideOnContentClick': true,
		'overlayShow': true,
		'overlayOpacity': 0.8
	});
});




/* DESTAQUES HOME */
$(document).ready(function() {
  $('.produtosDestacados').hide();
	$('.first').show();
});

$(document).ready(function(){
	$('div.imghomecontrol a').click(function(){
		ref = $(this);
		var num = ref.attr("id");
		$('.produtosDestacados').hide();
		$('#produto'+num).fadeIn();	
	});
	
});



/* PRODUTOS DETAIL */
$(document).ready(function(){
	$('div.detalhe').hide();
	$('div.first').show();
	$('a.first').css('background-color','#E1E1E1');
});

$(document).ready(function(){
	$('div#articlelist a').click(function(){
		ref = $(this);
		var num = ref.attr("id");
		$('div.detalhe').hide();
		$('a.lista').css('background-color','#A1A3A1');
		$('a#'+num).css('background-color','#E1E1E1');
		$('#detalhe'+num).fadeIn();	
	});
	
});


//INOVAÇÃO ALTURAS

function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}



$(document).ready(function() {
    equalHeight($(".inovacaoAreas"));
});


//mouseover menu inovacoes
$(document).ready(function(){
	$('div.selected').css('background-color','#E1E1E1');
	$('div.artigos a').hover(function(){
		ref = $(this);
		var num = ref.attr("id");
		$('div.artigos').css('background-color','#FFFFFF');
		$('div#artigos'+num).css('background-color','#E1E1E1');
	},function(){
		$('div.artigos').css('background-color','#FFFFFF');
	});
	
});


//IMAGENS PORTFOLIO
$(document).ready(function(){
	$('div#imgsPortfolio div.imagemActiva').hide();
	$('div#imgsPortfolio div.first').show();
});

$(document).ready(function(){
	$('div#imgsPortfolio a').click(function(){
		ref = $(this);
		var num = ref.attr("id");
		$('div#imgsPortfolio div.imagemActiva').hide();
		$('div#imgsPortfolio div#imagePortfolio'+num).fadeIn();
	});
	
});