var BASEDIR="/";function cancelItem(){new Effect.BlindUp('dinamicSuperior')}
function obre_popup(ruta,width,height,left,top,resizable){
	window.open(ruta,'somixx_player','width='+width+'px, height='+height+'px, left='+left+'px, top='+top+'px, resizable='+resizable)
}


var Popup = {
  open: function(options)
  {
    this.options = {
      name: 'somixx_player',
      url: '#',
      width: 275,
      height: 265,
      location:"no",
      menubar:"no",
      toolbar:"no",
      status:"no",
      scrollbars:"no",
      resizable:"no",
      left:"",
      top:"",
      normal:false
    }
    Object.extend(this.options, options || {});

    if (this.options.normal){
        this.options.menubar = "yes";
        this.options.status = "yes";
        this.options.toolbar = "yes";
        this.options.location = "yes";
    }

    this.options.width = this.options.width < screen.availWidth?this.options.width:screen.availWidth;
    this.options.height=this.options.height < screen.availHeight?this.options.height:screen.availHeight;
    var openoptions = 'width='+this.options.width+',height='+this.options.height+',location='+this.options.location+',menubar='+this.options.menubar+',toolbar='+this.options.toolbar+',scrollbars='+this.options.scrollbars+',resizable='+this.options.resizable+',status='+this.options.status
    if (this.options.top!="")openoptions+=",top="+this.options.top;
    if (this.options.left!="")openoptions+=",left="+this.options.left;
    window.open(this.options.url, this.options.name,openoptions );
    return false;
  }
}
	
	
	function mostrar(div){document.getElementById(div).style.display='block'}function ocultar(div){document.getElementById(div).style.display='none'}function getMovieName(movieName){if(navigator.appName.indexOf("Microsoft")!=-1){return window[movieName]}else{return document[movieName]}}function addCartFlash(){var id;var reproductorFlash=getMovieName("proves");var associativeArray=[];id=reproductorFlash.addCart();var resposta=sendFormGET(BASEDIR+"libs/reproductor/carrito.php?id="+id);if(resposta=="OK"){window.location=window.location}else{window.location="http://www.somixx.com"+BASEDIR+"usuarios/registro/1/"}}function createChartJ(){var lista;var reproductorFlash=getMovieName("proves");lista=reproductorFlash.createChart();if(lista!="null")window.location=BASEDIR+"charts/formulario/"+lista.substring(0,lista.length-1)}function createPlayerJ(){var lista;var reproductorFlash=getMovieName("proves");lista=reproductorFlash.createChart();if(lista!="null")window.location=BASEDIR+"players/formulario/"+lista.substring(0,lista.length-1)}function sendFormGET(url){if(window.XMLHttpRequest)var ajaxObject=new XMLHttpRequest();else if(window.ActiveXObject)var ajaxObject=new ActiveXObject("Microsoft.XMLHTTP");else if(window.ActiveXObject)var ajaxObject=new ActiveXObject("Msxml2.XMLHTTP");else return(false);ajaxObject.open("GET",url,false);if(ajaxObject.readyState==1){}ajaxObject.send(null);if(ajaxObject.readyState==4){return(ajaxObject.responseText)}else return(false)}function enviarFormulario(url,formid){var Formulario=document.getElementById(formid);var longitudFormulario=Formulario.elements.length;var cadenaFormulario="";var sepCampos="";for(var i=0;i<=Formulario.elements.length-1;i++){cadenaFormulario+=sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);sepCampos="&"}if(window.XMLHttpRequest)var ajaxObject=new XMLHttpRequest();else if(window.ActiveXObject)var ajaxObject=new ActiveXObject("Microsoft.XMLHTTP");else if(window.ActiveXObject)var ajaxObject=new ActiveXObject("Msxml2.XMLHTTP");else return(false);ajaxObject.open("POST",url,true);ajaxObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-1');ajaxObject.onreadystatechange=function(){if(ajaxObject.readyState==4){return true}};ajaxObject.send(cadenaFormulario)}

function listenAll(){
	var tracks = $$('div.icon_play a');
	var max = tracks.length;
	
	var xtra = "";
	
	switch(navigator.appName){
		case "Netscape":
			xtra = "function onclick(event)";
			break;
		case "Opera":
			xtra = "function (event)";
			break;
		case "Microsoft Internet Explorer":
			xtra = "function onclick()";
			break;
	}
		
	for (var i = 0; i<max; i++){
		var s = new String(tracks[i].onclick);
		
		s = s.replace(xtra, "").replace("{", "").replace("}", "");
		
		
		eval(s.split(";",1)+";");
		
	}
	
	
}

function listenAll_reverse(){
	var tracks = $$('div.icon_play a');
	var max = tracks.length;
	
	var xtra = "";
	
	switch(navigator.appName){
		case "Netscape":
			xtra = "function onclick(event)";
			break;
		case "Opera":
			xtra = "function (event)";
			break;
		case "Microsoft Internet Explorer":
			xtra = "function onclick()";
			break;
	}
		
	for(var i=tracks.length-1; i>=0; i--) {
		var s = new String(tracks[i].onclick);
		
		s = s.replace(xtra, "").replace("{", "").replace("}", "");
		
		
		eval(s.split(";",1)+";");
		
	}
	
	
}



