<!--
// All JavaScripts contained herein are
// Copyright 2006 SiempreGente.com
// All rights reserved.
// Commercial distribution or modification prohibited without
// express written permission.
	var popup = null;
	var strFlashPlayer = "";
	var strWMPlayer = "";
	var intWidth = 267;
	var intHeightFlash = 42;
	var intHeightWMP = 45;	
	
   strFlashPlayer = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='Tag.w' height='Tag.h' align='middle'>";
   strFlashPlayer = strFlashPlayer + "<param name='movie' value='images/flash/sgPlayerMusic.swf?strFILE=Tag.file&strColorPlayer=Tag.CP' />";
   strFlashPlayer = strFlashPlayer + "<param name='quality' value='high' />";
   strFlashPlayer = strFlashPlayer + "<param name='menu' value='false'/>";
   strFlashPlayer = strFlashPlayer + "<param name='bgcolor' value='#ffffff' />";
   strFlashPlayer = strFlashPlayer + "<embed src='images/flash/sgPlayerMusic.swf?strFILE=Tag.file&strColorPlayer=Tag.CP' quality='high' bgcolor='#ffffff' width='Tag.w' height='Tag.h' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />    ";
   strFlashPlayer = strFlashPlayer + "</object>";
		
	strWMPlayer = 	strWMPlayer + "<embed type='application/x-mplayer2' src='Tag.file' width='Tag.w' height='Tag.h'></embed>";		
	
	function fnSG_Player(strLink){
	  strLink = strLink.replace(/"/g,"'");
	  arrSegmentos = strLink.split('||');
		intMultimedia_id = arrSegmentos[0];
		strLink = arrSegmentos[1];
		strNombre = arrSegmentos[2];
 		if(arrSegmentos.length > 3){
			strTitle = arrSegmentos[3];		
			strTitle = strTitle + " " + strNombre + "</font>";
			document.getElementById('PopUpSongTitle').innerHTML = strTitle;
		}
	  strLinkTmp = strLink.toLowerCase();
	   if(strLinkTmp.indexOf('<') > -1){ //El archivo viene con mas parametros
			if(strLinkTmp.search(/width/i)>0){
				arrParametros = strLink.split("'");
			   if(arrParametros.length > 1){ //Hay que buscar el segmento que contiene el width, en caso de que venga encapsulado
				   for(intI = 0; intI < arrParametros.length; intI++){
						if(arrParametros[intI].toLowerCase().search(/width/i) > 0){
							break; //Este es
						}
					}	   
				   strLink=strLink.replace(arrParametros[intI]+"'"+arrParametros[intI+1]+"'",arrParametros[intI]+"'"+intWidth+"'");
			   }else{
				   strLink = strLink.substr(0,strLink.search(/embed/i)) + "embed width='"+intWidth+"' " + strLink.substr(strLink.search(/embed/i) + 5);
			   }
			}else{
				strLink = strLink.substr(0,strLink.search(/embed/i)) + "embed width='"+intWidth+"' " + strLink.substr(strLink.search(/embed/i) + 5);
		   }
			document.getElementById("sgPlayer").innerHTML = strLink;
		}else{ //Es solo una liga
		  if(strLinkTmp.search(/mp3/i) > 0){ //Si es uno de los formatos soportados por nuestro Flash Player (actualmente solo mp3)
				arrParametros = strLink.split("'");
			   if(arrParametros.length > 1){ //Hay que buscar el segmento que contiene el archivo, en caso de que venga encapsulado
				   for(intI = 0; intI < arrParametros.length; intI++){
						if(arrParametros[intI].search(/mp3/i) > 0){
							break; //Este es
						}
					}	   
				   strFlashPlayerTmp=strFlashPlayer.replace(/Tag.file/g,arrParametros[intI]);
				}else{ //El archivo es el unico parametro
				   strFlashPlayerTmp=strFlashPlayer.replace(/Tag.file/g,strLink);
				}
			   strFlashPlayerTmp=strFlashPlayerTmp.replace(/Tag.w/g,intWidth);
			   strFlashPlayerTmp=strFlashPlayerTmp.replace(/Tag.h/g,intHeightFlash);
			   strBGColor = document.getElementById("sgPlayerBGColor").style.backgroundColor;
			   strBGColor = strBGColor.replace('#','');
			   strFlashPlayerTmp=strFlashPlayerTmp.replace(/Tag.CP/g,"0x" + strBGColor);
			   document.getElementById("sgPlayer").innerHTML = strFlashPlayerTmp;
		  }else{
			   strWMPlayerTmp = strWMPlayer.replace(/Tag.w/g,intWidth);
			   strWMPlayerTmp = strWMPlayerTmp.replace(/Tag.h/g,intHeightWMP);		  		   
			   strWMPlayerTmp = strWMPlayerTmp.replace(/Tag.file/g,strLink);
			   document.getElementById("sgPlayer").innerHTML = strWMPlayerTmp;
		  }
		 }	

		}
	
	function fnSG_QuitarMusicBox(blnFlag,usr_id,lgn_tm, multimedia_id , h, w){
		document.getElementById('restaurar').style.display='block';
		document.getElementById('quitar').style.display='none';
		document.getElementById('sgPlayer').innerHTML = '';
		document.getElementById('playlist').style.display='none';
		if(blnFlag==1){
			arrSegmentos = multimedia_id.split('||');
			intMultimedia_id = arrSegmentos[0];			
			popup = window.open('index.php?page_id=124&user_id=' + (usr_id + lgn_tm) + '&multimedia_id=' + intMultimedia_id, 'PopupPlayer' + usr_id, 'scrollbars=yes,resizable=yes,directories=no,location=no,menubar=no,status=no,toolbar=no,height='+ h +', width='+ w);
		}
	}
	
	function fnSG_RestaurarMusicBox(){
		document.getElementById('restaurar').style.display='none';
		document.getElementById('quitar').style.display='block';
		document.getElementById('sgPlayer').innerHTML= '';
		document.getElementById('playlist').style.display='block';
		if(!popup.closed){
			document.getElementById('multimedia_id').options[popup.document.getElementById('multimedia_id').selectedIndex].selected = true;
			popup.close();
		}else{
			document.getElementById('multimedia_id').options[0].selected = true;			
		}
		fnSG_Player(document.getElementById('multimedia_id').options[document.getElementById('multimedia_id').selectedIndex].value);
	}	 

	function fnSG_PopUp_PlayList(strTitulo){
		arrSegmentos = strTitulo.split('||');
		strTitle = arrSegmentos[0];
		strTitleTmp = '';
		strTitulo = arrSegmentos[1];
		strTituloTmp = '';		
		for(intI=0; intI < window.opener.document.getElementById('multimedia_id').length; intI++){
			strElemento = window.opener.document.getElementById('multimedia_id').options[intI].value;
			arrSegmentos = strElemento.split('||');
			intMultimedia_id = arrSegmentos[0];
			strLink = arrSegmentos[1];
			strNombre = arrSegmentos[2];				
			if(window.opener.document.getElementById('multimedia_id').selectedIndex == intI){
				strTituloTmp = strTituloTmp + "<option value='" + strElemento + "' selected>" + (intI + 1) + ": " + strNombre + "</option>";
				strTitleTmp = " " + strNombre + "</font>";
			}else
				strTituloTmp = strTituloTmp + "<option value='" + strElemento + "'>" + (intI + 1) + ": " + strNombre + "</option>";
		}
		strTitulo = strTitulo + '<select id="multimedia_id" name="multimedia_id" onChange="fnSG_Player(document.getElementById(\'multimedia_id\').options[document.getElementById(\'multimedia_id\').selectedIndex].value';
		strTitulo = strTitulo + ' + \'||' + strTitle.replace(/"/g,"\\\'") + '\');">' + strTituloTmp.replace(/"/g,'\"') + '</select>';
		document.getElementById('PopUpPlayList').innerHTML = strTitulo;		
		strTitle = strTitle + strTitleTmp;
		document.getElementById('PopUpSongTitle').innerHTML = strTitle;		
	}

//-->