
//Inicializacion de las variables para guardar los ids de los vídeos 
//que hay simultáneamente
if(typeof(video_ids) == 'undefined'){ var video_ids=new Array(); }
if(typeof(videos) == 'undefined'){ var videos={}; }


/***********************************************/
//Se llamará desde el flash cuando se quiera minimizar
function minimizar(id, args) {
	

	
	var divVideoObj = document.getElementById("divVideo_"+id);
	var auxWidth = videos[id]['width'];
	var auxHeight = videos[id]['height'];

	if(!auxWidth.match("%") && !auxWidth.match("px")){
		auxWidth += "px";
	}
	divVideoObj.style.width = auxWidth;

	if(!auxHeight.match("%") && !auxHeight.match("px")){
		auxHeight += "px";
	}
	divVideoObj.style.height = auxHeight;
    divVideoObj.style.position = "relative";
	divVideoObj.style.top = "0px";
	divVideoObj.style.left = "0px";
	
	//Vuelve a mostrar los div de listas y de los vídeos
	for (i in video_ids){
		var element = document.getElementById("divVideo_"+video_ids[i]);
		if (element)
			element.style.display = "block"; 
	}
		
}

/***********************************************/
//Se llamará desde el flash cuando se quiera maximizar
function maximizar(id, args) {

	//Oculta todos los div de listas y vídeos para que no interfieran
	for (i in video_ids){
		if(video_ids[i] != id){
			var element = document.getElementById("divVideo_"+video_ids[i]);
			if (element)
				element.style.display = "none";
		}
	}
	
	
	var divVideoObj = document.getElementById("divVideo_"+id);
	//Posición según el scroll
	var auxTop = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
	    auxTop = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	    auxTop = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	    auxTop = document.documentElement.scrollTop;
	}
	var auxRealTop = getRealTop(divVideoObj);
	auxTop -= auxRealTop;
	auxTop += "px";
	
	//Tamaños
	var auxHeight = 0;
	if( typeof( window.innerHeight ) == 'number' ) {
		auxHeight = window.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		auxHeight = document.documentElement.clientHeight;
	} else if( document.body && document.body.clientHeight ) {
		auxHeight = document.body.clientHeight;
	}
	auxHeight += "px";

	var auxWidth = 0;
	if( document.body && document.body.clientWidth ) {
	    auxWidth = document.body.clientWidth;
	} else if( typeof( window.innerWidth ) == 'number' ) {
		auxWidth = window.innerWidth;
	} else if( document.documentElement && document.documentElement.clientWidth ) {
	    auxWidth = document.documentElement.clientWidth;
	}
	auxWidth += "px";
	
	var auxRealLeft = getRealLeft(divVideoObj);
    divVideoObj.style.position = "absolute";
	divVideoObj.style.left = (-1*auxRealLeft)+"px";
	divVideoObj.style.top = auxTop;
	divVideoObj.style.width = auxWidth;
	divVideoObj.style.height = auxHeight;
	//divVideoObj.style.backgroundColor = "#ffcc00";	


}


function getRealLeft(objeto) {
	xPos = 0;
	if(objeto){
//		xPos += objeto.offsetLeft;
		tempEl = objeto.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			if(typeof(tempEl.offsetParent) != 'undefined'){
				tempEl = tempEl.offsetParent;
			}else{
				tempEl = null;
			}
		}
	}
	return xPos;
}

function getRealTop(objeto) {
	yPos = 0;
	if(objeto){
//		yPos += objeto.offsetTop;
		tempEl = objeto.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			if(typeof(tempEl.offsetParent) != 'undefined'){
				tempEl = tempEl.offsetParent;
			}else{
				tempEl = null;
			}
		}
	}
	return yPos;
}

function loadVideo (div,idCanal){
	var aux = "";
	aux += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
	aux += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="480px" height="360px" id="video" align="middle">';
	aux += '<param name="allowScriptAccess" value="sameDomain" />';
	aux += '<param name="movie" value="/flash/videoCanal.swf" />';
	aux += '<param name="FlashVars" value="urlVideo=/ws/videoCanalListaXML.php?idCanal=' + idCanal + '&publi_fv=&canal_fv=' + idCanal + ' &id_fv=media" />';
	aux += '<param name="quality" value="best" />';
	aux += '<param name="wmode" value="transparent" />';
	aux += '<param name="allowFullScreen" value="true" />';
	aux += '<param name="bgcolor" value="#000000" />';
	aux += '<embed src="/flash/videoCanal.swf" FlashVars="urlVideo=/ws/videoCanalListaXML.php?idCanal=' + idCanal +'&publi_fv=&canal_fv=' + idCanal + '&id_fv=media"';
	aux += 'quality="best" bgcolor="#000000" wmode="transparent" width="100%" height="100%" swliveconnect="true" name="video" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="../../../../www.adobe.com/shockwave/download/downloaddbe9.html" />';
	aux += '</object>';
	var DIVFLASH = document.getElementById("div_"+div);
	DIVFLASH.innerHTML = aux;

};

