//window.open("imagens/banner.swf","topo","width=261,height=400");

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function submenu(num) {
	document.getElementById("submenu_quemsomos").style.display = 'none';
	document.getElementById("submenu_servicos").style.display = 'none';
	document.getElementById("submenu_entreemcontato").style.display = 'none';
	if(num==1) {
		document.getElementById("submenu_quemsomos").style.display = 'block';
	} else if(num==2) {
		document.getElementById("submenu_servicos").style.display = 'block';
	} else if(num==3) {
		document.getElementById("submenu_entreemcontato").style.display = 'block';
	}
}
function volta_submenu(num) {
	timmerID=setTimeout("submenu("+num+")",9000);
}
function ampliar(figura,texto,creditos) {
url = "janfiguras.php?figura="+figura+"&texto="+texto+"&creditos="+creditos
window.open(url ,"imagem","resizable,width=500px,height=450px,scrollbars=no")
}
function vai(endereco) {
	window.document.location.href = endereco;
}
function indique() {
	endereço = escape(window.document.location.href);
	window.open("indique.php?urlpagina="+endereço,"indique","width=380,height=302")
}
function addSWF (URL, WIDTH, HEIGHT, TRANSPARENT) {
	document.write (' <object classid="clsid:27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write (' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');
	document.write (' width="'+ WIDTH +'" height="'+ HEIGHT +'">');
	document.write (' <param name="movie" value="'+ URL +'" />');
	document.write (' <param name="quality" value="high" />');
	if ( TRANSPARENT ) {
		document.write (' <param name="Wmode" value="Transparent" />'); 
	}
	document.write (' <embed src="'+ URL +'" quality="high" ');
	if ( TRANSPARENT ) {
		document.write (' Wmode = "transparent" ');
	}
	document.write (' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
	document.write (' type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
	document.write (' </object>');
}

function centraliza_menu() {
	largura_da_tela = document.body.clientWidth;
	document.all.menu.style.left = parseInt(largura_da_tela / 2)-380;
	if(largura_da_tela<780) {document.all.menu.style.left = "10px";}
	document.all.menu.style.top = "10px";
}


//início validação de formulário

function existe(nome_do_campo,f) {  
	if(f=="") { f = document.formulario; }
	for (i=0; i<f.elements.length; i++) {    //faz um loop por todos os campos do formulário
		if (f.elements.item(i).name == nome_do_campo) {  //verifica se o nome do campo é o solicitado
			return true;
		} 
	}
	return false;
}

function tipoarquivo (campo,f,ext) {
	//campo é o nome do campo. f é o nome do formulário e extensão é a(s) extensões exigidas, separadas por vírgula
	if(f==null) { f = eval(document.formulario); }
	if(existe(campo,f)) {
		obj = eval("document."+f.name+"."+campo);
		valor = obj.value;
		
		if(obj.type == "file") {
			if(obj.title != "") { nome = obj.title; } else { nome = campo; }
			
			//verifica se o nome do arquivo tem menos de 3 caracteres ou é vazio
			if (valor==""||valor.length<3) {
				alert("Você deve escolher um arquivo para enviar no campo "+nome+".");
				obj.style.backgroundColor = "#F9F7E3";
				obj.focus();
				return false;
			}
			//verifica se a extensão do arquivo é uma das que são requisito
			pedacos = valor.split(".");
			extensao_do_arquivo = pedacos[pedacos.length-1]
			extensao_requisito = ext.split(",");
			extensao = false;
			for(i=0;i<extensao_requisito.length;i++) {
				if(extensao_requisito[i] == extensao_do_arquivo) {
					extensao = true;
				}
			}
			if(extensao == false) {
				alert("Não é permitido enviar este tipo de arquivo no campo "+nome+".");
				obj.style.backgroundColor = "#F9F7E3";
				obj.focus();
				return false;
			} else {
				return true;
			}
		}
	}
}
function preenchido(campo,f) {
	if(f==null) { f = eval(document.formulario); }
	if(existe(campo,f)) {
		obj = eval("document."+f.name+"."+campo);
		valor = obj.value;
		if(obj.type == "text" || obj.type == "textarea" || obj.type == "password") {
			if (valor==""||valor=="Escreva sua mensagem"||valor=="Seu nome"||valor=="Seu email"||valor=="Pesquisar") {
				if(obj.title != "") { nome = obj.title; } else { nome = campo; }
				alert("O campo "+nome+" deve ser preenchido.");
				obj.style.backgroundColor = "#F9F7E3";
				obj.focus();
				return false;
			} 
		}
		if(obj.type == "file") {
			if(obj.title != "") { nome = obj.title; } else { nome = campo; }
			if (valor==""||valor.length<3) {
				alert("Você deve escolher um arquivo para enviar no campo "+nome+".");
				obj.style.backgroundColor = "#F9F7E3";
				obj.focus();
				return false;
			}
			alert(obj.value);
		}
		if(obj.length > 0) {
			if(obj[0].type == "radio" || obj[0].type == "checkbox") {
				//faz um loop por todos os filhos do elemento e verifica se está preenchido
				for (i=0; i<obj.length; i++) { if (obj.item(i).checked) { return true; } } 
			}
			if(obj.tagName == "SELECT") {				
				if(obj.options[obj.options.selectedIndex].value!="") { return true; }
			}
			if(obj[0].title != "") { nome = obj[0].title; } else { nome = campo; }
			alert("O campo "+nome+" deve ser preenchido.");
			for (i=0; i<obj.length; i++) { obj[i].style.backgroundColor = "#F9F7E3"; }  			
			obj[0].focus();
			return false;
		} else {
			if(obj.type == "radio" || obj.type == "checkbox") {
				if(obj.title != "") { nome = obj.title; } else { nome = campo; }
				if (obj.checked) { return true; } 
				alert("O campo "+nome+" deve ser preenchido.");
				obj.style.backgroundColor = "#F9F7E3";
				obj.focus();
				return false;
			}
		}
		return true;
	}
}

function validanumero(campo,f) {
	if(f==null) { f = document.formulario; }
	if(existe(campo,f)) {
		obj = eval("document."+f.name+"."+campo);
		valor = obj.value;
		str = "0123456789";	
		result = true;
		for (var i=0;i<valor.length;i++)
			if (str.indexOf(valor.substr(i,1))<0) {
				result = false;
				break;
			}
		if (result==false) {
			alert("Este campo só aceita números!");
			obj.value = "";
			obj.style.backgroundColor = "#F9F7E3";
			obj.focus();
			return false;
		} else {
			return true;
		}
	}
}
function validaemail(campo,f) {
	if(f==null) { f = document.formulario; }
	if(existe(campo,f)) {
		obj = eval("document."+f.name+"."+campo);
		valor = obj.value;
		if ( (valor.length<=5) || (valor.substr(valor.indexOf('@')).indexOf('.') < 3) ) {
			alert("Escreva corretamente seu email.");
			obj.style.backgroundColor = "#F9F7E3";
			obj.focus();
			return false;
		} else {
			return true;
		}
	}
}

// fim validaçao formulário 


function validar(){
	if((preenchido('nome')) &&
	(validaemail('email')) &&
	(preenchido('mensagem'))) {
		document.formulario.submit();
	}
}

function validar_busca(){
	if(preenchido('buscar',document.fm_busca)) {
		endereco = document.fm_busca.action+"&buscar="+document.fm_busca.buscar.value;
		document.location.href=endereco;
	}
}

function validar_indique(){
	if((preenchido('nome')) &&
	(validaemail('email')) &&
	(preenchido('nomeamigo')) &&
	(validaemail('emailamigo'))
	) {
		document.formulario.submit();
	}
}

function limpa_texto (texto,objeto) {
	if(objeto.value==texto){objeto.value='';}
}
function volta_texto (texto,objeto) {
	if(objeto.value==''){objeto.value=texto;}
}
function mostradorflutuante(mostrador,exibe) {
	// define o objeto mostrador
	if (mostrador != "") {
		if (document.layers){mostrador = document.layers[mostrador]; //nn
		} else {
			if (document.all){mostrador = document.all[mostrador]; 
			} else {
				if (document.getElementById){mostrador = document.getElementById(mostrador)}
			}
		}
	}
	if(exibe) {
		mostrador.style.display = "block";
	} else {
		mostrador.style.display = "none";
	}
}
function validar_forum(){
	f=document.formulario;
	email=f.email.value;
	nome=f.nome.value;
	mensagem=f.mensagem.value;
	valido=true;
	if((mensagem == '') || (mensagem == "Escreva sua mensagem")){
		valido=false;
		msg='Você precisa escrever a mensagem!';
		f.mensagem.focus();
	}
	if((email.length<=5) || (email.substr(email.indexOf('@')).indexOf('.') < 2)){
		valido=false;
		msg='Confira o endereço de email!';
		f.email.focus();
	}
	if(nome == '' || (nome == "Seu nome")){
		valido=false;
		msg='Você precisa preencher o nome!';
		f.nome.focus();
	}
	if(valido) {
		f.submit();
	} else { 
		alert(msg);
	}
}


function validar_depoimento(){
	f=document.formulario;
	email=f.email.value;
	nome=f.nome.value;
	mensagem=f.mensagem.value;
	autoriza=f.autoriza.checked;
	valido=true;
	if(autoriza == false){
		valido=false;
		msg='Sem a sua autorização para publicação a mensagem não poderá ser enviada!';
		f.autoriza.focus();
	}
	if((mensagem == '') || (mensagem == "Escreva sua mensagem")){
		valido=false;
		msg='Você precisa escrever a mensagem!';
		f.mensagem.focus();
	}
	if((email.length<=5)|| (email.substr(email.indexOf('@')).indexOf('.') < 2)){
		valido=false;
		msg='Confira o endereço de email!';
		f.email.focus();
	}
	if(nome == '' || (nome == "Seu nome")){
		valido=false;
		msg='Você precisa preencher o nome!';
		f.nome.focus();
	}
	if(valido) {
		f.submit();
	} else { 
		alert(msg);
	}
}
function validar_receba(){
	f=document.formulario;
	email=f.email.value;
	nome=f.nome.value;
	endereco=f.endereco.checked;
	valido=true;
	msg = "";
	if((email.length<=5) || (email.substr(email.indexOf('@')).indexOf('.') < 2)){
		valido=false;
		msg='Confira o endereço de email!';
		f.email.focus();
	}
	if(nome == '' || (nome == "Seu nome")){
		valido=false;
		msg='Você precisa preencher o nome!';
		f.nome.focus();
	}
	if(endereco){
		if(!preenchido(f.rua) || !preenchido(f.numero) || !preenchido(f.bairro) || !preenchido(f.municipio) || !preenchido(f.estado) || !preenchido(f.cep)) {
		valido=false;
		}
	}
	if(valido) {
		f.submit();
	} else { 
		if(msg != "")
		alert(msg);
	}
}
function validar_sua_ideia(){
	f=document.formulario;
	email=f.email.value;
	nome=f.nome.value;
	ideia=f.ideia.value;
	valido=true;
	msg = "";
	if(!preenchido(f.rua) || !preenchido(f.numero) || !preenchido(f.bairro) || !preenchido(f.municipio) || !preenchido(f.estado) || !preenchido(f.cep) || !preenchido(f.telefone)) {
	valido=false;
	} else {
		if(ideia == ''){
			valido=false;
			msg='Você ainda não escreveu sua idéia';
			f.ideia.focus();
		}
	}
	if((email.length<=5) || (email.substr(email.indexOf('@')).indexOf('.') < 2)){
		valido=false;
		msg='Confira o endereço de email!';
		f.email.focus();
	}
	if(nome == '' || (nome == "Seu nome")){
		valido=false;
		msg='Você precisa preencher o nome!';
		f.nome.focus();
	}
	if(valido) {
		f.submit();
	} else { 
		if(msg != "")
		alert(msg);
	}
}
function loja_amplia_foto(cod,largura,altura) {
	window.open("loja_amplia_foto.php?cod="+cod,"loja_amplia_foto","width="+largura+",height="+altura)
}

function pega_obj(nome) {
	if (document.layers) { nome = document.layers[nome]; } //nn
	else { if (document.all) { nome = document.all[nome]; } //ie6
	else { if (document.getElementById) { nome = document.getElementById(nome) } } } //ff
	return nome;
}

function zoom(acao,estilo) {
	var isIE = (/\bmsie\b/i.test(navigator.userAgent) // é Internet Explorer?
							&& document.all && !(/\bopera\b/i.test(navigator.userAgent)));
	// propriedades que mudam de nome do IE para o Mozilla...
	var nome_da_regra = isIE ? 'rules' : 'cssRules';
	var no_dom = isIE ? 'owningElement' : 'ownerNode';
	var stl = document.styleSheets;
	for(var i = 0; i < stl.length; i++) { // para cada elemento de estilo na página
		for(var g = 0; g < stl[i][nome_da_regra].length; g++) { // para cada regra desse elemento
			if(stl[i][nome_da_regra][g].selectorText == estilo) {
				fontSize = parseInt(stl[i][nome_da_regra][g].style.fontSize);
				if(!isNaN( fontSize ) ){
					if(fontSize < 18 && acao == '+') {
						stl[i][nome_da_regra][g].style.fontSize = fontSize+1;
					}
					if(fontSize > 8 && fontSize < 20 && acao == '-') {
						stl[i][nome_da_regra][g].style.fontSize = fontSize-1;
					}
				}
			}
		}
	}
}