$(function() {

	$(".slidetabs").tabs(".images > div", {
		effect: 'fade', // http://flowplayer.org/tools/tabs/index.html#effects
		fadeOutSpeed: 'slow',
		rotate: true

	}).slideshow(
		{	
			autoplay: true,
			interval: '15000'
		}
	);
	
	$(".box-endereco").tooltip(
		{ 
			position: 'bottom center',
			effect: 'slide'
		}
	);

	if ($("#telefone").length)
	{
		$("#telefone").mask("(99) - 9999-9999");
	}

	$("#frmContato").submit(
		function () {
			var retorno = true;
			var regEmail = /^[a-zA-Z0-9_\-\.\+\&]+@[a-zA-Z0-9\-]+(\.[a-zA-Z]{2,4})+$/;
			$("#frmContato input, textarea").each(
				function() {
					if ( $(this).val() == '' )
					{
						var campo = $(this).attr('name');
						alert("Preencha o campo " + campo + " corretamente");
						retorno = false;
						return false;
					}
					else if( $(this).attr('name') == 'email' )
					{
						if (!regEmail.test($(this).val()))
						{
							alert("Email inválido");
							retorno = false;
							return false;
						}
					}
				}
			);

			return retorno;
		}
	);
});

function showHide(theId){
	var theArray= new Array('um', 'dois', 'tres', 'quatro', 'cinco');
	w=document.getElementById(theId)
	if(w.style.display=="block") { w.style.display='none'; }
	else{ 
		for(i=0; i<theArray.length; i++){
			if(theArray[i] == theId) {
				w.style.display='block';
			}else{
				document.getElementById(theArray[i]).style.display='none';
			}
		}
	}
}
