 /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
jQuery(function($){
    $.datepicker.regional['fr'] = {clearText: 'Effacer', clearStatus: '',
            closeText: 'Fermer', closeStatus: 'Fermer sans modifier',
            prevText: '&lt;Préc', prevStatus: 'Voir le mois précédent',
            nextText: 'Suiv&gt;', nextStatus: 'Voir le mois suivant',
            currentText: 'Courant', currentStatus: 'Voir le mois courant',
            monthNames: ['janvier','février','mars','avril','mai','juin',
            'juillet','août','septembre','octobre','novembre','décembre'],
            monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
            'Jul','Aoû','Sep','Oct','Nov','Déc'],
            monthStatus: 'Voir un autre mois', yearStatus: 'Voir un autre année',
            weekHeader: 'Sm', weekStatus: '',
            dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
            dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
            dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
            dayStatus: 'Utiliser DD comme premier jour de la semaine', dateStatus: 'Choisir le DD, MM d',
            dateFormat: 'dd/mm/yy', firstDay: 0,
            initStatus: 'Choisir la date', isRTL: false};
    $.datepicker.setDefaults($.datepicker.regional['fr']);
});

    $(document).ready(function(){
							   
    	if( $('#datepicker') ){
            $('#datepicker').datepicker({dateFormat: 'dd/mm/yy'});
    	}

        if( $('#speedA').length > 0 && $('#speedB').length > 0 ){
            $(function(){
                $('#speedA').selectmenu({style:'dropdown'});
                $('#speedB').selectmenu({style:'dropdown'});
            });
        }

        /*
         * Popin Mail
         */
        if($("a.popin-open").length > 0){
            $("a.popin-open").popin({
                width:320,
                height:275,
                className: "mypopin",
                loaderImg :  $('#baseUrl').val()+'/style/style_commun/images/ajax-loader.gif'
            });
        }
        
        $("#even_tabs").tabs();
        
        $('#accordion .head').click(function() {
            $(this).prev().toggle();
            if( $(this).hasClass('services_icon_plus') ){
                $(this).removeClass('services_icon_plus');
                $(this).addClass('services_icon_moins');
            } else {
                $(this).removeClass('services_icon_moins');
                $(this).addClass('services_icon_plus');
            }
            
            return false;
        }).prev().hide();
        
        //select pages
        $('#selectpages').change(function() {
            window.location = $(this).val();
        });

        $('#formpostuler').submit(function() {
          $(this).attr('action', $(this).attr('action') + '/categorie/' + $('#selectcategorie').val());
        });

        //programme tv
         $('#program_date').change(function() {
          $(this).attr('action', $(this).attr('action') + '/programme/' + $('#program_date').val());
        });
        
        // Personnalisation Moblie
        $('#accordion_2 .head').click(function() {
            $(this).prev().toggle();
            if( $(this).hasClass('services_icon_plus') ){
                    $(this).removeClass('services_icon_plus');
                            $(this).addClass('services_icon_moins');
                    } else {
                            $(this).removeClass('services_icon_moins');
                            $(this).addClass('services_icon_plus');
                    }
                    return false;
            }).prev().hide();

        //Services de transparence
        $('#accordion_3 .head').click(function(){
            $(this).prev().toggle();
            if( $(this).hasClass('services_icon_plus') ){
                $(this).removeClass('services_icon_plus');
                        $(this).addClass('services_icon_moins');
            } else {
                $(this).removeClass('services_icon_moins');
                $(this).addClass('services_icon_plus');
            }

            if( $(this).hasClass('services_horoscope_plus') ){
                $(this).removeClass('services_horoscope_plus');
                        $(this).addClass('services_horoscope_moins');
            } else {
                $(this).removeClass('services_horoscope_moins');
                $(this).addClass('services_horoscope_plus');
            }
            return false;
        }).prev().hide();
        
        /* METEO */
        if( $('#meteo-ville').length > 0 ){
            $('#meteo-ville').change(function(){
                if($('#meteo-ville').val() == ''){
                    alert('Vous devez sélectionner une ville :!!');
                    return false;
                }
                $.ajax({
                    url: $('#baseUrl').val()+ '/divertissement/pratique/detailmeteoajax',
                    type: 'POST',
                    data: 'format=json&id=' + $(this).val(),
                    success : function(response){
                        callbackMeteo(response);
                    }
                });
            });
        }
        
        // delete navigation last bar
        $('.main_nav > li:last').addClass('clear_separ');
        $('.sub_nav > ul > li:last').addClass('clear_separ');
        $('.sub_nav_div > ul > li:last').addClass('clear_separ');
        
        //point de vente
        $('#pdvVilles').change(function(){
            $.ajax({
                url : $('#baseUrl').val() + '/entreprises/nousconnaitre/quartiers',
                type : 'POST',
                data : 'format=json&idVille=' + $(this).val(),
                success : function(response){
                        dispatchQuartiers(response);
                }
            });
        });

	//point de paiement
        $('#pdvVillesPaiement').change(function(){
            $.ajax({
                url : $('#baseUrl').val() + '/entreprises/nousconnaitre/quartiers',
                type : 'POST',
                data : 'format=json&pe=1&idVille=' + $(this).val(),
                success : function(response){
                        dispatchQuartiers(response);
                }
            });
        });
    
        //Couverture Réseaux
        if( $('#couvRegion').length > 0 ){
            $('#couvRegion').change(function(){
                $.ajax({
                    url : $('#baseUrl').val() + '/entreprises/voix/getprovinces',
                    type : 'POST',
                    data : 'format=json&idRegion=' + $(this).val(),
                    success : function(response){
                        dispatchProvinces(response);
                    }
                });
            });
        }

         if( $('#couv3GRegion').length > 0 ){
            $('#couv3GRegion').change(function(){
                $.ajax({
                    url : $('#baseUrl').val() + '/entreprises/data/getprovinces',
                    type : 'POST',
                    data : 'format=json&idRegion=' + $(this).val(),
                    success : function(response){
                        dispatchGProvinces(response);
                    }
                });
            });
        }
        /*
        * Couverture Entreprises
        */
        if( $("#type").val() == 'entreprises' ){
            //Couverture Entreprises Reseau GSM

            $("#couverture_button").click(function(){

                var region = $('#couvRegion').val();
                var province = $('#couvProvince').val();

                if( region == '' || province == ''){
                    alert('Vous devez selectionner région/province');
                    return false;
                }

                $.ajax({
                    url : $('#baseUrl').val() + '/entreprises/voix/getvilles',
                    type : 'POST',
                    data : 'format=json&region=' + region + '&province=' + province,
                    success : function(response){
                        dispatchResult(response, $("#type").val());
                    }
                });

                $("#object").animate({top: "340px", margin: '0 auto 0 100px', padding: '0'}, 10 ).fadeIn(1000);
            });
            
            //Couverture Entreprises Reseau 3G
            if($("#couverture_3g_button").length > 0 ){
                $("#couverture_3g_button").click(function(){

                    var region = $('#couv3GRegion').val();
                    var province = $('#couv3GProvince').val();

                    if( region == '' || province == ''){
                        alert('Vous devez selectionner région/province');
                        return false;
                    }
                    
                    $.ajax({
                        url : $('#baseUrl').val() + '/entreprises/data/getvilles',
                        type : 'POST',
                        data : 'format=json&region=' + region + '&province=' + province,
                        success : function(response1){
                            $.ajax({
                                url : $('#baseUrl').val() + '/entreprises/voix/getvilles',
                                type : 'POST',
                                data : 'format=json&region=' + region + '&province=' + province,
                                success : function(response2){
                                    dispatchTroisGResult(response1, response2, $("#type").val());
                                }
                            });
                        }
                    });
                    $("#object3g").animate({top: "340px", margin: '0 auto 0 100px',  margintop: '-400px', padding: '0'}, 10 ).fadeIn(1000);
                });
            }
        }


        /*
        *Couverture Particuliers Reseau GSM
        */
        if( $("#type").val() == 'particuliers' ){

            //Couverture Particuliers Reseau GSM
            $("#couverture_button").click(function(){

                var region = $('#couvRegion').val();
                var province = $('#couvProvince').val();

                if( region == '' || province == ''){
                    alert('Vous devez selectionner région/province');
                    return false;
                }
                
                $.ajax({
                    url : $('#baseUrl').val() + '/mobile/getvilles',
                    type : 'POST',
                    data : 'format=json&region=' + region + '&province=' + province,
                    success : function(response){
                        dispatchResult(response, $("#type").val());
                    }
                });

                $("#object").animate({top: "340px", margin: '0 auto 0 100px', padding: '0'}, 10 ).fadeIn(1000);
            });

           
            //Couverture Particuliers Reseau 3G
           /* if($("#couverture_3g_button").length > 0 ){
                $("#couverture_3g_button").click(function(){

                    var region = $('#couv3GRegion').val();
                    var province = $('#couv3GProvince').val();

                    if( region == '' || province == ''){
                        alert('Vous devez selectionner région/province');
                        return false;
                    }

                    $.ajax({
                        url : $('#baseUrl').val() + '/internethdm/getvilles',
                        type : 'POST',
                        data : 'format=json&region=' + region + '&province=' + province,
                        success : function(response1){
                            $.ajax({
                                url : $('#baseUrl').val() + '/mobile/getvilles',
                                type : 'POST',
                                data : 'format=json&region=' + region + '&province=' + province,
                                success : function(response2){
                                    dispatchTroisGResult(response1, response2, $("#type").val());
                                }
                            });
                        }
                    });
                    $("#object3g").animate({top: "340px", margin: '0 auto 0 100px', padding: '0'}, 10 ).fadeIn(1000);
                });
            }*/
        }


      if($('#ville_pharmacie').length > 0){
            $('#ville_pharmacie').change(function(){
                $.ajax({
                    url: $('#pharmacieUrl').val(),
                    type: 'POST',
                    data: 'format=json&ville=' + $(this).val(),
                    success : function(response){
                        response = eval('('+response+')');
                        //$('#selectquartier_pharmacie').html('');
                        var options = '';
                        for( var i in response.quartiers ){
                            options += '<option value="' + response.quartiers[i].quartier + '">' + response.quartiers[i].quartier + '</option>';
                        }
                        $('#quartier_pharmacie').html(options);
                    }
                });
            });
        }
        
        $('#selectoffre').change(function(){
            $.ajax({
                url : $('#baseUrl').val() + '/corporate/carrieres/postulerenligne/categorie/'+ $(this).val(),
                type : 'GET',
                success : function(response){
                    $('#listeOffres').html(response);
                }
            });
        });


       /* $('#program_date').change(function(){
            $.ajax({
                url : $('#baseUrl').val() + '/divertissement/pratique/guidetv/programme/'+ $(this).val(),
                type : 'GET',
                success : function(response){
                    $('#listeProgrammes').html(response);
                }
            });
        });*/

         //programme
    $('#program_date').change(function(){
        $.ajax({
            url : $('#baseUrl').val() + '/divertissement/pratique/guidetv',
            type : 'POST',
            data : 'format=json&date=' + $(this).val() + '&idchaine=' + $('#currentchaine').val(),
            
            success : function(response){            
              dispatchProgrammeparchaine(response);
            }
        });
    });

    //Résultat de matchs

    /*$('#selectjours').change(function(){
        //alert($('#selectjours').val());
        $.ajax({
            url : $('#baseUrl').val() + '/divertissement/news/sport/championnat/championnat-d1',
            type : 'POST',
            data : 'format=json&journee=' + $('#selectjours').val(),

            success : function(response){
              dispatchResultatMatchs(response);
            }
        });
    });*/
     $('#selectjours').change(function(){
            $.ajax({
                url : $('#baseUrl').val() + '/divertissement/news/sport/request/journee',
                type : 'POST',
                data : 'date=' + $(this).val(),
                success : function(response){
                    $('#listeResultats').html(response);
                }
            });
        });

    
     $('#selectcalendrier').change(function(){
           $.ajax({
                url : $('#baseUrl').val() + '/divertissement/news/sport/request/calendrier',
                type : 'POST',
                data : 'date=' + $(this).val(),
                success : function(response){
                    $('#listeCalendrier').html(response);
                }
            });
        });

        //programme en choisissant une chaine

         $('.choixchaine').each(function(){
             $(this).click(function() {
                 //$(this).attr('action', $(this).attr('action') + '/chaine/' + $('#chainestv').val());
                 $('#currentchaine').val($(this).attr('val'));
                   $.ajax({
                    url : $('#baseUrl').val() + '/divertissement/pratique/guidetv',
                    type : 'POST',
                    data : 'format=json&date=' + $('#program_date').val() +'&idchaine='+$(this).attr('val'),

                    success : function(response){
                      dispatchProgrammeparchaine(response);
                    }
                });
            });
         });

        // fin
       //chaine homme divertissement
       /*$('.chainetv').each(function(){
             $(this).click(function() {
                 $('#currentchaine').val($(this).attr('val'));
                   $.ajax({
                    url : $('#baseUrl').val() + '/pratique/guidetv',
                    type : 'POST',
                    data : 'format=json&idchaine=' +$(this).attr('val'),

                    success : function(response){
                      dispatchProgrammeparchaine(response);
                    }
                });
            });
         });*/
       //fin homme divertissement
        //programme
    $('#programsoiree').change(function(){
        $.ajax({
            url : $('#baseUrl').val() + '/divertissement/pratique/guidetv',
            type : 'POST',
            data : 'format=json&datesoiree=' + $(this).val(),

            success : function(response){
              dispatchProgrammesoiree(response);
            }
        });
    });
        //fin du programme de la soireé

        $('#searchParmacie').click(function(){
            var ville =  $('#ville_pharmacie').val();
            var quartier = $('#quartier_pharmacie').val();
            var baseUrl = $('#baseUrl').val();
            window.location = Url.encode( baseUrl + '/divertissement/pratique/pharmaciesdegarde/ville/' + ville + '/quartier/' + quartier);
        });

        // Horaires de prieres, pratique home page
        $('#priere-ville-index').change(function(){
            window.location = $('#baseUrl').val() + '/divertissement/pratique/horairesdeprieres/ville/' + $(this).val();
        });
        
        // Horaires de prieres
        $('#priere-ville').change(function(){
            $.ajax({
                url: $('#baseUrl').val(),
                type: 'POST',
                data: 'format=json&ville=' + Url.encode($(this).val()),
                success : function(response){
                    callbackHoraires(response);
                }
            });
        });

        // Horaires de prieres divertissement Home page
        $('#priere-ville-diver').change(function(){
            $.ajax({
                url: $('#priereUrl').val(),
                type: 'POST',
                data: 'format=json&ville=' + Url.encode($(this).val()),
                success : function(response){
                    callbackDiverHoraires(response);
                }
            });
        });

        if( $("#loading") ){
            $("#loading").ajaxStart(function(){
               $(this).show();
            });
            $("#loading").ajaxStop(function(){
               $(this).hide();
            });
        }
//quizz noujoum
    $('#search_quizz_noujoum').click(function(){
        var idQuestions =  $('#idQuestion').val();
        $.ajax({
            url : $('#baseUrl').val() + '/divertissement/loisirs/reponsequizznoujoum',
            type : 'POST',
            data : 'format=json&idQuestion='+ $('#idQuestion').val(),
            //+ $(this).val(),

            success : function(response){
               // alert(idQuestions);
              dispatchQuizznoujoum(response);
            }
        });
    });
    
//fin quizz noujoum

//quizz cinema
    $('#search_quizz_cinema').click(function(){
        //var idQuestions =  $('#idQuestioncinema').val();
        $.ajax({
            url : $('#baseUrl').val() + '/divertissement/loisirs/cinema',
            type : 'POST',
            data : 'format=json&idQuestion='+ $('#idQuestioncinema').val(),
            //+ $(this).val(),

            success : function(response){
               // alert(idQuestions);
              dispatchQuizzcinema(response);
            }
        });
    });

//fin quizz cinema

        /* Charger les options */
        $("#produitconcerne").change(function(){
            option = '';
            if( $(this).val() == 'Mobile sans abonnement' ||  $(this).val() == 'Mobile avec abonnement'){
              option += '<option value="Promotion">Promotion</option>'+
                        '<option value="Service">Service</option>'+
                          '<option value="Recharge">Recharge</option>'+
                          '<option value="Téléphone">Téléphone</option>'+
                          '<option value="Forfait">Forfait</option>'+
                          '<option value="Roaming">Roaming</option>'+
                          '<option value="Tarifs">Tarifs</option>'+
                          '<option value="Mes données personnelles">Mes données personnelles</option>'+
                          '<option value="Facture">Facture</option>'+
                          '<option value="Réseau wana">Réseau inwi</option>';
            }

            if( $(this).val() == 'Internet HDM sans abonnement' ||  $(this).val() == 'Internet HDM avec abonnement'){
              option += '<option value="Promotion">Promotion</option>'+
                        '<option value="Service">Service</option>'+
                          '<option value="Recharge">Recharge</option>'+
                          '<option value="Forfait">Forfait</option>'+
                          '<option value="Tarifs">Tarifs</option>'+
                          '<option value="Modem">Modem</option>'+
                          '<option value="Mes données personnelles">Mes données personnelles</option>'+
                          '<option value="Facture">Facture</option>'+
                          '<option value="Réseau wana">Réseau inwi</option>';
            }
            
                $("#ausujetde").html(option);
                $("#reclamation").html(option);
        });


        /* Boutons Radio 'Objet de la demande' */
        $('div.bloque_form').css('display', 'none')
        $('#objet_demande_info').click(function(){
            $('div.bloque_form').css('display','none')
            $('#bloque_information').css('display','block')
        });
        $('#objet_demande_reclamations').click(function(){
            $('div.bloque_form').css('display','none')
            $('#bloque_reclamation').css('display','block')
        });
        /* Fin Boutons Radio 'Objet de la demande' */

        if($('a#couverture_gsm')){
            $('a#couverture_gsm').click(function(){
                
                var action =  $(this).attr('name');
                var seed = action.split(':');
                setGsmUrl(seed[0],seed[1],seed[2]);
            });
        }
        
        if($('a#couverture_troisg')){
           $('a#couverture_troisg').click(function(){
                
                var action =  $(this).attr('name');
                var seed = action.split(':');
                setTroisgUrl(seed[0],seed[1],seed[2]);
            });
        }


        $('#esn_execute').click(function(){
            $.ajax({
                url : $('#basUrl').val() + '/mobile/getesntel/esn/'+ $('#esn').val(),
                type : 'POST',
                data :'format=json&esn='+ $('#esn').val(),
                success : function(response){ 
                    //var response = eval('('+response+')');
                    //var result = response.result['NUMR_TELP'];
                    if( response != ''){
                        $('#rsn_result').html( response );
                    }else{
                        $('#rsn_result').html( 'Aucun résultat pour cette recherche' );
                    }
                }
            });
        });

        $('#searchVideo').click(function(){
            var url = $('#formRechercheVideos').attr('action');

            if( $('#motcle').val() == '' && $('#categorie').val() == '' ){
                alert('Veuillez préciser votre recherche ! ');
                return;
            }

            if( $('#motcle').val() != ''){
                url += '/motcle/' + $('#motcle').val();
            }

            if( $('#categorie').val() != ''){
                url += '/categorie/' + $('#categorie').val();
            }

            window.location = Url.encode(url);

        });

        $('#searchStars').click(function(){
            var url = $('#formRechercheStars').attr('action');

           if( $('#stars').val() == ''){
                alert('Veuillez préciser votre recherche ! ');
                return;
            }else{
                url += '/star/' + $('#stars').val();
            }
            
            window.location = Url.encode( url );

        });
        // Recherche Film
          $('#searchFilms').click(function(){
            var url = $('#formrecherchefilm').attr('action');

           /*if( $('#salles').val() == ''){
                alert('Veuillez préciser votre recherche ! ');
                return;
            }else{*/
                url += '/salle/' + $('#salles').val() + '/film/' + $('#films').val();
           // }

            window.location = Url.encode( url );

        });
        
        // Recherche Prochaine sortie
          $('#searchProchaineSortie').click(function(){
            var url = $('#formrecherchefilm').attr('action');
                //url += '/salle/' + $('#salles').val() + '/film/' + $('#prochainesortie').val();
                url += '/prochaine-sortie/' + $('#prochainesortie').val();
            window.location = Url.encode( url );

        });
        //

        $('#searchStarsMusic').click(function(){
            var url = $('#formRechercheStarsMusic').attr('action');

            if( $('#motcle').val() == ''){
                alert('Veuillez préciser votre recherche ! ');
                return;
            }else{
                url += '/motcle/' + $('#motcle').val();
            }

            window.location = Url.encode( url );

        });

        $('#searchRecette').click(function(){

            var titre =  $('#titrerecette').val();
            var category = $('#category').val();
            var subcategory = $('#subcategory').val();

            if( titre == '' & category == '' & subcategory == '' ){
                alert('Veuillez compléter le champ de recherche');
                return;
            }
            var baseUrl = $('#baseUrl').val();
            var url = '';
            
            if( titre != '' ){
                url += '/motcle/' + titre;
            }
            if( category != '' ){
                url += '/categorie/' + category;
            }
            if( subcategory != '' ){
                url +='/souscategorie/' + subcategory;
            }
            
            window.location = Url.encode( baseUrl + '/divertissement/pratique/rechercherecette' + url );
        });


        if( $(".stars-wrapper").length > 0 ){
            $(".stars-wrapper").each(function(){
                var str = '#'+$(this).attr('caption');
                var table = $('#table').val();
                $(this).stars({
                    oneVoteOnly: true,
                    split: 1,
                    captionEl: $(str),
                    callback: function(){
                        doRate($(this).val(), $(this).attr('name'), table);
                    }
                });
            });
        }

         if( $("#mobile_pdv").length > 0 ){
              $("#mobile_pdv").click(function(){
                   var mobile = $('#idMobile').val();
                   var ville = $('#pdvVilles').val();
                   var quartier = $('#pdvQuartiers').val();

                   $.ajax({
                        url : $('#baseUrl').val() + '/mobile/getpdvmobile',
                        type : 'POST',
                        data :'format=json&mobile='+mobile+'&ville='+ville+'&quartier='+quartier,
                        success : function(response){
                          
                          var response = eval('('+response+')');

                          var html = '';
                          html += '<div class="search_point_row_0"><b style="font-size:12px; color:#787878">Résultats pour : </b><span style="color:#9d3393;">'+ville+' >> '+quartier+'</span></div>';

                          var k = 1;
                          for(i = 0; i<response.result.length ; i++ ){
                            html += '<div class="search_point_row_'+k+'">'+
                                    '<div style="float:left; width:100%; margin:10px 0; padding: 0 4% 0 0;">'+
                                    '<div><b>'+response.result[i]['quartier']+'</b></div>'+
                                    '<div>'+response.result[i]['adresse']+'</div>'+
                                    '<div>'+response.result[i]['ville']+'</div>'+
                                    '</div><div class="clear"></div></div>';

                            k = 1-k;
                          }

                           if( response.result != false){
                                $('#pdv_result').html( html );
                           }else{
                               html = '<div class="search_point_row_0"><b style="font-size:12px; color:#787878"> Ce mobile n’est pas disponible dans le quartier spécifié </b><span style="color:#9d3393;"></span></div>';
                                $('#pdv_result').html( html );
                           }
                        }
                    });
              });
         }


         if( $("#mobile_pdv_btob").length > 0 ){
              $("#mobile_pdv_btob").click(function(){
                   var ville = $('#pdv-villes').val();
                   $.ajax({
                        url : $('#baseUrl').val() + '/entreprises/voix/getpdvmobile',
                        type : 'POST',
                        data :'format=json&ville='+ville,
                        success : function(response){

                         var response = eval('('+response+')');

                          var html = '';
                          html += '<div class="search_point_row_0"><b style="font-size:12px; color:#787878">Résultats pour : </b><span style="color:#9d3393;">'+ville+'</span></div>';

                          var k = 1;
                          for(i = 0; i<response.result.length ; i++ ){
                            html += '<div class="search_point_row_'+k+'">'+
                                    '<div style="float:left; width:100%; margin:10px 0; padding: 0 4% 0 0;">'+
                                    //'<div><b>'+response.result[i]['quartier']+'</b></div>'+
                                    '<div>'+response.result[i]['ville']+'</div>'+
                                    '<div>'+response.result[i]['adresse']+'</div>'+
                                    '</div><div class="clear"></div></div>';

                            k = 1-k;
                          }

                           if( response.result != false){
                                $('#pdv_result').html( html );
                           }else{
                               html = '<div class="search_point_row_0"><b style="font-size:12px; color:#787878"> Ce mobile n’est pas disponible dans la ville spécifiée </b><span style="color:#9d3393;"></span></div>';
                                $('#pdv_result').html( html );
                           }
                        }
                    });
              });
         }
    });
	
    var Url = {
    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },
    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },
    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
                var c = string.charCodeAt(n);
                if (c < 128) {
                        utftext += String.fromCharCode(c);
                }
                else if((c > 127) && (c < 2048)) {
                        utftext += String.fromCharCode((c >> 6) | 192);
                        utftext += String.fromCharCode((c & 63) | 128);
                }
                else {
                        utftext += String.fromCharCode((c >> 12) | 224);
                        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                        utftext += String.fromCharCode((c & 63) | 128);
                }
        }
        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
        while ( i < utftext.length ) {
                c = utftext.charCodeAt(i);
                if (c < 128) {
                        string += String.fromCharCode(c);
                        i++;
                }
                else if((c > 191) && (c < 224)) {
                        c2 = utftext.charCodeAt(i+1);
                        string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                        i += 2;
                }
                else {
                        c2 = utftext.charCodeAt(i+1);
                        c3 = utftext.charCodeAt(i+2);
                        string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                        i += 3;
                }
        }
        return string;
    }
}


