

function meteoDetailByCity(el,city, tpl){
	Ext.Ajax.request({		   
		   url: "rcv.meteo?ville="+city,
		   callback: function(options, success, o) {
		       if(success){
		         var rep=eval('('+o.responseText+')');
                          var data = {
			        ville: rep.location.displayName.split(",")[0],
			        temperature: rep.currentConditions.temperature,
			        tempRessentie: rep.currentConditions.feelsLikeTemperature,
			        humidite:rep.currentConditions.humidity,
			        icon: rep.currentConditions.icon,
			        lastUpdated: (rep.currentConditions.lastUpdated).substring(0,12),	        
			        jours: rep.forecast.days,
			        location:rep.location,
			        visibilite: rep.currentConditions.visibility,
			        max: (rep.forecast.days[0].high=="N/A")? rep.forecast.days[0].high : rep.forecast.days[0].high +"&#186;C" ,
			        min:(rep.forecast.days[0].low=="N/A")? rep.forecast.days[0].low : rep.forecast.days[0].low +"&#186;C" ,
			        max1: (rep.forecast.days[1].high=="N/A")? rep.forecast.days[1].high : rep.forecast.days[1].high +"&#186;C" ,
			        min1:(rep.forecast.days[1].low=="N/A")? rep.forecast.days[1].low : rep.forecast.days[1].low +"&#186;C" ,
			        max2: (rep.forecast.days[2].high=="N/A")? rep.forecast.days[2].high : rep.forecast.days[2].high +"&#186;C" ,
			        min2:(rep.forecast.days[2].low=="N/A")? rep.forecast.days[2].low : rep.forecast.days[2].low +"&#186;C" ,
			        jour:rep.forecast.days[0].dayName,
			        jour1:rep.forecast.days[1].dayName,
			        jour2:rep.forecast.days[2].dayName,
			        icon01:rep.forecast.days[0].parts[0].icon,
			        icon02:rep.forecast.days[0].parts[1].icon,
			        icon11:rep.forecast.days[1].parts[0].icon,
			        icon12:rep.forecast.days[1].parts[1].icon,
			        icon21:rep.forecast.days[2].parts[0].icon,
			        icon22:rep.forecast.days[2].parts[1].icon,
			        lever:rep.location.sunriseTime,
			        coucher:rep.location.sunsetTime			      
			  };//fin data
					
			     tpl.overwrite(el, data);	
			}
		  }
		})
}

//En ce moment
CMV.radio=[

'<div class="zone-radio" style="padding:0px;margin:0px;">',
    '<div id="photo-nowplaying"></div>',
    '<div id="nowplaying-zone">',
        '<div class="song-nowplaying">',
             '<p><span id="song-nowplaying-artiste"></span></p>',
             '<p><span id="song-nowplaying-emiss"></span></p>',
             '<p class="listenlive"><a href="#" style="color:#fff;text-decoration:none;">Ecouter en direct...</a></p>',
        '</div>',
    '</div>',
'</div>'


].join('')


//En ce moment
CMV.encemoment=['<table  border="0" width="305px"  cellspacing="0" cellpadding="0" id="table-radio">',
	'<tbody>',	
	  '<tr>',
		'<td>',
		'<div class="radio-zone-podcast" style="margin-top:15px;border-top:0px;">',
                      '<table><tr><td width="40"><img src="resources/images/camV/0000003/logo-rts-35x35.jpg" valign="bottom"></td><td>Journal de midi&nbsp;</td><td><img src="resources/images/camV/0000003/haut-parleur-red.gif" valign="bottom"></td></tr></table>',
                '</div>',

                '</td>',
		'</tr>',
		'<tr>',
		'<td>',
		'<div class="radio-zone-podcast" style="margin-top:5px;border-top:0px;">',
                      '<table><tr><td width="40"><img src="resources/images/camV/0000003/logo-rts-35x35.jpg" valign="bottom"></td><td>Journal de 18H00&nbsp;</td><td><img src="resources/images/camV/0000003/haut-parleur-red.gif" valign="bottom"></td></tr></table>',
                '</div>',
                '</td>',
		'</tr>',
		'<tr>',
		'<td>',

		'<div class="radio-zone-podcast" style="margin-top:5px;border-top:0px;">',
		      '<table><tr><td width="40"><img src="resources/images/camV/0000003/logo-35x16.jpg" valign="bottom"></td><td>Entrevue de Bertrand Njongang &nbsp;</td><td><img src="resources/images/camV/0000003/haut-parleur-red.gif" valign="bottom"></td></tr></table>',
                '</div>',
                '</td>',
		'</tr>',
        '</tbody>',
'</table>'

].join('')

