//escreve o flash na div desejada para que nao precise clicar nele antes de usa-lo
function montaFlash(destino, flavez, width, height, trans, scale){

	var myFlash =
	'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="'+flavez+'" align="middle">'+
	'<param name="allowScriptAccess" value="sameDomain" />'+
	'<param name="movie" value="swf/'+flavez+'.swf" />'
	;
	if (trans == "yes"){
		myFlash += '<param name="wmode" value="transparent" />';
	}
	if (scale == "yes"){
		myFlash += '<param name="scale" value="noscale" />';
	}
	myFlash +=
	'<param name="quality" value="high" />'+
	'<param name="bgcolor" value="#ffffff" />'+
	'<embed src="swf/'+flavez+'.swf" wmode="transparent" quality="high" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="empresas" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'+
	'</object>'
	;
	document.getElementById(destino).innerHTML = myFlash;
}


// SOLUÇÃO PARA O SCRIPT DO JQUERY QUE ENTRA EM CONFLITO COM O SCRIPT DO PROTOTYPE.
// FOI SUBSTTITUIDO O $ PARA %foo PARA SOLUCIONAR O PROBLEMA DO CONFLITO ENTRE OS SCRIPTS.
var $foo = jQuery.noConflict();

var inHome = true;


function verificaHome(){
	var urlAtual = window.location.href;
	var tamanho = urlAtual.split("#").length;
	if(tamanho==1)
	carregapagina("home");
}

//carrega a pagina solicitada
function carregapagina(pagina){
	if(inHome == true){
		show_loading();
		setTimeout("pausa('"+pagina+"')",1000);
		inHome = false;

	}else{
		if(pagina == "home"){
			$foo("#internas").slideUp("normal");
			inHome = true;
		}else{
			$foo("#internas").slideDown("normal");
			show_loading();
			setTimeout("pausa('"+pagina+"')",1000);
		}
	}
}
function pausa (pagina) {
	$foo('#internas').load("ctrlImplementa.php?acao="+pagina, function() {
		hide_loading();
	})
}

//mostra a mensagem de carregando
show_loading = function() {
	$foo("#ajax_loader").show();
	$foo("#internas").slideUp("normal");
}

//oculta a mensagem de carregando
hide_loading = function() {

	$foo("#ajax_loader").hide();
	$foo("#internas").slideDown("normal");
	document.title="{{ BUFETE OLIVER }}";

	//inicializa novamente o lightbox para paginas carregadas internamente via ajax
	setTimeout(""+Lightbox.prototype.updateImageList()+"", 1000);
}

//verifica se o email informada eh valido
function validaEmail(email){
	ER = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,64}(\.[a-z0-9-]{2,64})*\.[a-z]{2,4}$");
	if (ER.test(email)){
		return true;
	}
	else{
		return false;
	}
}

//valida o formulario de contato e submita ele
function validaFrmContato(form){
	document.getElementById("resposta").style.display = "block";
	if(form.txtNome.value==""){
		form.txtNome.focus();
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo NOME!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}
	if(form.txtEmail.value==""){
		form.txtEmail.focus();
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo EMAIL!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}else{
		if(!validaEmail(form.txtEmail.value)){
			form.txtEmail.focus();
			document.getElementById("resposta").innerHTML = "Por favor, informe um EMAIL V&Aacute;LIDO!";
			setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
			return false;
		}
	}
	if(form.txtDDD.value==""){
		form.txtDDD.focus();
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DDD!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}
	if(form.txtFone.value==""){
		form.txtFone.focus();
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo FONE!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}
	/*if(form.txtDDDF.value==""){
	form.txtDDDF.focus();
	document.getElementById("resposta").innerHTML = "Por favor, preencha o campo DDD do FAX!";
	setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
	return false;
	}
	if(form.txtFax.value==""){
	form.txtFax.focus();
	document.getElementById("resposta").innerHTML = "Por favor, preencha o campo FAX!";
	setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
	return false;
	}
	if(form.txtCidade.value==""){
	form.txtCidade.focus();
	document.getElementById("resposta").innerHTML = "Por favor, preencha o campo CIDADE!";
	setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
	return false;
	}
	if(form.txtEstado.value==""){
	form.txtEstado.focus();
	document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ESTADO!";
	setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
	return false;
	}*/
	if(form.txtSite.value==""){
		form.txtSite.focus();
		document.getElementById("resposta").innerHTML = "Por favor, n&oacute;s diga o que voc&ecirc; achou do site!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}
	if(form.txtChegou.value==""){
		form.txtChegou.focus();
		document.getElementById("resposta").innerHTML = "Por favor, n&oacute;s diga como voc&ecirc; chegou ao site!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}
	if(form.txtAssunto.value==""){
		form.txtAssunto.focus();
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo ASSUNTO!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}
	if(form.txtMensagem.value==""){
		form.txtMensagem.focus();
		document.getElementById("resposta").innerHTML = "Por favor, preencha o campo MENSAGEM!";
		setTimeout("document.getElementById(\"resposta\").style.display = \"none\"",3000);
		return false;
	}
	//$foo("#resposta").load('ctrlImplementa.php?'+$foo("#frmContato").formSerialize());
}


function mudaLamDest(){
	var qtdeLamDest  = document.getElementById("qtdeLamDest");
	var lamDestAtual = document.getElementById("lamDestAtual");
	var newLam;

	//avancando as laminas
	newLam = parseInt(lamDestAtual.value)+1;

	lamDestAtual.value = newLam;

	//mudando a lâmina a ser mostrada
	for(i=0;i<qtdeLamDest.value;i++){
		//mostra a lâmina atual
		if(i==newLam){
			//document.getElementById("lamDest"+i).style.display = "block";
			$foo("#lamDest"+i).fadeIn("slow");
		}
		//oculta as outras lâminas
		else{
			//document.getElementById("lamDest"+i).style.display = "none";
			$foo("#lamDest"+i).hide();
		}
	}

	//se for a ultima
	if(newLam==(qtdeLamDest.value-1)){
		lamDestAtual.value = -1;
	}
}
var intervalo;
function dispara(){
	intervalo = setInterval("mudaLamDest()", 7000);
}


function CarregarPagina(pagina,destino){
	$foo("#"+destino).load("ctrlImplementa.php?acao="+pagina);
}