function doRate(val,id, table){
    $.ajax({
        url  : $('#baseUrl').val() + '/divertissement/loisirs/dorate',
        type : 'POST',
        data : 'format=json&value='+val+'&starId='+id+'&table='+table,
        success : function(response){
            response = eval( '('+response+')');
            $('#comment_label').html(response.vote);
        }
    });
}


function setGsmUrl( module, controller, action ){

     var region = $("#couvRegion").val();
     var province = $("#couvProvince").val();

    if( region == '' || province == '' ){
        alert('Vous devez selectionner une Region/Province');
        if( module == 'default' ){
             //var href = $('#baseUrl').val()+'/'+controller+'/errorcouverture';
             var href = $('#baseUrl').val()+'/'+controller+'/'+action;
             href = Url.encode(href);
        }else{
             //var href = $('#baseUrl').val()+'/'+module+'/'+controller+'/errorcouverture';
             var href = $('#baseUrl').val()+'/'+module+'/'+controller+'/'+action;
             href = Url.encode(href);
        }
        $("#couverture_gsm").attr("href", href);
        return false;
    }else{
        if( module == 'default' ){
             var href = $('#baseUrl').val()+'/'+controller+'/'+action+'/region/'+region+'/province/'+province;
             href = Url.encode(href);
        }else{
             var href = $('#baseUrl').val()+'/'+module+'/'+controller+'/'+action+'/region/'+region+'/province/'+province;
             href = Url.encode(href);
        }
        $("#couverture_gsm").attr("href", href);
    }
}


