// Coddigo Javascript By Andy (^_^)!
var cabecera = '<span  style="padding-right:50px; height:16px"><a href="#cerrar" onclick=" ocultar(); return false"><img border=0 align=right  src="./Imagenes/x-i.gif"></a></span><div style="width:450px; padding:30px">';
function MostraGN() { if($('publicidad').style["display"] != "none"){$('MostGn').src = "./Imagenes/i_26k.jpg";$('publicidad').style["display"] = "none";} else {$('MostGn').src = "./Imagenes/i_26.gif";$('publicidad').style["display"] = "";}}
var cabecera = '<span  style="padding-right:50px; height:16px"><a href="#cerrar" onclick=" ocultar(); return false"><img border=0 align=right  src="./Imagenes/x-i.gif"></a></span><div style="width:450px; padding:30px">';
function limitesPantalla() {	  
    if(typeof( window.innerWidth ) == 'number' ) 
    {return window.innerWidth +"-"+window.innerHeight; 
    }else if(document.documentElement && (document.documentElement.clientWidth||document.documentElement.clientHeight))
    {return document.documentElement.clientWidth+"-"+document.documentElement.clientHeight;
    }else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {return document.body.clientWidth+"-"+document.body.clientHeight;
    }return null;
}
function arreglaraResolucion(capa){
	var resolucion = limitesPantalla().split("-");
	$(capa).style.width = Math.floor(resolucion[0])+"px";
	$(capa).style.height = Math.floor(resolucion[1])+"px";
}


function MuestraCapa(){	
     arreglaraResolucion("Aero");	
    $("Aero").style.display = "block";	
	$("Overlay").style.display = "block";    
	    
}

function ocultar(){
   $("Aero").style.display = "none";
   $("Overlay").style.display = "none";
}
function ReportarError(){
	MuestraCapa();	
	var FoHTML = '<div style="width:500px"><div id="Errors"></div>Email:<br /><input class="CampoLg" id="rep_Email" style="font:normal 12px Arial; width:450px" onclick="this.focus();this.select()"><br>';
	FoHTML += '<br />Tipo de reporte:<br />';
	FoHTML += '<select size="1" style="width:460px" id="rep_Asunto">';
	FoHTML += '<option value="">Seleccione el tipo de reporte</option>';
	FoHTML += '<option value="Derechos de autor">Derechos de autor</option>';
	FoHTML += '<option value="El audio defectuoso o de muy mala calidad">El audio defectuoso o de muy mala calidad</option>';
	FoHTML += '<option value="El audio no reproduce adecuademente">El audio no reproduce adecuademente</option>';
	FoHTML += '<option value="El audio no pertene al interprete o autor">El audio no pertene al interprete o autor</option>';
	FoHTML += '<option value="El audio no pertene al genero">El audio no pertene al género</option>';
	FoHTML += '<option value="Escritura incorrecta del nombre">Escritura incorrecta del nombre</option>';
	FoHTML += '</select><br /><br />';
	FoHTML += 'Mensaje: <br />';
	FoHTML += '<textarea id="rep_Mensaje" class="CampoLg" rows="3" name="S1" cols="20"  style="width:450px" ></textarea>';
	FoHTML += '<br /><br /><div class=Btn_m><div class="iEstBoton CapaBt b">';
	FoHTML += '<input class="Tmn150" type="button" value="Reportar ahora!" onClick="Reportar(); return false;" />';
	FoHTML += '</div> </div></div></div>';
	$("Overlay").innerHTML = cabecera + FoHTML;
	
}
function Reportar()
{
	var falla = peticionXMLHttp();
	falla.open("POST","Procesos/Proc.Falla.php",true);
	falla.onreadystatechange = function(){
		 if(falla.readyState == 4 && falla.status == 200){
			  $("Errors").innerHTML = "";;
			  
		 }else{
			  $("Errors").innerHTML ="<center><br><img height=15 src='./Imagenes/Carg1.gif'></center>";	
		}
	}
	falla.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    falla.send("rep_Email="+valor("rep_Email")+"&rep_Asunto="+valor("rep_Asunto")+"&rep_Mensaje="+valor("rep_Mensaje")+"&nocache="+Math.random()*99999);
}

/*Agregar Album **/
function Agregar(id,num){	
    MuestraCapa();
    var nuevo = peticionXMLHttp();
	nuevo.open("POST","Procesos/Proc.Acciones.php",true);
	nuevo.onreadystatechange = function(){
		if(nuevo.readyState == 4){
			if(nuevo.status == 200){
				$("Overlay").innerHTML = cabecera + nuevo.responseText;
			}
		}else{
			$("Overlay").innerHTML = "<center><br><br><br><br><br><br><img height=15 src='./Imagenes/Carg1.gif'></center>";		
		}
	}
	nuevo.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    nuevo.send("Accion=Agregar&idm="+id+"&nocache="+Math.random()*99999);
}
/**/
var elid = "";
function elValor(rd){
	elid = rd.value;	
}
function Nuevo(idmus)
{ 
     if(elid == ""){
	    alert("Seleccione una Lista o un Album Por Favor");
	}else{
		MuestraPag("inc/Agregar.php?modo=2&idm="+idmus+"&ida="+elid,"Overlay");
		elid = "";
	}
}
/**/

