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://www.eluniversaltv.com.mx/flvplayer.swf";

function checaRefresh(salta){
  if(salta==1){
    if(currentState ==1 || currentState==2){
		  exit;
        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){
				if(pid=='player1'){
	 			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){
			if(salta==false){
			if( pid=='player1'){
			addEnd=true;
	 		sendEvent('player1','stop');
			loadFile('player1',{file:archivoFlv[indiceVideo],autostart:'true',category:'videos'});
	 		sendEvent('player1','playpause');
			salta=true;
			addRunning=false;
			}else{
			salta=false;
			addEnd=false;
			addRunning=true;
			}
         }else{
				if(indiceVideo==5){
					loadFile('player1',{file:archivoFlv[0],autostart:'true',category:'videos'});
					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){
				if(pid=='player1'){
				var obj = thisMovie("player1").itemData(0);
				   if(obj["category"]=="videos" && 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>"; }
				   }
				}else{
					if(addEnd==false){
					addEnd=true;
					showAds=true;
					salta=false;
					datoHits=pid.split("|");
                                        var hit="http://hits.eluniversal.com.mx/accesos/accesos_detalle.php?p_id_nota="+datoHits[0]+"&var_cabeza="+datoHits[1]+"&var_secc=300&fin=fin";
                                        var tmpHit = document.getElementById("msgHit"); if (tmpHit) { tmpHit.innerHTML = " <image src=" + hit + " width=1 height=1>"; }
					}else{
					   //addEnd=false;
					//addRunning=true;
					//salta=false;
					}
				}
			}
		}
   }
};

	
function generaCarrusel(ini){
  var txtImg="" ;
  var txtTit="" ;
  var tmpImg ;
  var tmpTit ;
  var y=1;
  for(x=ini; x<= 5; x++) {
	   if(x==indiceVideo){ x++; }
    txtImg='<a href="javascript:reproduceVideo('+x+',\'true\')"><img src="'+archivoMiniImg[x]+'" alt="" height="59" width="105" border="0" /></a>';
    tmpImg=document.getElementById("barraImg"+y);if (tmpImg) { tmpImg.innerHTML = txtImg; }
    txtTit='<a href="javascript:reproduceVideo('+x+',\'true\')"><span class="tahazul11">'+archivoTitulo[x]+'</span></a>';
    tmpTit=document.getElementById("barraTxt"+y);if (tmpTit) { tmpTit.innerHTML = txtTit; }
    //if(y > indiceVideo){y++;}
    y++;
  }
	defineTextoInferior(indiceVideo);
}
function defineTextoInferior(id){
   var txtSeccion=archivoSec[id];
   var tmpTxtSeccion=document.getElementById("seccionP");if (tmpTxtSeccion) { tmpTxtSeccion.innerHTML = txtSeccion; } 
   var txtTitulo=archivoTitulo[id];
   var tmpTxtTitulo=document.getElementById("tituloP");if (tmpTxtTitulo) { tmpTxtTitulo.innerHTML = txtTitulo; } 
   var txtDesc=archivoTexto[id];
   var tmpTxtDesc=document.getElementById("descP");if (tmpTxtDesc) { tmpTxtDesc.innerHTML = txtDesc; } 
   var txtFecha=archivoFecha[id];
   var tmpTxtFecha=document.getElementById("fechaP");if (tmpTxtFecha) { tmpTxtFecha.innerHTML = txtFecha; } 
   var nada="";
   var tmpNada=document.getElementById("loading");if (tmpNada) { tmpNada.innerHTML = nada; } 
   var coment="";
	 var invicoment='<a href=detalle'+archivoId[id]+'.html>comenta este video</a>';
	 
   if(archivoComent[id]==""){coment='0'}else{coment=archivoComent[id]}
   var tmpComent=document.getElementById("cantComentarios");if (tmpComent) { tmpComent.innerHTML = coment; }
   
	 var tmpinviComent=document.getElementById("inviComentarios");if (tmpinviComent) { tmpinviComent.innerHTML = invicoment; } 
	 
   //var tools='<img src="img/tools.gif" alt="" usemap="#toolsc5f69da0" border="0" height="15" width="186"> <map name="toolsc5f69da0"> <area shape="rect" coords="172,3,183,13" target="_blank" href="http://www.eluniversaltv.com.mx/rss/universalTV.xml" alt="rss"> <area shape="rect" coords="143,3,163,12" href="javascript:despliega(\'http://www.eluniversaltv.com.mx/video_envia_mail_new.html?p_id='+archivoId[id]+'&amp;p_fold=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html&amp;p_cabeza='+archivoTituloSin[id]+'\',500,400);" alt="Envía a un amigo"> <area shape="rect" coords="117,2,129,14" target="_blank" href="http://www.digg.com/submit?url=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Digg"> <area shape="rect" coords="94,2,109,12" target="_blank" href="http://meneame.net/submit.php?url=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Meneame"> <area shape="rect" coords="70,2,87,12" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Yahoo"> <area shape="rect" coords="47,3,60,12" target="_blank" href="http://www.technorati.com/search/http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Technorati"> <area shape="rect" coords="24,3,37,14" target="_blank" href="http://del.icio.us/post?title='+archivoTituloSin[id]+'&amp;url=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Delicious"> <area shape="rect" coords="2,3,14,12" target="_blank" href="http://www.facebook.com/sharer.php?u=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html&amp;t='+archivoTituloSin[id]+'" alt="Compartir Facebook"> </map> ';
	 var tools='<a href="http://twitter.com/home?status='+archivoTituloSin[id]+' http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" target="_blank" ><img width=13 height=13 src=/img/icono_twitter.gif alt=Twitter></a>&nbsp;<a href="http://www.google.com/bookmarks/mark?op=add&bkmk=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html&title='+archivoTituloSin[id]+'" target="_blank" ><img width=13 height=13 src=/img/icono_google.gif alt=Google></a>&nbsp;';
   tools= tools+'<a href="http://www.linkedin.com/shareArticle?mini=true&url=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html&title='+archivoTituloSin[id]+'" target="_blank" ><img width=13 height=13 src=/img/icono_linkedin.gif alt=LinkedIn></a>&nbsp;<img src="img/tools.gif" alt="" usemap="#toolsc5f69da0" border="0" height="15" width="186"> <map name="toolsc5f69da0"> <area shape="rect" coords="172,3,183,13" target="_blank" href="http://www.eluniversaltv.com.mx/rss/universalTV.xml" alt="rss"> <area shape="rect" coords="143,3,163,12" href="javascript:despliega(\'http://www.eluniversaltv.com.mx/video_envia_mail_new.html?p_id='+archivoId[id]+'&amp;p_fold=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html&amp;p_cabeza='+archivoTituloSin[id]+'\',500,400);" alt="Envía a un amigo"> <area shape="rect" coords="117,2,129,14" target="_blank" href="http://www.digg.com/submit?url=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Digg"> <area shape="rect" coords="94,2,109,12" target="_blank" href="http://meneame.net/submit.php?url=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Meneame"> <area shape="rect" coords="70,2,87,12" target="_blank" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Yahoo"> <area shape="rect" coords="47,3,60,12" target="_blank" href="http://www.technorati.com/search/http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Technorati"> <area shape="rect" coords="24,3,37,14" target="_blank" href="http://del.icio.us/post?title='+archivoTituloSin[id]+'&amp;url=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html" alt="Compartir Delicious"> <area shape="rect" coords="2,3,14,12" target="_blank" href="http://www.facebook.com/sharer.php?u=http://www.eluniversaltv.com.mx/detalle'+archivoId[id]+'.html&amp;t='+archivoTituloSin[id]+'" alt="Compartir Facebook"> </map> ';
	 	 
 var tmpTools=document.getElementById("toolsP");if (tmpTools) { tmpTools.innerHTML = tools; }
   fratings(archivoId[id]);
}
var s2 = new SWFObject(ligaplayer,'player1','620','370','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','620');
   s2.addVariable('displayheight','370');
   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','620');
   s2.addVariable('height','370');
   s2.write('showPlayer1');
generaCarrusel(0);
checaRefresh(0);
function placebo(){
}

