var vecVideosComp=new Array();
//FUNCION ENCARGADA DE CARGAR EL FLASH DE MULTIMEDIA
function loadMflash(containerX,kind,xmlroute,heigthobj) 
{
	var swfplayer="";
	var nameofplayer="";
	if(!heigthobj){heigthobj='420';}
	//VERIFICAMOS QUE TIPO DE MULTIMEDIA ES PARA ASI MISMO LLAMAR EL VISOR DE CADA UNO
	switch(kind)
	{
		case 'audio':
			swfplayer="knowleerAudio2.swf";
			nameofplayer="audiogallery";
			break;
		case 'video': 
			swfplayer="knowleerVideoTotal2.swf";
			nameofplayer="videogallery";
			break;
		default:
			swfplayer="knowleerGallery2.swf";
			nameofplayer="imagegallery";
	}
	//CARGAMOS EL OBJETO VISUALIZADOR DE FLASH 
	var so = new SWFObject("/"+aplicaptr+"/vistacomunidad/style/flash/"+swfplayer,nameofplayer,"98%",heigthobj, "6", "#FFFFFF");
	so.addVariable("XMLPath", xmlroute);
	so.addVariable("wmode", "transparent");
	so.addParam("wmode", "transparent");
	so.addParam("allowFullScreen", "true");	
	if(kind=='video') so.addVariable("SKINPath", "/"+aplicaptr+"/vistacomunidad/style/flash/ClearOverNoVol.swf");
	so.write(containerX);
}
//FUNCION ENCARGADA DE CARGAR EL XML AL FLASH
function loadXMLtoflash(xmlroute,to)
{
	var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var PeliculaObj = document.getElementById(to);
	PeliculaObj.SetVariable("XMLPath",xmlroute);
	PeliculaObj.SetVariable("semaforo",true);
	PeliculaObj.SetVariable("wmode","transparent");
}
//FUNCION ENCARGADAD DE EJECUTAR UNA URL MEDIANTE CALLSERVER
function ejecutarURL1(cadena,funcion,mensaje)
{
	var mycarga = new callServer();				
	mycarga.loadXMLhttp(cadena);
	mycarga.onLoad = function(ok)
	{
		if(ok)
		{
			if ((funcion != undefined) && (funcion != "")) { eval(funcion); }
			if (mensaje != undefined) { alert(mensaje);}
		}	
	}
}