/*CMV.invite=['<table><tbody><tr>',
                                 '<td valign="top" width="60%"><div style="margin-left:10px;margin-right:3px;">',
                                      '<br><p style="font:bold 14px arial;color:#555;">Hermann Ngoudjo</p><br>',
                                      '<p style="font:normal 11px verdana;color:#333;">Ce dimanche &agrave; Multisport, suivez un ph&eacute;nom&egrave;ne... La panth&egrave;re noire sera cham- pionne dans la prochaine ann&eacute;e!!!</p>',
                                      '<br><p>&raquo; <a href="/multisport" style="text-decoration:none;color:#dc1301;font-weight:bold;">Lire plus</a></p>',
                                 '</div></td>',
                                 '<td><div style="margin-right:4px;padding:3px;border:1px solid #999999;"><img src="resources/images/invites/Ngoudjo-120x132.jpg"></div</td>',
'</tr></tbody></table>'].join(''); */

CMV.invite=[''].join('');


CMV.messages=['<div id="scroller_messages1">',
      '<div class="jscroller2_up">',
'<p><span class="date">20h52 Temp&ecirc;te</span> - 14.700 foyers encore priv&eacute;s d\'&eacute;lectricit&eacute; dans le Sud-Ouest (ERDF)</p>',
'<p><span class="date">20h31 Football</span> - Willy Sagnol annonce l\'arr&ecirc;t de sa carri&egrave;re</p>',
'<p><span class="date">20h22 Enqu&ecirc;te</span> - Un homme mis en examen pour une balle perdue qui a bless&eacute; un chauffeur-livreur</p>',
'<p><span class="date">22h12 Corse</span> - Un homme de 26 ans abattu par balles &agrave; Bastia</p>',
'<p><span class="date">20h52 Temp&ecirc;te</span> - 14.700 foyers encore priv&eacute;s d\'&eacute;lectricit&eacute; dans le Sud-Ouest (ERDF)</p>',
'<p><span class="date">20h31 Footbal</span> - Willy Sagnol annonce l\'arrecirc;t de sa carri&egrave;re</p>',
'<p><span class="date">20h22 Enqu&ecirc;te</span> - Un homme mis en examen pour une balle perdue qui a bless&eacute; un chauffeur-livreur</p>',
'</div>',
'</div>'].join('')


//PODCAST
CMV.PodcastPortlet = Ext.extend(Ext.Panel, {
    title: 'PODCASTS',
    closeable: false,
    settings: false,
    resizeable: false,
    height:200,
    id:'box-id-podcast',
    html:'',
   // cls:'x-panel',
    plugins: Ext.ux.PortletPlugin ,
    autoLoad:{
       url: "/rcv.podcast",
       text: "Chargement...",
       callback: function(options, success, o) {
	      if(success){
                var rep=eval('('+o.responseText+')');
                var boxPodcast=Ext.getCmp('PodcastPortlet');
                var tpl4=new Ext.XTemplate(
                   '<div class="infiniteCarousel">',
                         '<div class="wrapper">',
                          '<ul>',
                                 '<tpl for=".">',
			              '<tpl if="radio==\'rcv\'">',
                                             '<li>',
                                                   '<a href="/news/podcast.rcv" title="{titre}">',
                                                        '<div  class="opacite" style="height:100px; width:100px;"><img src="{photo}" height="100" width="100"/></div>',
                                                        '<div class="box-inf">{journaliste}</div>',
                                                        '<div class="box-text">{[this.getTitre(values)]}</div>',
                                                    '</a>',
                                             '</li>',
                                      '</tpl>',
                                 '</tpl>',
                             '</ul>',
                         '</div>',
                             '<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>',
                     '</div>',
                  //  '<div style="font:normal 12px verdana,geneva, arial, helvetica;height:30px;width:305px;color:#851607;margin-bottom:10px;float:left;">Consulter tous les podcasts</div>',
                   {
                         getTitre: function(values){
                         var b=values.titre
                                 var a=b.split(" ")
                                 for(var i=0;i<a.length;i++){
                                   if(IsNumeric(a[i]) ){
                                    c=b.split(a[i])
                                   // alert(c[1])
                                   d=c[1].split(" ")
                                   var e=""
                                   if(d.length==5)
                                      e=d[3]+d[4]
                                    return "<p><span class='podcast-titre'>"+c[0]+"</span></p><p>"+ a[i]+ d[0]+" "+d[1]+" "+d[2]+"</p><p>"+ e+"</p>"
                                   }
                                 }

                         }
                   }


                 );
		 tpl4.overwrite(boxPodcast.body, rep.podcasts);
		 $('.infiniteCarousel').infiniteCarousel();
             }
         }
    }   
});
Ext.reg('PodcastPortlet', CMV.PodcastPortlet);

