var cont=0;
var currentState=0;
var currentRemaining =0;
var currentPosition=0;
var indiceVideo = 0;
var flag= 0;
var salta= new Boolean(false);
var showAds = new Boolean(true);
var addRunning = new Boolean(true);
var addEnd= new Boolean(true);
var estadis= new Boolean(true);
var ligaAds ="http://ads.eluniversal.com.mx/RealMedia/ads/adstream_nx.ads/www.eluniversal.com.mx/video@x66";
//var ligaplayer="http://videos.eluniversal.com.mx/flvplayer.swf";
var ligaplayer="http://www.eluniversal.com.mx/flvplayer.swf";

function checaRefresh(salta){
  if(salta==1){
    if(currentState ==1 || currentState==2){
        setTimeout("checaRefresh(1)",(10 * 60) * 1000);
    }else{
        window.location.reload();
    }
  }else{
     setTimeout("checaRefresh(1)",(10 *60) *1000);

  }
}

function reproduceVideo(idVideo,status){
				salta=false;
            sendEvent('player1','stop');
            loadFile('player1',{file:ligaAds,autostart:'true',category:'commercial'});
            indiceVideo=idVideo;
            //generaCarrusel(0);
				flag=1;
            showAds=false;
				
}

function loadFile(swf,obj) { 
    thisMovie(swf).loadFile(obj); 
}
function sendEvent(swf,typ,prm) { 
  thisMovie(swf).sendEvent(typ,prm); 
}

function thisMovie(swf) {
     if(navigator.appName.indexOf("Microsoft") != -1) {
        return window[swf];
     } else {
        return document[swf];
     }
}

function getUpdate(typ,pr1,pr2,pid) {
	if(pid != "null") {
		if(typ == "size" && pr1 != undefined ) {
			if(showAds==true){
	 			sendEvent('player1','stop');
				loadFile('player1',{file:ligaAds,autostart:'true',category:'commercial',linkfromdisplay:true});
				showAds=false;
				addRunning=true;
			flag=1;
			}
		}
		if(typ == "state"){
		 currentState = pr1;
		}
		if(typ == "state" && pr1==3){
			addEnd=true;
			if(salta==false){
	 		sendEvent('player1','stop');
			loadFile('player1',{file:archivoFlv[indiceVideo],autostart:'true',category:'video'});
	 		sendEvent('player1','playpause');
			flag=0;
			salta=true;
			addRunning=false;
         }else{
				if(indiceVideo==0){
					loadFile('player1',{file:archivoFlv[0],autostart:'true',category:'video'});
					sendEvent('player1','stop');
					showAds=false;
					flag=1;
					indiceVideo=0;
					addRunning=true;
					//generaCarrusel(0);
					exit;
				}else{
					salta=false;
					sendEvent('player1','stop');
					loadFile('player1',{file:ligaAds,autostart:'true',category:'commercial'});
					showAds=false;
					flag=1;
					indiceVideo=indiceVideo+1;
					//generaCarrusel(0);

				}
			}
		}
		if(typ == "load" && showAds==false  && (addRunning==true)){
			addRunning=false;
			addEnd=false;
		}
		if(typ == "load" && showAds==false  && addRunning==false){
			if(flag==0){
				sendEvent('player1','playpause');
			flag=1;
			}
		}
		if(typ == "item" && pr1==0 && flag==1){
				sendEvent('player1','playpause');
				if(addRunning==false){
				sendEvent('player1','playpause');
				}
			flag=0;
		}
		if(typ == "time") {
			currentPosition = pr1; pr2 == undefined ? null: currentRemaining = Math.round(pr2);
			if((currentPosition==5) && currentState==2 && addRunning==false){
				var obj = thisMovie("player1").itemData(0);
				if(obj["category"]=="video" && addEnd==true){
		               		addEnd=false;
					var hit="http://hits.eluniversal.com.mx/accesos/accesos_detalle.php?fin=fin&var_cabeza="+archivoTituloSin[indiceVideo]+"&var_secc=300&p_id_nota="+archivoId[indiceVideo]+"&ini=ini&autor=crux";
					var tmpHit = document.getElementById("msgHit"); if (tmpHit) { tmpHit.innerHTML = " <image src=" + hit + " width=1 height=1>"; }
				}
			}
		}
   }
};
	