function setTroisgUrl( module, controller, action ){

    var region = $("#couv3GRegion").val();
    var province = $("#couv3GProvince").val();

    if( region == '' || province == '' ){
        alert('Vous devez selectionner une Region/Province');
        if( module == 'default' ){
             //var href = $('#baseUrl').val()+'/'+module+'/'+controller+'/errorcouverture';
             var href = $('#baseUrl').val()+'/'+controller+'/'+action;
             href = Url.encode(href);
        }else{
             //var href = $('#baseUrl').val()+'/'+module+'/'+controller+'/errorcouverture';
             var href = $('#baseUrl').val()+'/'+module+'/'+controller+'/'+action;
             href = Url.encode(href);
        }
        $("#couverture_troisg").attr("href", href);
        return false;
    }else{
        if( module == 'default' ){
             var href = $('#baseUrl').val()+'/'+controller+'/'+action+'/region/'+region+'/province/'+province;
             href = Url.encode(href);
        }else{
             var href = $('#baseUrl').val()+'/'+module+'/'+controller+'/'+action+'/region/'+region+'/province/'+province;
             href = Url.encode(href);
        }
        $("#couverture_troisg").attr("href", href);
    }
}
// programme par chaine
function dispatchProgrammeparchaine(response){
	    //response = JSON.parse(response);
            response = eval('(' + response + ')');
            var conatiner = $('#listeProgrammes');

            html ='<img class="correct-png" src="<?php echo $this->baseUrl(); ?>/images/tv/<?php echo $this->programmeparchaine[0]->logochaine; ?>"  />';
	    html = '<div>';
            html += '<table cellpadding="0" cellspacing="0" width="100%" class="grogramme_tv">';
            html += '<tr class="tv_label" align="center">';
            html += '<td width="22%">L\'heure</td>';
            html += '<td width="56%" align="left">Programme</td>';
            html += '<td width="22%">Genre</td>';
            html += '</tr>';         
            
            for( var i in response.programmechaine ){
            //alert(response.programmechaine);
            $('#logochaine').html('<img class="correct-png" title="'+response.programmechaine[i].logo+'" alt="'+response.programmechaine[i].logo+'" src="'+$('#baseUrl').val()+'/images/tv/'+response.programmechaine[i].logo+'"/>');
                       html += ' <tr class="tv_row_0" >';
                       html += '<td>'+response.programmechaine[i].heure_debut+'</td>';
                       html += '<td><a href="'+$('#baseUrl').val()+'/divertissement/pratique/guidetv/article/'+response.programmechaine[i].id+'">'+response.programmechaine[i].titre+'</a></td>';
                       html += '<td>'+response.programmechaine[i].categorie+'</td>';
                       html += '</tr>';
            }
            html += '</table></div>';
            conatiner.html(html);
	}