//SPORT
CMV.SportPortlet = Ext.extend(Ext.Panel, {
    title: 'SPORT',
    closeable: false,
    settings: false,
    id:'box-id-sport',
     draggable: false,
   validatedrop:true,

    html: '',
   plugins: Ext.ux.PortletPlugin ,
    autoLoad:{
       url: "/rcv.news?rubrique=2",
       text: "Chargement...",
       callback: function(options, success, o) {
	      if(success){
                var rep=eval('('+o.responseText+')');
                var boxSport=Ext.getCmp('SportPortlet');
                var tpl4=new Ext.XTemplate(

                   '<tpl for=".">',
			 '<tpl if="xindex &lt;7">',
                              '<div class="news" style="{[xindex ==1 ? "background:none;padding-top:5px;" : ""]}">',
                                    '<div class="news-picture">',
                                          '<img src="{smallimage}" width="90" height="62" alt=""/>',
                                    '</div>',
                                    '<p class="date">{pubdate}</p>',
                                    '<p class="titre"><a href="/news/sport.rcv?id={id}">{titre}</a></p>',
                              '</div>',
                         '</tpl>',
                         '<tpl if="xindex &gt; 6">',
                              '<tpl if="xindex==7">',
                                   '<div class="news">',
                                       '<ul class="news-more-list">',
                              '</tpl>',
                              '<li>',
                                   '<a href="/news/sport.rcv?id={id}">{titre}</a>',
                              '</li>',
                         '</tpl>',
                    '</tpl>',
                        '</ul>',
                    '</div>'

                 );
		 tpl4.overwrite(boxSport.body, rep.news);
             }
         }
    }
});
Ext.reg('SportPortlet', CMV.SportPortlet);

//Opinion
CMV.OpinionPortlet = Ext.extend(Ext.Panel, {
    title: 'Opinion',
    closeable: false,
    settings: false,
    resizeable: false,
    height: 370,
    id:'box-opinion',
    html: '',
    plugins: Ext.ux.PortletPlugin   ,
    autoLoad:{
       url: "/rcv.reactionsvocale",
       text: "Chargement...",
       callback: function(options, success, o) {
  	             if(success){
                        var rep=eval('('+o.responseText+')');
                        var boxOpinion=Ext.getCmp('OpinionPortlet');
                        var tpl4=new Ext.XTemplate(
                            '<div class="opinion">',
                                  /*  '<div class="opinion-top-header">',
                                          '<div class="opinion-header">',
                                                '<span class="double-sup">&raquo;</span> Votre opinion sur CRTVgate et Epervier',
                                          '</div>',
                                    '</div>',  */
                                    '<div class="holder">',

                                       '<div id="opinion-body" class="scroll-pane">',
                                                '<tpl for=".">',
                                                    '<div class="col-1" id="{id}mmmm{fichieraudio}" style="{[xindex % 2 !==0? "background-color:#fff;" : "background-color:#eee;"]}"><a href="#">{nom:ellipsis(28)}</a></div>',
                                                    '<div class="col-2" style="{[xindex % 2 !==0? "background-color:#fff;" : "background-color:#eee;"]}">{ladate:substr(5, 7)}</div>',
                                                '</tpl>',
                                       '</div>',
                                    '</div>',
                                    '<div class="reagir">Votre opinion compte. (1 514) 225-4126</div>',
                            '</div>'
                        )
                        tpl4.overwrite(boxOpinion.body, rep.reactionsvocales);
                        $('#opinion-body').jScrollPane({showArrows:true, scrollbarWidth:14, scrollbarMargin:0})
                        $(".col-1").click(function(){
                                  var id=this.id
                                  var params=id.split("mmmm");
                                  window.open("/player/player.html?fichier=reactionsvocales/"+params[1], "WinE", "width=420,height=290,toolbar=no,resizable=no");
                          })
                     }
         }
    }
});
Ext.reg('OpinionPortlet', CMV.OpinionPortlet);


