/**************************************
@Clase SGparrilla 
***************************************
@Autor: Sergio Cerrillo
@Fecha: 2007/08/23
@Dependencia: clsajxgrg.js, jsEPG.js
@
*/

var jsParrilla = Array();
var jsNumParrilla=0;

var SGparrilla = Class.create();

var positionActual=0;
var selectActual=0;
var mydayActual=0;
var heightEPG="";
var heightChannel="";
var minews=0;
var fecha = new Date();
		
SGparrilla.prototype = {
   
	/**********************************************************************************************
	* Constructor
	**********************************************************************************************/
	initialize: function(capa, showDebug, parrillaWidth, parrillaHeight, pathServer, showFiltros, isMini, curDate, startDate){
		/*==========================================================================
		== Variables recogidas por parámetros
		==========================================================================*/
		this.capa = capa; // ID de la capa DIV donde aparecerán los resultados
		jsNumParrilla=jsParrilla.length;
		jsParrilla[jsNumParrilla]=this;
		if (this.capa==undefined){
			this._error=true;
			this._errorTxt+="- El nombre de capa proporcionado no es válido.";
			this.showError(true);
		}
		
		this._parrillaWidth=parseInt(parrillaWidth);
		this._parrillaHeight=parseInt(parrillaHeight);
		this._canalesWidth=42;
		this._canalHeight=50;//60;
		this._lineEPGHeight=54;//64;
		this._programHeight=90;//98;
		this._horarioHeight=30;
		
		this._pathServer=pathServer;
		this._showFiltros=showFiltros;
		this._isMini=isMini;
			
		this._horaWidth=165;
		this._padding=10;
		this.showDebug=showDebug;
		this.capaDebug=null;
		if (this.showDebug==undefined) this.showDebug=false;
		
		this.nomNavegador = navigator.appName;
		this.navegador = 0; //< 1=ie; 2=firefox
		if (this.nomNavegador == "Microsoft Internet Explorer"){
  	   this.ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; }}()||@*/0;
			 this.navegador=1;
		}
		else
			this.navegador=2;
    if (this.nomNavegador =="Netscape")
      this.navegador=3;
        /*==========================================================================
		== Recogemos enventos
		==========================================================================*/
		
		if (this.navegador==1){
			document.obj = this;
			document.onmousedown = this._doEvents;
			document.onmousemove = this._doEvents;
			document.onmouseup = this._doEvents;
			document.onkeydown = this._doKeyDown;
			document.onclick = this._doClick;
			document.onselectstart = function () { return false; };
		}else{
			window.obj = this;
			window.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP | Event.CLICK);
			window.onmousedown = this._doEvents; 
			window.onmousemove = this._doEvents; 
			window.onmouseup = this._doEvents; 
			window.onkeydown = this._doKeyDown;
			window.onclick = this._doClick;
		}
		document.navegador=this.navegador;

		/*==========================================================================
		== Variables obligatorias
		==========================================================================*/
		this._aDias = {0:"Domingo", 1:"Lunes", 2:"Martes", 3:"Miércoles", 4:"Jueves", 5:"Viernes", 6:"Sábado"};
		this._aMeses = {0:"Enero", 1:"Febrero", 2:"Marzo", 3:"Abril", 4:"Mayo", 5:"Junio", 6:"Julio", 7:"Agosto", 8:"Septiembre", 9:"Octubre", 10:"Noviembre", 11:"Diciembre"};
		this._objOwner = null;
		this._error=false;
		this._errorTxt="";
		this._result=null;
		this._capaCanales = null;
		this._capaCanalestop = 0;
		this._capaCanalesleft = 0;
		this._capaContenido=null;
		this._capaEPG = null;
		this._capaProgram = null;
		this._capaEPGtop = -1;
		this._capaEPGleft = 0;
		this._capaHorario = null;
		this._capaHorariotop = 0;
		this._capaHorarioleft = 0;
		this._enableDrag=false;
		this.moving=false;
		this.isOpenProgram=false;
		this.firstTime=true;
		this._eventDatos = Array();
		this._popup="";
		this._numDias = 0;
		myCategoria="";
		myTitle="";
		miFecha="";
		miFechaCodigoPostal="";
		idProgramclick="";
		miroute="";
		Safari=false;
		var miCanal="";
		
		this._hoyTxt="";
		this.currentDateTXT="";
        
		// BUG 000957: Log current date
		if(curDate)
		{
/*
 	[2010-05-19] +J
  	Bug 2508
			
            var fechaactualizada=getCookie("inicioparrilla","");
*/
			var fechaactualizada = ""; //+J
			
		    fechaactualizada.replaceAll("-0","-");
		    if ((fechaactualizada!="") && (fechaactualizada!="undefined"))
		    {
		 	  this.currentDateTXT=fechaactualizada;
			  this._hoyTxt=fechaactualizada;
			  datos=fechaactualizada.replaceAll(":","-").replaceAll(" ","-").split("-");
			  document.cookie="inicioparrilla=";
		    }
		    else
		    {
		 	  this.currentDateTXT=curDate;
			  this._hoyTxt=curDate;
			  datos=curDate.replaceAll(":","-").replaceAll(" ","-").split("-");
		    }
		 	
			fecha.setHours(Number(datos[3]));
			fecha.setDate(Number(datos[2]));
			fecha.setMonth(Number(datos[1])-1);
			fecha.setFullYear(Number(datos[0]));
			this.currentDate=datos;
			
		  
		}
		else 
		{
		    this.currentDate=Array(fecha.getFullYear(),fecha.getMonth()+1,fecha.getDate()+1,fecha.getHours(),fecha.getMinutes(),fecha.getSeconds());
		}
        
        this.startDate=startDate.split("-");
	    this._hoyTxt=""+this._aDias[fecha.getDay()]+", "+fecha.getDate()+" de "+this._aMeses[fecha.getMonth()];

        fecha.setMinutes(0);
        fecha.setSeconds(0);
			
		this._Dia = (""+fecha.getDate()).toDigit(2);
		this._Mes = (""+(fecha.getMonth()+1)).toDigit(2);
		this._Year = (""+(fecha.getYear()-100)).toDigit(2);
		this._FullYear = fecha.getFullYear();

		this._Hora = (""+fecha.getHours()).toDigit(2);
		this._Minuto = (""+fecha.getMinutes()).toDigit(2);
		
        this.fecIni = ""+this._FullYear+"-"+(""+(this._Mes-1)).toDigit(2)+"-"+this._Dia+" "+this._Hora+":"+this._Minuto;        
		
		this.horaIni=0;

		this._offset=-95;

		this.ajx = new clsAjx()
		this.ajx_TxtCargando="... cargando ...";

		this._epg = Array();
		this._epgByID = Array();
		this._Channels = Array();
		this._ChannelsByID = Array();
		this._Programs = Array();
		this._onlyChannelsTxt = "";
		this._horario = Array();
		
		this.mousePosX=0;
		this.mousePosY=0;
		this.mousePosXnew=0;
		this.mousePosYnew=0;