//fin programme par chaine

//programme de la soiree

function dispatchProgrammesoiree(response){


            response = eval('(' + response + ')');
            var conatiner = $('#programmesoiree');


	    html = '<div>';
            html += '<table cellpadding="0" cellspacing="0" width="100%" class="grogramme_tv">';
            html += ' <tr class="tv_label" align="center">';
            html += '<td height="20">Grandes chaînes</td>';
            html += '<td align="center" height="20">Programmes</td>';
            html += '</tr>';
        if(typeof(response.programmecettesoiree[0][0])== 'undefined'){
            alert("pas de programmes dans cette date")
            }
            else
            {
            for( var i in response.chaine ){

                       html += ' <tr class="tv_row_0" >';
                       html += '<td align="center" width="50"><a href="'+$('#baseUrl').val()+'/divertissement/pratique/guidetv/chaine/'+response.chaine[i].id+'"  class="choixchaine" id="'+response.chaine[i].nom+'" val="'+response.chaine[i].id+'"><img border="0" class="correct-png"  title="'+response.chaine[i].thumb+'" alt="'+response.chaine[i].thumb+'" src="'+$('#baseUrl').val()+'/images/tv/vignette/'+response.chaine[i].thumb+'"/></a></td>';
                       html += '<td width="100%">';
                       for( var j in response.programmecettesoiree[i] ){
                       html += '<table border="0" width="180" style="border:none; float:left"  ><tr valign="top"><td width="70" style="border:none; padding:0"><img class="correct-png" width="70"  title="'+response.programmecettesoiree[i][j].visuel+'" alt="'+response.programmecettesoiree[i][j].visuel+'" src="'+$('#baseUrl').val()+'/images/tv/programmes/'+response.programmecettesoiree[i][j].visuel+'"/></td>';
                       html += '<td style="border:none; padding:0 0 0 5px">'+response.programmecettesoiree[i][j].heure_debut+'<br>'+'<a href="'+$('#baseUrl').val()+'/divertissement/pratique/guidetv/article/'+response.programmecettesoiree[i][j].id+'">'+response.programmecettesoiree[i][j].titre+'</a><br>'+response.programmecettesoiree[i][j].categorie+'</td>';
                       html += '</tr>';
                       html += '</table>';
                        }
                       html += '</td>';

                       html += '</tr>';
            }
        }
            html += '<tr class="tv_label">';
            //html += '<td  align="left"><input type="hidden" id="currentchaine" value="" name="currentchaine"/></td>';
            html += '</tr>';
            html += '</table></div>';
            conatiner.html(html);
	}

