var xmlhttp1;
var xmlhttp;
var aux_onde;

function popup_foto(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) 
{  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<img src=\"'+imageName+'\" alt=\"'+alt+'\">'); 	
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function move_scroll(y)
{
	scrollTo(0,y);
}	

function abre_pagina(pagina,onde) 
{ 
	var body = ""; 	
	if (window.XMLHttpRequest) 
	{ 
		xmlhttp = new XMLHttpRequest(); 
	} else if (window.ActiveXObject) 
	{ 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	} else 
	{ 
		alert("Seu navegador n&atilde;o suporta XMLHttpRequest."); 
		return; 
	}		
	
	aux_onde = onde;		
	xmlhttp.open("GET", pagina, true); 	
	var aux_x = event.clientX + window.document.body.scrollLeft+15;
	var aux_y = event.clientY + window.document.body.scrollTop;								
	document.getElementById("carrega").innerHTML = '<div id="Layer1" style="position:absolute; left:'+aux_x+'px; top:'+aux_y+'px; width:160px; height:20px; z-index:1; background-color: #FF0000; layer-background-color: #FF0000; border: 1px none #000000; overflow: visible; visibility: visible;"><table width="100%" height="20"  border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="left" valign="middle"><font color="#FFFFFF" size="1"><b>Carregando ||||</b></font></td></tr></table></div>';
	xmlhttp.onreadystatechange = processReqChangepagina; 
	xmlhttp.send(null); 
} 
function processReqChangepagina() 
{ 					
	var cont;
	var cont2;
	var aux;
	var aux2;
	cont = document.getElementById("carrega").innerHTML.indexOf("|");
	aux = document.getElementById("carrega").innerHTML.substr(0,cont+1);
	cont2 = document.getElementById("carrega").innerHTML.length;
	aux2 = document.getElementById("carrega").innerHTML.substr(cont+1,cont2);
	document.getElementById("carrega").innerHTML = aux+'|||'+aux2;
	if (xmlhttp.readyState == 4) 
	{
		if (xmlhttp.status == 200) 
		{				
			move_scroll(0);
			document.getElementById("carrega").innerHTML = '';			
			document.getElementById(aux_onde).innerHTML = unescape(xmlhttp.responseText);
		} else
		{
			alert("Problemas ao carregar o arquivo.");  
			document.getElementById("carrega").innerHTML = '';
		} 
	}	
}

function get_envia() {
  var getstr = "";

  getstr = document.form1.nome.id+'='+document.form1.nome.value+'&'+document.form1.texto.id+'='+document.form1.texto.value+'&'+document.form1.codigo.id+'='+document.form1.codigo.value;
  return getstr;
}
var foto_aux;
var pagina_aux;
function enviar() 
{ 
    var body = ""; 	
	if (window.XMLHttpRequest) 
	{ 
      xmlhttp = new XMLHttpRequest(); 
   	} else if (window.ActiveXObject) 
	{ 
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
   	} else 
	{ 
       alert("Seu navegador n&atilde;o suporta XMLHttpRequest."); 
      return; 
   	}
	var form_string = get_envia(); 
	pag = 'inclui_comentario.php';	
	xmlhttp.open("POST", pag, true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
    xmlhttp.onreadystatechange = processenviar; 
	xmlhttp.send(form_string);
} 

function processenviar()
{ 
     if (xmlhttp.readyState == 1) 
	 { 
	 	document.getElementById("carrega").innerHTML = '<div id="Layer1" style="position:absolute; left:1px; top:750px; width:134px; height:20px; z-index:1; background-color: #FF0000; layer-background-color: #FF0000; border: 1px none #000000; overflow: visible; visibility: visible;">  <table width="100%" height="20"  border="0" align="center" cellpadding="0" cellspacing="0">    <tr>      <td align="center" valign="middle"><font color="#FFFFFF" size="1"><b>Enviando ...</b></font></td>    </tr>  </table></div>';
	 }	
	if (xmlhttp.readyState == 4) 
	{        
	   if (xmlhttp.status == 200) 
	   { 	   				
			if(xmlhttp.responseText == 1)
			{
				alert("Comentário enviado com sucesso. Ele será analisado e liberado breve."); 
		  		document.getElementById("carrega").innerHTML = '';
				document.form1.Botao.disabled = false;
				document.form1.Botao.value = "Enviar";
				esconde('coments');
			}
			else 
			{          		
				alert("Problemas ao enviar comentário. Por favor tente mais tarde."); 
		  		document.getElementById("carrega").innerHTML = '';
				document.form1.Botao.disabled = false;
				document.form1.Botao.value = "Enviar";
     		 } 
      	}
		else 
		{ 
          alert("Problemas ao enviar comentário. Por favor tente mais tarde."); 
		  document.getElementById("carrega").innerHTML = '';
		  document.form1.Botao.disabled = false;
		  document.form1.Botao.value = "Enviar";
      } 
    } 
}

function envia() 
{ 
	if(document.form1.nome.value != "")
	{
		if(document.form1.texto.value != "")
		{	
			document.form1.Botao.disabled = true;
			document.form1.Botao.value = "Enviando...";
			enviar();		
		}else
		{
			alert('O campo Comentário precisa ser preenchido!!');
		}				
	}else
	{
		alert('O campo Nome precisa ser preenchido!!');
	}
}

/*-----------------*/
function get_envia_promo() {
  var getstr = "";

  getstr = document.form1.nome.id+'='+document.form1.nome.value+'&'+document.form1.email.id+'='+document.form1.email.value+'&'+document.form1.codigo.id+'='+document.form1.codigo.value+'&'+document.form1.telefone.id+'='+document.form1.telefone.value+'&'+document.form1.resposta.id+'='+document.form1.resposta.value;
  return getstr;
}
function enviar_promo() 
{ 
    var body = ""; 	
	if (window.XMLHttpRequest) 
	{ 
      xmlhttp = new XMLHttpRequest(); 
   	} else if (window.ActiveXObject) 
	{ 
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
   	} else 
	{ 
       alert("Seu navegador n&atilde;o suporta XMLHttpRequest."); 
      return; 
   	}
	var form_string = get_envia_promo(); 
	pag = 'inclui_inscri_promo.php';	
	xmlhttp.open("POST", pag, true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
    xmlhttp.onreadystatechange = processenviar_promo; 
	xmlhttp.send(form_string);
} 

function processenviar_promo() 
{ 
     if (xmlhttp.readyState == 1) 
	 { 
	 	document.getElementById("carrega").innerHTML = '<div id="Layer1" style="position:absolute; left:1px; top:550px; width:134px; height:20px; z-index:1; background-color: #FF0000; layer-background-color: #FF0000; border: 1px none #000000; overflow: visible; visibility: visible;">  <table width="100%" height="20"  border="0" align="center" cellpadding="0" cellspacing="0">    <tr>      <td align="center" valign="middle"><font color="#FFFFFF" size="1"><b>Enviando ...</b></font></td>    </tr>  </table></div>';
	 }	
	if (xmlhttp.readyState == 4) 
	{        
	   if (xmlhttp.status == 200) 
	   { 	   				
			if(xmlhttp.responseText == 1)
			{
				alert("Sua inscrição nesta promoção foi enviada com sucesso"); 
		  		document.getElementById("carrega").innerHTML = '';
				//document.form1.Botao.disabled = false;
				//document.form1.Botao.value = "Enviar";
				document.form1.reset();
			}else 
			{          		
				if(xmlhttp.responseText == 2)
				{
					alert("Sua inscrição nesta promoção não foi feita!! Esse nome já está inscrito!!"); 
		  			document.getElementById("carrega").innerHTML = '';
					//document.form1.Botao.disabled = false;
					//document.form1.Botao.value = "Enviar";
				}else
				{
					alert("Problemas ao enviar a inscrição. Por favor tente mais tarde."); 
			  		document.getElementById("carrega").innerHTML = '';
					//document.form1.Botao.disabled = false;
					//document.form1.Botao.value = "Enviar";
				}
     		 } 
      	}else 
		{ 
          alert("Problemas ao enviar a inscrição. Por favor tente mais tarde."); 
		  document.getElementById("carrega").innerHTML = '';
		  //document.form1.Botao.disabled = false;
		  //document.form1.Botao.value = "Enviar";
      } 
    } 
}

function valida_email(objeto)
{
         parte1 = objeto.value.indexOf("@");
         parte2 = objeto.value.indexOf(".");
         parte3 = objeto.value.length;
         if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
                   alert ("O campo " + objeto.name + " deve ser um endereço eletrônico!");
                   
                 return false;
         }else
		 {
		 	 return true;
		 }
}

function envia_promo() 
{ 
	if(document.form1.nome.value != "")
	{
		if(document.form1.resposta.value != "")
		{	
			if(document.form1.email.value != "")
			{
				if(valida_email(document.form1.email))
				{
					if(document.form1.telefone.value != "")
					{
						//document.form1.Botao.disabled = true;
						//document.form1.Botao.value = "Enviando...";			
						enviar_promo();		
					}else
					{
						alert('O campo Telefone precisa ser preenchido!!');
					}
				}else
				{
					alert('Coloque um Email válido!!');
				}
			}else
			{
				alert('O campo Email precisa ser preenchido!!');
			}
		}else
		{
			alert('O campo Resposta precisa ser preenchido!!');
		}				
	}else
	{
		alert('O campo Nome precisa ser preenchido!!');
	}
}
/*-----------------*/
function esconde(divi)
{
	if(document.all[divi].style.display == "") 
	{
		document.all[divi].style.display = "none";
	}else 
	{
		document.all[divi].style.display = "";
	}
}
/*------------------*/
function envia_contato() 
{ 
	if(document.form1.nome.value != "")
	{
		if(document.form1.msg.value != "")
		{	
			if(document.form1.email.value != "")
			{
				document.form1.Botao.disabled = true;
				document.form1.Botao.value = "Enviando...";			
				enviar_contato();						
			}else
			{
				alert('O campo Email precisa ser preenchido!!');
			}
		}else
		{
			alert('O campo Mensagem precisa ser preenchido!!');
		}				
	}else
	{
		alert('O campo Nome precisa ser preenchido!!');
	}
}

function get_envia_contato() {
  var getstr = "";

  getstr = document.form1.nome.id+'='+document.form1.nome.value+'&'+document.form1.email.id+'='+document.form1.email.value+'&'+document.form1.msg.id+'='+document.form1.msg.value+'&'+document.form1.para.id+'='+document.form1.para.value;
  return getstr;
}
function enviar_contato() 
{ 
    var body = ""; 	
	if (window.XMLHttpRequest) 
	{ 
      xmlhttp = new XMLHttpRequest(); 
   	} else if (window.ActiveXObject) 
	{ 
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
   	} else 
	{ 
       alert("Seu navegador n&atilde;o suporta XMLHttpRequest."); 
      return; 
   	}
	var form_string = get_envia_contato(); 
	pag = 'envia_contato.php';	
	xmlhttp.open("POST", pag, true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
    xmlhttp.onreadystatechange = processenviar_contato; 
	xmlhttp.send(form_string);
} 

function processenviar_contato() 
{ 
     if (xmlhttp.readyState == 1) 
	 { 
	 	document.getElementById("carrega").innerHTML = '<div id="Layer1" style="position:absolute; left:1px; top:550px; width:134px; height:20px; z-index:1; background-color: #FF0000; layer-background-color: #FF0000; border: 1px none #000000; overflow: visible; visibility: visible;">  <table width="100%" height="20"  border="0" align="center" cellpadding="0" cellspacing="0">    <tr>      <td align="center" valign="middle"><font color="#FFFFFF" size="1"><b>Enviando ...</b></font></td>    </tr>  </table></div>';
	 }	
	if (xmlhttp.readyState == 4) 
	{        
	   if (xmlhttp.status == 200) 
	   { 	   				
			if(xmlhttp.responseText == 1)
			{
				alert("Seu contato foi enviado com sucesso"); 
		  		document.getElementById("carrega").innerHTML = '';
				document.form1.Botao.disabled = false;
				document.form1.Botao.value = "Enviar";
				document.form1.reset();
			}else 
			{          		
				alert("Problemas ao enviar o contato. Por favor tente mais tarde."); 
		  		document.getElementById("carrega").innerHTML = '';
				document.form1.Botao.disabled = false;
				document.form1.Botao.value = "Enviar";				
     		 } 
      	} else 
		{ 
          alert("Problemas ao enviar o contato. Por favor tente mais tarde."); 
		  document.getElementById("carrega").innerHTML = '';
		  document.form1.Botao.disabled = false;
		  document.form1.Botao.value = "Enviar";
      } 
    } 
}
/*-----------------*/
function votar_top10(cod_music) 
{ 
    var body = ""; 	
	if (window.XMLHttpRequest) 
	{ 
      xmlhttp = new XMLHttpRequest(); 
   	} else if (window.ActiveXObject) 
	{ 
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
   	} else 
	{ 
       alert("Seu navegador n&atilde;o suporta XMLHttpRequest."); 
      return; 
   	}
	pag = 'vota_top10.php?cod='+cod_music;	
	xmlhttp.open("GET", pag, true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
    xmlhttp.onreadystatechange = processenviar_voto; 
	xmlhttp.send();
} 

function processenviar_voto() 
{ 
     if (xmlhttp.readyState == 1) 
	 { 
	 	document.getElementById("carrega").innerHTML = '<div id="Layer1" style="position:absolute; left:1px; top:350px; width:134px; height:20px; z-index:1; background-color: #FF0000; layer-background-color: #FF0000; border: 1px none #000000; overflow: visible; visibility: visible;">  <table width="100%" height="20"  border="0" align="center" cellpadding="0" cellspacing="0">    <tr>      <td align="center" valign="middle"><font color="#FFFFFF" size="1"><b>Votando ...</b></font></td>    </tr>  </table></div>';
	 }	
	if (xmlhttp.readyState == 4) 
	{        
	   if (xmlhttp.status == 200) 
	   { 	   				
			if(xmlhttp.responseText == 1)
			{
				alert("Seu voto foi efetuado com sucesso"); 
		  		document.getElementById("carrega").innerHTML = '';				
			}else 
			{          		
				if(xmlhttp.responseText == 2)
				{
					alert("Seu voto não foi efetuado!! Tente mais tarde!!"); 
		  			document.getElementById("carrega").innerHTML = '';					
				}else
				{
					if(xmlhttp.responseText == 3)
					{
						alert("Você já votou!!"); 
			  			document.getElementById("carrega").innerHTML = '';					
					}else
					{
						alert("Problemas para processar o voto. Por favor tente mais tarde."); 
			  			document.getElementById("carrega").innerHTML = '';
					}
				}
     		 } 
      	} else 
		{ 
          alert("Problemas para processar o voto. Por favor tente mais tarde."); 
		  document.getElementById("carrega").innerHTML = '';		 
      } 
    } 
}
var sent;
function mostra(divi,opac)
{	
	if(document.all[divi].style.display == "") 
	{
		sent = '-';
		alpha(divi, 10, 0, 100, 0, '-');
	}else 
	{		
		document.all[divi].style.filter = 'alpha(opacity=0)';
		sent = '+';
		alpha(divi, 10, 0, 0, opac, '+');		 		
		document.all[divi].style.display = "";
	}			
}

function StartAlpha(obje, opacity, fim)
{   
  
	var obj = document.all[obje].style;     
	var resultado = (opacity/100);   
    
	obj.filter = 'alpha(opacity='+resultado * 100+')';  
	if(obj.filter == 'alpha(opacity=1)' && sent == '-')document.all[obje].style.display = "none";		
}  

function alpha(obj, speed, timer, inicio, fim, sentido)
{   
	var speed = speed;   
	var timer = timer;   
	var obj = obj;   
  
	var inicio = inicio   
	var fim = fim   
	var opacity = opacity;   
  
	switch (sentido)
	{   
  
		case '+':   
			for(i=inicio; i < fim ;i++) setTimeout('StartAlpha("'+obj+'", '+i+', '+fim+')', timer ++ * speed)   
			break;   
  
		case '-':   
			for(i=inicio; i > fim ;i--) setTimeout('StartAlpha("'+obj+'", '+i+', '+fim+')', timer ++ * speed)
			break ;    
	}   
}  
function posiciona(obje,x1,y1)
{
	var x = screen.width;
	var y = screen.height;
	x = (x-x1)/2;
	y = (y-y1)/2;
	document.all[obje].style.left = x;
	document.all[obje].style.top = y;
}
var tamanho = 2;
function muda_tamanho_letra(sinal)
{	
	if(sinal == '+' && tamanho < 4)
	{
		tamanho = tamanho+1;
		document.getElementById("texto_not").size = tamanho;
	}
	if(sinal == '-' && tamanho > 1)
	{
		tamanho = tamanho-1;
		document.getElementById("texto_not").size = tamanho;
	}
}

function tamanho_full(nome_div)
{	
	var x = window.document.body.scrollWidth;
	var y = window.document.body.scrollHeight;
	x = x+20;
	y = y+20;	
	document.all[nome_div].style.width = x;
	document.all[nome_div].style.height = y;
}