function generaCarrusel(ini){
	var textCarrusel;
	var tmpSec ;
        var tmpTit ;
        var tmpTexto;
        var tmpFecha;
	var textoInferior;
	var tip;
	textCarrusel="<br> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"462\">";
	textCarrusel="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"217\"> <tbody> ";
	for(x=ini; x< 8; x++) {
	   var tmpCarrusel = document.getElementById("zonaCarrusel");
	   if(x==indiceVideo){ x++; }		
		var tip="' <div class=&quot;argrisvideo12&quot;>"+archivoTexto[x]+"</div>', TITLE, '<div class=&quot;geoamarillo14b&quot;>"+archivoTitulo[x]+"</div>', BGCOLOR, '#666666', TITLEFONTCOLOR, '#fc3' , FONTCOLOR, '#333333', FONTSIZE, '10pt', FONTFACE, 'Georgia, Times New Roman, Times, serif', WIDTH, 250, BORDERCOLOR, '#333333'";
		textCarrusel= textCarrusel + "<tr align=left> <td valign=\"top\" width=\"104\" ><span class=\"tbgris12\">"+archivoSec[x]+"</span><br>";
		textCarrusel= textCarrusel + "<a href=\"javascript:reproduceVideo("+x+",\'true\');\" onMouseover=\"Tip("+ tip +");\" onMouseout=\"UnTip();\"><div id=\"foto"+x+"\"><img src=\""+archivoMiniImg[x]+"\" alt=\""+archivoTitulo[x]+": "+archivoTexto[x]+"\" border=\"0\" height=\"72\" width=\"104\"></div></a></td>";
		textCarrusel= textCarrusel + "<td width=\"9\"></td>";
		textCarrusel= textCarrusel + "<td valign=\"top\" width=\"104\">";
		textCarrusel= textCarrusel + "<div align=\"left\">";
		x++;
      if(x==indiceVideo){ x++; }
		var tip="' <div class=&quot;argrisvideo12&quot;>"+archivoTexto[x]+"</div>', TITLE, '<div class=&quot;geoamarillo14b&quot;>"+archivoTitulo[x]+"</div>', BGCOLOR, '#666666', TITLEFONTCOLOR, '#fc3' , FONTCOLOR, '#333333', FONTSIZE, '10pt', FONTFACE, 'Georgia, Times New Roman, Times, serif', WIDTH, 250, BORDERCOLOR, '#333333'";
		textCarrusel= textCarrusel + "<span class=\"tbgris12\">"+archivoSec[x]+"</span><br>";
		textCarrusel= textCarrusel + "<a href=\"javascript:reproduceVideo("+x+",\'true\');\" onMouseover=\"Tip("+ tip +");\" onMouseout=\"UnTip();\"><div id=\"foto"+x+"\"><img src=\""+archivoMiniImg[x]+"\" alt=\""+archivoTitulo[x]+": "+archivoTexto[x]+"\" border=\"0\" height=\"72\" width=\"104\"></div></a></td>";
		textCarrusel= textCarrusel + "<td width=\"9\"></td>";
		textCarrusel= textCarrusel + "</td> </tr> <tr height=\"6\">";
		textCarrusel= textCarrusel + "<td height=\"6\" width=\"104\"></td>";
		textCarrusel= textCarrusel + "<td height=\"6\" width=\"9\"></td>";
		textCarrusel= textCarrusel + "<td height=\"6\" width=\"104\"></td> </tr>";

	}	
	textCarrusel= textCarrusel +	"</table>"; 

	if (tmpCarrusel) {
	   tmpCarrusel.innerHTML = textCarrusel;
	}
	defineTextoInferior(indiceVideo);
	tmpSec = document.getElementById("zonaSeccion"); if (tmpSec) { tmpSec.innerHTML = archivoSec[indiceVideo]; }

}
function defineTextoInferior(id){
	var textoInferior=" <span class=\"geoamarillo14b\">"+archivoTitulo[id]+"</span><br>";
        textoInferior=textoInferior+" <span class=\"argris12\">"+archivoTexto[id]+"</span><br>";
        textoInferior=textoInferior+" <span class=\"arblanco11\">"+archivoFecha[id]+"</span> ";
        tmpTextoInferior = document.getElementById("zonaInfoVideo"); if (tmpTextoInferior) { tmpTextoInferior.innerHTML = textoInferior; }
}
var s2 = new SWFObject(ligaplayer,'player1','302','280','8');
   s2.addParam('allowfullscreen','true');
   s2.addParam('allowScriptAccess','always');
   s2.addParam('wmode', 'opaque');
   s2.addVariable('file',archivoFlv[0]);
   s2.addVariable('image',archivoImg[0]);
   s2.addVariable('displaywidth','302');
   s2.addVariable('displayheight','260');
   s2.addVariable('backcolor','0x000000');
   s2.addVariable('frontcolor','0xCCCCCC');
   s2.addVariable('lightcolor','0x557722');
   s2.addVariable('javascriptid','player1');
   s2.addVariable('category','videos');
   s2.addVariable('autostart','false');
   s2.addVariable('linkfromdisplay','true');
   s2.addVariable('enablejs','true');
   s2.addVariable('width','302');
   s2.addVariable('height','280');
   s2.write('zonaPlayer');
//generaCarrusel(0);
//checaRefresh(0);
function placebo(){
}