//fin du programme soirée
//function quizz noujoum
function dispatchQuizznoujoum(response){
    
                response = eval('(' + response + ')');
                var conatiner = $('#resultatnoujoumquizz');
                 html = '<div>';
               	 /*html += '<div class="content_page" style="padding:20px 0 0 20px">';
                 html += '<h1><label>Question : </label>'+response.resultatquizznoujoum[0].question+'</h1>';
                 html += '<div class="quizz_result">';
                 var k =1;
                for( var i in response.resultatquizznoujoum ){
                 html += '<div class="result_'+(k=1-k)+'"><label>'+response.resultatquizznoujoum[i].reponses+':</label>'+response.resultatquizznoujoum[i].total+'</div>';
                 }
                 html += '</div>';
                 html += '</div>';*/

                 html += '<div class="content_page" style="padding:20px 0 0 20px">';
                 //html += '<h1><label>Question : </label>'+response.resultatquizznoujoum[0].question+'</h1>';
                 html += '<div class="quizz_result">';
                for( var i in response.resultatquizznoujoum ){
                 html += '<div class="result_0"><label> La bonne réponse est : </label><label>'+response.resultatquizznoujoum[i].reponse+' </label></div>';
                 }
                 html += '</div>';
                 html += '</div>';

                html += '<br></div>';
                conatiner.html(html);
	}
