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 MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function validaEmail(objFrm) {
	if (objFrm.email.value == "") {
		alert("Por favor preencha o email para enviar o roteiro.");
		return false;
	}
	else return true;
}

function validaContato(objForm){
	if (objForm.nome.value == "") {
		alert('Por favor preencha o campo nome.');
		objForm.nome.focus();
		return false;
	}
	if (objForm.comentario.value == "") {
		alert('Por favor preencha o campo comentário.');
		objForm.comentario.focus();
		return false;
	}
	return true;
}

/*
function validaCadastroRalacao(objForm){
	if (objForm.nome.value == "") {
		alert('Por favor preencha o campo nome.');
		objForm.nome.focus();
		return false;
	}
	if (objForm.crm_cro.value == "") {
		alert('Por favor preencha o campo CRM/CRO.');
		objForm.crm_cro.focus();
		return false;
	}
	if (objForm.profissao.value == "") {
		alert('Por favor preencha o campo Profissão.');
		objForm.profissao.focus();
		return false;
	}
	if (objForm.especialidade_principal.value == "") {
		alert('Por favor preencha o campo Especialidade principal.');
		objForm.especialidade_principal.focus();
		return false;
	}
	if (!objForm.sexo[0].checked && !objForm.sexo[1].checked) {
		alert('Por favor preencha o campo Sexo.');
		return false;
	}
	if (objForm.email.value == "") {
		alert('Por favor preencha o email.');
		objForm.email.focus();
		return false;
	}
	if (objForm.senha.value == "") {
		alert('Por favor preencha a senha.');
		objForm.senha.focus();
		return false;
	}
	if (objForm.repita_senha.value == "") {
		alert('Por favor preencha a senha novamente.');
		objForm.repita_senha.focus();
		return false;
	}
	if (objForm.repita_senha.value != objForm.senha.value) {
		alert('A senha deve ser igual nos dois campos: senha e repita a senha.');
		objForm.repita_senha.focus();
		return false;
	}
	return true;
}
*/

function mudafonte(tipo) {
	objTexto = document.getElementById("texto");
	if (tipo == 0 && objTexto.style.fontSize == "10px")
		objTexto.style.fontSize = "9px";
	else if (tipo == 0 && objTexto.style.fontSize == "11px")
		objTexto.style.fontSize = "10px";
	else if (tipo == 0 && objTexto.style.fontSize == "12px")
		objTexto.style.fontSize = "11px";
	else if (tipo == 0 && objTexto.style.fontSize == "13px")
		objTexto.style.fontSize = "12px";
	else if (tipo == 0 && objTexto.style.fontSize == "14px")
		objTexto.style.fontSize = "13px";
	else if (tipo == 0 && objTexto.style.fontSize == "15px")
		objTexto.style.fontSize = "14px";

	if (tipo == 1 && objTexto.style.fontSize == "9px")
		objTexto.style.fontSize = "10px";
	else if (tipo == 1 && objTexto.style.fontSize == "10px")
		objTexto.style.fontSize = "11px";
	else if (tipo == 1 && objTexto.style.fontSize == "11px")
		objTexto.style.fontSize = "12px";
	else if (tipo == 1 && objTexto.style.fontSize == "12px")
		objTexto.style.fontSize = "13px";
	else if (tipo == 1 && objTexto.style.fontSize == "13px")
		objTexto.style.fontSize = "14px";
	else if (tipo == 1 && objTexto.style.fontSize == "14px")
		objTexto.style.fontSize = "15px";
}

function abreRegulamento(id){
	var width = 600;
	var height = 450;
	var x = parseInt((screen.width-width)/2);
	var y = parseInt((screen.height-height)/2);
	window.open( 'promocoes_regulamento.php?id='+id, 'pop', 'scrollbars=1,statusbar=1,menubar=0,resizable=1,width='+width+',height='+height+',left='+x+',top='+y+'' ); 

}

var cssmenuids=["topmenu1"] //Enter id(s) of CSS Horizontal UL menus, separated by commas
var csssubmenuoffset=-9 //Offset of submenus from main menu. Default is 0 pixels.
function createTopMenu(){
for (var i=0; i<cssmenuids.length; i++){
  var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px"
    	var spanref=document.createElement("span")
			spanref.className="arrowdiv"
			spanref.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;"
			ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
    	ultags[t].parentNode.onmouseover=function(){
					this.style.zIndex=100
    	this.getElementsByTagName("ul")[0].style.visibility="visible"
					this.getElementsByTagName("ul")[0].style.zIndex=0
    	}
    	ultags[t].parentNode.onmouseout=function(){
					this.style.zIndex=0
					this.getElementsByTagName("ul")[0].style.visibility="hidden"
					this.getElementsByTagName("ul")[0].style.zIndex=100
    	}
    }
  }
}