//METEO
CMV.MeteoPortlet = Ext.extend(Ext.Panel, {
    title: 'Meteo',
    closeable: false,
    settings: false,
    resizeable: false,
    autoHeight: true,
    id:'box-meteo',
    html: '',
    plugins: Ext.ux.PortletPlugin   ,
    autoLoad:{
       url: "/rcv.meteo",
       text: "Chargement...",
       callback: function(options, success, o) {
  	             if(success){
                        var rep=eval('('+o.responseText+')');
                        var boxMeteo=Ext.getCmp('MeteoPortlet');
                        var data = {
			        ville: rep.location.displayName.split(",")[0],
			        temperature: rep.currentConditions.temperature,
			        tempRessentie: rep.currentConditions.feelsLikeTemperature,
			        humidite:rep.currentConditions.humidity,
			        icon: rep.currentConditions.icon,
			        lastUpdated: (rep.currentConditions.lastUpdated).substring(0,12),	        
			        jours: rep.forecast.days,
			        location:rep.location,
			        visibilite: rep.currentConditions.visibility,
			        max: (rep.forecast.days[0].high=="N/A")? rep.forecast.days[0].high : rep.forecast.days[0].high +"&#186;C" ,
			        min:(rep.forecast.days[0].low=="N/A")? rep.forecast.days[0].low : rep.forecast.days[0].low +"&#186;C" ,
			        max1: (rep.forecast.days[1].high=="N/A")? rep.forecast.days[1].high : rep.forecast.days[1].high +"&#186;C" ,
			        min1:(rep.forecast.days[1].low=="N/A")? rep.forecast.days[1].low : rep.forecast.days[1].low +"&#186;C" ,
			        max2: (rep.forecast.days[2].high=="N/A")? rep.forecast.days[2].high : rep.forecast.days[2].high +"&#186;C" ,
			        min2:(rep.forecast.days[2].low=="N/A")? rep.forecast.days[2].low : rep.forecast.days[2].low +"&#186;C" ,
			        jour:rep.forecast.days[0].dayName,
			        jour1:frenchDay(rep.forecast.days[1].dayName),
			        jour2: frenchDay(rep.forecast.days[2].dayName),
			        icon01:rep.forecast.days[0].parts[0].icon,
			        icon02:rep.forecast.days[0].parts[1].icon,
			        icon11:rep.forecast.days[1].parts[0].icon,
			        icon12:rep.forecast.days[1].parts[1].icon,
			        icon21:rep.forecast.days[2].parts[0].icon,
			        icon22:rep.forecast.days[2].parts[1].icon,
			        lever:rep.location.sunriseTime,
			        coucher:rep.location.sunsetTime			      
			  };//fin data


                        var tpl4=new Ext.XTemplate(
                            '<div class="meteo">',
                                       '<div class="meteo-body" div="meteo-body-div">',
                                         //  '<div class="bk1-header" style="margin-top:5px;margin-bottom:5px;"><div class="bk2-header"><div class="autreville"><span class="double-sup">&raquo;</span> {ville}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;details</div></div></div>',
                                           '<div class="firstday">',
                                                 '<img src="{icon01}" />',
                                                 '<p class="jour">Aujourd\'hui</p>',
                                                 '<p class="temperature">Max {max}</p>',
                                                 '<p class="temperature">Min {min}</p>',
                                           '</div>',
                                           '<div class="secondday">',
                                             '<img src="{icon11}"/>',
                                             '<p class="jour">Demain</p>' ,
                                             '<p class="temperature">Max {max1}</p>',
                                             '<p class="temperature">Min {min1}</p>',
                                           '</div>',
                                         '<div class="thirdday">',
                                           '<img src="{icon21}"/>',
                                           '<p class="jour">{jour2}</p>',
                                           '<p class="temperature">Max {max2}</p>',
                                           '<p class="temperature">Min {min2}</p>',
                                         '</div>',
                                       '</div>',
                                        '<div class="bk1-footer" style="margin-top:5px;margin-bottom:5px;"><span class="double-sup">&raquo;</span> {ville}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></div></div>',
                            '</div>'
                        )
                        tpl4.overwrite(boxMeteo.body, data);
                     //  	meteoDetailByCity($(".meteo-body")[0], "Douala",tpl4)
                        
                        new Ext.XTemplate('<div class="meteo"><div class="bk1-header"><div class="bk2-header"><div class="autreville"><span class="double-sup">&raquo;</span> Autre ville du Cameroun</div></div></div>',
                        '<div class="autreville-recherche">',
                          '<input type="text" name="ville-search" id="ville-search" size="40"/>',
                          '<input type="button" id="ville-search-button" class="search-button"/>',
                        '</div></div>').append(boxMeteo.body);

                         var store = new Ext.data.SimpleStore({
                            fields: ['abbr', 'ville'],
                            data : [['Bafoussam', 'Bafoussam'],['Bamenda', 'Bamenda'],['Bu&eacute;a', 'Buea'],['Douala', 'Douala'],['&Eacute;', 'Edea'],['Yaound&eacute;', 'Yaounde']]
                         });

                        var combo = new Ext.form.ComboBox({
                            store: store,
                            displayField:'ville',
                           // typeAhead: true,
                            mode: 'local',
                            forceSelection: true,
                            triggerAction: 'all',
                            cls:'meteo input',
                            width:200,
                            height:36,
                            hideTrigger :true,
                            emptyText:'Taper une ville...',
                            selectOnFocus:false,
                            applyTo: 'ville-search'
                        });
                        var elLink = Ext.select(".search-button", true);
        		elLink.each(function(el){
        			el.on('click', function(){
        				meteoDetailByCity($(".meteo-body")[0], combo.value,tpl4)
        			})				

        		 });
                     }          
         }       
    }
});
Ext.reg('MeteoPortlet', CMV.MeteoPortlet);