//fin quizz noujoum

//function quizz cinema
function dispatchQuizzcinema(response){

                response = eval('(' + response + ')');
                var conatiner = $('#resultatcinemaquizz');
                 html = '<div>';
                 html += '<div class="content_page" style="padding:20px 0 0 20px">';
                 //html += '<h1><label>Question : </label>'+response.resultatquizzcinema[0].question+'</h1>';
                 html += '<div class="quizz_result">';
                for( var i in response.resultatquizzcinema ){
                 html += '<div class="result_0"><label> La bonne réponse est : </label><label>'+response.resultatquizzcinema[i].reponse+' </label></div>';
                 }
                 html += '<br></div>';
                 html += '</div>';

                html += '</div>';
                conatiner.html(html);
	}
//fin quizz cinema

//Résultat de Matchs
function dispatchResultatMatchs(response){
	    //response = JSON.parse(response);
            response = eval('(' + response + ')');
            var conatiner = $('#listeResultats');
            html ='<table cellspacing="0" style="color:white;" width="100%">';
              for( var i in response.resultats ){
                alert(response.resultats[i]);
                    html ='<tr>';                    
                     html ='<td class="td_couleur_page_sport_v1">';
                    html ='<span style="margin-left:10px;color:#fc96e3">'+response.resultats[i].date+'</span>';
                    html ='</td>';
                    html ='<td class="td_couleur_page_sport_v1" align="center">';
                    html ='<span style="margin-left:10px">'+response.resultats[i].nomequipe1+'</span>';
                    html ='</td>';
                    html ='<td class="td_couleur_page_sport_v1" align="center">';
                    html ='<span style="font-weight:bold">'+response.resultats[i].resultat+'</span>';
                    html ='</td>';
                    html ='<td class="td_couleur_page_sport_v1">';
                    html ='<span style="margin-left:10px">'+response.resultats[i].nomequipe2+'</span>';
                    html ='</td>';
                    html ='</tr>';
             }

            html ='</table></div>';
            conatiner.html(html);
	}
//fin

//Calendrier de Matchs
function dispatchResultatCalendrier(response){
	    //response = JSON.parse(response);
            response = eval('(' + response + ')');
            var conatiner = $('#listeCalendrier').html(response);
             /*html ='<table cellspacing="0" style="color:white;" width="100%">';
             //alert(response.resultatsCalendrier);
             for( var i in response.resultatsCalendrier ){
               alert(response.resultatsCalendrier[i].date);
                          html ='<tr>';
                          html ='<td class="td_couleur_page_sport_v1">';
                          html ='<span style="margin-left:10px;color:#fc96e3">'+response.resultatsCalendrier[i].date+'</span>';
                          html ='</td>';
                          html ='<td class="td_couleur_page_sport_v1" align="center">';
                          html ='<span style="margin-left:10px">'+response.resultatsCalendrier[i].nomequipe1+'</span>';
                          html ='</td>';
                          html ='<td class="td_couleur_page_sport_v1" align="center">';
                          html ='<span style="font-weight:bold">-</span>';
                          html ='</td>';
                          html ='<td class="td_couleur_page_sport_v1">';
                          html ='<span style="margin-left:10px">'+response.resultatsCalendrier[i].nomequipe2+'</span>';
                          html ='</td>';
                          html ='</tr>';
             }
            html ='</table>';    
            html ='</div>';
            conatiner.html(html);*/
	}
