function showVideo(source, title, type){
	var divObject = document.getElementById("divPlayer");
		if(type == "flv"){
		var source2=eval(source);		var innerHTMLCode = "<embed width=\"480\" height=\"360\" ";
		innerHTMLCode+= "flashvars=\"width=480&amp;height=360&amp;file="+source2+"&amp;logo=/swf/mosca2008.png&amp;displayheight=360&amp;autostart=true\" ";
		innerHTMLCode+= "wmode=\"transparent\" allowfullscreen=\"true\" allowscriptaccess=\"always\" quality=\"high\" bgcolor=\"#FFFFFF\" name=\"mymovie\" id=\"mymovie\" src=\"/swf/flvplayer.swf\" ";
		innerHTMLCode+= "type=\"application/x-shockwave-flash\"/>";
	}else if(type == "youTube"){
		var source2=eval(source);		var innerHTMLCode = "<object width=\"480\" height=\"360\">";
		innerHTMLCode+= "<param name=\"movie\" value=\""+source2+"\"></param>";
		innerHTMLCode+= "<param name=\"wmode\" value=\"transparent\"></param>";
		innerHTMLCode+= "<embed src=\"http://www.youtube.com/v/"+source2+"&hl=es&rel=0\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"480\" height=\"360\" ></embed>";
		innerHTMLCode+= "</object>";
		
	}else if(type == "embed"){
		var innerHTMLCode = eval(source);
			
	}else{
		var innerHTMLCode = "<img src=\""+source+"\" alt=\""+title+"\" title=\""+title+"\" width=\"480\" />";
	}
	divObject.innerHTML = innerHTMLCode;
}

function popWindow(destUrl, params) {
	window.open( destUrl, "", params );
}

var Desplegable = {
	easerInterval: null,
	speed: 1.25,
	switchElId: null,
	switchElOpenedText: "-&nbsp; cerrar listado alfabético de artistas",
	switchElClosedText: "+&nbsp; listado alfabético de artistas",
	destElId: null,
	destElHeight: 0,
	destElRealHeight: 0,
	state: true,
	
	init: function( destEl, switchEl, beginOpened ) {
		if ( beginOpened === undefined ) { //Esto hace de beginOpened un param opcional...
			beginOpened = false;
		}
		Desplegable.destElId = document.getElementById( destEl );
		Desplegable.destElRealHeight = parseInt( Desplegable.destElId.offsetHeight );
		Desplegable.switchElId = document.getElementById( switchEl );
		
		if( !beginOpened ) {
			Desplegable.destElId.style.height = Desplegable.destElHeight = "1px";
			Desplegable.state = false;
			Desplegable.switchElId.innerHTML = Desplegable.switchElClosedText;
		} else {
			Desplegable.destElId.style.height = Desplegable.destElHeight = Desplegable.destElRealHeight;
			Desplegable.state = true;
			Desplegable.switchElId.innerHTML = Desplegable.switchElOpenedText;
		}
	},
	
	activate: function() {
		if( Desplegable.state == true ) {
			Desplegable.hider();
		} else {
			Desplegable.shower();
		}
	},
	
	shower: function() {
		clearInterval( Desplegable.easerInterval );
		if( Desplegable.destElId ) {
			Desplegable.state = true;
			Desplegable.switchElId.innerHTML = Desplegable.switchElOpenedText;
			Desplegable.easerInterval = window.setInterval( Desplegable.easerIn, 20 );
		}
	},
	
	hider: function() {
		clearInterval( Desplegable.easerInterval );
		if(Desplegable.destElId) {
			Desplegable.state = false;
			Desplegable.switchElId.innerHTML = Desplegable.switchElClosedText;
			Desplegable.easerInterval = window.setInterval( Desplegable.easerOut, 20 );
		}
	},
	
	easerIn: function() {
		nuevaDist = parseFloat( Desplegable.destElHeight ) * Desplegable.speed;
		Desplegable.destElId.style.height = Desplegable.destElHeight = nuevaDist + "px";
		if( nuevaDist >= parseFloat( Desplegable.destElRealHeight ) ) {
			Desplegable.destElId.style.height = Desplegable.destElRealHeight + "px";
			clearInterval( Desplegable.easerInterval );
		}
	},
	
	easerOut: function() {
		nuevaDist = parseFloat( Desplegable.destElHeight ) / Desplegable.speed;
		Desplegable.destElId.style.height = Desplegable.destElHeight = nuevaDist + "px";
		if( nuevaDist <= 1 ) {
			Desplegable.destElId.style.height = 1 + "px";
			clearInterval( Desplegable.easerInterval );
		}
	}
}