//NEWS
CMV.NewsPortlet = Ext.extend(Ext.Panel, {
    title: 'NEWS',
    closeable: false,
    settings: false, 
    id:'box-id-news',
    html: '',
    plugins: Ext.ux.PortletPlugin ,
    autoLoad:{
       url: "/rcv.news?action=begin&rubrique=1",
       text: "Chargement...",
       callback: function(options, success, o) {
  	             if(success){
                        var rep=eval('('+o.responseText+')');
                        var boxNews=Ext.getCmp('NewsPortlet');
                        var tpl4=new Ext.XTemplate(
                           '<tpl for=".">',
    				'<tpl if="xindex &lt;8">',
                                          '<div class="news" style="{[xindex ==1 ? "background:none;padding-top:5px;" : ""]}">',
                                                '<div class="news-picture">',
                                                      // '<img src="{smallimage}" alt=""/>',
                                                       '<tpl if="bigimage==null">',
                                                            '<img src="{smallimage}" alt=""/>',
                                                       '</tpl>',
                                                       '<tpl if="bigimage!=null">',
                                                            '<img src="{bigimage}"  width="90" height="62" alt=""/>',
                                                       '</tpl>',
                                                '</div>',
                                                '<p class="date">{pubdate}</p>',
                                                '<p class="titre"><a href="/news/news.rcv?id={id}">{titre}</a></p>',
                                          '</div>',
                                     '</tpl>',
                                     '<tpl if="xindex &gt;7">',
                                          '<tpl if="xindex==8">',
                                               '<div class="news">',
                                                   '<ul class="news-more-list">',
                                          '</tpl>',
                                          '<li>',
                                               '<a href="/news/news.rcv?id={id}">{titre}</a>',
                                          '</li>',
                                     '</tpl>',
                                '</tpl>',
                                    '</ul>',
                                '</div>'
                              );

      		          tpl4.overwrite(boxNews.body, rep.news);
                     }
         }
    }
});

Ext.reg('NewsPortlet', CMV.NewsPortlet);





//VIDEO
CMV.VideoPortlet = Ext.extend(Ext.Panel, {
    title: 'VIDEO',
    closeable: false,
    settings: false,
    settingHandler: function(e, target, panel){
        Ext.Msg.alert('Demo Setting', 'You clicked a dummy portlet setting for ' + this.id + '.');
    },
    html: 'shortBogusMarkup',
    plugins: Ext.ux.PortletPlugin
});
Ext.reg('VideoPortlet', CMV.VideoPortlet);

//AUDIO
CMV.AudioPortlet = Ext.extend(Ext.Panel, {
    title: 'AUDIO',
    closeable: false,
    settings: false,
    html: 'shortBogusMarkup',
    plugins: Ext.ux.PortletPlugin
});
Ext.reg('AudioPortlet', CMV.AudioPortlet);

//TRIBUNELIBRE
CMV.TribuneLibrePortlet = Ext.extend(Ext.Panel, {
    title: 'TRIBUNE LIBRE',
    closeable: false,
    settings: false,
    html: '',
    plugins: Ext.ux.PortletPlugin ,
    autoLoad:{
       url: "/rcv.news?action=begin&rubrique=3",
       text: "Chargement...",
       callback: function(options, success, o) {
	     if(success){
                        var rep=eval('('+o.responseText+')');
                        var boxNews=Ext.getCmp('TribuneLibrePortlet');
                        var tpl4=new Ext.XTemplate(
                           '<tpl for=".">',
    				'<tpl if="xindex &lt;8">',
                                          '<div class="news" style="{[xindex ==1 ? "background:none;padding-top:5px;" : ""]}">',
                                                '<div class="news-picture">',
                                                      // '<img src="{smallimage}" alt=""/>',
                                                       '<tpl if="bigimage==null">',
                                                            '<img src="{smallimage}" alt=""/>',
                                                       '</tpl>',
                                                       '<tpl if="bigimage!=null">',
                                                            '<img src="{bigimage}"  width="90" height="62" alt=""/>',
                                                       '</tpl>',
                                                '</div>',
                                                '<p class="date">{pubdate}</p>',
                                                '<p class="titre"><a href="/news/news.rcv?id={id}">{titre}</a></p>',
                                          '</div>',
                                     '</tpl>',
                                     '<tpl if="xindex &gt;7">',
                                          '<tpl if="xindex==8">',
                                               '<div class="news">',
                                                   '<ul class="news-more-list">',
                                          '</tpl>',
                                          '<li>',
                                               '<a href="/news/news.rcv?id={id}">{titre}</a>',
                                          '</li>',
                                     '</tpl>',
                                '</tpl>',
                                    '</ul>',
                                '</div>'
                              );

      		          tpl4.overwrite(boxNews.body, rep.news);
                     }
         }
    }
});
Ext.reg('TribuneLibrePortlet', CMV.TribuneLibrePortlet);