//FUNCIONES NUEVAS FLASH, ASINCRONAS, NO CUELGAN LA PAGINA
function capturarCancion(){
	var reproductorFlash=getMovieName("proves");
	if(reproductorFlash) var temps=reproductorFlash.capturaTiempo();
	new Ajax.Request(BASEDIR+"libs/reproductor/tiempo.php?tiempo="+temps, {method: 'get'});

}
function lanzarPlayer(){
	var reproductorFlash=getMovieName("proves");
	new Ajax.Request(BASEDIR+"libs/reproductor/cargarTema.php?idTracks=-1&titulo=-1&imagen=-1&session_id=-1", {
		method: 'get',
		onSuccess: function (res){
			new Ajax.Request(BASEDIR+"libs/reproductor/tiempo.php?tiempo=-1", {
				method: 'get',
				onSuccess: function (temps){
					if(reproductorFlash) reproductorFlash.generem(res.responseText,temps.responseText);
					//obre_popup('/players/popup/&layout=none','265','260',-1,-1,'no');
				}
			});
		}
	});
}
function cargarTracks(idTrack,Titulo,Imagen,session_id){
	var reproductorFlash=getMovieName("proves");
	if(reproductorFlash) var temps=reproductorFlash.capturaTiempo();	
	new Ajax.Request(BASEDIR+"libs/reproductor/cargarTema.php?idTracks="+idTrack+"&titulo="+Titulo+"&imagen="+Imagen+"&session_id="+session_id, {
		method: 'get',
		onSuccess: function (res){
			new Ajax.Request(BASEDIR+"libs/reproductor/tiempo.php?tiempo="+temps,{method: 'get'});
			//reproductorFlash.generem(res.responseText,temps);
			//obre_popup('/players/popup/&layout=none','270','260',-1,-1,'no');
			//window.open('/players/popup/&layout=none','somixx_player','width=270px, height=260px, left=-1px, top=-1px, resizable=no');

		}
	});
}
function cargarEps(idEp,Titulo,Imagen,session_id){
	var reproductorFlash=getMovieName("proves");
	if(reproductorFlash) var temps=reproductorFlash.capturaTiempo();	
	new Ajax.Request(BASEDIR+"libs/reproductor/cargarEp.php?idEps="+idEp+"&imagen="+Imagen+"&session_id="+session_id, {
		method: 'get',
		onSuccess: function (res){
			new Ajax.Request(BASEDIR+"libs/reproductor/tiempo.php?tiempo="+temps,{method: 'get'});
			//reproductorFlash.generem(res.responseText,temps);
			//obre_popup(,'270','260',-1,-1,'no');
			//window.open('/players/popup/&layout=none','somixx_player','width=270px, height=260px, left=-1px, top=-1px, resizable=no');

		
		}
	});
}
function cargarPacks(idEp,Titulo,Imagen,session_id){
	var reproductorFlash=getMovieName("proves");
	if(reproductorFlash) var temps=reproductorFlash.capturaTiempo();	
	new Ajax.Request(BASEDIR+"libs/reproductor/cargarEp.php?idEps="+idEp+"&imagen="+Imagen+"&session_id="+session_id, {
		method: 'get',
		onSuccess: function (res){
			new Ajax.Request(BASEDIR+"libs/reproductor/tiempo.php?tiempo="+temps,{method: 'get'});
			//reproductorFlash.generem(res.responseText,temps);
			//obre_popup('/players/popup/&layout=none','270','260',-1,-1,'no');
			//window.open('/players/popup/&layout=none','somixx_player','width=270px, height=260px, left=-1px, top=-1px, resizable=no');
		}
	});
}
function deleteItemFlash(){
	var id;
	var reproductorFlash=getMovieName("proves");
	id=reproductorFlash.deleteItem();
	new Ajax.Request(BASEDIR+"libs/reproductor/deleteItem.php?idTrack="+id,{method: 'get'});
}


//Total cesta
function totalCesta(){
	var resTotal = sendFormGET(BASEDIR+"carrito/ajax_totalcesta&template=none");
	//alert(resTotal);
	document.getElementById('header_total_carrito').innerHTML=resTotal;
}


//Total cesta
function anadirCesta(tabla,id,calidad,lang){
	var resTotal = sendFormGET(BASEDIR+"carrito/ajax_anadircesta&tabla="+tabla+"&id="+id+"&calidad="+calidad+"&lang="+lang+"&template=none");
	Aviso(resTotal);
	totalCesta();
	//document.getElementById('header_total_carrito').innerHTML=resTotal;
}

function Aviso(texto){
	Dialog.info(texto, {className: "dialog",  width:500, height: 50, id: "dialoguete"});
	setTimeout(CierraAviso, 3000);
}

function CierraAviso(){
	Dialog.closeInfo();
}
