$(document).ready(function(){
	//Select all anchor tag with rel set to tooltip

jQuery(function($) {
	
	
	menusel="";
	$("#dados").hide();
	$("#acarregar").hide();
	$("#loadingpanel").hide();
	acarregar = "A Carregar";
 	if(menusel=="") {
				menusel="inicio";
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				
				$('#acarregar').show();								
				$.post("dados.php", { menu: menusel },
				function(data) {
				
				$('#acarregar').stop(true, true).fadeOut('slow');
				$("#dados").stop(true, true).fadeOut('slow');	
				$("#dados").html(data);
				$("#dados").stop(true, true).fadeIn('slow');
			  	});
	}
// Menus Hovers Imgs
/*
		$(".button").hover(function() {
			nlink=($(this).attr("src"));		
			var pos = nlink.lastIndexOf('.');
					if(pos>0){
					hoverImg = nlink.substr(0,pos)+"h"+nlink.substr(pos);
					}else{
					hoverImg = nlink+"h";
					}
			
			$(this).attr("src",hoverImg);
			}, function() {
			$(this).attr("src",nlink);
			
		});
		*/
		$('.button').imghover({
		suffix: 'h',
		fade: 'true',
		fadeSpeed: 500
		});

});
///////////////////////////////////////
// Menus
/*
				$("#mempresa").click(function() {
				$('#dados').stop(true, true).fadeOut('slow');
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				$('#acarregar').show();




				$('#dados').load("empresa.php");
				$('#dados').stop(true, true).fadeIn('slow');				
				$('#acarregar').stop(true, true).fadeOut('fast');
				})
				
	*/			$("#toplogo").click(function() {
				menusel="inicio";
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				
				$('#acarregar').show();								
				$.post("dados.php", { menu: menusel },
				function(data) {
				
				$('#acarregar').stop(true, true).fadeOut('slow');
				$("#dados").stop(true, true).fadeOut('slow');	
				$("#dados").html(data);
				$("#dados").stop(true, true).fadeIn('slow');
			  	});				
		
				})
				
				$("#mempresa").click(function() {
				menusel="empresa";
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				
				$('#acarregar').show();								
				$.post("dados.php", { menu: menusel },
				function(data) {
				
				$('#acarregar').stop(true, true).fadeOut('slow');
				$("#dados").stop(true, true).fadeOut('slow');	
				$("#dados").html(data);
				$("#dados").stop(true, true).fadeIn('slow');
			  	});
				})			
				
				
				$("#mprodutos").click(function() {
				menusel="produtos";
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				$('#acarregar').show();
								
				$.post("dados.php", { menu: menusel },
				function(data) {
				
				$('#acarregar').stop(true, true).fadeOut('slow');
				$("#dados").stop(true, true).fadeOut('slow');	
				$("#dados").html(data);
				$("#dados").stop(true, true).fadeIn('slow');
			  	});
				})
				
				$("#mclientes").click(function() {
				menusel="clientes";
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				$('#acarregar').show();
								
				$.post("dados.php", { menu: menusel },
				function(data) {
				
				$('#acarregar').stop(true, true).fadeOut('slow');
				$("#dados").stop(true, true).fadeOut('slow');	
				$("#dados").html(data);
				$("#dados").stop(true, true).fadeIn('slow');
			  	});
				})
				
				
				$("#mportfolio").click(function() {
				menusel="portfolio";
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				$('#acarregar').show();			
				$.post("dados.php", { menu: menusel },
				function(data) {
				
				$('#acarregar').stop(true, true).fadeOut('slow');
				$("#dados").stop(true, true).fadeOut('slow');	
				$("#dados").html(data);
				$("#dados").stop(true, true).fadeIn('slow');
			  	}); 

				})
				

				$("#mcontactos").click(function() {
				menusel="contactos";
				$('#acarregar').html('<img src="images/loading.png" width="25" height="25" /><p>'+acarregar);
				$('#acarregar').show();
								
				$.post("dados.php", { menu: menusel },
				function(data) {
				
				$('#acarregar').stop(true, true).fadeOut('slow');
				$("#dados").stop(true, true).fadeOut('slow');	
				$("#dados").html(data);
				$("#dados").stop(true, true).fadeIn('slow');
			  	});
				})
				
/////////////////////////////////////////////////////////



///////////////////////////////////////////
// Banners Rotativos
var timer;
function button1_click(event)
{
$(".slide").css("visibility","hidden");
$("#image1").css("visibility","visible");
$("#image1").css("opacity","0");

$("#image1").animate({"opacity":1},1000, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image1").animate({"opacity":1},1000, "linear", null);
$("#button1").addClass("active");
clearTimeout(timer);
timer = setTimeout(eval("button2_click"),"5000");
$("#image1").animate({"opacity":1},1000, "linear", null);
}

function button2_click(event)
{
$(".slide").css("visibility","hidden");
$("#image2").css("visibility","visible");
$("#image2").css("opacity","0");

$("#image2").animate({"opacity":1},1000, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image2").animate({"opacity":1},1000, "linear", null);
$("#button2").addClass("active");
clearTimeout(timer);
timer = setTimeout(eval("button3_click"),"5000");
$("#image2").animate({"opacity":1},1000, "linear", null);
}

function button3_click(event)
{
$(".slide").css("visibility","hidden");
$("#image3").css("visibility","visible");
$("#image3").css("opacity","0");

$("#image3").animate({"opacity":1},1000, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image3").animate({"opacity":1},1000, "linear", null);
$("#button3").addClass("active");
clearTimeout(timer);
timer = setTimeout(eval("button4_click"),"5000");
$("#image3").animate({"opacity":1},1000, "linear", null);
}

function button4_click(event)
{
$(".slide").css("visibility","hidden");
$("#image4").css("visibility","visible");
$("#image4").css("opacity","0");

$("#image4").animate({"opacity":1},1000, "linear", null);
$("ul.buttons li").removeClass("active");
$("#image4").animate({"opacity":1},1000, "linear", null);
$("#button4").addClass("active");
clearTimeout(timer);
timer = setTimeout(eval("button1_click"),"5000");
$("#image4").animate({"opacity":1},1000, "linear", null);
}

function OnLoad(event)
{
clearTimeout(timer);
timer = setTimeout(eval("button2_click"),"5000");
}

$('#button1').bind('click', button1_click);

$('#button2').bind('click', button2_click);

$('#button3').bind('click', button3_click);

$('#button4').bind('click', button4_click);

OnLoad();



});
///////////////////////////////////////