function openPop(URL, popName, popFeatures) {
	window.open(URL, popName, popFeatures);
}

function impre_pes() {
		if (document.forms['enquete'].qual.value == ""){
			alert("Escolha uma opção");
			return false;
		}else{
				return true;
		}
}

function passarValor(parm1) { 
	document.forms['enquete'].qual.value = parm1; 
} 

function mostraVotacao(){
	document.getElementById("votacao").style.display='block';
	document.getElementById("resultado").style.display='none';
}

function mostraResultado(){
	document.getElementById("votacao").style.display='none';
	document.getElementById("resultado").style.display='block';
}

function dadosPessoais()
{
	document.getElementById("pessoal").style.display='block';
	document.getElementById("responsavel").style.display='none';
}

function dadosResponsavel()
{
	document.getElementById("responsavel").style.display='block';
	document.getElementById("pessoal").style.display='none';
}

function votar(){
	if(impre_pes()){
				var oHTTPRequest = createXMLHTTP(); 
					oHTTPRequest.open("post", "votar.php", true);
					oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					oHTTPRequest.onreadystatechange=function(){
							if (oHTTPRequest.readyState==4){
								//eval("document.cadastro.existeEmail.value="+oHTTPRequest.responseText);
								mostraResultado()
								document.getElementById("verVot").style.display='none';
								}
								
						}
					oHTTPRequest.send("arr=" + document.enquete.id_pergunta.value + "," + document.enquete.qual.value);
				}
}

function swapFaq(objName) {
	document.getElementById(objName).style.display = 'block';
	id = objName.substring(3,6);
	
	for(x=0;x<totalFaq;x++){
		if(id!=x){
			document.getElementById("faq"+x).style.display = 'none';
		}
	}
}

function setPhotoGallery(img, desc) {
	MM_swapImage('imgFoto','',img,1);
	document.getElementById("descFoto").innerHTML = desc;
}

function abreComentarios(areaid,id){
	
	if(navigator.appName=="Microsoft Internet Explorer"){
	altura='675';}
	else{
	altura='705';}
	
	largura = 520;
	esq = parseInt(screen.width/2-(largura/2));
	topo  = parseInt(screen.height/2-(altura/2));
	
	window.open('blog_comentarios.php?areaid='+areaid+'&id='+id,'comentarios','width='+largura+',left='+esq+',top='+topo+',statusbar=no,toolbar=no,height='+altura);
}

function validaComentario(form){

	if (form.comentario.value == "" || form.comentario.value == "Comentário...") {
		alert('Digite seu comentário.');
		form.comentario.focus();
		return false;
	}
	return true;
}

function validaPecamusicaOn(form){
 
	if (form.nome.value == "") {
		alert('Digite o seu nome.');
		form.nome.focus();
		return false;
	}
	
	if (form.email.value == "") {
		alert('Digite o seu email.');
		form.email.focus();
		return false;
	}

	if(!isEmail(form.email.value)){
		alert('Email digitado é inválido.');
		form.email.focus();
		return false;
	}
	
	
	
	if (form.banda.value == "") {
		alert('Digite a banda.');
		form.banda.focus();
		return false;
	}
	if (form.musica.value == "") {
		alert('Digite a música.');
		form.musica.focus();
		return false;
	}

	return true;
}

function indica(form){

	if (form.nomeAmigo.value == "") {
		alert('Digite o nome do seu amigo.');
		form.nomeAmigo.focus();
		return false;
	}
	if (form.emailAmigo.value == "") {
		alert('Digite o email do seu amigo.');
		form.emailAmigo.focus();
		return false;
	}
	return true;
}


function imprimir(areaid,id){
		altura=705;
		largura = 520;
		esq = parseInt(screen.width/2-(largura/2));
		topo  = parseInt(screen.height/2-(altura/2));
		
		window.open('blog_print.php?areaid='+areaid+'&id='+id,'imprimir','width='+largura+',left='+esq+',top='+topo+',statusbar=no,toolbar=no,height='+altura);
}

function indique(areaid,id){
		altura=192;
		largura = 520;
		esq = parseInt(screen.width/2-(largura/2));
		topo  = parseInt(screen.height/2-(altura/2));
		
		window.open('blog_indique.php?areaid='+areaid+'&id='+id,'imprimir','width='+largura+',left='+esq+',top='+topo+',statusbar=no,toolbar=no,height='+altura);
}


function TopMix(url){
		altura=222;
		largura = 352;
		esq = parseInt(screen.width/2-(largura/2));
		topo  = parseInt(screen.height/2-(altura/2));
		
		window.open('playerTop.php?url='+url,'player','width='+largura+',left='+esq+',top='+topo+',statusbar=no,toolbar=no,height='+altura);
}