
if (!window['RSS_EPD']) {
	window['RSS_EPD'] = {};
}

RSS_EPD.onReady = null;
RSS_EPD.win = window;
RSS_EPD.doc = window.document;
RSS_EPD.elementRSS = {tipo:"diario",params:null};
RSS_EPD.scripts = ['feedReader.js'];
RSS_EPD.css = ['rssStyle.css','rssOvacion.css'];
RSS_EPD.loaded = 0;
RSS_EPD.active = false;
RSS_EPD.rendered = false;
RSS_EPD.containerId = "elpais-rss";
RSS_EPD.domain = "www.elpais.com.uy";
RSS_EPD.config = {
		tipo:"diario",
		feed:true,
		feedChannel:"ultmom",
		feedURL: "http://www.elpais.com.uy/formatos/rss/index.asp?seccion=",
		logoUrl: "http://www.elpais.com.uy/formatos/rss/rss_vertical/images/logoELPAIS.gif", 
		width: 300,
		height: 350,
		scrollable: true,
		numEntries: 30,
		container:null,
		hideLogo:false};


RSS_EPD.render_handler = function(elem){
	try{		
		if(String(elem).indexOf(".js")!=-1){
			
			RSS_EPD.loaded++;
		}		
		
		if(RSS_EPD.loaded>=RSS_EPD.scripts.length){
			RSS_EPD.active=true;
			if(!RSS_EPD.rendered){
				RSS_EPD.renderAll(RSS_EPD.elementRSS.tipo,RSS_EPD.elementRSS.params);
			}
		}

	}catch(e){

	}

	return;
}



RSS_EPD.epd_render  =function(a,b,c,e){
	var m = window.document;
	
	if(c){
		var obj;
		if(a=="script"){
			obj=m.createElement("script");
			obj.type="text/javascript";
			obj.language="javascript";
			obj.src= "http://"+RSS_EPD.domain+"/formatos/rss/rss_vertical/"  + b;
		}else if(a=="css"){
			obj=m.createElement("link");
			obj.type="text/css";
			obj.href="http://"+RSS_EPD.domain+"/formatos/rss/rss_vertical/"  + b;
			obj.rel="stylesheet"
		}

		var f=m.getElementsByTagName("head")[0];
		f||(f=m.body.parentNode.appendChild(m.createElement("head")));

		if(a=="script"){
			try{

				
				if (obj.readyState){  //IE
					obj.onreadystatechange = function(){
						
						if (obj.readyState == "loaded" ||
								obj.readyState == "complete"){
							obj.onreadystatechange = null;
							
							RSS_EPD.render_handler(b);
						}
					};
				}else{  //Others
					obj.onload = function(){
						obj.onload=null;
						RSS_EPD.render_handler(b);
					};
				}
			}catch(e){

			}
		}

		f.appendChild(obj)
	}else if(a=="script")
			m.write('<script src="http://'+RSS_EPD.domain+'/formatos/rss/rss_vertical/'+b+'" type="text/javascript"><\/script>');
	else a=="css"&&m.write('<link href="http://'+RSS_EPD.domain+'/formatos/rss/rss_vertical/'+b+'" type="text/css" rel="stylesheet"></link>')


	return;

};


RSS_EPD.epd_feed_init = function(){
			
			var url = this.config.feedURL + this.config.feedChannel;

			var params = {logoUrl:this.config.logoUrl, 
				width:this.config.width,
				height:this.config.height,
				scrollable:this.config.scrollable,
				numEntries:this.config.numEntries,
				hideLogo: this.config.hideLogo};
						
			var feed = new FeedReader(document.getElementById(this.containerId));
			feed.show(url, params);
			
			return false;
}

RSS_EPD.epd_feed = function(){
	
	if(typeof FeedReader =="undefined"){
		RSS_EPD.epd_render("script","feedReader.js",true);
	}
}