//FUNCION PARA LA VOTACION DE VIDEOS
function guardarVoto1(dk,clase,calificacion,rutaimg,tipo,otros,num,dkvideo)
{
	var vecVideosCompVal= eval("vecVideosCompVal"+dk);
	for (i=0;i<vecVideosCompVal.length;i++)
	{
		if (vecVideosCompVal[i].dk == dkvideo)
		{
			var vecVidvot=vecVideosCompVal[i].votaciones;
			var num = i;
		}				
	}
	if(vecVidvot !=1)
	{
		document.getElementById('valoraciontema').innerHTML="<img src='"+rutaimg+"/indicator.gif' align='middle' />&nbsp;"+mostrar_mensaje('49')+"&nbsp;&nbsp;";
		var valoracion;
		var numvotos;
		vecVideosCompVal[num].votaciones=1;
		ejecutarURL1(cgiurl+"/s.cgi?votacion"+dkvideo+"=1");
		var mySend = new callServer();
		var myCarga= new callServer();
		myCarga.onLoad=function(cargo)
		{
			if (cargo)
			{ 
				if (myCarga.getCampo('D.k').length!=0)
				{
					valoracion =  myCarga.getValue('valoracion',0);
					if(valoracion == null){ valoracion=0; } else { valoracion=parseFloat(valoracion); }
					numvotos = myCarga.getValue('numvotos',0);
					if(numvotos == null){ numvotos = 0; } else { numvotos=parseInt(numvotos); }
					var total=valoracion*numvotos;
					numvotos+=1;
					valoracion=(total+calificacion)/numvotos;
					mySend.sendValues = 'D.dataformat=XML&D.action=modify&D.k='+dkvideo+'&D.y='+clase+'&valoracion='+valoracion+'&numvotos='+numvotos;
					mySend.loadXMLhttp(cgiurl + "/a.cgi?","POST");
				}
			}
		};
		if(dk != ""){ myCarga.loadXMLhttp(cgiurl+"/q2XML.cgi?campos=nombre,D.k,valoracion,numvotos&where=D.k=" + dkvideo + "&random="+Math.random()); }
		mySend.onLoad = function(ok)
		{
			if(ok)
			{
				var err = 0;
				if (err != 0)
				{
					msg=mySend.getValue("descripcion",0);
					alert('Error: '+msg);
				}
				else
				{
					var txtvaloracion='';
					var contiene = mostrar_mensaje('50');	
					var lblvaloracion = contiene.split(",");
					var clasev;
					for(var item=1; item<=4; item++)
					{
						if(valoracion >= item) { clasev="voteOn"; } else { clasev="voteOff"; }
						txtvaloracion+='<div class="'+clasev+'" title="'+lblvaloracion[item-1]+'" alt="'+lblvaloracion[item-1]+'" onClick="guardarVoto1(\''+dk+'\',\''+clase+'\','+item+',\''+rutaimg+'\');"></div>';
					}
					document.getElementById('valoraciontema').innerHTML='<h3>'+mostrar_mensaje('52')+'</h3>'+txtvaloracion;
					document.getElementById('numvotostema').innerHTML='<h3>'+mostrar_mensaje('53')+'<strong>'+numvotos+'</strong></h3>';
					alert(mostrar_mensaje('265'));
				}
			} 
		};
	}
	else {
		alert(mostrar_mensaje('51')); 
		//alert('Ya registraste tu voto para este vídeo!');
		}
}
//CARGA DE LA INFORMACION DE VIDEOS
function loadInfoVideo(dk)
{
	var myCarga= new callServer();
	myCarga.onLoad=function(cargo)
	{
		if (cargo)
		{ 
			if (myCarga.getCampo('D.k').length!=0)
			{
				for(i=0;i<vecVideosComp.length;i++)
				{
					if (vecVideosComp[i].dk==dk)
					{
						var titulo="tituloVideo";
						var descripcion="descripcionVideo";
						var autor="autorVideo";
						if(document.getElementById(titulo))
						{
							document.getElementById(titulo).innerHTML=vecVideosComp[i].titulo;
							document.getElementById(descripcion).innerHTML=vecVideosComp[i].descripcion;
							document.getElementById(autor).innerHTML="Autor: "+vecVideosComp[i].autor;
						}
						valoracion =  myCarga.getValue('valoracion',0);
						if(valoracion == null){ valoracion=0; } else { valoracion=parseFloat(valoracion); }
						numvotos = myCarga.getValue('numvotos',0);
						if(numvotos == null){ numvotos = 0; } else { numvotos=parseInt(numvotos); }
						var total=valoracion*numvotos;
						valoracion=(total)/numvotos;
						var txtvaloracion='';
						var contiene=mostrar_mensaje('50');
						var lblvaloracion = contiene.split(",");
						//var lblvaloracion=new Array('Flojo','Bueno','Muy Buneo','Excelente');
						var clasev;
						for(var item=1; item<=4; item++)
						{
							if(valoracion >= item) { clasev="voteOn"; } else { clasev="voteOff"; }
							txtvaloracion+='<div class="'+clasev+'" title="'+lblvaloracion[item-1]+'" alt="'+lblvaloracion[item-1]+'" onClick="guardarVoto1(\''+dk+'\',\'archivo\','+item+',\''+dirreccionurl+'\');"></div>';
						}
						document.getElementById('valoraciontema').innerHTML='<h3>'+mostrar_mensaje('52')+'</h3>'+txtvaloracion;
						document.getElementById('numvotostema').innerHTML='<h3>'+mostrar_mensaje('53')+'<strong>'+numvotos+'</strong></h3>';
					}
				 
				 }
			}
		}
	};
	myCarga.loadXMLhttp(cgiurl+"/q2XML.cgi?campos=D.k,valoracion,numvotos&where=D.k=" + dk + "&random="+Math.random());
}

