﻿
 var xcookie=new Ext.state.CookieProvider("boxDuCentre")
 var xState=xcookie.state.boxDuCentre

CMV.PortletList=[
    {boxLabel: 'D&eacute;p&ecirc;ches', name: 'settingOptions', inputValue:'DepechePortlet',id:'box-depeche', colonne:0,position:1},
    {boxLabel: 'M&eacute;t&eacute;o', name: 'settingOptions', inputValue:'MeteoPortlet',id:'box-meteo', colonne:0,position:0},
    {boxLabel: 'Actualit&eacute;s', name: 'settingOptions', inputValue:'NewsPortlet',id:'box-news', colonne:1,position:0},
   // {boxLabel: 'Ils&nbsp;l\'ont&nbsp;dit', name: 'settingOptions', inputValue:'ExtraitRadioPortlet',id:'box-extraitRadio', colonne:1,position:1} ,
    {boxLabel: 'Facebook', name: 'settingOptions',id:'box-fb', inputValue:'FBPortlet',colonne:0,position:0},
    {boxLabel: 'Services', name: 'settingOptions',id:'box-sv', inputValue:'ServicesPortlet',colonne:0,position:0},
    {boxLabel: 'Sport', name: 'settingOptions',id:'box-sport', inputValue:'SportPortlet', colonne:2,position:3},
    {boxLabel: 'Annonces', name: 'settingOptions',id:'box-annonces', inputValue:'AnnoncePortlet',colonne:2,position:2},
    {boxLabel: 'Cette semaine', name: 'settingOptions',id:'box-invite', inputValue:'InvitePortlet',colonne:2,position:2},
    {boxLabel: 'Podcasts', name: 'settingOptions',id:'box-podcast', inputValue:'PodcastPortlet',colonne:2,position:2},
 //   {boxLabel: 'Tribune libre', name: 'settingOptions',id:'box-voxpop', inputValue:'VoxpopPortlet',colonne:0,position:2}
    {boxLabel: 'Tribune libre', name: 'settingOptions',id:'box-tribunelibre', inputValue:'TribuneLibrePortlet',colonne:1,position:0}
]


var defaultPortlet= [{boxLabel: 'D&eacute;p&ecirc;ches', name: 'settingOptions', inputValue:'DepechePortlet',id:'box-depeche', colonne:0,position:2},
    {boxLabel: 'M&eacute;t&eacute;o', name: 'settingOptions', inputValue:'MeteoPortlet',id:'box-meteo', colonne:0,position:0},
    //{boxLabel: 'Opinions', name: 'settingOptions',id:'box-opinion', inputValue:'OpinionPortlet',colonne:0},
    //{boxLabel: 'Ils&nbsp;l\'ont&nbsp;dit&nbsp;sur&nbsp;CV', name: 'settingOptions', inputValue:'ExtraitRadioPortlet',id:'box-extraitRadio', colonne:1,position:0} ,
    {boxLabel: 'Facebook', name: 'settingOptions',id:'box-fb', inputValue:'FBPortlet',colonne:0,position:0},
    {boxLabel: 'Services', name: 'settingOptions',id:'box-sv', inputValue:'ServicesPortlet',colonne:0,position:0},
    {boxLabel: 'Actualit&eacute;s', name: 'settingOptions', inputValue:'NewsPortlet',id:'box-news', colonne:1,position:1},
    {boxLabel: 'Sport', name: 'settingOptions',id:'box-sport', inputValue:'SportPortlet', colonne:2,position:3},
    {boxLabel: 'Annonces', name: 'settingOptions',id:'box-annonces', inputValue:'AnnoncePortlet',colonne:2,position:1} ,
  //{boxLabel: 'Cette semaine', name: 'settingOptions',id:'box-invite', inputValue:'InvitePortlet',colonne:1},
    {boxLabel: 'Podcasts', name: 'settingOptions',id:'box-podcast', inputValue:'PodcastPortlet',colonne:2,position:1},
   // {boxLabel: 'Tribune libre', name: 'settingOptions',id:'box-voxpop', inputValue:'VoxpopPortlet',colonne:0,position:2}
    {boxLabel: 'Tribune libre', name: 'settingOptions',id:'box-tribunelibre', inputValue:'TribuneLibrePortlet',colonne:1,position:0}
]