RSS_EPD.epd_feed_clima =function (doc){ // 

	// ---sólo hay que modificar los parametros ----------------
	// --inicio parametros--------------------------------------------------
	var archivo="http://www.elpais.com.uy/formatos/rss/rss_vertical/clima.swf"; // nombre de la pelicula swf que quieres incluir (incluir ruta si es necesario)
	var ancho="300";  // ancho de la peli swf en píxeles o en porcentaje
	var alto="70";  // alto de la peli swf en píxeles o en porcentaje
	var version="7,0,19,0"; // version del flash player
	var quality="high"; // calidad de visualización de la peli
	var wmode="transparent";
	var s="";


	try{
	
	
	 s +=('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'" width='+ancho+' height='+alto+'>\n');
	 s +=('<param name="movie" value='+archivo+' />\n');
	 s +=('<param name="quality" value='+quality+' />\n');
	 s +=('<param name="wmode" value='+wmode+' />\n');
	 s +=('<embed src='+archivo+' wmode='+wmode+' quality='+quality+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+'><\/embed>');
	 s +=('</object>');
		oDiv = RSS_EPD.createElement("div", RSS_EPD.config.container, "", s, "divEPDClima");

	}catch(e){
		
	}

	return this;
}

RSS_EPD.renderAll = function(t,params){
	
	try{

		RSS_EPD.epd_feed.rendered=true;
		var cfg = RSS_EPD.config;
		cfg.tipo = t.toLowerCase();

		
		
		if(typeof(params)=="object"){
			cfg.numEntries = (params.numEntries || cfg.numEntries);
			cfg.height = (params.height || cfg.height);
			cfg.height = ((cfg.height>350)?350:cfg.height);
			cfg.feedChannel = (params.feedChannel || cfg.feedChannel);
		}

		if( ((cfg.tipo).indexOf("diario")!=-1) && cfg.feedChannel=="deportes"){
			cfg.tipo="ovacion";
		}

		
		switch(cfg.tipo){
			case "ovacion":
				cfg.feedURL = "http://www.ovaciondigital.com.uy/rss.asp";
				cfg.feedChannel="";
				cfg.logoUrl = "http://www.elpais.com.uy/formatos/rss/rss_vertical/images/logoOvacion.jpg";
				cfg.containerId = "ovacion-rss";
				break;
			case "clima":
				cfg.feed=false;
				break;
			case "diario":				
				break;
			case "diario+clima":
				cfg.hideLogo=true;
				break;
		}

		RSS_EPD.config = cfg;

		if(cfg.feed){
			RSS_EPD.epd_render("css","rssStyle.css",true);
		}

		switch(cfg.tipo){	
			case "clima":
				RSS_EPD.epd_feed_clima(RSS_EPD.doc);
				break;
			case "diario":
				break;
			case "diario+clima":				
				RSS_EPD.epd_feed_clima(RSS_EPD.doc);
				break;
			case "ovacion":
				RSS_EPD.epd_render("css","rssOvacion.css",true);
				break;
			default:

		}

		if(cfg.feed){
			oDiv = RSS_EPD.createElement("div", RSS_EPD.config.container, "", "Cargando...", RSS_EPD.containerId);
			RSS_EPD.epd_feed_init();
		}
		
	}catch(e){
		
		RSS_EPD.epd_feed.rendered=false;
	}
		
}


RSS_EPD.render = function(obj,t,config){
	
	RSS_EPD.onReady = RSS_EPD.epd_feed;
	RSS_EPD.config.container = (typeof(obj)=="object")?obj:document.getElementById(obj);
	RSS_EPD.elementRSS.tipo = (t||RSS_EPD.elementRSS.params);
	RSS_EPD.elementRSS.params = config;


	RSS_EPD.config.tipo = RSS_EPD.elementRSS.tipo;
	if(RSS_EPD.active){
		if(!RSS_EPD.rendered){
			RSS_EPD.renderAll(RSS_EPD.elementRSS.tipo,RSS_EPD.elementRSS.params);
			
		}
	}
	return false;
}

function epd_attachEvent (evt,callback){

	if(window.addEventListener)
		window.addEventListener(evt,callback,false);
	else if(window.attachEvent)
		window.attachEvent("on"+evt,callback);
	else{	
		var d=window["on"+evt];
		if(d!=null){
			window["on"+evt]=callback;
		}
	}
	return false;
}


RSS_EPD.createElement = function(tagName, parent, className, html, elemId) {
  var div = document.createElement(tagName);
  div.className = className;
  div.innerHTML = html;
  div.id = elemId;
  parent.appendChild(div);
  return div;
}

try{
	google.load("feeds", "1");
	google.setOnLoadCallback(RSS_EPD.epd_feed);
}catch(e){}