/* orgazmo@live.no*/
var peticion;
var musica;
var actual;
var domain = 'http://www.grantono.com/';


function OrGaZmoMovie(path) 
{      
var swf = navigator.appName.indexOf("Microsoft") != -1;      
return (swf) ? window[path] : document[path];
}	

function $(p)
{ 
 var elObjeto = document.getElementById(p)|| document.getElementsByName(p);
 return elObjeto;
}

function scrollMoveTo(target,pos)
{	for(var n=0;n<=4;n++)
	{$(target).scrollTop = 25*(pos-4);
	}
}
function initPlaylist(_pl,now)
{	
	actual = (typeof actual == '')?1:now;
	scrollMoveTo(_pl,actual);
	var total = $(_pl).getElementsByTagName("tr").length;
	for(var p=0;p<total;p++)
	{	var indice = p+1;
		var clase = (indice%2==0)?'musEvver':'';
	    $("pl_"+indice).className = clase;			 					
		
	}
	$("pl_"+actual).className = 'musChecked';
	
}
function overM(i)
{
	$(i.id).className = 'musOver';
}
function outM(i){
	$(i.id).className = '';
	var numerico = i.id.substring(3,i.id.length);
	if(numerico%2 == 0)
	{ $(i.id).className = 'musEvver';	
	}else
	{ $(i.id).className = '';
  }
	$("pl_"+actual).className = 'musChecked';
}
function clickM(i)
{
	for(var p = 0;p<=musica.split("@").length;p++)
	{
		if(p == i)	
		{  
		  actual = i; 
		  $("pl_"+actual).className = 'musChecked';	
		  scrollMoveTo('playlist',actual);
		}else
		{	 var _clase = (p%2==0)?'musEvver':'';		  
			$("pl_"+p).className = _clase;			
		}
	}	
}

function getMusica(i,text)
{
	OrGaZmoMovie('www.grantono.com').initMusic(i);
	clickM(i);	
}
function peticionHTTP(url,metodo,contexto,value)
{	
	if(window.XMLHttpRequest)   
	{peticion = new XMLHttpRequest(); 
	}else if(window.ActiveXObject) 
	{peticion = new ActiveXObject("Microsoft.XMLHTTP");
	}
	peticion.open(metodo,url,true);
	peticion.onreadystatechange = function()
	{
		isMultiAjax(contexto);
	}
	peticion.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	peticion.send(value);
}

function isMultiAjax(_load)
{
	$(_load).innerHTML = '';
	if(peticion.readyState == 1)
	{
		$(_load).innerHTML = "<br /><br /><br /><br /><br /><br />";
		$(_load).innerHTML += "<center><b><font face=\"verdana\" size=\"2px\">Cargando.....</font><b><br></center>";
		$(_load).innerHTML += "<center><img height=15 src=\"img/Carg1.gif\"></center>";		
	}
	else if(peticion.readyState == 4)
	{
		if(peticion.status == 200)
		{
			$(_load).innerHTML = peticion.responseText;
		}
		else 
		{     $(_load).innerHTML = "";
		      $(_load).innerHTML  += "<center><br><font face='Verdana' size='10px' >Upps!<br></font></center>";
			  $(_load).innerHTML  += "<center><font face='Verdana' size='4px' >Ocurrio un Error : "+peticion.statusText+"</font></center>";	
			  $(_load).innerHTML  += "<center><br><font face='Verdana' size='4px' >Estado : "+peticion.status+"</font></center>";			
		}
	}
}

function  Show(_accion,_capa)
{
	
    var isvisible = $(_capa).style.display;
	(isvisible=='block')? $(_capa).style.display='none': $(_capa).style.display='block';	
	var offtitulo = musica.split("@")[actual].split("*")[1]+" - " + musica.split("@")[actual].split("*")[0];
	
	if(_accion == "lr")
	{
    var getvars = offtitulo ;
	var url = "Ficheros/Letras.php?p="+getvars+"&nocache="+Math.random()*9999;
	var metodo = "GET";
	var value = null;
	var contexto = _capa;
	peticionHTTP(url,metodo,contexto,value);
	}
	else if(_accion == "vid")
	{
    var getvars = offtitulo;
	var url = "Videos.php?v="+getvars+"&nocache="+Math.random()*9999;
	var metodo = "GET";
	var value = null;
	var contexto = _capa;
	peticionHTTP(url,metodo,contexto,value);
	}
	else if(_accion == "img")
	{
    var getvars = offtitulo;
	var url = "Imagenes.php?i="+getvars+"&nocache="+Math.random()*9999;
	var metodo = "GET";
	var value = null;
	var contexto = _capa;
	peticionHTTP(url,metodo,contexto,value);
	}
}