//VOXPOP
CMV.VoxpopPortlet = Ext.extend(Ext.Panel, {
    title: 'VOX POP',
    closeable: false,
    settings: false,
    html: '',
    plugins: Ext.ux.PortletPlugin ,
    autoLoad:{
       url: "/rcv.voxpop?action=begin",
       text: "Chargement...",
       callback: function(options, success, o) {
	      if(success){
                var rep=eval('('+o.responseText+')');
                var boxVoxpop=Ext.getCmp('VoxpopPortlet');
                var tpl4=new Ext.XTemplate(
                  '<div class="news" style="background:none;padding-top:8px;">',
                      '<ul class="news-more-list">',
                      '<tpl for=".">',
                           '<li>',
                                 '<a href="/news/voxpop.rcv?id={id}">{titre}</a>',
                           '</li>',
                      '</tpl>',
                      '</ul>',
                   '</div>'
                 );
		 tpl4.overwrite(boxVoxpop.body, rep.voxpop);
             }
         }
    }
});
Ext.reg('VoxpopPortlet', CMV.VoxpopPortlet);


//SMS
CMV.SMSPortlet = Ext.extend(Ext.Panel, {
    title: 'SMS',
    closeable: true,
    settings: false,
    html: 'shortBogusMarkup',
    plugins: Ext.ux.PortletPlugin
});
Ext.reg('SMSPortlet', CMV.SMSPortlet);

//DEPECHE
CMV.DepechePortlet = Ext.extend(Ext.Panel, {
    title: 'DEPECHE',
    closeable: false,
    settings: false,
    html: '<div id="scroller_container"><div id="scroller" class="jscroller2_up jscroller2_speed-20 jscroller2_mousemove jscroller2_dynamic"></div></div>',
    plugins: Ext.ux.PortletPlugin 
});
Ext.reg('DepechePortlet', CMV.DepechePortlet);

//REACTIONS
CMV.ReactionPortlet = Ext.extend(Ext.Panel, {
    title: 'REACTIONS',
    closeable: false,
    settings: false,
    resizeable: false,
    html: 'shortBogusReactions',
    plugins: Ext.ux.PortletPlugin
});
Ext.reg('ReactionPortlet', CMV.ReactionPortlet);


//RADIO
CMV.RadioPortlet = Ext.extend(Ext.Panel, {
    title: 'RADIO',
    closeable: false,
    settings: false,
    settingHandler: function(e, target, panel){
       // Ext.Msg.alert('Demo Setting', 'You clicked a dummy portlet setting for ' + this.id + '.');
    },
    html: CMV.encemoment,
    plugins: Ext.ux.PortletPlugin
});
Ext.reg('RadioPortlet', CMV.RadioPortlet);