//		this.mousePosOffsetX = 0;
//		this.mousePosOffsetY = 0;
    

		this.initializePanel();
	},
	
	/**********************************************************************************************
	* initializePanel
	**********************************************************************************************/
	initializePanel: function (){
		    
		    //PANEL WIDGET
		    YAHOO.namespace("example.container");
			YAHOO.example.container.panel2 = new YAHOO.widget.Panel("panel2", 
				{ 
					width:"449px", 
					close:false,
					visible:false, 
					fixedcenter:false,
					draggable:false, 
					x: 10,
					y: 10,
					modal:true,
					constraintoviewport:false, 
					underlay: "none",
					effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.5} 
				} 
			);
			YAHOO.example.container.panel2.setHeader(" ");
			YAHOO.example.container.panel2.setBody("<div id='rstpopup'>... cargando ... </div>");
			YAHOO.example.container.panel2.setFooter("");
		    YAHOO.example.container.panel2.render(document.body);

			YAHOO.example.container.panelbig = new YAHOO.widget.Panel("panelbig", 
				{ 
					width:"901px", 
					close:false,
					visible:false, 
					fixedcenter:false,
					draggable:false, 
					x: 10,
					y: 10,
					modal:true,
					constraintoviewport:false, 
					underlay: "none",
					effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.5} 
				} 
			);
			YAHOO.example.container.panelbig.setHeader(" ");
			YAHOO.example.container.panelbig.setBody("<div id='rstpopupbig'>... cargando ... </div>");
			YAHOO.example.container.panelbig.setFooter("");
			YAHOO.example.container.panelbig.render(document.body);

			YAHOO.example.container.panelmedium = new YAHOO.widget.Panel("panelmedium", 
				{ 
					width:"601px", 
					close:false,
					visible:false, 
					fixedcenter:false,
					draggable:false, 
					x: 10,
					y: 10,
					modal:true,
					constraintoviewport:false, 
					underlay: "none",
					effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.5} 
				} 
			);
			YAHOO.example.container.panelmedium.setHeader(" ");
			YAHOO.example.container.panelmedium.setBody("<div id='rstpopupmedium'>... cargando ... </div>");
			YAHOO.example.container.panelmedium.setFooter("");
			YAHOO.example.container.panelmedium.render(document.body);
   
	},
	
	/**********************************************************************************************
	* popupPanel
	**********************************************************************************************/
	popupPanel: function(tipo){
        
        if(document.getElementById("ajaxloading") && document.getElementById("ajaxloading").style.display!="none")
		    return;
		   
		var bool=false;
		var tmpparams="";
		var tmpcapa="rstpopup";
		switch(tipo){
			case "autonomicos":
			case "tdt":
				YAHOO.example.container.panel2.show();
				bool=true;
				tmpparams="";
			break;
			case "vercanal":
				YAHOO.example.container.panel2.show();
				bool=true;
				try {
						if (miCanal==""){
							  
								tmpparams="&idChannel="+this._eventDatos["idChannel"];
								this.action="vercanal::"+this._eventDatos["idChannel"];
					  }
					  else{
					  	  tmpparams="&idChannel="+miCanal;
								this.action="vercanal::"+miCanal;
								miCanal="";
					  }
			  } catch(error) {
			  			  
								tmpparams="&idChannel="+this._eventDatos["idChannel"];
								this.action="vercanal::"+this._eventDatos["idChannel"];
					
			  }
			  
			break;
			case "vernextcanal":
				YAHOO.example.container.panel2.show();
				bool=true;
				tipo="vercanal";
				tmpparams="&go=next&idChannel="+this._eventDatos["idChannel"]+"&date="+this._eventDatos["date"];
			break;
			case "vercanaldig":
				YAHOO.example.container.panelbig.show();
				bool=true;
				tmpparams="";
				tmpcapa+="big";
			break;
			case "vertodos":
				YAHOO.example.container.panelbig.show();
				bool=true;
				tmpparams="";
				tmpcapa+="big";
			break;
			case "vertodossmall":
				YAHOO.example.container.panelmedium.show();
				bool=true;
				tmpparams="";
				tmpcapa+="medium";
			break;
		}
		
		if (bool)
		{
			  
			 
				if (document.getElementById(tmpcapa)!=undefined)
				{
					
					var params = "do=ajax@Parrilla&accion="+tipo+tmpparams;
					this.ajx.setTxtCargando("&nbsp;&nbsp;Cargando...");
					this.ajx.objOwner = this;
					this.ajx.setValores(params);
					this.ajx.setURL("index.php");
					this.ajx.ResultinTA(false);
					this.ajx.setCapa(tmpcapa);
					this.ajx.setCallBack("");
					this.ajx.runAjx();
				}
				else parent.Create.alerta("No se puede mostrar panel.",miroute);
		}
	},
	
	/**********************************************************************************************
	* disableSelection
	**********************************************************************************************/
	disableSelection: function (target){
		if (typeof target.onselectstart!="undefined") //IE route
			target.onselectstart=function(){return false}
		else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
			target.style.MozUserSelect="none"
		else //All other route (ie: Opera)
			target.onmousedown=function(){return false}
		//target.style.cursor = "default"
	},
  /*******************************************************************************************
  **  Show Programs channels automatic.
  *********************************************************************************************/
  _doAutomatic: function(cadena){
  	 miCanal=cadena;
  	 this.popupPanel("vercanal");
  	 
  	 
  	
  },
	/**********************************************************************************************
	* _doEvents
	**********************************************************************************************/
	_doEvents: function(e){
		  var tmpid=null;
		var tmpname=null;
		if(document.navegador==1)
		{
		    tmpid = event.srcElement.id;
			tmpname = event.srcElement.name;
				
		}
		else
		{
			
			
			try
			{
				tmpname = e.originalTarget.getAttribute("name");
				tmpid = e.originalTarget.id;
			}
			catch(exc)
			{
			  tmpid= e.target.id;
			  tmpname=e.target.name	
			  Safari=true;
			//this.obj._info("warning", 0, "No se ha podido recuperar la propiedad ID. ["+e.originalTarget+"::"+tmpname+"::"+exc.description+"]");
			}
			event=e;
		}
		/*if (event.type!="mousemove")
				 alert(event.type+"--"+tmpid+"--"+tmpname);
				 */
		if (tmpname=="epg" || tmpname=='button' || Safari==true ){
			switch(event.type){
				case "mousedown":
					this.obj._capaEPGtop=this.obj._capaEPG.offsetTop;
					this.obj._capaEPGleft=this.obj._capaEPG.offsetLeft;
					this.obj._capaCanalestop=this.obj._capaCanales.offsetTop;
					this.obj._capaCanalesleft=this.obj._capaCanales.offsetLeft;
					this.obj._capaHorariotop=this.obj._capaHorario.offsetTop;
					this.obj._capaHorarioleft=this.obj._capaHorario.offsetLeft;
					
					if(tmpid!="btn_ficha")
					{
					    this.obj._enableDrag=true;
					}
					this.obj.getMousePos(false,event);
				break;
				case "mouseup":
          if(this.obj._chkFinalEPG() || ( document.getElementById("ajaxloading") && document.getElementById("ajaxloading").style.display=="block") )
					{
		                this.obj._enableDrag=false;
		                this.obj._capaEPG.style.cursor="auto";
					          this.obj.moving=false;
		                return;
		            }

					//Miramos si ha pinchado para mostrar la ficha de programa
					if (tmpname=="epg" || Safari)
					{
					    if(tmpid=="btncerrar") idProgramclick="";
					    this.obj.restoreHeight();
					}
					if (tmpid.indexOf("ellipsisSpan")>=0 && !this.obj.moving){
						this.obj._eventDatos = Array();
						a_tmpid=tmpid.split("#");
						idChannel = a_tmpid[0].replace("ellipsisSpan", "");
						idProgram = a_tmpid[1];
						idEvent = a_tmpid[2];
						this.obj._info("info", 0, "Solicitando ficha de programa id:"+idProgram);
						this.obj._eventDatos = {"idChannel":idChannel, "idProgram":idProgram, "idEvent":idEvent};
						
						//bug 1060 double click in  Program tab
						if (idProgramclick=="")
						{
							this.obj.getProgram(idProgram,idEvent);
							idProgramclick=idProgram;
						}
						else
						{
						    if (idProgramclick!=idProgram)
						    {
						       this.obj.getProgram(idProgram,idEvent);
						       idProgramclick=idProgram;
						    }
						    else
						    	idProgramclick="";
						}
					}
					// miramos si ha pulsado el botón de "Ver Hoy" en columna canales
					if (tmpid.indexOf("vercanal")>=0 && (document.navegador==1 || !this.obj.moving))
					{
						tmpid=tmpid.replace("vercanal#", "");
						this.obj._eventDatos = Array();
						this.obj._eventDatos = {"idChannel":tmpid};
						
						this.obj.popupPanel("vercanal");
						this.obj._popup="vercanal";
					}
					
					// miramos si a pulsado el link del dia siguiente
					if (tmpid.indexOf("vernextcanal")>=0 && (document.navegador==1 || !this.obj.moving))
					{
						
						var tab = tmpid.replace("vernextcanal#", "").split('&');
						this.obj._eventDatos = {"idChannel":tab[0],"date":tab[1]};
                        this.obj.popupPanel("vernextcanal");
						this.obj._popup="vernextcanal";
					}
					
					// miramos si ha pulsado algun check del filtro de canales
					if (tmpid.indexOf("chk")>=0){
						var el = document.getElementById(tmpid);
						var aselch = tmpid.split("#");
						if (aselch.length){
							var sel = document.getElementById("selchannels");
							sel.value = sel.value.replaceAll(";"+aselch[1]+";", ";");
							if(!el.checked)
							{
								sel.value+=aselch[1]+";";
							}
						}
					}
					
					//Miramos si ha pinchado en los botones de scroll
					switch (tmpid){
						case "left":
						case "right":
						case "up":
						case "down":
						    idProgramclick="";
				        this.obj.restoreHeight();
							  this.obj._scrollMe(tmpid);
						break;
						case "btn_buscar": //Miramos si ha pinchado en los botones de filtro
							this.obj.gotoHora( (document.navegador==1) ? event.srcElement : e.originalTarget );
						break;
						case "btn_autonomicos": 
						  
					    miFechaCodigoPostal=this.obj.currentDateTXT;
							this.obj.popupPanel("autonomicos");
							this.obj._popup="autonomicos";
						break;
						case "btn_parrilla":
						    parent.Create.popup("miparrilla","panelPopup",true,false);
						break;
						case "btn_tdt": 
							this.obj.popupPanel("tdt");
							this.obj._popup="tdt";
						break;
						case "btn_digitales": 
							this.obj.popupPanel("vercanaldig");
							this.obj._popup="vercanaldig";
						break;
						case "btn_todos": 
							this.obj.popupPanel("vertodos");
							this.obj._popup="vertodos";
						break;
						case "btnCerrarPopup": 
							YAHOO.example.container.panel2.hide();
							YAHOO.example.container.panelbig.hide();
							YAHOO.example.container.panelmedium.hide();
						break;
						case "btnAceptarverchanneldig": 
							var il = document.getElementById("totalcanal");
							
							if(Check.checkChannelsDig(il.value,miroute))
							{
							var el = document.getElementById("selchannels");
							top.location.href="?do=Programacion&idchannels="+el.value+"&date="+this.obj.currentDateTXT;
						  }
						break;
						case "btnAceptarverchanneltodos": 
							var il = document.getElementById("totalcanal");
							
							if(Check.checkChannelsTodos(il.value,miroute))
							{
							var el = document.getElementById("selchannels");
							top.location.href="?do=Programacion&idchannels="+el.value+"&date="+this.obj.currentDateTXT;;
						  }
						break;
						case "btn_enviar": //Recogemos datos del popup
							this.obj.getDataPopup();
						break;
						case "btn_enviartdt":
							this.obj.getDataPopup();
						break;
 						case "btn_rec": //Miramos si ha pinchado en los botones de rec
                    break;

						case "btn_ficha": //Miramos si ha pinchado en los botones de ficha programa
							if (this.obj._eventDatos["idProgram"]!="")
							{
/*
 	[2010-05-19] +J
  	Bug 2508
 
								document.cookie="inicioparrilla=" + miFecha;
								document.cookie="heightEPG=" + heightEPG;
								document.cookie="heightChannel=" + heightChannel;
*/
								top.window.open(myCategoria + "/"+myTitle + "_" + this.obj._eventDatos["idEvent"] + ".html","_blank");
							}
							else parent.Create.alerta("No se ha podido cargar la ficha.\nPor favor, inténtelo más tarde.",miroute);
								
						break;
						case "btn_noticias": //Miramos si ha pinchado en los botones de noticias programa
						if (this.obj._eventDatos["idProgram"]!="")
						{
/*
 	[2010-05-19] +J
  	Bug 2508
 
								document.cookie="inicioparrilla=" + miFecha;
								document.cookie="heightEPG=" + heightEPG;
								document.cookie="heightChannel=" + heightChannel;
*/
								var misnews=parseInt(minews);
								top.location.href="noticias/"+myTitle+"_"+minews+".html";
								
							}
							else parent.Create.alerta("No se ha podido cargar la ficha.\nPor favor, inténtelo más tarde.",miroute);
					}

					this.obj._enableDrag=false;
					this.obj._capaEPG.style.cursor="auto";
					this.obj.moving=false;
				break;
				case "mousemove":
					if (this.obj._enableDrag)
					{
                        idProgramclick="";
						this.obj.restoreHeight();
						this.obj.moving=true;
						this.obj._capaEPG.style.cursor="move";
						this.obj.getMousePos(true,event);
						this.obj._dragMe();
					}
				break;
				default:
					//alert("type: "+e.type);
				break;
			}
		}else{
			this.obj._enableDrag=false;
			this.obj.moving=false;
		}
		
	}, 

	_doKeyDown: function(event)
    {
        if (window.event && window.event.keyCode == 13)
        {
            return false;
        }
        else if (event && event.which == 13)
            return false;
        return true;
    },
	/**********************************************************************************************
	* _dragMe
	**********************************************************************************************/
	_dragMe: function(){
		
		 
        if (this._Channels.length){
			var el = document.getElementById('epg'+this._Channels[0]._idChannel);
			var el2 = document.getElementById('epg'+this._Channels[this._Channels.length-1]._idChannel);
			var elini = document.getElementById('divepginicio');
			if (el!=undefined && el2!=undefined){
				var movY = (this.mousePosYnew-this.mousePosY);
				var movX = (this.mousePosXnew-this.mousePosX);
	//			this._info("info", 0, ""+el2.offsetTop+" > ("+this._capaEPG.offsetTop+"+"+this._capaEPG.offsetHeight+") || "+movX+">0");
				
				if ((parseInt(this._capaEPG.offsetTop) < parseInt(el.offsetTop) && movY>0) || 
						(parseInt(this._capaEPG.offsetTop) > -(parseInt(el2.offsetTop)-(this._parrillaHeight+this._offset)) && movY<0)
					){//movimiento vertical
						
					this._capaEPG.style.top = this._capaEPGtop + movY;
					this._capaCanales.style.top = this._capaCanalestop + movY;
					if(this._capaEPGtop + movY>0 || this._capaCanalestop + movY>0) 
					{
					    this._capaEPG.style.top=0;
					    this._capaEPGtop=0;
					    this._capaCanales.style.top=0;
					    this._capaCanalestop=0;
					}
				}
				
	//			this._info("info", 0, ""+this.getOffsetLeft(elini)+" < "+this._capaEPG.offsetLeft+" && "+movX+">0 || "+movX+"<0");
				if ((Number(this.getOffsetLeft(elini)) < Number(this._capaContenido.offsetLeft) && movX>0)
					|| (movX < 0)
				){//movimiento horizontal 
					this._capaEPG.style.left = this._capaEPGleft + movX;
					//TODO: Change Day BUG 11-02-2008
					
					var diff=Math.abs(parseInt(this._capaHorario.style.left))-Math.abs(parseInt(positionActual));
					var numhoras=(diff / this._horaWidth)
					var mydate= new Date();
				  var myhour=mydate.getHours();
				  var hastamanana=24-myhour;
				  var se=document.getElementById("dias");
				  if (numhoras<=((-myhour)+1))
				  {
                  	 if(se) se.selectedIndex=selectActual;
				  }
				  else if(se)
				  {
				  	var posSelect;
					  if (numhoras>0)
					  {
    			  	    numhoras=numhoras-(hastamanana);
						posSelect=Math.round(numhoras) / 24+1;
						if (selectActual+posSelect<=(se.length-1))
						  se.selectedIndex=selectActual+posSelect
					  }
					  else
					  {
					        se.selectedIndex=selectActual;
					  }
					}
					
					//TODO
					
					this._capaHorario.style.left = this._capaHorarioleft + movX;
					if(this._capaEPGleft + movX>0 || this._capaHorarioleft + movX>0) 
					{
					    this._capaEPG.style.left=0;
					    this._capaEPGleft=0;
					    this._capaHorario.style.left=0;
					    this._capaHorarioleft=0;
					}
				}
			}
		}
	}, 
	

	/**********************************************************************************************
	* _scrollMe
	**********************************************************************************************/
	
	_scrollMe: function(tmpid){
		   
    	if (this._Channels.length)
    	{
            var movX=0;
            var movY=0;
            switch (tmpid)
            {
                case "left":
                    movX=this._horaWidth;
                    movY=0;
                    break;

                case "right":
                    movX=-this._horaWidth;
                    movY=0;
                    break;
                
                case "up":
                    movX=0;
                    movY=(this._canalesWidth+(4*3));
                    break;
                
                case "down":
                    movX=0;
                    movY=-(this._canalesWidth+(4*3));
                    break;
            }
        
            var el = document.getElementById('epg'+this._Channels[0]._idChannel);
            var el2 = document.getElementById('epg'+this._Channels[this._Channels.length-1]._idChannel);
            var elini = document.getElementById('divepginicio');
            if (el!=undefined && el2!=undefined)
            {
                if ((parseInt(this._capaEPG.offsetTop) < parseInt(el.offsetTop) && movY>0) ||
                    (parseInt(this._capaEPG.offsetTop) > -(parseInt(el2.offsetTop)-(this._parrillaHeight+this._offset)) && movY<0))
                {   
                    //movimiento vertical
                    this._capaEPG.style.top = this._capaEPGtop + movY;
                    this._capaCanales.style.top = this._capaCanalestop + movY;
                }
        
                if ((Number(this.getOffsetLeft(elini)) < Number(this._capaContenido.offsetLeft) && movX>0)
                    || (movX < 0))
                {
                    //movimiento horizontal
                    this._capaEPG.style.left = this._capaEPGleft + movX;
                    this._capaHorario.style.left = this._capaHorarioleft + movX;
                    
                    //TODO: Change Day BUG 11-02-2008
                    var diff=Math.abs(parseInt(this._capaHorario.style.left))-Math.abs(parseInt(positionActual));
                    var numhoras=(diff / this._horaWidth)
                    var mydate= new Date();
                    var myyear=mydate.getFullYear();
                    var mymoth=mydate.getMonth()+1;
                    var myday=mydate.getDate();
                    var myhour=mydate.getHours();
                    var myd=myyear + "-" + mymoth +"-" +myday+myhour;
                    var hastamanana=24-myhour;
                    if (numhoras<=((-myhour)+1))
                    {
                        //alert("Dia de ayer");
                    }
                    else
                    {
                        if (numhoras>hastamanana-1)
                        {
                            numhoras=numhoras-hastamanana;
                            var posSelect=Math.round(numhoras / 24)+2;
                            var se=document.getElementById("dias");
                            se.selectedIndex=posSelect;
                        }
                    }
        
                    if(this._capaEPGleft + movX>0 || this._capaHorarioleft + movX>0)
                    {
                        this._capaEPG.style.left=0;
                        this._capaEPGleft=0;
                        this._capaHorario.style.left=0;
                        this._capaHorarioleft=0;
                    }
                }
            }
        }
	}, 
	
	/**********************************************************************************************
	* getMousePos
	**********************************************************************************************/
	getMousePos: function(_bool,myEvent)
	{
	    if(document.navegador==1)
	    {
	        if (_bool)
	        {
				this.mousePosXnew = myEvent.clientX+document.body.scrollLeft;
				this.mousePosYnew = myEvent.clientY+document.body.scrollTop;
			}
			else
			{
				this.mousePosX = myEvent.clientX+document.body.scrollLeft;
				this.mousePosY = myEvent.clientY+document.body.scrollTop;
			}
	    }
	    else
	    {
	        if (_bool)
	        {
    			this.mousePosXnew = myEvent.pageX;
    			this.mousePosYnew = myEvent.pageY;
    		}
    		else
    		{
    			this.mousePosX = myEvent.pageX;
    			this.mousePosY = myEvent.pageY;
    		}
	    }
	},
	
	/**********************************************************************************************
	* whoIam
	**********************************************************************************************/
	whoIam: function(){
		alert("SGparrilla.js");
	}, 
	
	/**********************************************************************************************
	* showError
	**********************************************************************************************/
	showError: function(isAlert){
		if (isAlert){
			//alert("err: "+this._errorTxt);
		}else{
			document.write("err: "+this._errorTxt);
		}
		
		this._error=false;
		this._errorTxt="";
		return false;
	},
	
	/**********************************************************************************************
	* showParrilla
	**********************************************************************************************/
	showParrilla: function(obj,route){
		try {
			miroute=route;
			this._Me = obj;
			if (!this.drawParrilla()){
				this._error=true;
				this._errorTxt+="-No se ha podido crear la parrilla.";
				this.showError(true);
			}else{
				this._info("info", 1, "");
				this._Year=this.currentDate[0];
				this._Mes=this.currentDate[1];
				this._Dia=this.currentDate[2];
				this.getChannels(null, null, null, null, null, null);
			}
		}catch (e) {
			this._error=true;
			this._errorTxt+="exception: "+e.description;
			this.showError(true);
		}
	}, 
	
	/**********************************************************************************************
	* findHorario
	**********************************************************************************************/
	findHorario: function(val){
		var retorno=-1;
		for (var i=0; i < this._horario.length; i++){
			if (this._horario[i]["dias"]==val) retorno=i;
		}
		return retorno;
	},
	
	/**********************************************************************************************
	* gotoHora
	**********************************************************************************************/
	gotoHora: function(obj){
		var dias = document.getElementById('dias');
		var horas = document.getElementById('horas');
		
		if (dias==undefined && horas==undefined)
		{
		    var el = document.getElementById(""+this.currentDate[0]*1+"-"+this.currentDate[1]*1+"-"+this.currentDate[2]*1+Number(this.currentDate[3]));
			if (el!=undefined)
			{
				
				movX = Number(this.getOffsetLeft(this._capaHorario)) - (Number(this.getOffsetLeft(el)) - Number(this.getOffsetLeft(this._capaContenido)));//+this._horaWidth;
				this._capaHorario.style.left = movX;
			  this._capaEPG.style.left = movX;
				this._chkFinalEPG(); //Buscamos la marca final de epg
			}
		}
    else if (dias!=undefined && horas!=undefined)
        {
			if (obj!=null && dias.id == obj.id)
			{
				idx = this.findHorario(dias.value);
				
		        if (idx>=0)
				{
					this.cleanHorario("horas");
					for (var i=0; i < this._horario[idx]["horas"].length; i++)
					{
					    tmphoratxt=(""+this._horario[idx]["horas"][i]).toDigit(2)+":00h";
						this.addElementFiltro(horas, tmphoratxt,Number(this._horario[idx]["horas"][i]));
					}
				}
			}
			
			var el = document.getElementById(""+dias.value+horas.value);
			if (el!=undefined)
			{
				movX = Number(this.getOffsetLeft(this._capaHorario)) - (Number(this.getOffsetLeft(el)) - Number(this.getOffsetLeft(this._capaContenido)));//+this._horaWidth;
				this._capaHorario.style.left = movX;
				positionActual=this._capaHorario.style.left;
				var se=document.getElementById("dias");
				selectActual=se.selectedIndex
				mydayActual=1;
				
				this._capaEPG.style.left = movX;
					
				
				this._chkFinalEPG(); //Buscamos la marca final de epg
			}
			else 
			{
			    // BUG 000957: Reload page with current date
			    hora=horas.value.toDigit(2);
			    var fecha=dias.value.split("-");
			    if(fecha[0]*1!=this.currentDate[0]*1 || fecha[1]*1!=this.currentDate[1]*1 || fecha[2]*1!=this.currentDate[2]*1 || hora*1!=this.currentDate[3]*1)
			        top.location.href="?do=Programacion&date="+dias.value+" "+hora;
			    else
			    {
			       //SetTimeout("parrilla.gotoHora(null);",10000);
                }
			}
			
		}
		else 
		{
		    parent.Create.alerta("No se puede recuperar la hora seleccionada",miroute);
		}
	},
	
	/**********************************************************************************************
	* drawParrilla
	**********************************************************************************************/
	drawParrilla: function(){
    //DVG:detección de navegador. Esto se hace porque la parrilla se construye con posiciones a fuego. Sería necesaria una refactorización para convertir la parrilla en un objeto independiente de posiciones
    var topOffset = 0;
    var offsetHeight = 0;
    var offsetHeight2 = 0;
    var correctRight = 1;
    if (BrowserDetect.isInternetExplorer())
    {
        if (Number(BrowserDetect.version) <= 6)
            {
            if (this._isMini)
                {
                topOffset = 16;
                offsetHeight = 16;
                offsetHeight2 = 12;
                }
            else
                {
                topOffset = 0;
                offsetHeight = 16;
                offsetHeight2 = 0;
                correctRight = 0;
                }
            }
        else
            {
            if (this._isMini)
                {
                topOffset = 4;
                offsetHeight = 2;
                offsetHeight2 = 0;
                }
             else
                {
                topOffset = 0;
                offsetHeight = 2;
                offsetHeight2 = 0;
                }
            }
    } 
    else
    {
       topOffset = 0;
       offsetHeight = 2;
       offsetHeight2 = -1;
    }
          
		var estructura="";
		//document.write("<div name='SGresult2' id='SGresult2' style='display: block;'></div>\n");
		if (this.showDebug)	m_display="block";
		else m_display="none";
		
		if (this._showFiltros)
		{
			var dia=""+this._FullYear+this._Mes+this._Dia;
			estructura+="<div class='filtros' name='epg'><div class='filtroDias' name='epg'>";
			estructura+="<select name='dias' id='dias' style='margin-left:10px; font-size:11px;font-family:arial;' ></select>";
            estructura+="&nbsp;<select name='horas' style='font-size:11px;font-family:arial;' id='horas' ></select>";
            estructura+="&nbsp;&nbsp;<a id='btn_buscar' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;' name='button'>[ Buscar ]</a></div>";
            var btnparrilla="";
            if(this.uid=="")
                btnparrilla="<a  id='btn_parrilla' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;'  name='button'>[ Mi parrilla ]</a>&nbsp;";

            //+J ** Bug 2482 ** estructura+="<div class='filtroCanales'>"+btnparrilla+"<a  id='btn_autonomicos' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;' name='button'>[ Canales autonómicos ]&nbsp;<a id='btn_tdt' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;'  name='button'>[ Canales TDT ]</a>&nbsp;<a  id='btn_digitales' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;' name='button'>[ Canales digitales ]</a>&nbsp;<a id='btn_todos' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;' name='button'>[ Todos los canales ]</a>&nbsp;</div></div>";
            estructura+="<div class='filtroCanales'>"+btnparrilla+"<a  id='btn_autonomicos' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;' name='button'>[ Canales autonómicos ]&nbsp;<a  id='btn_digitales' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;' name='button'>[ Canales digitales ]</a>&nbsp;<a id='btn_todos' style='cursor:pointer; font-size:11px; height:11px;line-height:11px;' name='button'>[ Todos los canales ]</a>&nbsp;</div></div>";
		}
		if (this._isMini)
		{
		    
		    if (this.navegador==1){
		          if (this.ieVer==7)
		          	estructura+="<div id='SGparrilla' style='position:relative;left:-20;top:-35px; width:"+(this._parrillaWidth-30)+"; height:"+(this._parrillaHeight+5)+";'>\n";
		
		          else
		          	estructura+="<div id='SGparrilla' style='position:relative;left:0;top:-20px; width:"+this._parrillaWidth+"; height:"+(this._parrillaHeight+15)+";'>\n";
		
		    }
		    else{
		    	    estructura+="<div id='SGparrilla' style='style='position:relative;left:0;top:-60px;width:"+this._parrillaWidth+"; height:"+(this._parrillaHeight+15)+";'>\n";
		
		    }
		}
		else
		{
		    estructura+="<div id='SGparrilla' style='width:"+this._parrillaWidth+"; height:"+(this._parrillaHeight+15)+";'>\n";
		}
		
		
		
		if (this._showFiltros)
		    estructura+="<div class='scrollLat' style='left:30px; top:"+(20+topOffset)+"px; z-index:1; '><img src='"+miroute+"/btn_left.gif?nca' width='19' height='26' id='left' name='button'></div>";
		else{
			 if (this.navegador==1){
			 	
        if (this.ieVer==7)
           estructura+="<div class='scrollLat' style='position:relative; left:50px; top:"+(38+topOffset)+"px; z-index:1; '><img src='"+miroute+"/btn_left.gif?nca' width='19' height='26' id='left' name='button'></div>";
        else if (this.ieVer==0)
        	 estructura+="<div class='scrollLat' style='position:relative; left:50px; top:"+(12+topOffset)+"px;'><img src='"+miroute+"/btn_left.gif?nca' width='19' height='26' id='left' name='button'></div>";
        else
        		estructura+="<div class='scrollLat' style='position:relative; left:28px; top:"+(12+topOffset)+"px;'><img src='"+miroute+"/btn_left.gif?nca' width='19' height='26' id='left' name='button'></div>";
        
       }
       else
       	estructura+="<div class='scrollLat' style='position:relative; left:40px; top:"+(14+topOffset)+"px; z-index:1; '><img src='"+miroute+"/btn_left.gif?nca' width='19' height='26' id='left' name='button'></div>";
    }
		
		if (this._isMini)
		{
		    
		    if (this.navegador==1){
		          if (this.ieVer==7)
		          	estructura+="<div style='border:1px solid #000;position:relative;top:40px;left:61px;background-color:#fff ;height:"+(12+offsetHeight)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		          else
		          	estructura+="<div style='border:1px solid #000;position:relative;top:40px;left:20px;background-color:#fff;height:"+(12+offsetHeight)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		    }
		    else{
		    	    estructura+="<div style='border:1px solid #000;position:relative;top:40px;left:43px;background-color:#fff ;height:"+(12+offsetHeight)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		    }
		}
		else
		{
		    estructura+="<div style='position:absolute;top:47px;left:43px;background-color:white;height:"+(12+offsetHeight)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		}
		estructura+="<div id='SGhorario' style='width:"+(this._parrillaWidth-this._canalesWidth)+"; height:"+this._horarioHeight+"; margin-left:"+(this._canalesWidth)+"; clip: rect(1px "+(this._parrillaWidth-this._canalesWidth-15)+" "+(this._horarioHeight+this._padding)+" 0px);'><div id='cliphorario'></div></div>\n";
		if (this._showFiltros){
		    if (this._isMini)
		       {
		    	   if (this.navegador==1){
				          if (this.ieVer==7)
				          	 estructura+="<div class='scrollLat2' style='left:"+(this._parrillaWidth-this._padding-(this.navegador==1?10:9))+"; top:"+(42+topOffset-2)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
				          else
				          	 estructura+="<div class='scrollLat2' style='left:"+(this._parrillaWidth-this._padding-(this.navegador==1?10:9))+"; top:"+(42+topOffset-2)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
				          }
		          else{
		    	    		 estructura+="<div class='scrollLat2' style='left:"+(this._parrillaWidth-this._padding-(this.navegador==1?10:9))+"; top:"+(22+topOffset-2)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
		        	}
		       }
		   else{
		      estructura+="<div class='scrollLat2' style='left:"+(this._parrillaWidth-this._padding-(this.navegador==1?10:9))+"; top:"+(22+topOffset-2)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
		  }
		}
		else
		       if (this._isMini)
		       {
		    	   if (this.navegador==1){
				          if (this.ieVer==7)
				          	 estructura+="<div class='scrollLat2' style='position:relative;float:left;left:610px; top:"+(topOffset-6)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
				          else
				          	 estructura+="<div class='scrollLat2' style='left:"+(this._parrillaWidth-this._padding-(this.navegador==1?10:9))+"; top:"+(12+topOffset-2)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
				          }
		          else{
		    	    		 estructura+="<div class='scrollLat2' style='position:relative;float:left;left:576px; top:"+(topOffset-2)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
		        	}
		       }
		       else
		          estructura+="<div class='scrollLat2' style='left:"+(this._parrillaWidth-this._padding-(this.navegador==1?10:9))+"; top:"+(34+topOffset-2)+"px; z-index:1; '><img src='"+miroute+"/btn_right.gif?nca' width='19' height='26' id='right' name='button'></div>";
		    
		estructura+="<div class='scroll' style='margin-left:3px;margin-top:"+(this._horarioHeight-4)+"px;'><img src='"+miroute+"/btn_up.gif' width='39' height='13' id='up' name='button'></div>";
		estructura+="<div id='SGcanales' 	style='margin-top: "+(this._horarioHeight+this._padding)+"; clip: rect(0px "+this._canalesWidth+" "+(this._parrillaHeight-(this._horarioHeight)*2)+" 0px);'><div id='clipcanales' style='width:"+this._canalesWidth+";'></div></div>\n";
		estructura+="<div class='scroll' style='margin-left:3px;margin-top:"+(this._parrillaHeight+this._padding-this._horarioHeight)+"px;*margin-top:"+(3+this._parrillaHeight+this._padding-this._horarioHeight)+"px;'><img src='"+miroute+"/btn_down.gif' width='39' height='13' id='down' name='button'></div>";
		var channels=getCookie("heightChannel");
	  	if ((channels!=undefined) && (channels!=""))
	  	{
			altura=getCookie("heightChannel");
		    altura=(parseInt(altura)*-1)+50;  
		    }  
        else
        {
            altura=100;
        }
        estructura+="<div id='SGcontenido' 	style='margin-top: "+(this._horarioHeight+this._padding)+"; margin-left:"+(this._canalesWidth)+"; width:"+(this._parrillaWidth-this._canalesWidth-(this.navegador==1?4:0))+"; height:"+(this._parrillaHeight-this._horarioHeight)+"; clip: rect(0px "+(this._parrillaWidth-this._canalesWidth-(this.navegador==1?2:0))+" "+(this._parrillaHeight-(this._horarioHeight*2))+" 0px);' name='epg'><div id='epg' name='epg'><div align='center' style='position:absolute;left:"+(this._isMini?130:250)+"px;top:"+altura+"px;' id='ajaxloading' name='ajaxloading' ><img src='"+miroute+"/ajaxload.gif?nc'><br><br>Cargando informaci&oacute;n, aguarde un instante por favor</div></div></div>\n";
		
		if (this._isMini)
		{
		    if (this.navegador==1){
		          if (this.ieVer==7)
		          	estructura+="<div style='position:relative;top:"+(this._parrillaHeight+(-45)+offsetHeight2)+"px;px;left:61px;background-color:#fff ;height:"+(this.navegador==0?11:13)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		          else if (this.ieVer==0)
		          	estructura+="<div style='position:relative;top:"+(this._parrillaHeight+(-20)+offsetHeight2)+"px;left:43px;background-color:#fff ;height:"+(this.navegador==0?11:13)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		          else
		          	estructura+="<div style='position:relative;top:"+(this._parrillaHeight+(-31)+offsetHeight2)+"px;left:43px;background-color:#fff ;height:"+(this.navegador==0?11:13)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		    }
		    else{
		    	    estructura+="<div style='position:relative;top:"+(this._parrillaHeight+(-20)+offsetHeight2)+"px;left:43px;background-color:#fff;height:"+(this.navegador==0?11:13)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		    }
		}
		else
		{
		    
		    if (this.navegador==1){
		          if (this.ieVer==7)
		          	estructura+="<div style='position:relative;top:"+(this._parrillaHeight+(-19)+offsetHeight2)+"px;left:43px;background-color:white;height:"+(this.navegador==0?11:13)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		          else
		          	estructura+="<div style='position:relative;top:"+(this._parrillaHeight+(-19)+offsetHeight2)+"px;left:43px;background-color:white;height:"+(this.navegador==0?11:13)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		    }
		    else{
		    	    estructura+="<div style='position:relative;top:"+(this._parrillaHeight+(-20)+offsetHeight2)+"px;left:43px;background-color:white;height:"+(this.navegador==0?11:13)+"px;width:"+(this._parrillaWidth-1-this._canalesWidth)+"px;border-color:black;border-style:solid;border-width:1px;' ><img src="+miroute+"/empty.gif width=1 height=14 ></div>\n";
		    }
		}
		
		if (this._isMini)
		{
		    
		    if (this.navegador==1){
		          if (this.ieVer==7)
		          	estructura+="<div id='leyenda' style='margin-left:40px;float:left;left:100px;margin-top:"+((-30)+this._parrillaHeight+this._padding-this._horarioHeight+16)+"px;'><span class='cine'>Cine</span> | <span class='series'>Series</span> | <span class='deportes'>Deportes</span> | <span class='programas'>Programas</span> | <span class='infantil'>Infantil</span></div>";
		
		          else
		          	estructura+="<div id='leyenda' style='margin-top:"+((-5)+this._parrillaHeight+this._padding-this._horarioHeight+16)+"px;'><span class='cine'>Cine</span> | <span class='series'>Series</span> | <span class='deportes'>Deportes</span> | <span class='programas'>Programas</span> | <span class='infantil'>Infantil</span></div>";
		
		    }
		    else{
		    	    estructura+="<div id='leyenda' style='margin-top:"+((-5)+this._parrillaHeight+this._padding-this._horarioHeight+16)+"px;'><span class='cine'>Cine</span> | <span class='series'>Series</span> | <span class='deportes'>Deportes</span> | <span class='programas'>Programas</span> | <span class='infantil'>Infantil</span></div>";
		    }
		}
		else
		{
		    estructura+="<div id='leyenda' style='margin-top:"+((-5)+this._parrillaHeight+this._padding-this._horarioHeight+16)+"px;'><span class='cine'>Cine</span> | <span class='series'>Series</span> | <span class='deportes'>Deportes</span> | <span class='programas'>Programas</span> | <span class='infantil'>Infantil</span></div>";
		
		}
		
		
		estructura+="<div id='SGprogram' 	style='display: none; position:absolute; width: "+(this._parrillaWidth-this._canalesWidth-(this.navegador==1?2:1))+"; height: "+(this._programHeight+this._padding-1)+";' name='button'></div>\n";
		estructura+="</div>\n";
		
		// Right black line between channels and EPG
		if (this._isMini){
		  if (this.navegador==1){
		          if (this.ieVer==7)
		          	estructura+="<div style='position:relative;top:53px;left:-547px;background-color:#000 ;height:"+(this._parrillaHeight-(this._horarioHeight)*2+20+offsetHeight2)+"px;width:1px;' ><img src="+miroute+"/empty.gif width=1 height=1 ></div>\n";
		          else
		          	estructura+="<div style='position:relative;top:51px;left:-577px;background-color:#000;height:"+(this._parrillaHeight-(this._horarioHeight)*2+20+offsetHeight2)+"px;width:1px;' ><img src="+miroute+"/empty.gif width=1 height=1 ></div>\n";
		    }
		    else{
		    	    estructura+="<div style='position:relative;top:58px;left:43px;background-color:#000;height:"+(this._parrillaHeight-(this._horarioHeight)*2+20+offsetHeight2)+"px;width:1px;' ><img src="+miroute+"/empty.gif width=1 height=1 ></div>\n";
		    }
		}
		else
			estructura+="<div style='position:absolute;top:59px;left:43px;background-color:black;height:"+(this._parrillaHeight-(this._horarioHeight)*2+20+offsetHeight2)+"px;width:1px;' ><img src="+miroute+"/empty.gif width=1 height=1 ></div>\n";
		
		if (this.showDebug)
			estructura+="<br><br><br><div id='SGdebug' style='z-index: 0;'>[INFO] Inicializando objeto.<br>\n</div>\n";
		
		estructura+="<textarea name='SGresult' style='display: "+m_display+";' id='SGresult' rows='10' cols='60'></textarea>\n";
		
		document.write(estructura);
		
		this._capaHorario = document.getElementById('cliphorario');
		this._capaCanales = document.getElementById('clipcanales');
		this._capaContenido = document.getElementById('SGcontenido');
		this._capaEPG = document.getElementById('epg');
		this._capaProgram = document.getElementById('SGprogram');
		this._result = document.getElementById('SGresult');
		if (this.showDebug)	this.getDebug('SGdebug');

		var channels=getCookie("heightChannel");
		if ((channels!=undefined) && (channels!="")){
			    this._capaEPG.style.top=getCookie("heightChannel");
		      this._capaCanales.style.top=getCookie("heightChannel");
		      document.cookie="heightEPG=";
				  document.cookie="heightChannel="; 
    } 
  
        //if(this._capaEPG.style.top==0) this._capaEPG.style.top="-1px";
		this.disableSelection(this._capaEPG);
			    
		return true;
	}, 
	
	drawDay: function(dia,i)
	{
	    if(i!=0) return;
	    try
	    {
	        if(!this.drawDayFirst)
	        {
	            var mdatearr=dia.split("-");
	            var mdate= new Date();
			        mdate.setDate(Number(mdatearr[2]*1));
			        mdate.setMonth(Number(mdatearr[1]*1)-1);
                    mdate.setFullYear(Number(mdatearr[0]*1));
                this.drawDayFirst=mdate;
            }
            else 
            {
	            this.drawDayFirst.setDate(this.drawDayFirst.getDate()+1);
            }
            mdate=this.drawDayFirst;   
            var mdatetxt=""+this._aDias[mdate.getDay()]+", "+mdate.getDate()+" de "+this._aMeses[mdate.getMonth()];
            this._capaHorario.innerHTML+="<div id=textdate style='top:"+(this._isMini?25:24)+"px;left:"+(this.numHoras*this._horaWidth)+"px;' >"+mdatetxt+"</div>";
	    }
	    catch(ex) {}
	},
	
	/**********************************************************************************************
	* drawHorario
	**********************************************************************************************/
	drawHorario: function(days){
			var ini=this.horaIni;
			
			var dia=""+this._FullYear+"-"+(1*this._Mes)+"-"+(this._Dia*1);
			if (days!=0)
			{
				var tmpfecha= new Date();
			    
			    tmpfecha.setHours(Number(this._Hora*1));
			    tmpfecha.setDate(Number(this._Dia*1));
			    tmpfecha.setMonth(Number(this._Mes*1)-1);
                tmpfecha.setFullYear(Number(this._FullYear*1));
            
                tmpfecha.setDate(tmpfecha.getDate()+days);
			    dia= tmpfecha.getFullYear() + "-" +(tmpfecha.getMonth()+1) + "-" + tmpfecha.getDate() ;
			}
			
			var now = new Date();

			if (this._capaHorario!=undefined)
			{
				for (var i=ini; i < 24; i++)
				{
				    this._capaHorario.innerHTML+="<div id='"+dia+i+"' title='"+dia+i+"' style='width: "+this._horaWidth+";' class='hora'>&nbsp;&nbsp;&nbsp;"+(i*1)+":00h</div>";
				    if(dia==now.getFullYear() + "-" +(now.getMonth()+1) + "-" + now.getDate() && i==now.getHours())
				    {
				       this.showLineaHora(now);
				    }
				    this.drawDay(dia,i);
				    this.numHoras++;
				}
				var tmpfecha= new Date();
			    tmpfecha.setHours(Number(this._Hora*1));
                tmpfecha.setDate(Number(this._Dia*1));
			    tmpfecha.setMonth(Number(this._Mes*1)-1);
			    tmpfecha.setFullYear(Number(this._FullYear*1));
			    
                tmpfecha.setDate(tmpfecha.getDate()+(days+1));
            
			    dia= tmpfecha.getFullYear() + "-" +(tmpfecha.getMonth()+1) + "-" + tmpfecha.getDate() ;
			    
				
                for (var i=0; i < ini; i++)
				{
				    this._capaHorario.innerHTML+="<div id='"+dia+i+"' title='"+dia+i+"' style='width: "+this._horaWidth+";' class='hora'>&nbsp;&nbsp;&nbsp;"+(i*1)+":00h</div>";
				    if(dia==now.getFullYear() + "-" +(now.getMonth()+1) + "-" + now.getDate() && i==now.getHours())
				    {
				       this.showLineaHora(now);
				    }
				    this.drawDay(dia,i);
				    this.numHoras++;
				}
				
				return true;
			}
			else
			{
				this._info("critical", 0, "No se ha podido recuperar la capa horario.");
				return false;
			}
	}, 
	
	showLineaHora: function(now)
    {
        var hora=(""+now.getHours()).toDigit(2)+":"+(""+now.getMinutes()).toDigit(2);
        this._capaHorario.innerHTML+="<div id=textohora style='left:"+(((this.numHoras+now.getMinutes()/60)*this._horaWidth)-5)+"px;' >"+hora+"</div>";
        this._capaEPG.innerHTML+="<div id=lineahora style='left:"+(((this.numHoras+now.getMinutes()/60)*this._horaWidth)-2)+"px;' ></div>";
    },

	/**********************************************************************************************
	* getChannels
	**********************************************************************************************/
	getChannels: function(userId, includeAutonomics, includeTDT, includeDigitalPlatform, postalCode, includeAll){

		this._info(1, 3," [getChannels]");
		this._cleanResults();

		// miramos si se quiere cargar algun canal adicional (seleccionado desde los filtros);
		var el = document.getElementById('inichannel');
		var additionalChannels="";
		if (el!=undefined) if (el.value!="")
        {
			    additionalChannels=el.value.split(";").join(",");
		}
		var params = "&includeAutonomics="+includeAutonomics+"&includeTDT="+includeTDT+"&postalCode="+postalCode+"&includeAll="+includeAll+"&additionalIdChannels="+additionalChannels;
		this.getEPG(params, null, true);
		return;
		
	}, 
		
	/**********************************************************************************************
	* drawChannel
	**********************************************************************************************/
	drawChannel: function(obj){
	    this._capaCanales.innerHTML+="<div id='ch"+obj._idChannel+"' class='canal' style='height:"+this._canalHeight+"px; *height:"+(this._canalHeight-2)+"px;'><br /><img id='imgcanal"+obj._idChannel+"' src='http://www.inout.tv/"+obj._logo+"' border='0' title='"+obj._longName+"'><br><a href='javascript:;' id='vercanal#"+obj._idChannel+"' class='epg_ver_hoy' name='button' style='font-size: 8px;color:#888888;' >VER HOY</a></div>";
		this._capaCanales.innerHTML+="<div class='finlogocanal'></div>";
		this._capaEPG.innerHTML+="<div id='epg"+obj._idChannel+"' name='epg' class='linepg' style='height: "+this._lineEPGHeight+"; *height: "+(this._lineEPGHeight-4)+"'></div>";
	}, 
	
	/**********************************************************************************************
	* getDebug
	**********************************************************************************************/
	getDebug: function(capaDebug){
			this.capaDebug = document.getElementById(capaDebug);
			if (this.capaDebug==undefined){
				this._error=true;
				this._errorTxt+="-No se ha podido crear la ventana de salida.";
				this.showDebug=false;
				this.showError(true);
			}
	}, 
	
	/**********************************************************************************************
	* getEPG
	**********************************************************************************************/
	getEPG: function(params, days, getchannels){
		
		// Do not try to load 2 times ePG if it's loading
		if(document.getElementById("ajaxloading") && document.getElementById("ajaxloading").style.display=="block")
		    return;
		
		if(document.getElementById("ajaxloading"))
		{
		    var off=100;
		    var el = document.getElementById("epgfinal");
			if (el!=undefined) 
			{
			    off=this.getOffsetLeft(el)+300;
		        document.getElementById("ajaxloading").style.left= ((-this._capaEPGleft)+off)+"px";
		        document.getElementById("ajaxloading").style.top= ((-this._capaEPGtop)+100)+"px"; 
		        document.getElementById("ajaxloading").className='ajaxloading';
		    }
			document.getElementById("ajaxloading").style.display="block";
		}
		
		var tmpdate = ""+this._FullYear+"-"+this._Mes+"-"+this._Dia+" "+this._Hora+":"+this._Minuto+":00";
		if(days>0)
		{
			  var tmpfecha= new Date();
			
			tmpfecha.setHours(Number(this._Hora*1));
			tmpfecha.setDate(Number(this._Dia*1));
			tmpfecha.setMonth(Number(this._Mes*1)-1);
			tmpfecha.setFullYear(Number(this._FullYear*1));

        tmpfecha.setDate(tmpfecha.getDate()+days);
			tmpdate = tmpfecha.getFullYear() + "-" +(tmpfecha.getMonth()+1) + "-" + tmpfecha.getDate() + " " + tmpfecha.getHours() + ":00:00";
		    
		}
		
		this._info(1, 3," [getEPG]");
		if(document.getElementById("epginfo") && document.getElementById("epginfo").value.length>10)
		{
		    this._result.value=document.getElementById("epginfo").value;
		    document.getElementById("epginfo").value="";
		    this.getEPG_callback();
		    return true;
		}
		this._cleanResults();
		var params = "do=ajax@Parrilla&accion=getepg"+params+"&date="+tmpdate;
		this._info("info", 0, params);
		this.ajx.setTxtCargando(this.ajx_TxtCargando);
		this.ajx.objOwner = this;//this._objOwner;
		this.ajx.setValores(params);
		this.ajx.setURL("index.php");
		this.ajx.ResultinTA(true);
		this.ajx.setCapa("SGresult");
		this.ajx.setCallBack("getEPG_callback");
		this.ajx.runAjx();
		return true;
		
	}, 

		
	/**********************************************************************************************
	* getEPG_callback
	**********************************************************************************************/
	getEPG_callback: function(){
		this._info(1, 0,"..:: OK ::.. getEPG cargada!!");
		
		if(this.firstTime && document.getElementById("ajaxloading"))
		{
		    document.getElementById("ajaxloading").style.display="none";
		    //document.getElementById("ajaxloading").innerHTML="<br>";
		}
		
		this.myChannels = new Array();
		
		xmlsrc = this._result.value;
        var recibido=new Date();
        if (xmlsrc && xmlsrc.length>200)
        {
            try { eval(xmlsrc); } catch(ex)  {  }
                
			if(retchls && retchls=="OK")
			{
			    // Do nothing
			}
			else if (retchls && retchls!="OK" && retchls.length)
			{
			    this._Channels=retchls;
			    this._onlyChannelsTxt="&channels=0";
				for (var i=0; i < this._Channels.length; i++)
				{
					this.drawChannel(this._Channels[i]);
					this._onlyChannelsTxt += ","+this._Channels[i]._idChannel;
					this._ChannelsByID[this._Channels[i]._idChannel] = i;
				}
			}
		    else if(!this._Channels || this._Channels!="OK")
		    {
		        if(document.getElementById("ajaxloading"))
        		{
        		    document.getElementById("ajaxloading").style.display="none";
        		}
		         parent.Create.alerta("No se han obtenido canales.",miroute);
		        return;
		    }
		    
			this.retornos=retorno;
			if (retorno.length)
			{
				this._info("info", 0, retorno.length+" eventos recuperados.");
				
				if (this.firstTime)
				{
				    //Buscamos la hora de inicio más antigua
					this._info("info", 0, " Buscamos la hora de inicio más antigua.");//Buscamos la hora de inicio más antigua
					var aFechaMenor = this.fecIni.split(" ");
					var aDiaMenor = aFechaMenor[0].split("-");
					var aHoraMenor = aFechaMenor[1].split(":");
					var horaActual =Number(""+aDiaMenor[0]+aDiaMenor[1]+aDiaMenor[2]+aHoraMenor[0]+aHoraMenor[1]);
					var firstHour=Number(""+aDiaMenor[0]+aDiaMenor[1]+aDiaMenor[2]+"0000");
					
					for (var i=0; i < retorno.length; i++){
						ainicio = retorno[i]._startTime.split(" ");
						a_dia = ainicio[0].split("-");
						a_hora = ainicio[1].split(":");
						var horaEvento = Number(""+a_dia[0]+a_dia[1]+a_dia[2]+a_hora[0]+a_hora[1]);
//						this._info("info", 0, "[CHK HoraInicio] "+horaEvento+" < "+horaActual);
						if (horaEvento < horaActual){
//							this._info("info", 0, " **** [HORA CAMBIADA] *** "+a_hora[0]);
							this.horaIni=a_hora[0];
							this.fecIni = retorno[i]._startTime;
							aFechaMenor = this.fecIni.split(" ");
							aDiaMenor = aFechaMenor[0].split("-");
							aHoraMenor = aFechaMenor[1].split(":");
							horaActual =Number(""+aDiaMenor[0]+aDiaMenor[1]+aDiaMenor[2]+aHoraMenor[0]+aHoraMenor[1]);
						}
					}
					this.numHoras=0;
					if(horaActual<=firstHour)
					{
					    this.drawHorario(this._numDias-1);
					    this.drawHorario(this._numDias);
					}
					else 
                    {
					    this.drawHorario(this._numDias);
					    this.drawHorario(this._numDias+1);
					}
					this._info("info", 0, "Hora inicio establecida en: "+this.horaIni);
					
				}
			    else this.drawHorario(this._numDias);
				
				var maxTimeout=0;
				var oldCh=0;
				var cond=false;
				for (var i=0; i < retorno.length; i++)
				{
					if (i==0 && this.firstTime) 
					{
						var el = document.getElementById('epg'+retorno[0]._idChannel);
						if (el!=undefined)
							el.innerHTML+="<div id='divepginicio' name='epg' class='SGfinal'><input type='hidden' name='inicio' value='fecha'><img id='epginicio' name='epginicio' src='"+miroute+"/pixtrans.gif' border='0'></div>";
					}
					if (oldCh!=retorno[i]._idChannel)
					{
						oldCh = retorno[i]._idChannel;
						cond=true;
					}	else cond=false;
					
					if(!this.myChannels[retorno[i]._idChannel]) 
					{
					    this.myChannels[retorno[i]._idChannel]=0;
					}
					if(!this._epgByID[retorno[i]._idEvent])
					{   
					    this._epg[this._epg.length]=retorno[i];
					    this._epgByID[retorno[i]._idEvent]=this._epg.length-1;
					    if(this.myChannels[retorno[i]._idChannel]<10)
					        this.drawEPG(retorno[i], cond);
					    else 
					    {
					        var myTimeout=500+(this.myChannels[retorno[i]._idChannel]*100);
					        if(maxTimeout<myTimeout) maxTimeout=myTimeout;
					        setTimeout("parrilla.drawEPGRet("+i+","+cond+");",myTimeout);
					    }
					    this.myChannels[retorno[i]._idChannel]++;
					}
				}

                setTimeout("parrilla.drawEPGLast("+retorno[0]._idChannel+");",maxTimeout);
                
                this._numDias++;	
				
				if(this.firstTime)
                {
				    if (this._showFiltros) 
				    {
				        this.setFiltro();
				    }
			        else this.gotoHora(document.getElementById('divepgfinal'));
			    }
			}else{
				this._info("warning", 0, "No hay resultados para el getEPG");
			}
			retorno=null;
		}
		else 
		{
		    this._info("error", 4, " [getEPG]");
		    if(document.getElementById("ajaxloading"))
        	{
        	    document.getElementById("ajaxloading").style.display="none";
            }
		    parent.Create.alerta("No se han obtenido canales.",miroute);
		}    
		var sgaction=getCookie("sgaction","");    
		if(sgaction!="")
		{
		    var sgparams=sgaction.split("::");
		    switch(sgparams[0])
		    {
		        case "vercanal":
		           
		            this._eventDatos = Array();
					this._eventDatos = {"idChannel":sgparams[1]};
					this.popupPanel("vercanal");
					this._popup="vercanal";
		      break;
		    }
		}
		document.cookie="sgaction=";
	}, 

	/**********************************************************************************************
	* setFiltro
	**********************************************************************************************/
	setFiltro: function()
	{
		var dias = document.getElementById("dias");
		var horas = document.getElementById("horas");
		if (dias!=undefined && horas!=undefined)
		{
			if(dias.length<=0) 
			{
                this._horario= Array();
    			var fecha = new Date();

    			this.currentIndexDate=1;
    			for(var numdias=0;numdias<8;numdias++)
    			{
    				//BUG 1008 yesterday
    			    if (numdias==0) this.subFecha(0,0,1,0,0,0);
    			  	
    			    this._horario[this._horario.length]={"dias":(this.startDate[0]*1)+"-"+(this.startDate[1]*1)+"-"+(this.startDate[2]), "horas":Array()};
    			    for (var i=0; i<24; i++)
    			    {
    			        this._horario[this._horario.length-1]["horas"][this._horario[this._horario.length-1]["horas"].length]=i;
    			    }
    			    if(this.currentDate[0]==this.startDate[0] && this.currentDate[1]==this.startDate[1] && this.currentDate[2]==this.startDate[2]) 
    			    {
    			        this.currentIndexDate=numdias;
    			    }
    			    tmpdiatxt=this.getTxtDateFiltro(this._horario[this._horario.length-1]["dias"]);
    			    
    				
    				if(this.startDate[0]==fecha.getFullYear() && this.startDate[1]==fecha.getMonth()+1 && this.startDate[2]==fecha.getDate()) 
    			    {
    			        tmpdiatxt="Hoy";
    			    }
    			    
    			    if(this.startDate[0]==fecha.getFullYear() && this.startDate[1]==fecha.getMonth()+1 && this.startDate[2]==fecha.getDate()-1) 
    			    {
    			        tmpdiatxt="Ayer";
    			    }
      			 
    			    this.addElementFiltro(dias, tmpdiatxt, this._horario[this._horario.length-1]["dias"]);
                    this.addFecha(0,0,1,0,0,0);
          
                }
             
              
    			for (var j=0; j < this._horario[0]["horas"].length; j++)
    			{
    			    tmphoratxt=(""+this._horario[0]["horas"][j]).toDigit(2)+":00h";
    				this.addElementFiltro(horas, tmphoratxt,Number(this._horario[0]["horas"][j]));
    		    }
    		}
		    dias.selectedIndex=this.currentIndexDate;
			horas.selectedIndex=this.currentDate[3];
			this.gotoHora(horas);
			
		}
		else parent.Create.alerta("[setFiltro] No se pueden iniciar los filtros.",miroute);
		
	},
	
	/**********************************************************************************************
	* getTxtDateFiltro
	**********************************************************************************************/
	getTxtDateFiltro: function(fecha){
		var afecha = fecha.split("-");
		var tmpdia= new Date();
    
    var dia = Number(afecha[2]);
    var mes = Number(afecha[1])-1;
    var anno = Number(afecha[0]);
    var diferencial = 0;

    //DVG::bug 1244:aparentemente, el orden en el que se realiza el set debe ser este para que no haya problemas. poneindo
    //como antes, si, por ejemplo, tenemos que hoy es 30 de enero, cuando vamos a poner el mes, y ponemos febrero, como no hemos
    //cambiado el día, se queda con el siguiente mes que sí que tenga ese día 
		tmpdia.setDate(dia);
    tmpdia.setMonth(mes);
    tmpdia.setYear(anno);
    
		tmpdiatxt=""+this._aDias[tmpdia.getDay()]+", "+tmpdia.getDate()+" de "+this._aMeses[tmpdia.getMonth()];
		return tmpdiatxt;
	},
	
	/**********************************************************************************************
	* addElementFiltro
	**********************************************************************************************/
	addElementFiltro: function(el, txt, val){
	  var y=document.createElement('option');
	  y.text=txt;
	  y.value=val;
		try{
			el.add(y,null); 
		}	catch(ex){
			el.add(y); // IE only
		}

	},
	
	drawEPGLast: function(idch){
	    var el = document.getElementById('epg'+idch);
        if (el!=undefined)
		{
			var divepg=document.getElementById('divepgfinal');
            if(divepg!=undefined)
            {
                el.removeChild(divepg);
            }
		    el.innerHTML+="<div id='divepgfinal' name='epg' class='SGfinal'><input type='hidden' name='final' value='fecha'><img id='epgfinal' name='epgfinal' src='"+miroute+"/pixtrans.gif' border='0'></div>";
        }
        if(document.getElementById("ajaxloading"))
		    document.getElementById("ajaxloading").style.display="none";
		this.retornos=null;
	},
	
	drawEPGRet: function(i,cond){
	    
	    if(document.getElementById("ajaxloading"))
        {
            document.getElementById("ajaxloading").style.display="none";
        	//document.getElementById("ajaxloading").innerHTML="<br>";
        }
		if(this.retornos && this.retornos[i])
		    this.drawEPG(this.retornos[i],cond);
	},
	
	/**********************************************************************************************
	* drawEPG
	**********************************************************************************************/
	drawEPG: function(obj, cond)
	{
		var el = document.getElementById('epg'+obj._idChannel);
		if (el!=undefined)
		{
			var hora="";
			if (obj._startTime!="")
			{
				ainicio = obj._startTime.split(" ");
				afin = obj._endTime.split(" ");
				a_dia = ainicio[0].split("-");
				a_hora = ainicio[1].split(":");
				a_diafin = afin[0].split("-");
				a_horafin = afin[1].split(":");
				hora = a_hora[0]+":"+a_hora[1];
				if (this.firstTime && cond)
				{
					this.setEspacios(el, a_hora[0], a_hora[1]);
				}
			}

			eventWidth = this._horaWidth * obj._diffHoras ; 
			
			if(document.navegador==2)
                eventWidth-=6;
            else eventWidth+=0.5;
            var label = obj._idChannel+"#"+obj._programId+"#"+obj._idEvent;
            if(obj._HTMLTitle=="") obj._HTMLTitle="+";
            
            var rel="";
            if(this.navegador==1 && obj._Relevant*1>0) rel="Relevant";
            else if(obj._Relevant*1>0)  obj._HTMLTitle+="<div class='estrellita' ></div>";
                
            if(!obj._Cathegory || obj._Cathegory=="undefined" || obj._Cathegory=="") cat="";
            else if(obj._Cathegory.indexOf("Infantil")>=0 || obj._Genre.indexOf("Infantil")>=0) cat="Infantil";
            else if(obj._Cathegory.indexOf("Programas - Cine")>=0) cat="Cine";
            else cat=obj._Cathegory.split("-")[0].replaceAll(" ","").toLowerCase();
            
            if(cat=="película" || cat=="Película") cat="Cine";
            el.innerHTML+="<div id='program"+label+"' name='epg' class='event' style=' width: "+eventWidth+"; background:url("+miroute+"/bg_"+escape(cat.toLowerCase())+".gif) left top;' title='"+obj._startHour+"-"+obj._endHour+" "+obj._Title+"\n["+obj._Cathegory+"]'><span name='epg' id='ellipsisSpan"+label+"' class='txtEpg"+rel+"'>" + obj._HTMLTitle + "</span></div>";
			
		}
		else
		{
			this._info("error", 0, "No se ha podido dibujar (drawEPG) el evento: "+obj._idEvent+" "+obj._Title);
		}
	}, 

	/**********************************************************************************************
	* setEspacios
	**********************************************************************************************/
	setEspacios: function(el, hora, minutes){
		
		var cond=true
		for (var i=Number(this.horaIni); i!=Number(hora); i++){
			if (i>=24){
				i=-1;
				cond=false;
			}else{
				el.innerHTML+="<div id='blank' name='epg' style='width: "+this._horaWidth+";'>&nbsp;</div>";
			}
		}
		if (Number(minutes)>0)
			el.innerHTML+="<div id='blank' name='epg' style='width: "+((Number(minutes)*this._horaWidth)/60)+";'>&nbsp;</div>";
	}, 
		
	/**********************************************************************************************
	* days_between
	**********************************************************************************************/
	hours_between: function(date1, date2) {
	
    // The number of milliseconds in one day
//    var ONE_DAY = 1000 * 60 * 60 * 24;
    var ONE_DAY = 1000 * 60 * 60;

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime();
    var date2_ms = date2.getTime();

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms);
    
    // Convert back to days and return
   //return Math.round(difference_ms/ONE_DAY);
    return (difference_ms/ONE_DAY);
	
	},

	/**********************************************************************************************
	* getProgram
	**********************************************************************************************/
	getProgram: function(idProgram,idEvent){
		
	  this._info(1, 3," [getProgram]");
		this._cleanResults();
		var params = "do=ajax@Parrilla&accion=getprogram&idprogram="+idProgram+"&idevent="+idEvent;
		this._info("info", 0, params);
		this.ajx.setTxtCargando(this.ajx_TxtCargando);
		this.ajx.objOwner = this;//this._objOwner;
		this.ajx.setValores(params);
		this.ajx.setURL("index.php");
		this.ajx.ResultinTA(true);
		this.ajx.setCapa("SGresult");
		this.ajx.setCallBack("getProgram_callback");
		this.ajx.runAjx();
	}, 
	
	/**********************************************************************************************
	* getProgram_callback
	**********************************************************************************************/
	getProgram_callback: function(){
		this._info("info", 0,"..:: OK ::.. getProgram cargado!!");
		xmlsrc = this._result.value;
		if (xmlsrc!=" " && xmlsrc!=""){
		    var obj = new jsProgram();
			this._Programs = obj.parser(xmlsrc);
			if (this._Programs.length)
			{
				this.drawProgram();
				return;
			}
		    else parent.Create.alerta("No se obtuvo información para este programa",miroute);
		}
		else 
		{
		    parent.Create.alerta("No se obtuvo información para este programa",miroute);
		}
		idProgramclick="";
	}, 

	/**********************************************************************************************
	* drawProgram
	**********************************************************************************************/
	drawProgram: function(){
		this._capaProgram.style.display="none";

		var el = document.getElementById('ellipsisSpan'+this._eventDatos["idChannel"]+'#'+this._eventDatos["idProgram"]+'#'+this._eventDatos["idEvent"]);
		var elprog = document.getElementById('program'+this._eventDatos["idChannel"]+'#'+this._eventDatos["idProgram"]+'#'+this._eventDatos["idEvent"]);
		
		if (el!=undefined)
		{
			
			
			if (this._isMini)
		{
		    
		    if (this.navegador==1){
		          if (this.ieVer==7){
		          	this._capaProgram.style.left = 20+ this.getOffsetLeft(el) - (this.getOffsetLeft(el)- this.getOffsetLeft(this._capaContenido));
								this._capaProgram.style.top = (-15)+(document.navegador==1?-6:-2) + this.getOffsetTop(el) + this._lineEPGHeight;
							}
		          else{
		          	this._capaProgram.style.left = -1+ this.getOffsetLeft(el) - (this.getOffsetLeft(el)- this.getOffsetLeft(this._capaContenido));
								this._capaProgram.style.top = (-29)+(document.navegador==1?-6:-2) + this.getOffsetTop(el) + this._lineEPGHeight;
							}
		
		    }
		    else{
		    	    this._capaProgram.style.left = this.getOffsetLeft(el) - (this.getOffsetLeft(el)- this.getOffsetLeft(this._capaContenido));
							this._capaProgram.style.top = (document.navegador==1?-6:-2) + this.getOffsetTop(el) + this._lineEPGHeight;
		
		    }
		}
		else{
			this._capaProgram.style.left = this.getOffsetLeft(el) - (this.getOffsetLeft(el)- this.getOffsetLeft(this._capaContenido));
			this._capaProgram.style.top = (document.navegador==1?-6:-2) + this.getOffsetTop(el) + this._lineEPGHeight;
    }  
      
      
      
      
      
            
            cat=elprog.style.backgroundImage.replaceAll("_",".").split(".");
            cat=cat[cat.length-2];
            
            this._capaProgram.style.backgroundImage = "url("+miroute+"/pico_"+cat+".gif)";
            this._capaProgram.style.backgroundRepeat = "repeat";
            this._capaProgram.style.backgroundPosition = "left top";
            
            m_title=this._Programs[0]._title;
            m_newsassociated=this._Programs[0]._newsassociated;
            minews=this._Programs[0]._newsassociated;
			
		    /*if (this._Programs[0]._chapterNumber!="" && this._Programs[0]._chapterNumber!="undefined" && this._Programs[0]._chapterNumber!="0"){
				m_chapterNumber=" : Episodio "+this._Programs[0]._chapterNumber;
			}else */
			m_chapterNumber="";
				
			m_genre=""+this._Programs[0]._genre;
			m_cathegory=""+this._Programs[0]._cathegory;
			var m_gencat='';
			if(m_genre!="undefined" && m_genre!="" && m_cathegory!="undefined" && m_cathegory!=""){
			    m_gencat=m_genre+' - '+m_cathegory;
			    
			}
			else if(m_genre!="undefined" && m_genre!="")
			    m_gencat=m_genre;
			else if(m_cathegory!="undefined" && m_cathegory!="")
			    m_gencat=m_cathegory;
			    
			m_shortSynopsis=""+this._Programs[0]._longSynopsis;
			if(m_shortSynopsis=="" || m_shortSynopsis=="undefined") m_shortSynopsis=""+this._Programs[0]._shortSynopsis;
			if(m_shortSynopsis=="undefined") m_shortSynopsis="";
			
			if (this._isMini) widthInfo=" style='width: 45%' ";
			else widthInfo="";
			    
		    miFecha=this._epg[this._epgByID[this._eventDatos["idEvent"]]]._startTime.substr(0,13);
		    if (m_cathegory.toLowerCase().indexOf("series")!=-1) myCategoria="series-tv";
        if (m_cathegory.toLowerCase().indexOf("deporte")!=-1) myCategoria="deportes";
        if (m_cathegory.toLowerCase().indexOf("infantil")!=-1) myCategoria="infantil";
        if (m_cathegory.toLowerCase().indexOf("programa")!=-1) myCategoria="programas-tv";
        if (m_cathegory.toLowerCase().indexOf("cine")!=-1) myCategoria="peliculas";
        
        myTitle=m_title;
        myTitle=myTitle.toLowerCase();
 				var salida='';
 				var letra;
 				for(i=0;i<myTitle.length;i++){
 				   letra=myTitle.charAt(i);
 				   letra=letra.replace(' ','-');
 				   letra=letra.replace('á','a');
 				   letra=letra.replace('é','e');
 				   letra=letra.replace('í','i');
 				   letra=letra.replace('ó','o');
 				   letra=letra.replace('ú','u');
 				   letra=letra.replace('@','-');
 				   letra=letra.replace('/','-');
 				   letra=letra.replace('?','-');
 				   letra=letra.replace('¿','-');
 				   letra=letra.replace('.','-');
 				   letra=letra.replace(':','-');
 				   letra=letra.replace(';','-');
 				   letra=letra.replace('"','-');
 				   letra=letra.replace('\'','-');
 				   letra=letra.replace('(','-');
 				   letra=letra.replace(')','-');
 				   letra=letra.replace('!','-');
 				   letra=letra.replace('º','-');
 				   letra=letra.replace('ª','-');
 				   letra=letra.replace('*','-');
 				   letra=letra.replace('&','-');
 				   letra=letra.replace('\\','-');
 				   letra=letra.replace('ñ','n');
 				   letra=letra.replace('%','');
 				   salida+=letra
 				}
 				myTitle=salida;
        
            //this._capaProgram.innerHTML='<div class="fichaprogramafoto" name="button"><img src="'+this._pathServer+this._epg[this._epgByID[this._eventDatos["idEvent"]]]._Logo+'" onerror="if(this.src.indexOf(\'ima_dest.jpg?nc\')<=0) this.src=\''+miroute+'/ima_dest.jpg?nc\';" width="111" height="75" /></div>';
            this._capaProgram.innerHTML='<div class="fichaprogramaflecha" name="button"><img src="'+miroute+'/f_ficha.gif" ></div>';
      		this._capaProgram.innerHTML+='<div class="fichaprogramainfo" '+widthInfo+' name="button"><strong>'+this._Channels[this._ChannelsByID[this._eventDatos["idChannel"]]]._longName+' - '+this._epg[this._epgByID[this._eventDatos["idEvent"]]]._startHour+' - '+this._epg[this._epgByID[this._eventDatos["idEvent"]]]._endHour+'<br /><span class="fichaprogramainfoHigh"><b>'+m_title+'</b>'+m_chapterNumber+'</span><br />'+m_gencat+'<br /></strong><span id=m_shortSynopsisSpan >'+m_shortSynopsis+'</span></div>';
      		
      		if (this._isMini)
      				if (this.navegador==3)
      					this._capaProgram.innerHTML+='<div class="fichaprogramacerrar" name="button" ><a href="javascript:;"><span style="cursor:pointer;font-size:11px;  margin-left:-90px;  display:block; width:100px; text-align:right;" class="botonficha"  name="epg" id="btncerrar">[ Cerrar ]</span></a></div>';
      				else
      					this._capaProgram.innerHTML+='<div class="fichaprogramacerrar" name="button" ><a href="javascript:;"><span style="cursor:pointer;font-size:11px; display:block; width:100px; text-align:right;" class="botonficha"  name="epg" id="btncerrar">[ Cerrar ]</span></a></div>';	


      		else{
      			 if (this.navegador==1)
      			  	this._capaProgram.innerHTML+='<div class="fichaprogramacerrar2" name="button" ><a href="javascript:;"><span style="cursor:pointer;font-size:11px; display:block; width:100px; text-align:right;" class="botonficha"  name="epg" id="btncerrar">[ Cerrar ]</span></a></div>';
      		   else
      		   	  this._capaProgram.innerHTML+='<div class="fichaprogramacerrar" name="button" ><a href="javascript:;"><span style="cursor:pointer;font-size:11px; display:block; width:100px; text-align:right;" class="botonficha"  name="epg" id="btncerrar">[ Cerrar ]</span></a></div>';
      		   	  
      		}
      		var botonnoticias="";
      		if ((this._Programs[0]._newsassociated!=undefined) && (this._Programs[0]._newsassociated!="")) 
      		{
      		   if (this._isMini)
					      botonnoticias='<a href="javascript:;" target="_parent"><span style="cursor:pointer;font-size:11px; display:block; width:100px; text-align:right; " class="botonficha" name="button" id="btn_noticias">[ Noticia ]</span></a>';
					   else{
					      if (this.navegador==1)
					        botonnoticias='<a href="javascript:;" target="_parent"><span style="cursor:pointer;font-size:11px; display:block; text-align:right; " class="botonficha" name="button" id="btn_noticias">[ Noticia ]</span></a>';
					      else
					      	botonnoticias='<a href="javascript:;" target="_parent"><span style="cursor:pointer;font-size:11px; display:block; width:100px; text-align:right; " class="botonficha" name="button" id="btn_noticias">[ Noticia ]</span></a>';
					   }
					     	
      		}
  		    
  		    
  		    if (this._isMini)
					{
					    
					    if (this.navegador==1){
					          if (this.ieVer==7)
											this._capaProgram.innerHTML+='<div class="fichaprogramabtn2" style="width:140px;" name="button"><a href="javascript:;"><span style="cursor:pointer; font-size:11px; display:block; width:100px; text-align:right; " class="botonficha"  name="button" id="btn_ficha">[ Ver ficha ]</span></a>'+botonnoticias+'</div>';					
					          else
					          	this._capaProgram.innerHTML+='<div class="fichaprogramabtn2" style="width:140px;" name="button"><a href="javascript:;"><span style="cursor:pointer; font-size:11px; display:block; width:100px; text-align:right; " class="botonficha"  name="button" id="btn_ficha">[ Ver ficha ]</span></a>'+botonnoticias+'</div>';
					
					    }
					    else{
					    	    this._capaProgram.innerHTML+='<div class="fichaprogramabtn" name="button"><a href="javascript:;"><span style="cursor:pointer; font-size:11px; display:block; width:80px; text-align:right; " class="botonficha" name="button" id="btn_ficha">[ Ver ficha ]</span></a></div><br /><div class="fichaprogramabtn4">'+botonnoticias+'</div>';
					
					    }
					}
					else
					{
						   if (this.navegador==1)
					        this._capaProgram.innerHTML+='<div class="fichaprogramabtn3" name="button"><a href="javascript:;"><span style="cursor:pointer;font-size:11px; display:block; width:80px; text-align:right; " class="botonficha" name="button" id="btn_ficha">[ Ver ficha ]</span></a>'+botonnoticias+'</div>';
					     else
					        this._capaProgram.innerHTML+='<div class="fichaprogramabtn" name="button"><a href="javascript:;"><span style="cursor:pointer; font-size:11px; display:block; width:80px; text-align:right; " class="botonficha" name="button" id="btn_ficha">[ Ver ficha ]</span></a></div><br /><div class="fichaprogramabtn4">'+botonnoticias+'</div>';
					       
					}

           /**********************************************************************************
           GRABACIONES REMOTAS
           **********************************************************************************/            
           //id del botón: "btn_rec"
           var startTime    = this._epg[this._epgByID[this._eventDatos["idEvent"]]]._startHour;
           var endTime      = this._epg[this._epgByID[this._eventDatos["idEvent"]]]._endHour
           var title        = m_title;
           if (m_chapterNumber!=null && m_chapterNumber!="")
             title+="("+m_chapterNumber+")";
          //alert ("Insertando rec para '"+title+"' ("+startTime+"-"+endTime+")");
           
  		   var jsrec = new JSRecorder(this._eventDatos["idEvent"],this._Channels[this._ChannelsByID[this._eventDatos["idChannel"]]]._longName,title,this._epg[this._epgByID[this._eventDatos["idEvent"]]]._startTime,true,true,false,"","javascript:;","","onRecPressed","");
           jsrec.CONST_RECORD_STR = "<img src='"+miroute+"/btn_grabar.gif?nca' />";
           //jsrec.CONST_RECORD_STR = "";
  		    if (this._isMini)
    		{
    		    if (this.navegador==1)
                {
                   jsrec.CONST_DIV_CSS ="RECbtn2";jsrec.CONST_SPAN_CSS ="botonREC";jsrec.CONST_LINK_CSS ="botonREC";
                   this._capaProgram.innerHTML+=jsrec.draw();
    		    }
    		    else
                {
                   jsrec.CONST_DIV_CSS ="RECbtn";jsrec.CONST_SPAN_CSS ="botonREC";jsrec.CONST_LINK_CSS ="botonREC";
                   this._capaProgram.innerHTML+=jsrec.draw();
    			}
    		}
    		else
    		{
  				if (this.navegador==1)
  			    {
                   jsrec.CONST_DIV_CSS ="RECbtn3";jsrec.CONST_SPAN_CSS ="botonREC";jsrec.CONST_LINK_CSS ="botonREC";
                   this._capaProgram.innerHTML+=jsrec.draw();
                }
  			    else
                {
                   jsrec.CONST_DIV_CSS ="RECbtn";jsrec.CONST_SPAN_CSS ="botonREC";jsrec.CONST_LINK_CSS ="botonREC";
                   this._capaProgram.innerHTML+=jsrec.draw();
               }
  					       
    		}
           /**********************************************************************************
           GRABACIONES REMOTAS
           **********************************************************************************/            
  		
			var ch = document.getElementById('ch'+this._eventDatos["idChannel"]);
			var epg = document.getElementById('epg'+this._eventDatos["idChannel"]);
			ch.style.height=Number(ch.style.height.replace("px",""))+this._programHeight+this._padding+"px";
			epg.style.height=Number(epg.style.height.replace("px",""))+this._programHeight+this._padding+"px";
			this._capaProgram.style.display="block";
			
			var m_shortSynopsisSpan=document.getElementById("m_shortSynopsisSpan");
			m_shortSynopsis=m_shortSynopsis.addVDots(m_title+m_chapterNumber+'<br />'+m_gencat+'<br />',"m_shortSynopsisSpan",62);
            m_shortSynopsisSpan.innerHTML=m_shortSynopsis;
            heightEPG=this._capaProgram.style.top;
            heightChannel=this._capaCanales.style.top;
          
            while(this._capaProgram.style.top.replace("px","")*1+this._capaProgram.style.height.replace("px","")*1>=this.maxHeight())
            {
                this._capaEPGtop--;
                this._capaEPG.style.top=this._capaEPGtop+"px";
                this._capaCanalestop--;
                this._capaCanales.style.top=this._capaCanalestop+"px";
                this._capaProgram.style.top=this._capaProgram.style.top.replace("px","")*1-1;
            }
            
			this.isOpenProgram=true;
		}else{
			this._info("info", 0, "no se ha podido recuperar el origen del evento 'ellipsisSpan#"+this._Programs[0]._programId+"'");
		}
		
	}, 
	/**********************************************************************************************
	* restoreHeight
	**********************************************************************************************/
	restoreHeight: function()
	{
		this._capaProgram.style.display="none";
		if (this._eventDatos["idChannel"]!=undefined && this.isOpenProgram)
		{
			while(this._capaEPGtop<0 && this._capaProgram.style.top.replace("px","")*1<this.maxHeight())
            {
                this._capaEPGtop++;
                this._capaEPG.style.top=this._capaEPGtop+"px";
                this._capaCanalestop++;
                this._capaCanales.style.top=this._capaCanalestop+"px";
                this._capaProgram.style.top=this._capaProgram.style.top.replace("px","")*1+1;
            }
            
			var ch = document.getElementById('ch'+this._eventDatos["idChannel"]);
			var epg = document.getElementById('epg'+this._eventDatos["idChannel"]);

			ch.style.height=Number(ch.style.height.replace("px",""))-(this._programHeight+this._padding)+"px";
			epg.style.height=Number(epg.style.height.replace("px",""))-(this._programHeight+this._padding)+"px";
			
			this.isOpenProgram=false;
		}
	}, 
	
    maxHeight: function()
	{
	    if(this._isMini)
	    {
	        return (this.navegador==1)?376:400;
	    }
	    return this._parrillaHeight+2;
	},
	
	/**********************************************************************************************
	* _cleanResults
	**********************************************************************************************/
	_cleanResults: function(){
		this._result.value="";
	}, 
	
	/**********************************************************************************************
	* _info
	**********************************************************************************************/
	_info: function(tipo, idMsg, txt){
		if (this.showDebug){
			var txtSalida="";
			var d = new Date();
			txtSalida+="("+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+") ";
			
			switch(tipo){
				case "info": txtSalida+=" [INFO] "; break;
				case "warning": txtSalida+=" [WARNING] "; break;
				case "error": txtSalida+=" [ERROR] "; break;
				case "critical": txtSalida+=" *** CRITICAL *** "; break;
				default: txtSalida+=" [INFO] "; break;
			}
			switch(idMsg){
				case 1:	txtSalida+=" Parrilla creada con éxito."+txt; break;
				case 2:	txtSalida+=" Objeto inicializado con éxito."+txt; break;
				case 3:	txtSalida+=" Estableciendo conexión con Web Service..."+txt; break;
				case 4:	txtSalida+=" No se han obtenido resultados."+txt; break;
				case 5:	txtSalida+=" Horario creado con éxito."+txt; break;
				default:
					if (txt==undefined) txtSalida+=" ***** mensaje no disponible *******";
					else txtSalida+=txt;
				break;
			}
			
			txtSalida+="<br>\n";
			this.capaDebug.innerHTML+=txtSalida;
			
		}
	},
	
	/**********************************************************************************************
	* getOffsetLeft
	**********************************************************************************************/
		getOffsetLeft: function(el) {
		  var ol = el.offsetLeft;
		  while ((el = el.offsetParent) != null)
		    ol += el.offsetLeft;
		  return ol;
		}, 
		
	/**********************************************************************************************
	* _cleanResults
	**********************************************************************************************/
		getOffsetTop: function(el) {
		  var ot = el.offsetTop;
		  while((el = el.offsetParent) != null)
		   ot += el.offsetTop;
		  return ot;
		},
		
	/**********************************************************************************************
	* _chkFinalEPG
	**********************************************************************************************/
	_chkFinalEPG: function()
    {
			var el = document.getElementById("epgfinal");
			if (el!=undefined)
			{
				if (this.getOffsetLeft(el) <= (this.getOffsetLeft(this._capaContenido)+this._parrillaWidth))
				{
					// Do not try to load 2 times ePG if it's loading
		            if(document.getElementById("ajaxloading") && document.getElementById("ajaxloading").style.display=="block")
		                return false;
		
					this._info("info", 0, "Recuperamos nueva EPG");

					if (this.firstTime) 
					    this.firstTime=false;
					
					if(this._numDias<7 && this.getEPG(this._onlyChannelsTxt, this._numDias, false)==true)
					{
					    return true;
					}
					el.id=""; //borramos marca
				}
			}
			else this._info("warning", 0, "marca 'epgfinal' no encontrada");
			return false;
		},
		
  /**********************************************************************************************
	* subFecha
	**********************************************************************************************/
			
	  subFecha: function(y,m,d,h,i,s) {
			
			var tmpfecha= new Date();
			tmpfecha.setFullYear(Number(this.startDate[0]*1),Number(this.startDate[1]*1)-1,Number(this.startDate[2]*1),12,0,0);
			tmpfecha.setDate(tmpfecha.getDate()-d);
			this.startDate[2] = tmpfecha.getDate();
	    this.startDate[1] = tmpfecha.getMonth()+1;
	    this.startDate[0] = tmpfecha.getFullYear();
	    return true;
		},
		/**********************************************************************************************
	* addFecha
	**********************************************************************************************/
	
		addFecha: function(y,m,d,h,i,s) {
			
			var tmpfecha= new Date();
			tmpfecha.setFullYear(Number(this.startDate[0]*1),Number(this.startDate[1]*1)-1,Number(this.startDate[2]*1),12,0,0);
			tmpfecha.setDate(tmpfecha.getDate()+d);
			this.startDate[2] = tmpfecha.getDate();
	    this.startDate[1] = tmpfecha.getMonth()+1;
	    this.startDate[0] = tmpfecha.getFullYear();
	    return true;
		},
		
	/**********************************************************************************************
	* getDataPopup
	**********************************************************************************************/
		getDataPopup: function() {
			switch(this._popup){
				case "autonomicos":
				
					var codpostal = document.getElementById("codigopostal");
					top.location.href="?do=Programacion&date="+miFechaCodigoPostal+"&postalCode="+ codpostal.value+"&type=a";
					if (codpostal!=undefined){
						if (!isNaN(codpostal.value) && codpostal.value!=""){
							this._cleanParrilla();
							YAHOO.example.container.panel2.hide();
							this._Year=this.currentDate[0];
							this._Mes=this.currentDate[1];
							this._Dia=this.currentDate[2];
                            this.fecIni = ""+this._Year+"-"+(""+(this._Mes-1)).toDigit(2)+"-"+this._Dia+" "+this._Hora+":"+this._Minuto;
							this.getChannels(null, "1", null, null, codpostal.value, null);
						}else parent.Create.alerta("Por favor, introduzca un código postal válido.",miroute);
					}else parent.Create.alerta("No se ha podido recuperar la información",miroute);
				break;
				case "tdt":
					var codpostal = document.getElementById("codigopostal");
					top.location.href="?do=Programacion&date="+miFechaCodigoPostal+"&postalCode="+ codpostal.value+"&type=t";
					
					if (codpostal!=undefined){
						if (!isNaN(codpostal.value) && codpostal.value!=""){
							this._cleanParrilla();
							YAHOO.example.container.panel2.hide();
							this._Year=this.currentDate[0];
							this._Mes=this.currentDate[1];
							this._Dia=this.currentDate[2];
                            this.fecIni = ""+this._Year+"-"+(""+(this._Mes-1)).toDigit(2)+"-"+this._Dia+" "+this._Hora+":"+this._Minuto;
							this.getChannels(null, null, "1", null, codpostal.value, null);
						}else parent.Create.alerta("Por favor, introduzca un código postal válido.",miroute);
					}else parent.Create.alerta("No se ha podido recuperar la información",miroute);
				break;
			}
		},
		
	/**********************************************************************************************
	* _cleanParrilla
	**********************************************************************************************/
		_cleanParrilla: function() {
			var channels=getCookie("heightChannel");
	  	if ((channels!=undefined) && (channels!="")){
			    altura=getCookie("heightChannel");
			    altura=(parseInt(altura)*-1)+50;
      }   
      else{
          altura=100;
      }
     
			this._capaEPG.innerHTML="<div align='center' style='position:absolute;left:"+(this._isMini?130:250)+"px;top:"+altura+"px;' id='ajaxloading' name='ajaxloading' ><img src='"+miroute+"/ajaxload.gif?nc'><br><br>Cargando informaci&oacute;n, aguarde un instante por favor</div>";
			
			this._capaEPG.style.top=0;
			this._capaEPG.style.left=0;
			this._capaEPGtop = -1;
		    this._capaEPGleft = 0;
		    this._capaHorario.innerHTML="";
			this._capaHorario.style.top=0;
			this._capaHorario.style.left=0;
			this._capaHorariotop = 0;
		    this._capaHorarioleft = 0;
			this._capaCanales.innerHTML="";
			this._capaCanales.style.top=0;
			this._capaCanales.style.left=0;
			this._capaCanalestop = 0;
			this._capaCanalesleft = 0;
			this._epg=Array();
			this._epgByID = Array();
			this._Channels = Array();
			this._ChannelsByID = Array();
			this._Programs = Array();
			this._onlyChannelsTxt = "";
			this._horario = Array();
			this._numDias = 0;
		
		},
		
	/**********************************************************************************************
	* cleanHorario
	**********************************************************************************************/
		cleanHorario: function(tipo) {
			switch(tipo){
				case "horas":
					var horas = document.getElementById("horas");
					if (horas != undefined){
						num=horas.length;
						for (var i=0; i < num; i++){
						  horas.remove(horas.selectedIndex);
						}
					}
				break;
			}
		},
		
	/**********************************************************************************************
	* _doClick
	**********************************************************************************************/
	_doClick: function(e) 
    {
        if(document.navegador==1)
		{
		    currHREF = event.srcElement.href;
		}
		else
		{
			try
			{
				currHREF = e.originalTarget.getAttribute("href");
				
			}
			catch(exc)
			{
				
				currHREF= e.target.href;
				//this.obj._info("warning", 0, "No se ha podido recuperar la propiedad ID. ["+e.originalTarget+"::"+tmpname+"::"+exc.description+"]");
			}
		}
		
		if(this.obj && this.obj.action)
		    this.action=this.obj.action;
		if(currHREF && currHREF.indexOf("do=Programacion&accion=verficha")>0 && this.action!="")
		{
		    document.cookie="sgaction="+this.action;
		}
	    else document.cookie="sgaction=";
	    return true;
	}
};

/**********************************************************************************
GRABACIONES REMOTAS
**********************************************************************************/            
function onRecPressed(canal,idevent,nameevent,pDate)
{
 parent.remoteRecord(UserIdGeneric,idevent,canal,nameevent,pDate,'RecordSingleProgram',couponIdGeneric);
}
/**********************************************************************************
GRABACIONES REMOTAS
**********************************************************************************/            