var newPortlet= [
    {boxLabel: 'Podcasts', name: 'settingOptions',id:'box-podcast', inputValue:'PodcastPortlet',colonne:0,position:0},
    {boxLabel: 'Services', name: 'settingOptions',id:'box-sv', inputValue:'ServicesPortlet',colonne:2,position:1},
    {boxLabel: 'Facebook', name: 'settingOptions',id:'box-fb', inputValue:'FBPortlet',colonne:2,position:2}  ,
    {boxLabel: 'Tribune libre', name: 'settingOptions',id:'box-tribunelibre', inputValue:'TribuneLibrePortlet',colonne:1,position:0}
]

CMV.PubPortletList= [{boxLabel: '', id:'box-pub', inputValue:'PubPortlet',colonne:2,position:0}]


/*var portletToRemove=[{boxLabel: '', id:'box-pub', inputValue:'PubPortlet',colonne:2,position:0}];*/

var panelCentre = new Ext.Panel({
    baseCls:'x-plain',
    layout:'table',    
    width:963,
    autoHeight:true,          
    titlebar: false,
    layoutConfig: {columns:1},
    defaults: {border: false,bodyStyle:"border:0px;background-color:#dbdbdb;padding:0px;padding-left:0px;", style:"border:0px solid green;margin:0px;",frame: false},
    items:[
 /*       {
	    html:Ext.PubliciteHeader,
	    colspan:2,
	    style:"width:960px;",
	    id:'north-panel10',
	    height:90
	 },*/
/*	  {
              html:Ext.AUJOURDHUI
             ,colspan:2
               ,style:"width:962px;background-color:#fff;border:1px solid red;"
             //,style:"width:962px;background-color:#fff;height:105px;"
             ,id:'north-panel1'
             ,height:97
          },*/
	  new Ext.Panel({
              title:""
              ,autoHeight:true
              ,defaults: {frame:false}
              ,closable:false
              ,id:"panneau"
              ,colspan:2
              ,width:962
              ,layoutConfig:{animate:true}
              ,border:false
              ,items:{
		   title:''
		  ,height:432
                  ,bodyStyle:"background:transparent;"
		  ,html: CMV.SectionLaUne
	      }
          })
	  ,Ext.BoxCenter
	 ,{
               html:Ext.Footer
              ,title:''
              ,width:962
              ,colspan:3
          }//fin south panel
]})
/*=======================================================*/	
Ext.onReady(function(){ 
   var onglets,onglets1;
   var encemoment,nowPhoto,nowSong;
   var sos=Ext.get("sos_radio");

   //MISE � JOUR DE LA DATE/HEURE
   var task = {
     run: function(){
        Ext.select("#date-entete span", true).update(getFullDateFrancais());
     },
     interval: 1000 //1 seconde
   }
   var runner = new Ext.util.TaskRunner();
   runner.start(task);

  /* new Ext.Panel({
          id:'main-panel',
          baseCls:'x-plain',
          renderTo: Ext.getBody(),
          layout:'table',                              
          border:false,
          autoHeight:true,
          style:"background-color:white;border:0px;padding:10px;padding-top:0px;padding-bottom:0px;width:963px;",
          titlebar:false,
          layoutConfig:{},
          defaults:{bodyStyle:"padding:0px;padding-left:0px;border:0px;", style:"border:0px solid #000;margin:0px;",frame: true},
          items:panelCentre
    
    })*/

        new Ext.Panel({
          baseCls:'x-plain',
          renderTo: Ext.getBody(),
        //  layout:'table',
          border:false,
          autoHeight:true,
          titlebar:false,
          layoutConfig:{},
          items:[
              new Ext.Panel({
                  id:'main-panel',
                  baseCls:'x-plain',
                  renderTo: Ext.getBody(),
                  layout:'table',
                  border:false,
                  autoHeight:true,
                  style:"margin-bottom:5px;background-color:white;border:0px;padding:10px;width:963px;",
                  titlebar:false,
                  layoutConfig:{},
                  defaults:{bodyStyle:"padding:0px;padding-left:0px;border:0px;", style:"border:0px solid #000;margin:0px;",frame: true},
                  items:panelCentre
              }) ,
             { title:''
              ,id:"footer-home"
              ,height:30
              ,width:982
              ,border:false
              ,bodyStyle:"text-align:right;background:#eaeaea;font-size:11px;"
              ,defaults:{frame: false}
              ,html: "<a href='/droit.rcv'> Politiques de diffusions</a><span style='color:#666;'> &nbsp; &nbsp; ©"+new Date().getFullYear()+" Cameroonvoice</span>"
             }]
    })

    var tools = [
    {
        id:'maximize',
        //qtip:"Ouvrir la radio",
        handler: function(e, target, panel){
          window.open("/radio/radio.html", "WinE", "width=980,height=740,toolbar=no,resizable=no");
        }
    }
];
    /*new Ext.Panel({
          title:"Radio",
          cls:'x-portlet',
          renderTo: Ext.get("boite-radio"),
          border:false,
          autoHeight:true,
          frame:true,
          tools:tools,
          layoutConfig:{},
          iconCls:"box-radio" ,
          defaults:{bodyStyle:"border:0px;"} ,
          html: CMV.radio
    
    })*/

  new Ext.Panel({
          title:"Radio",
          id:"bx-radio" ,
          cls:'x-portlet',
          renderTo: Ext.get("boite-radio"),
          border:false,
          height:160,
          frame:true,
          tools:tools,
          layoutConfig:{},
          iconCls:"box-radio" ,
          defaults:{bodyStyle:"padding:0px;border:0px;"} ,
          html: CMV.radio

    })



function addPortlet(){
     portal = Ext.getCmp('boxDuCentre');
     var PortletsMap=fp.getForm().items.items[0].items.items;

     for(var j=0; j<PortletsMap.length; j++) {
         var estDejaPresent=false;
         var tmp1=PortletsMap[j].inputValue;

         portal.items.each(function(it){
            it.items.each(function (it1){
                  if(it1.id==tmp1) {
                      estDejaPresent=true
                  }
            })
          });
         
         if(estDejaPresent==true){
               if(PortletsMap[j].checked==true){
               }else{
                    //retire du portail
                    var portlet1=Ext.getCmp(PortletsMap[j].inputValue)
                    portal.items.items[PortletsMap[j].colonne].remove(portlet1);
                    portal.doLayout();
               }
         }else{
             if(PortletsMap[j].checked==true){
                  //Ajoute le portlet au portail
                  portal.items.items[PortletsMap[j].colonne].add({xtype:tmp1 , position: PortletsMap[j].position,columnIndex: PortletsMap[j].colonne,title: PortletsMap[j].boxLabel, id:tmp1,iconCls:PortletsMap[j].id});
                  portal.doLayout();
             }
         }
     }
}
//$(function(){
var portal = Ext.getCmp('boxDuCentre');
portal.on('validatedrop', function(overEvent) {
   if (overEvent.source.id=="PubPortlet")
        //if (overEvent.columnIndex == 2 && overEvent.position ==0 )
        overEvent.status = false; //if in the last column and first position, don't allow drop
    return overEvent.status;  //otherwise, defer to default dropAllowed property of dropZone
});
 portal.on('beforedragover', function(overEvent) {
    if (overEvent.source.id=="PubPortlet" ) {
   //if (overEvent.columnIndex == 2 && overEvent.position ==0 ) {
        overEvent.status = false; //if in the last column and first position, don't allow drop
        return overEvent.status;  //otherwise, defer to default dropAllowed property of dropZone
    }
});

//})

if(CMV.PubPortletList !=undefined){
    if(!isAdvertising()) {
         xcookie.clearCookie("boxDuCentre")
         Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
         var xcol= portal.items.items[2]
         while (xcol.items && xcol.items.length)  xcol.remove(xcol.items.items[0]);
         portal.items.items[2].add({xtype:"PubPortlet", position:0, columnIndex:2,title: '', id:"PubPortlet",iconCls:"box-pub"});
         portal.doLayout();
    } else{
       Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    }

}  else{
   if(isAdvertising()) {
      xcookie.clearCookie("boxDuCentre")
      var portlet1=Ext.getCmp("PubPortlet")
      var xcol= portal.items.items[2]
      xcol.remove(portlet1);
      portal.doLayout();
   }
}

var activePortlets=[]
if(xState) {
   for (var i = 0; i < xState.length; i++) {
     for (var j = 0; j < xState[i].length; j++)  {
       activePortlets.push(xState[i][j]);
     }
   }

}else{
  //si aucun portlet sauvegard� dans le cookie.. alors on prend les portlets par d�faut
  for(var k=0; k<defaultPortlet.length;k++) 
        activePortlets.push(defaultPortlet[k])
}

//si nouveau portlet: ajouter
if( newPortlet.length >0) {
   for(var k=0; k<newPortlet.length;k++){
           activePortlets.push(newPortlet[k])
   }
}

for(var y=0;y<CMV.PortletList.length; y++){
  for(var x=0;x<activePortlets.length; x++){
     if(Ext.type(activePortlets[x])=="object")
       var tmp=activePortlets[x].xtype||activePortlets[x].inputValue
     else
       var tmp=activePortlets[x]
     if(tmp==CMV.PortletList[y].inputValue) {
       CMV.PortletList[y].checked=true
    }
 }
}

/***CHECKBOX***/
var fp = new Ext.FormPanel({
        frame: false,
        title:'',
        headerAsText:false,
        labelWidth: 110,
        width: 930,
        renderTo:'cv_setting_form',
        bodyStyle: 'padding:29px 4px 0px 4px;',
        items: [{
            layout: 'column',
            border: true,
            items: [
             {			
                xtype: 'checkboxgroup',
                fieldLabel: '',
                listeners: {change:{fn:function(){alert('checkbox changed');}}},
                hideLabel:true,
                border: false,
           	stateful: true,
               	columns: [150, 150, 150],
                vertical: true, 
                items: CMV.PortletList
            }
            ]
      	}],

        buttons: [{
            text: 'Sauvegarder'
            ,style:'color:#000;'
            ,handler: function(){
                   var actifPortlet= fp.getForm().getValues() ;
                   var portletsToAddArr;
                   if(Ext.type(actifPortlet.settingOptions)=='array')
                        portletsToAddArr= actifPortlet.settingOptions;
                   else
                        portletsToAddArr=[ actifPortlet.settingOptions];

                   addPortlet(portletsToAddArr)
            }
        },{
            text: 'Restaurer'
            ,handler: function(){
                fp.getForm().reset();
            }
        }]

});

addPortlet()

//Load Pub in bportlet
$(window).load(function(){
    $("#ads").find("iframe").appendTo("#pub-portlet");
    $("#ads1").find("iframe").appendTo("#ads-footer");
    $("#ads").remove();
    $("#ads1").remove();
});

$.fn.cycle.updateActivePagerLink = function(pager, currSlide) {
    var maxSlides=$(".pics").length-1

    $(pager).find('div').removeClass('activeSlide').filter('div:eq('+currSlide+')').addClass('activeSlide');
    if(currSlide==0)
       $('.activeSlide').css("background","transparent url(resources/images/camV/0000003/onglet-bk-red-top.jpg) no-repeat");
    else if(currSlide+1==maxSlides)
       $('.activeSlide').css("background","transparent url(resources/images/camV/0000003/onglet-bk-red-bottom.jpg) no-repeat");


    if(currSlide-1==0)
       $('.content1.top').css("background","transparent url(resources/images/camV/0000003/onglet-bk-top.jpg) no-repeat");
    else if(currSlide-1==-1)
          $('.content1.bottom').css("background","transparent url(resources/images/camV/0000003/onglet-bk-bottom.jpg) no-repeat");

};
//CETTE SEMAINE SUR CAMEROONVOICE
var cetteSemaine=function() {
              var cnt=false
	   // $('#slideshow').after('<ul id="nav">').cycle({
              $('#slideshow').after('<ul id="nav">').cycle({

	        speed:  '300',
	        timeout: 5000,
	        fx:     'fade',
	        //timeout: 0,
	        pager:  '#nav',
	        cleartype:0,
		pagerEvent: 'mouseover',
               // pagerEvent: 'click',
                prev:'7',
                prevNextClick:  function(isNext, zeroBasedSlideIndex, slideElement){
                          } ,
                pagerClick: function(zeroBasedSlideIndex, slideElement){
                    var g=$(".activeSlide")
                    var lastSlides=this.elements.length -1
                    if(g[0].id=="nav-0")
                       $('.content1.top').css("background","transparent url(resources/images/camV/0000003/onglet-bk-top.jpg) no-repeat");
                    else if(g[0].id=="nav-"+lastSlides)
                       $('.content1.bottom').css("background","transparent url(resources/images/camV/0000003/onglet-bk-bottom.jpg) no-repeat");
                },
	        pagerAnchorBuilder: function(idx, slide) {

                  var ind=slide.id.indexOf("(")
                  var titre= slide.id
                  if(ind >-1){
                      titre='<p>'+slide.id.split("(")[0]+'</p><p class="animateur">'+(slide.id.split("(")[1]).split(")")[0]+ '</p>'
                  }
                  if(idx==0)
		           // return '<div class="content1 top" id="nav-'+idx+'"><div class="texte1">'+titre +'</div></div>';
			return '<div class="content1 top" id="nav-'+idx+'">'+titre +'</div>';
		  else if(idx==3)
                       return '<div class="content1 bottom" id="nav-'+idx+'">'+titre +'</div>';
		  else
			return '<div class="content1" id="nav-'+idx+'">'+titre +'</div>';
	        },
	        fastOnEvent: true,
	        autostop: 1,
                end:      function() {
                    $('#slideshow').cycle(0);
                    return false;
                }
	    });
}


//Box Cette Semaine
$(function(){

        Ext.Ajax.request({
   		url: "cameroonvoice/rcv.thisweek",
   		callback: function(options, success, o) {
	             if(success){
                         var rep=eval('('+o.responseText+')');
                         var sortThisweek=rep.thisweek.sort( randOrd );
		         var boxCetteSem= $(".annonce-emission");
		         var tpl6 = new Ext.XTemplate(
                        	'<div class="cSemaine" id="cette_semaine" style="margin-top:12px;">',
                	              '<div id="slideshow" class="pics">',
                	                 '<tpl for=".">',
                	                     '<tpl if="xindex &lt;5">',
                	                   //  '<tpl if="[values.emission.nom] !=&quot;romance&quot;>',
                	                      '<div class="pics" id="{[values.emission.nom+"("+values.emission.idJournaliste.prenom+ " "+values.emission.idJournaliste.nom+")"]}">',
                	                      '<a href="/{[values.emission.lien]}" class="thisweek"',
                                                 /*'<tpl if="[values.emission.lien] !=\'cyberpresse\' && [values.emission.lien] !=\'ads\'">',
                                                    '<a href="/{[values.emission.lien]}" class="thisweek"',
                                                  '</tpl>',
                                                  '<tpl if="[values.emission.lien] ==&quot;cyberpresse&quot; || [values.emission.lien] ==&quot;ads&quot;">',
                                                    '<a href="#" class="thisweek"',
                                                  '</tpl>',     */
                                                 ' title="{[values.emission.nom]}"><img src="{photoInt}" height="212" width="711" id="thisweek-{id}"/>',
                                                 '<span class="texte">',
                                                        '<p class="titre">{titre}</p>',
                                                        '<span class="resume">{resume}</span>',
                                                 '</span></a>',
                                               '</div>',
                                               //'</tpl>',//if romance
                                             '</tpl>',
                		         '</tpl>',
            	    	              '</div>',
                        	'</div>'
		          );
		          var el=tpl6.applyTemplate(sortThisweek) ;

                          boxCetteSem.replaceWith(el);
                          cetteSemaine()
                     }
  	 	}
      }); // fin Ajax
})



//DEPECHE
var DepecheTask = {
     run: function(){
        Ext.Ajax.request({
   		url: "/rcv.rss",
   		callback: function(options, success, o) {
	             if(success){
                         var rep=eval('('+o.responseText+')');
                         var boxDepeche=Ext.getCmp('DepechePortlet');
                         var tpl4=new Ext.XTemplate(
                                '<tpl for=".">',
                                     '<p>',
                                         // '<a href="/cameroonvoice/news/depeches.rcv#[{values.id}]">{[values.pubdate.substring(17,22 )]} {values.titre}</a>',
                                          '<a href="/news/depeches.rcv">{[values.pubdate.substring(17,22 )]} {values.titre}</a>',
                                     '</p>',
                                '</tpl>'
                          );
                          tpl4.overwrite(Ext.get("scroller").dom, rep.filRss);
                     }
  	 	}
         }); // fin Ajax
     },
     interval: 1200000 //1 min
}
var runner1 = new Ext.util.TaskRunner();
runner1.start(DepecheTask);
ByRei_jScroller2.cache.refreshtime = 150;

//LA UNE
var LaUneTask = {
     run: function(){
        Ext.Ajax.request({
   		url: "cameroonvoice/rcv.news?action=begin&priorite=yes",
   		callback: function(options, success, o) {
	             if(success){
                         var rep=eval('('+o.responseText+')');
                         var boxPhotoLaUne=Ext.get('box-first-portlet');

                          var laune= $(".cUne");
                          var newEl=$('<div class="cUne" style="float:left;background: url('+ rep.news.bigimage+ ') no-repeat;margin-top:8px;width:209px;height:144px;"></div>')
                          laune.replaceWith(newEl)
                          $(".laune-detail-titre").html('<a href="/news/news.rcv?id='+rep.news.id+'">'+rep.news.titre+"</a>");

                          var resume=Ext.util.Format.ellipsis(rep.news.resume, 185);
                          $(".laune-detail-resume").html(resume);
                          $(".laune-detail-resume").remove("span");
                          $(".laune-detail-lire").html('&raquo; <a href="/news/news.rcv?id='+rep.news.id+'">Lire plus</a>');
                          $(".laune-detail-updated").html(dateFrench(rep.news.pubdate));

                          //Applique les coins ronds
                          $('.cUne').corner({
      			    tl: { radius: 8 },
      			    tr: { radius: 0.5 },
      			    bl: { radius: 8 },
      			    br: { radius: 0.5 },
      			    antiAlias: true,
      			    autoPad: true,
      			    validTags: ["div"]
      		         });
                     }
  	 	}
         }); // fin Ajax
     }
     ,interval: 3600000 //1 seconde
}
var runner = new Ext.util.TaskRunner();
runner.start(LaUneTask);




//NowPlaying
var nowSongEmiss=Ext.get("song-nowplaying-emiss");
var nowSongArtiste=Ext.get("song-nowplaying-artiste");
var nowPhoto=Ext.get("photo-nowplaying");

var nowPlayingTask = {
     run: function(){
        Ext.Ajax.request({
   		url: "cameroonvoice/rcv.nowplaying",
   		callback: function(options, success, o) {
	             if(success){
                         var rep=eval('('+o.responseText+')');
                         if(nowSongArtiste)
		        	nowSongArtiste.update(rep.nowplaying.artist);										
				
			if(nowSongEmiss)
				nowSongEmiss.update(rep.nowplaying.title);

			if(nowPhoto){      
			     var photo=rep.nowplaying.image=="" || rep.nowplaying.image=="rts.jpg"|| rep.nowplaying.image=="LOGORTS.JPG"  || rep.nowplaying.image=="blank.jpg" || rep.nowplaying.image=="equinoxe.jpg" ? "../resources/images/radio-rcv.jpg" :  "../resources/images/artistes/"+rep.nowplaying.image
			    /* nowPhoto.update("<img src='" + photo + "'>") ;*/
                 nowPhoto.update("<img src='" + photo + "' width='117' height='117'>") ;
			}

                     }
  	 	}
         }); // fin Ajax
     },
     interval: 55000 //1 min
}
var runner1 = new Ext.util.TaskRunner();
runner1.start(nowPlayingTask);


/*********FIN CHECKBOX********/
var elmenu = Ext.select(".x-tool-toggle", true);
elmenu.each(function(el){
	el.on('click', function(e, target, panel){	
              var a= panel.ownerCt
	      var animation=this.anim;
	})
});

$("#myform").submit( function() {
  $("#myform")[0].action = '/news/search.rcv?typesearch=news&search='+$("#myform")[0].search.value;
} );

$(function(){
   $(".sous-menu").click(function(){
     if(this.id== "menu-radio")
         window.open("/radio/radio.html", "WinE", "width=980,height=740,toolbar=no,resizable=no");
     else {
         var classe=this.className.split(" ")[1]
         window.location.href="/" +classe;
     }
   })

  $("#song-nowplaying-emiss").click(
     function(){
           window.open("/radio/radio.html", "WinE", "width=980,height=740,toolbar=no,resizable=no");
     }
   );
   $("#menu-radio").click(
     function(){
       window.open("/radio/radio.html", "WinE","width=980,height=740,toolbar=no,resizable=no");
     }
   );
   $(".click-radio").click(
     function(){
       window.open("/radio/radio.html", "WinE", "width=980,height=740,toolbar=no,resizable=no");
     }
   );
     $(".listenlive").click(
     function(){
       window.open("/radio/radio.html", "WinE", "width=980,height=740,toolbar=no,resizable=no");
     }
   );



})

$(function(){
  $(".makebookmark").click(
     function(){
       var title = 'Titre en favori';
       var url='http://www.cameroonvoice.com';
       if (document.all)
          window.external.AddFavorite(url, title);
       else if (window.sidebar)
          window.sidebar.addPanel(title, url, "")
       else if (window.sidebar&&window.sidebar.addPanel)
           window.sidebar.addPanel(title,url,"");
    }
   )
})
$(function(){
  $(".makehomepage").click(
    function(){
      // this.style.behavior='url(#default#homepage)';
       //this.setHomePage('http://www.yahoo.com');
        if (document.all)
        {
              window.external.AddFavorite(url, title) //addToFavorite
              document.body.style.behavior='url(#default#homepage)';
              document.body.setHomePage('http://www.cameroonvoice.com');
        }
        else if (window.sidebar)
             window.sidebar.addPanel("", 'http://www.cameroonvoice.com', "")
        else if (window.sidebar&&window.sidebar.addPanel)
             window.sidebar.addPanel("",'http://www.cameroonvoice.com',"");
    }
   )
})

//ROUNDED CORNER
$(function(){

                       $('.coin').corner({
      			  tl: { radius: 6 },
      			  tr: { radius: 6 },
      			  bl: { radius: 6 },
      			  br: { radius: 6 },
      			  antiAlias: true,
      			  autoPad: true,
      			  validTags: ["div"]
                        });
     $('.cUne').corner({
         tl: { radius: 8 },
	 tr: false,
         bl: { radius: 8 },
         br: false,
         antiAlias: true,
         autoPad: true,
         validTags: ["div"]
     });

     $('.cUne-1').corner({
         tl: false,
         tr: { radius: 8 },
         bl: false,
         br: { radius: 8 },
         antiAlias: true,
         autoPad: true,
         validTags: ["div"] });
});  //FIN ROUNDED CORNER


$.fn.infiniteCarousel = function () {

    function repeat(str, num) {
        return new Array( num + 1 ).join( str );
    }
  
    return this.each(function () {
        var $wrapper = $('> div', this).css('overflow', 'hidden'),
            $slider = $wrapper.find('> ul'),
            $items = $slider.find('> li'),
            $single = $items.filter(':first'),
            singleWidth = $single.outerWidth(),
           // visible = Math.ceil($wrapper.innerWidth() / singleWidth), // note: doesn't include padding or border
            visible =2
            currentPage = 1,
            pages = Math.ceil($items.length / visible);            


        // 1. Pad so that 'visible' number will always be seen, otherwise create empty items
        if (($items.length % visible) != 0) {
            //$slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
            $items = $slider.find('> li');
        }

        // 2. Top and tail the list with 'visible' number of items, top has the last section, and tail has the first
        $items.filter(':first').before($items.slice(- visible).clone().addClass('cloned'));
        $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
        $items = $slider.find('> li'); // reselect
        
        
        $items.mouseover(function(){
              //alert('1')
                  $(this).filter(':first').find('div').filter(':first').addClass('hover-opacite')
                  $(this).filter(':first').find('.box-text').show() ;
            })  ;
            $items.mouseout(function(){
                  $(this).filter(':first').find('.box-text').hide() ;
                  $(this).filter(':first').find('div').filter(':first').removeClass('hover-opacite')
         })
        

        // 3. Set the left position to the first 'real' item
        $wrapper.scrollLeft(singleWidth * visible);
        
        // 4. paging function
        function gotoPage(page) {
            var dir = page < currentPage ? -1 : 1,
                n = Math.abs(currentPage - page),
                left = singleWidth * dir * visible * n;

            $wrapper.filter(':not(:animated)').animate({
                 scrollLeft : '+=' + left
            }, 500, function () {
                if (page == 0) {
                    $wrapper.scrollLeft(singleWidth * visible * pages);
                    page = pages;
                } else if (page > pages) {
                    $wrapper.scrollLeft(singleWidth * visible);
                    // reset back to start position
                    page = 1;
                } 

                currentPage = page;
            });                
            
            return false;
        }

        // 5. Bind to the forward and back buttons
        $('a.back', this).click(function () {
            return gotoPage(currentPage - 1);                
        });

        $('a.forward', this).click(function () {
            return gotoPage(currentPage + 1);
        });
        
        // create a public interface to move to a specific page
        $(this).bind('goto', function (event, page) {
            gotoPage(page);
        });
    });  
};

});  //fin onReady