//ILS L'ONT DIT
CMV.ExtraitRadioPortlet = Ext.extend(Ext.Panel, {
    title: 'ILS L\'ONT DIT',
    closeable: true,
    settings: false,
    html: "",
    plugins: Ext.ux.PortletPlugin,
    autoLoad:{
      url: "rcv.reactionsvocale",
       text: "Chargement...",
       callback: function(options, success, o) {
  	             if(success){
                        var rep=eval('('+o.responseText+')');
                        var boxReaction=Ext.getCmp('ExtraitRadioPortlet');
                        var tpl4=new Ext.XTemplate(
                            '<div class="opinion">',
                                  /*  '<div class="opinion-top-header">',
                                          '<div class="opinion-header">',
                                                '<span class="double-sup">&raquo;</span> Votre opinion sur CRTVgate et Epervier',
                                          '</div>',
                                    '</div>',  */
                                    '<div class="holder">',

                                       '<div id="reaction-body" class="scroll-pane">',
                                                '<tpl for=".">',
                                                
                                                      '<div style="float:left;height:65px;width:300px;padding-left:10px;background:none;padding-top:5px;">',
                                                               // '<tpl if="values.image.length &gt== 0">',
                                                                    '<div style="float:left;height:60px;width:60px;">',
                                                                          '<img src="{image}" width="60" height="60" alt=""/>',
                                                                    '</div>',
                                                                    '<div class="col-1"  style="float:left;padding:0px 4px;width:200px;border:0px solid red;">{nom:ellipsis(28)}</div>',
                                                                    '<div class="col-2" style="padding:0px 4px;color:#333;">{ladate:substr(1, 8)}</div>',
                                                                    '<div class="col-1" id="{id}mmmm{fichieraudio}" style="padding:0px 4px;color:#dc1301;"><a href="#" style="font-weight:bold;color:#dc1301;">Ecouter...</a></div>',



                                                       '</div>',


                                                    //'<div class="col-1" id="{id}mmmm{fichieraudio}" style="{[xindex % 2 !==0? "background-color:#fff;" : "background-color:#eee;"]}"><a href="#">{nom:ellipsis(28)}</a></div>',
                                                    //'<div class="col-2" style="{[xindex % 2 !==0? "background-color:#fff;" : "background-color:#eee;"]}">{ladate:substr(1, 8)}</div>',
                                                '</tpl>',
                                       '</div>',
                                       
                                       



                            '</div>'
                        )
                        tpl4.overwrite(boxReaction.body, rep.reactionsvocales);
                        $('#reaction-body').jScrollPane({showArrows:true, scrollbarWidth:14, scrollbarMargin:0})
                        $(".col-1").click(function(){
                                  var id=this.id
                                  var params=id.split("mmmm");
                                  //window.open("/player/player.html?fichier=reactionsvocales/"+params[1], "WinE", "width=420,height=290,toolbar=no,resizable=no");
                                  window.open("/player/player.html?fichier="+params[1], "WinE", "width=420,height=290,toolbar=no,resizable=no");
                          })
                     }
         }
    }
});
Ext.reg('ExtraitRadioPortlet', CMV.ExtraitRadioPortlet);


//SHOWBIZ
CMV.ShowbizPortlet = Ext.extend(Ext.Panel, {
    title: 'SHOWBIZ',
    closeable: true,
    settings: false,
    html: 'shortBogusMarkup',
    plugins: Ext.ux.PortletPlugin
});
Ext.reg('ShowbizPortlet', CMV.ShowbizPortlet);

//COMMUNAUTE
CMV.CommunautePortlet = Ext.extend(Ext.Panel, {
    title: 'COMMUNAUTE',
    closeable: true,
    settings: false,
    resizeable: false,
    html: 'shortBogusReactions',
    plugins: Ext.ux.PortletPlugin ,
    autoLoad:{
       url: "/rcv.thisweek",
       text: "Chargement...",
       callback: function(options, success, o) {
	          if(success){
                         var rep=eval('('+o.responseText+')');
		         var boxReaction= Ext.getCmp("CommunautePortlet");
		         var tpl4=new Ext.XTemplate(
		          '<tpl for=".">',
				'<tpl if="xindex &lt;6">',
                                      '<div class="news" style="{[xindex ==1 ? "background:none;padding-top:5px;" : ""]}">',
                                            '<div class="news-picture">',
                                                  '<img src="{photo}" alt=""/>',
                                            '</div>',
                                            '<p class="date">{ladate}</p>',
                                            '<p class="titre"><a href="/{[values.emission.lien]}">{titre}</a></p>',
                                      '</div>',
                                 '</tpl>',
                          '</tpl>'
		          );
                          tpl4.overwrite(boxReaction.body, rep.thisweek);
		  }
  	} // fin Ajax
    }
});
Ext.reg('CommunautePortlet', CMV.CommunautePortlet);
//INVITES
CMV.InvitePortlet = Ext.extend(Ext.Panel, {
    title: 'CETTE SEMAINE',
    closeable: true,
    settings: false,
    resizeable: false,
    html: CMV.invite,
    plugins: Ext.ux.PortletPlugin
});
Ext.reg('InvitePortlet', CMV.InvitePortlet);

//ANNONCES
CMV.AnnoncePortlet = Ext.extend(Ext.Panel, {
    title: 'ANNONCES',
    closeable: false,
    settings: false,
    draggable:false,
    html: '',
    plugins: Ext.ux.PortletPlugin,
    autoLoad:{
       url: "/rcv.annonces",
       text: "Chargement...",
       callback: function(options, success, o) {
	      if(success){
                var rep=eval('('+o.responseText+')');
                var boxAnnonce=Ext.getCmp('AnnoncePortlet');
                var tpl4=new Ext.XTemplate(
                  '<div class="news" style="background:none;padding-top:8px;">',
                      '<ul class="news-more-list">',
                      '<tpl for=".">',
                           '<li>',
                                 '<a href="/annonces/annonces.rcv?id={id}">{titre}</a>',
                           '</li>',
                      '</tpl>',
                      '</ul>',
                   '</div>'
                 );
		 tpl4.overwrite(boxAnnonce.body, rep.annonces);
             }
         }
    }
});