var DesplegableSonarmatica = {
		easerInterval: null,
		speed: 1.25,
		switchElId: null,
		switchElOpenedText: "-&nbsp; cerrar listado alfabético de SonarMàtica",
		switchElClosedText: "+&nbsp; listado alfabético de SonarMàtica",
		destElId: null,
		destElHeight: 0,
		destElRealHeight: 0,
		state: true,
		
		init: function( destEl, switchEl, beginOpened ) {
			if ( beginOpened === undefined ) { //Esto hace de beginOpened un param opcional...
				beginOpened = false;
			}
			DesplegableSonarmatica.destElId = document.getElementById( destEl );
			DesplegableSonarmatica.destElRealHeight = parseInt( DesplegableSonarmatica.destElId.offsetHeight );
			DesplegableSonarmatica.switchElId = document.getElementById( switchEl );
			
			if( !beginOpened ) {
				DesplegableSonarmatica.destElId.style.height = DesplegableSonarmatica.destElHeight = "1px";
				DesplegableSonarmatica.state = false;
				DesplegableSonarmatica.switchElId.innerHTML = DesplegableSonarmatica.switchElClosedText;
			} else {
				DesplegableSonarmatica.destElId.style.height = DesplegableSonarmatica.destElHeight = DesplegableSonarmatica.destElRealHeight;
				DesplegableSonarmatica.state = true;
				DesplegableSonarmatica.switchElId.innerHTML = DesplegableSonarmatica.switchElOpenedText;
			}
		},
		
		activate: function() {
			if( DesplegableSonarmatica.state == true ) {
				DesplegableSonarmatica.hider();
			} else {
				DesplegableSonarmatica.shower();
			}
		},
		
		shower: function() {
			clearInterval( DesplegableSonarmatica.easerInterval );
			if( DesplegableSonarmatica.destElId ) {
				DesplegableSonarmatica.state = true;
				DesplegableSonarmatica.switchElId.innerHTML = DesplegableSonarmatica.switchElOpenedText;
				DesplegableSonarmatica.easerInterval = window.setInterval( DesplegableSonarmatica.easerIn, 20 );
			}
		},
		
		hider: function() {
			clearInterval( DesplegableSonarmatica.easerInterval );
			if(DesplegableSonarmatica.destElId) {
				DesplegableSonarmatica.state = false;
				DesplegableSonarmatica.switchElId.innerHTML = DesplegableSonarmatica.switchElClosedText;
				DesplegableSonarmatica.easerInterval = window.setInterval( DesplegableSonarmatica.easerOut, 20 );
			}
		},
		
		easerIn: function() {
			nuevaDist = parseFloat( DesplegableSonarmatica.destElHeight ) * DesplegableSonarmatica.speed;
			DesplegableSonarmatica.destElId.style.height = DesplegableSonarmatica.destElHeight = nuevaDist + "px";
			if( nuevaDist >= parseFloat( DesplegableSonarmatica.destElRealHeight ) ) {
				DesplegableSonarmatica.destElId.style.height = DesplegableSonarmatica.destElRealHeight + "px";
				clearInterval( DesplegableSonarmatica.easerInterval );
			}
		},
		
		easerOut: function() {
			nuevaDist = parseFloat( DesplegableSonarmatica.destElHeight ) / DesplegableSonarmatica.speed;
			DesplegableSonarmatica.destElId.style.height = DesplegableSonarmatica.destElHeight = nuevaDist + "px";
			if( nuevaDist <= 1 ) {
				DesplegableSonarmatica.destElId.style.height = 1 + "px";
				clearInterval( DesplegableSonarmatica.easerInterval );
			}
		}
	}

function voteTop(objectId,numVotos,position){
	var func = "voteTop";
	var data = "objectId="+objectId+"&numVotos="+numVotos+"&position="+position;
	//var data = "objectId="+objectId+"&numVotos="+numVotos;
	callAjaxPOST(voteTopCallback, func, data);
}

function voteTopCallback(xmlhttp){
	var data = xmlhttp.responseXML.getElementsByTagName("data")[0];
	var objectId = data.getAttribute("objectId");
	var numVotos = data.getAttribute("numVotos");
	var objectId = data.getAttribute("objectId");
	if(data.textContent){
		var artist = data.textContent;
	}else{
		var artist = data.text;
	}
	
	
	var divObject2 = document.getElementById("voto_score_"+objectId);

	//var innerHTMLCode2 = numVotos;
	divObject2.className='voted';
	divObject2.innerHTML = artist;
}

function mySonar(targetClass, targetId){
	var func = "mySonar";
	var data = "targetClass="+targetClass+"&targetId="+targetId;
	callAjaxPOST(mySonarCallback, func, data);
}

function mySonarCallback(xmlhttp){
	var response = xmlhttp.responseXML.getElementsByTagName("response")[0];
	var value = response.getAttribute("value");
	if(value == 1){
		var data = xmlhttp.responseXML.getElementsByTagName("data")[0];
		var targetClass = data.getAttribute("targetClass");
		var targetId = data.getAttribute("targetId");
		var elements = document.getElementsByName(targetClass+targetId);
		for (var i=0; i<elements.length; i++) {
			var element = elements[i];
			element.innerHTML = "<span class=\"miniMySonarBtn\"><img src=\"/img/programa/mysonar_disabled.gif\" /></span>";
		}
	}
}

function delMySonar(targetClass, targetId){
	if(confirm("\u00BFSeguro que desea eliminar este registro?")){
		var func = "delMySonar";
		var data = "targetClass="+targetClass+"&targetId="+targetId;
		callAjaxPOST(delMySonarCallback, func, data);
	}
}
function delMySonarCallback(xmlhttp){
var response = xmlhttp.responseXML.getElementsByTagName("response")[0];
	var value = response.getAttribute("value");
	if(value == 1){
		var data = xmlhttp.responseXML.getElementsByTagName("data")[0];
		var targetClass = data.getAttribute("targetClass");
		var targetId = data.getAttribute("targetId");
		var group = document.getElementById("myHorarioGroup");
		var element = document.getElementById(targetClass+targetId+"Div");
		group.removeChild(element);
	}
}