/**Ingreso **/
function Logeo(referente){
	
	var ingreso = peticionXMLHttp();
	ingreso.open("POST","Procesos/Proc.Login.php",true);
	ingreso.onreadystatechange = function(){
		if(ingreso.readyState == 4){
			if(ingreso.status == 200){
				if(ingreso.responseText == "exito"){
				MuestraPag(referente,"Overlay");	
				}else{
					$("Respuesta").innerHTML = ingreso.responseText;
				}
			}
		}else{
			$("Respuesta").innerHTML = "<div style='margin:0 auto;'><center><br><img height='15' src='./Imagenes/Carg1.gif'></center></div>";	
		}
	}
	ingreso.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    ingreso.send("Email="+valor("Email")+"&Clave="+valor("Clave")+"&Recordar="+valor("Recordar")+"&nocache="+Math.random()*99999);	
}
/***/

/***Mostrar Pagina */
function MuestraPag(pagina,capa){
	$("Overlay").innerHTML = "";
	var contexto = peticionXMLHttp();
	contexto.open("GET",pagina,true);
	contexto.onreadystatechange = function(){
		if(contexto.readyState == 4){
			if(contexto.status == 200){
				if(capa == "Overlay"){
					$("Overlay").innerHTML = cabecera + contexto.responseText;
				}else{
					$(capa).innerHTML = contexto.responseText;				
				}
			}
		}else{
			if(capa == "Overlay"){
			  $("Overlay").innerHTML = "<center><br><br><br><br><br><br><img height=15 src='./Imagenes/Carg1.gif'></center>";
			}else{
			  $(capa).innerHTML  = "<center><b><h2>Cargando........</h2></b></center>";
			}
		}
	}
	contexto.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    contexto.send(null);	
}
/**/


/**Dedicar Canciones **/
function Dedicar(){	
	var objeto = peticionXMLHttp();
	objeto.open("POST","Procesos/Proc.Dedicar.php",true);
	objeto.onreadystatechange = function(){
		if(objeto.readyState == 4){
			if(objeto.status == 200){
				$("carga").innerHTML = "";
			    $("ErroooOr").innerHTML  = objeto.responseText;						
			}
		}else{
			$("carga").innerHTML = "<img style='margin-top:7px;' height=15 src=\"./Imagenes/Carg.gif\">";
			 
		}
		
	}
	objeto.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    objeto.send("Tunombre="+valor("Tunombre")+"&Sunombre="+valor("Sunombre")+"&Tucorreo="+valor("Tucorreo")+"&Sucorreo="+valor("Sucorreo")+"&i="+valor("u_u")+"&Msj="+valor("Msj")+"&nocache="+Math.random()*99999);	
}
/****/



/**Pedidos Musicales **/
function  Psug()
{
	var artista = valor("Interprete");
	var tema = valor("Cancion");
	
	if(artista!="" && tema!=""){
	      var pedido = peticionXMLHttp();
    	   pedido.open("POST","Procesos/Proc.Acciones.php",true);
	       pedido.onreadystatechange = function()  {
		      if(pedido.readyState == 4)    {
			    if(pedido.status == 200)  {
					  var sugerencia = pedido.responseText;
					  if(sugerencia!=""){
$('NoCache').innerHTML = '<br><br><div style="padding:4px; border:1px solid #ccc"><b>Posibles int&eacute;rpretes de tu pedido:</b><br /><br />'+sugerencia+"</div>";	  }
				    					
			        }
		      }else{$('NoCache').innerHTML = "";}
          }
	       pedido.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
           pedido.send("Accion=Pedidos&a="+artista+"&t="+tema+"&nocache="+Math.random()*99999);
	}else{
		$('NoCache').innerHTML = "";
	}
}


function Syntaxis_Album(valor){
	var Caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIFKLMNOPQRSTUVWXYZ123456789_-!^ ";
	var Espacion = " ";

		var _HTTP = $(valor).value;
		var CuentaUSR = '';
		for(i=0;i<_HTTP.length;i++){
			if(Caracteres.indexOf(_HTTP.substr(i,1)) != -1){
				CuentaUSR += _HTTP.substr(i,1); 
			}
		}
		$(valor).value = CuentaUSR;	
}
function NuevoVoto(id,ratin){	
	var voto = peticionXMLHttp();
	voto.open("POST","Procesos/Proc.Acciones.php",true);
	voto.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    voto.send("Accion=Voto&idm="+id+"&ratio="+ratin+"&nocache="+Math.random()*99999);
	
}

window.onresize = function(){
	arreglaraResolucion("Aero");
}