Ext.reg('AnnoncePortlet', CMV.AnnoncePortlet);


//PUB
//CMV.Pub= ['<div style="color:#444;font-size:10.4px;text-align:right;padding-right:7px;height:9px;">PUBLICITE</div><div id='pub-portlet' style="margin:4px 0px 10px 5px;width:300px;height:240px;"><a href="#" target="_blank"><img src="resources/images/pubs/portlet/banniere.jpg"></a></div>'].join('')
CMV.Pub= ["<div style='color:#444;font-size:10.4px;text-align:right;padding-right:7px;height:9px;'>PUBLICITE</div>",
    "<div id='pub-portlet' style='margin:4px 0px 10px 5px;width:300px;height:250px;'>",
    "</div>"].join("")
CMV.PubPortlet = Ext.extend(Ext.Panel, {
   // title: '',
    frame:false,
    resizeable: false,
    header:false,
    closeable: false,
    settings: false,
    html: CMV.Pub
//    ,    plugins: Ext.ux.PortletPlugin
});

Ext.reg('PubPortlet', CMV.PubPortlet);

//FACEBOOK
CMV.facebook=['<div style="margin-left:5px;margin-right:5px;"><iframe src="http://www.facebook.com/plugins/likebox.php?id=150942708264034&amp;width=295&amp;connections=10&amp;stream=false&amp;header=false&amp;height=250" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:295px; height:250px;" allowtransparency="true"></iframe></div>'].join('');
CMV.FBPortlet = Ext.extend(Ext.Panel, {
    title: 'Facebook',
    closeable: false,
    settings: false,
    id:'box-fb',
    resizeable: false,
    html: CMV.facebook,
    plugins: Ext.ux.PortletPlugin
});

Ext.reg('FBPortlet', CMV.FBPortlet);

//SERVICES
CMV.services=['<div class="news" style="background:#fff;height:100px;margin-left:0px;margin-right:5px;"><table border="0" width="78%" cellspacing="10"><tbody>',

         '<tr><td width="10%" align="right"><a href="http://www.cameroonvoice.com/radio/radio.html"><img src="resources/images/camV/0000003/logo-25x16.jpg"></a></td><td width="40%"><a href="http://www.cameroonvoice.com/radio/radio.html">Radio</a></td><td width="15%" align="right"><a href="http://www.cameroonvoice.com/news/podcast.rcv"><img src="resources/images/camV/0000003/podcast.png"></a></td><td width="35%"><a href="http://www.cameroonvoice.com/news/podcast.rcv">Podcast</a></td></tr>',
        '<tr><td width="10%" align="right"><a href="http://www.cameroonvoice.com/feed.xml"><img src="resources/images/camV/0000003/rss.png"></a></td><td width="40%"><a href="http://www.cameroonvoice.com/feed.xml">RSS</a><td width="15%" align="right"><a href="http://www.twitter.com/cameroonvoice"><img src="resources/images/camV/0000003/cv_twitter.png"></a></td><td width="35%"><a href="http://www.twitter.com/cameroonvoice">Twitter</a></td></tr>',
        '<tr><td width="15%" align="right"><a href="http://www.facebook.com/cameroonvoice"><img src="resources/images/camV/0000003/cv_facebook.png"></a></td><td width="35%"><a href="http://www.facebook.com/cameroonvoice">Facebook</a></td><td width="10%" align="right"><a href="http://www.youtube.com/user/cameroonvoice"><img src="resources/images/camV/0000003/cv_youtube.png"></a></td><td width="40%"><a href="http://www.youtube.com/user/cameroonvoice">YouTube</a></tr>',
       //  '<tr><td width="10%" align="right"><a href="http://www.cameroonvoice.com/radio/radio.html"><img src="resources/images/camV/0000003/logo-30x19.jpg"></a></td><td width="40%" colspan="3"><a href="http://www.cameroonvoice.com/radio/radio.html">Radio</a></td></tr>',

    '</tbody></table></div>'].join('');
CMV.ServicesPortlet = Ext.extend(Ext.Panel, {
    title: 'Services',
    closeable: false,
    settings: false,
    id:'box-sv',
    resizeable: false,
    html: CMV.services,
    plugins: Ext.ux.PortletPlugin
});

Ext.reg('ServicesPortlet', CMV.ServicesPortlet);
