/* ************************************************************************** **
// JavaScript
// Funções úteis...
// Marco Pinheiro 2009
/* ************************************************************************** **
*/

function animHome()
{
					
		$("#lang span.pt").click(function () {
			//$("#lang").slideUp(800);
			setTimeout('window.location="?changeLang=pt"', 100)
		});
		
		$("#lang span.es").click(function () {
			//$("#lang").slideUp("slow");
			setTimeout('window.location="?changeLang=es"', 100)
		});
		
		$("#lang span.en").click(function () {
			//$("#lang").slideUp("slow");
			setTimeout('window.location="?changeLang=en"', 100)
		});
		
		
		$("#triger").click(function () {
		  if ($("#lang").is(":hidden")) {
			$("#lang").slideDown(800);
		  } else {
			  
			$("#lang").slideUp(800);
			
		  }
		});


			$('#header_message_home').css('visibility', 'visible');
			$('#projectslink').css('visibility', 'visible');
			$('#display').css('visibility', 'visible');
			$('#content').css('visibility', 'visible');
			
			$('#header_message_home').stop().css('opacity', 0);
			$('#projectslink').stop().css('opacity', 0);
			$('#display').stop().css('opacity', 0);
			$('#content').stop().css('opacity', 0);
			
		 	$('#header_message_home').stop().animate({opacity: 1},500,function() 
			{
				$('#display').stop().animate({opacity: 1},300,function()
				{
					$('#projectslink').stop().animate({opacity: 1},300,function()
					{
						$('#content').stop().animate({opacity: 1},300);
					})
			})
	})
}
	
	
function animOthers()
{


	$("#lang span.pt").click(function () {
		//$("#lang").slideUp(800);
		setTimeout('window.location="?changeLang=pt"', 100)
	});
	
	$("#lang span.es").click(function () {
		//$("#lang").slideUp("slow");
		setTimeout('window.location="?changeLang=es"', 100)
	});
	
	$("#lang span.en").click(function () {
		//$("#lang").slideUp("slow");
		setTimeout('window.location="?changeLang=en"', 100)
	});
	
	
	$("#triger").click(function () {
	  if ($("#lang").is(":hidden")) {
		$("#lang").slideDown(800);
	  } else {
		  
		$("#lang").slideUp(800);
		
	  }
	});


	$('#header_message').css('visibility', 'visible');
	$('#content').css('visibility', 'visible');

	$('#header_message').stop().css('opacity', 0);
	$('#content').stop().css('opacity', 0);
	
	$('#header_message').stop().animate({opacity: 1},500,function() 
	{
		$('#content').stop().animate({opacity: 1},700); 
	}
	);
}
	
	
	
	function init_prettyPhoto() {
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'slow', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.35, /* Value betwee 0 and 1 */
			showTitle: true, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
			callback: function(){}
		});
	}
	
	
	
function abreJanela(destino, w, h)
 {
	 
	 
	 var destino, w, h;
	

	if(screen.width)
	{
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	}
	else
	{
		winl = 0;wint =0;
	}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;

	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl;
	settings += 'resizable=0,toolbar=0,directories=0,status=0,location=no,scrollbars=no';
	
	win = window.open(destino,'admin',settings);
	//alert (destino);
	win.window.focus();
	
	 
 }


	function getInternetExplorerVersion()
			// Returns the version of Internet Explorer or a -1
			// (indicating the use of another browser).
			{
			  var rv = -1; // Return value assumes failure.
			  if (navigator.appName == 'Microsoft Internet Explorer')
			  {
				var ua = navigator.userAgent;
				var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
				if (re.exec(ua) != null)
				  rv = parseFloat( RegExp.$1 );
			  }
			  return rv;
			}
			function checkVersion()
			{
			  var msg = "You're not using Internet Explorer.";
			  var ver = getInternetExplorerVersion();
			
			  if ( ver > -1 )
			  {
				if ( ver >= 8.0 ) 
				  msg = "You're using a recent copy of Internet Explorer."
				else
				  msg = "You should upgrade your copy of Internet Explorer.";
			  }
			  alert( msg );
			}


function validateContact()
{
	var nome = document.getElementById('Name').value;
	var email = document.getElementById('Email').value;
	var mensagem = document.getElementById('Message').value;
	if (nome==""||email==""||mensagem=="") 
	
	{
		alert("Deverá preencher correctamente todos os campos disponíveis!");
	} 
	else 
	{
		if ( ((email.indexOf("@") < 1) || (email.indexOf('.') < 7)) )
		{
			alert('Email incorreto');
			document.getElementById('Email').focus();
		}else
		{
			if (confirm('Confirma que deseja mesmo fazer este contacto?')) 
			{
				document.contacto.submit();
			}
		}
	}	
}