//fin

function callbackMeteo(response){
    $("#resultatmeteo").html(response)
}

function setFrontAction( action ){
    document.frontForm.action = action;
    document.frontForm.submit();
}

    function dispatchResult( response , style){

        response = eval('('+response+')');

        var html = '';

        html += '<div class="pop-up-title-' +style+ '"> Couverture réseau <a href="#" class="close-pop-up-' +style+ '" id="close_message"></a> </div>'+
                '<div class="pop-up-content">'+
                '<p>Villes couvertes par le réseau Inwi :</p><br/>'+
                '<div class="ville-pop-up">';

        for( i=0; i< parseInt((response.villes.length)/2)+1 ; i++ ){
            html += '<div style="float:left; width:46%;">';
            if( typeof(response.villes[2*i]) != undefined && typeof(response.villes[2*i]) != null ){
                //alert(i+' '+response.villes.length);
                html += '<a href="'+response.villes[2*i].url+'">'+response.villes[2*i].key+'</a></div>'
            }
            html +=  '<div style="float:left; width:46%;">'
            if( typeof(response.villes[2*i+1]) != undefined && typeof(response.villes[2*i+1]) != null ){
                 html += '<a href="'+response.villes[2*i+1].url+'">'+response.villes[2*i+1].key+'</a>'
            }
            html += '</div>';
        }

         html += '<div class="clear"></div></div></div>';

        $('#object').html(html);

        //close the message box when cross red image is clicked
        $("#close_message").click(function(){
            $("#object").fadeOut(1000);
        });
    }

function dispatchProvinces(response){

    response = eval('('+response+')');

    var options = '';
    for( var i in response.provinces ){
        options += '<option value="' + response.provinces[i].key + '">' + response.provinces[i].value + '</option>';
    }
    $('#selectprovince').html('--Province--');
    $('#couvProvince').html(options);

}

function dispatchGProvinces(response){
    response = eval('('+response+')');
    var options = '';
    for( var i in response.provinces ){
        options += '<option value="' + response.provinces[i].key + '">' + response.provinces[i].value + '</option>';
    }
    $('#selectcouv3GProvince').html('--Province--');
    $('#couv3GProvince').html(options);
}

function dispatchQuartiers(response){
    response = eval('('+response+')');
    var options = '';
    for( var i in response.quartiers ){
        options += '<option value="' + response.quartiers[i].key + '">' + response.quartiers[i].value + '</option>';
    }
    $('#pdvQuartiers').html(options);
    $('#selectpdvQuartiers').html('--Quartier--');
}

function mobileIsChecked(elmId){
    maxOptionsSelect = 3;
    inputs = document.adminForm.getElementsByTagName("input");
    count = 0;
    
    for(i=0 ; i<inputs.length ; i++){
        if(inputs[i].type=="checkbox" && inputs[i].checked == true){
            
            count++;
        }
    }

    if(count > maxOptionsSelect){
        document.getElementById(elmId).checked = false;
        alert("Vous pouvez sélectionner que " + maxOptionsSelect + " mobiles maximum");
        return false;
    }
    return false;
}

function checkSelected(){

    inputs = document.adminForm.getElementsByTagName("input");
    count = 0;
    for(i=0 ; i<inputs.length ; i++){
        if( inputs[i].type=="checkbox" && inputs[i].checked==true ){
            count++;
        }
    }
    if( count == 0 || count == 1){
        
        alert('Vous devez sélectionner 2 ou 3 mobiles pour comparer !');
        
        inputs = document.adminForm.getElementsByTagName("input");

        for(i=0 ; i<inputs.length ; i++){
             if( inputs[i].type=="checkbox"){
                 inputs[i].checked = false;
                 //$( "div #"+inputs[i].id ).attr('style', 'background-position: 0pt 0px;');
             }

        }
        return false;
    }
    return true;
}

/**
* Submit the admin form
*/
function submitform(){

	if (typeof document.adminForm.onsubmit == "function") {

		document.adminForm.onsubmit();
	}
	document.adminForm.submit();
}

function setAction(seed){
	document.adminForm.action = seed;
	document.adminForm.submit();
}

function doRating(val,id){
    $.ajax({
        url  : $('#baseUrl').val() + '/divertissement/loisirs/rate',
        type : 'POST',
        data : 'format=json&value='+val+'&starId='+id,
        success : function(response){
            response = eval('('+response+')');
            var options = '';
            for( var i in response.quartiers ){
                options += '<option value="' + response.quartiers[i].quartier + '">' + response.quartiers[i].quartier + '</option>';
            }
            $('#quartier_pharmacie').html(options);
        }
    });
}

// Horaires de prieres
function callbackHoraires(response){
    response = eval('('+response+')');
    $('#container_horaire').css('display', 'block');
	
	if( response.horaires.assoubh == undefined ){
            assoubh = 'Non renseigné';
        }else{
            assoubh = response.horaires.assoubh;
        }

        if( response.horaires.addouhr == undefined ){
            addouhr = 'Non renseigné';
        }else{
            addouhr = response.horaires.addouhr;
        }

        if( response.horaires.alasr == undefined ){
            alasr = 'Non renseigné';
        }else{
            alasr = response.horaires.alasr;
        }
        if( response.horaires.almaghrib == undefined ){
            almaghrib = 'Non renseigné';
        }else{
            almaghrib = response.horaires.almaghrib;
        }

        if( response.horaires.alichaa == undefined ){
            alichaa = 'Non renseigné';
        }else{
            alichaa = response.horaires.alichaa;
        }

        /*if( response.horaires == false ){

            assoubh = 'Non renseigné';
            addouhr = 'Non renseigné';
            alasr = 'Non renseigné';
            almaghrib = 'Non renseigné';
            alichaa = 'Non renseigné';
	}else{
            assoubh = response.horaires.assoubh;
            addouhr = response.horaires.addouhr;
            alasr = response.horaires.alasr;
            almaghrib = response.horaires.almaghrib;
            alichaa = response.horaires.alichaa;
        }*/
	
        var html = '<div class="style_horaire_priere_page_priere correct-png"><span class="col horaire">'+assoubh+'</span><span>Salat As-sobh</span></div>';
        html += '<div class="style_horaire_priere_page_priere correct-png"><span class="col horaire">'+addouhr+'</span><span>Salat Ad-dohr</span></div>';
        html += '<div class="style_horaire_priere_page_priere correct-png"><span class="col horaire">'+alasr+'</span><span>Salat Al-asr</span></div>';
        html += '<div class="style_horaire_priere_page_priere correct-png"><span class="col horaire">'+almaghrib+'</span><span>Salat Al-maghrib</span></div>';
        html += '<div class="style_horaire_priere_page_priere correct-png"><span class="col horaire">'+alichaa+'</span><span>Salat Al-ichae</span></div>';

        $('#content_horaire').html(html);
}

//call back divertissement home horaires
function callbackDiverHoraires( response ){

    response = eval('('+response+')');
    //$('#container_horaire').css('display', 'block');

	if( response.horaires.assoubh == undefined ){
            assoubh = 'Non renseigné';
        }else{
            assoubh = response.horaires.assoubh;
        }

        if( response.horaires.addouhr == undefined ){
            addouhr = 'Non renseigné';
        }else{
            addouhr = response.horaires.addouhr;
        }

        if( response.horaires.alasr == undefined ){
            alasr = 'Non renseigné';
        }else{
            alasr = response.horaires.alasr;
        }
        if( response.horaires.almaghrib == undefined ){
            almaghrib = 'Non renseigné';
        }else{
            almaghrib = response.horaires.almaghrib;
        }

        if( response.horaires.alichaa == undefined ){
            alichaa = 'Non renseigné';
        }else{
            alichaa = response.horaires.alichaa;
        }

        var html =  '<table cellpadding="0" cellspacing="0" width="100%" id="container_horaire" class="horaire_priere_hp">'+
                   '<tr class="pr_0"><td width="130">Salat As-sobh</td><td width="130"><b>'+assoubh+'</b></td></tr>'+
                   '<tr class="pr_1"><td>Salat Ad-dohr</td><td><b>'+addouhr+'</b></td></tr>'+
                   '<tr class="pr_0"><td>Salat Al-asr</td><td><b>'+alasr+'</b></td></tr>'+
                   '<tr class="pr_1"><td>Salat Al-maghrib</td><td><b>'+almaghrib+'</b></td></tr>'+
                   '<tr class="pr_0"><td>Salat Al-ichae</td><td><b>'+alichaa+'</b></td></tr>'+
                   '</table>';

        $('#content_horaire_diver').html(html);
}

function gotopage( url, page ){
    document.adminForm.action = url;
    document.adminForm.page.value = page;
    document.adminForm.submit();
}

function setComparerAction( url ){
    if( checkSelected() ){
        $('#adminForm').attr('action', url);
        $('#comparateur').val(1);
        $('#adminForm').submit();
    }else{
        return false;
    }
}

/* Imprimer */
function imprime_zone(titre, obj) 
{
// Définie la zone à imprimer
var zi = document.getElementById(obj).innerHTML;
// Ouvre une nouvelle fenetre
var f = window.open("", "ZoneImpr", "height=500, width=600,toolbar=0, menubar=0, scrollbars=1, resizable=1,status=0, location=0, left=10, top=10");
// Définit le Style de la page
f.document.body.style.color = '#000000';
f.document.body.style.backgroundColor = '#FFFFFF';
f.document.body.style.padding = "20px";
// Ajoute les Données
f.document.title = titre;
f.document.body.innerHTML += " " + zi + " ";
// Imprime et ferme la fenetre
f.window.print();
f.window.close();
return true;
}
/* Fin Imprimer */

/* Radio inwi divertissement */
function PopUpPlayerHit()
{
window.open("radiohit.html", "PopUpPlayerHit", "location=no, toolbar=no, status=no, scrollbars=no, resizable=no, width=595, height=314");
}

function PopUpPlayerMaroc()
{
window.open("radiomaroc.html", "PopUpPlayerMaroc", "location=no, toolbar=no, status=no, scrollbars=no, resizable=no, width=595, height=314");
}

function PopUpPlayerDance()
{
window.open("radiodance.html", "PopUpPlayerDance", "location=no, toolbar=no, status=no, scrollbars=no, resizable=no, width=595, height=314");
}

function inOutVote(id, type, e){
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3){ // defeat Safari bug
            targ = targ.parentNode;
        }
	$(targ).attr('disabled', 'disabled');
	$(targ).css('cursor','text');
	span = targ.childNodes[1];
	$(span).css('color','#ccc');
    $.ajax({
         url : $('#baseUrl').val() + '/divertissement/loisirs/voteinout',
         type : 'POST',
         data :'format=json&id='+id+'&type='+type,
         success: function(response){ callbackVote(response);}
    });
}

function callbackVote(response){
    var vote = eval('(' + response + ')');
    $('#result_' + vote.id ).html(vote.vote + '%');
}

$(document).ready(function() {
	// sa3asa3ida();
	/* dynamic replace  */
	var corpspage = $('.col_left');
	//corpspage.html(corpspage.html().replace(/ inwi/ig,'<img border="0" src="/style/style_commun/images/illimite/inwi.png" alt="inwi" style="border:0;margin-left:3px;margin-bottom: -3px" />'));
});

/*
// interstitiel BB
if (!readCookie('inwibby201103')){
  createCookie('inwibby201103','1',0.5);
  window.location = 'http://www.inwi.ma/bby.html';
} else { }
// 2M
if (!readCookie('inwi-interstitiel-studio-2m')){
  createCookie('inwi-interstitiel-studio-2m','1',0.5);
  window.location = 'http://www.inwi.ma/studio-2m.html';
  exit;
} else { }

// forfait-zenz
if (!readCookie('inwi-interstitiel-forfait-zen')){
  createCookie('inwi-interstitiel-forfait-zen','1',0.5);
  window.location = 'http://www.inwi.ma/forfait-zen.html';
} else { }

function sa3asa3ida() {
	var sa3acontroller = 'mobile';
	var sa3aaction = 'sms-illimites';
	var vidlink = '/images/sa3a.swf';
	if ($(location).attr('pathname') == "/"+sa3acontroller+"/"+sa3aaction) {
		$('div.catalogue > object').attr('data', vidlink);
    	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
 */

