$(document).ready(function(){
    
    $("#diapo-fr").flash({
                swf: '/fileadmin/templates/flash/logos_'+ lang +'.swf',
                width: 189,
                height: 88
    });
        
    $.ajax({
        url: "/fileadmin/php/json.php",
        data: "special=json-cal",
        dataType: "json",
        success: function(calendarEvents){
        
           $("#calendar").datepicker({
               /*"dateFormat":'dd-mm-yy',*/
               numberOfMonths: [1, 1],               
               beforeShowDay: function (date){
                   for (i = 0; i < calendarEvents.length; i++) {
                       if (date.getMonth() == calendarEvents[i][0] - 1 
                       && date.getDate() == calendarEvents[i][1]
                       && date.getFullYear() == calendarEvents[i][2]) {
                           return [true,"date-hightlight",""]; 
                       }
                   }
                   return [true, ""];
               },
               onSelect: function(dateText, inst) {                   
                   document.location.href="/"+ lang +"/agenda/?date="+ dateText;
               }
           });
        }
    });
    
    
    /* fuckiiinng lang choice !*/
   
    function getQueryParams(qs) {
        qs = qs.split("+").join(" ");
        var params = {},
            tokens,
            re = /[?&]?([^=]+)=([^&]*)/g;

        while (tokens = re.exec(qs)) {
            params[decodeURIComponent(tokens[1])]
                = decodeURIComponent(tokens[2]);
        }

        return params;
    }
    
   //console.log('artiste:'+ $_GET["artiste"] +' concert :'+ $_GET["concert"]);
   
   
   $("#languages a").each(function(){        
        var $_GET = getQueryParams(document.location.search);        
        var href = $(this).attr("href");
        
        if($_GET["concert"]){
            var href = href+'?concert='+ $_GET["concert"];
            $(this).attr("href",href);
        }
        
        if($_GET["artiste"]){
            var href = href+'?artiste='+ $_GET["artiste"];
            $(this).attr("href",href);
        }
        
        
   });
   
   $("#footer")
   .html('<img src="/images/bottom_logo.png" usemap="#bottomLogo" /><map name="bottomLogo" id="bottomLogo"><area shape="rect" coords="1,58,31,98" href="http://www.stib.be" target="_blank" alt="stib mivb" /><area shape="rect" coords="74,66,131,93" href="http://www.arte-belgique.be/" target="_blank" alt="ARTE" /><area shape="rect" coords="168,62,209,93" href="http://radio.klara.be" target="_blank" alt="Klara" /><area shape="rect" coords="216,11,262,47" href="http://www.belgium.be" target="_blank" alt=".be" /><area shape="rect" coords="304,16,412,44" href="http://www.loterie-nationale.be" target="_blank" alt="Loterie Nationale" /><area shape="rect" coords="459,13,549,56" href="http://audi.be" target="_blank" alt="Audi" /><area shape="rect" coords="583,20,687,47" href="http://www.ethias.be/" target="_blank" alt="Ethias" /><area shape="rect" coords="252,63,325,93" href="http://www.levif.be" target="_blank" alt="Le Vif" /><area shape="rect" coords="359,66,424,89" href="http://www.knack.be" target="_blank" alt="Knack" /><area shape="rect" coords="458,67,539,95" href="http://www.lalibre.be/" target="_blank" alt="La Libre" /><area shape="rect" coords="572,72,675,88" href="http://www.canvas.be" target="_blank" alt="Canvas" /><area shape="rect" coords="714,64,791,92" href="http://www.demorgen.be/" target="_blank" alt="DeMorgen" /><area shape="rect" coords="839,62,901,95" href="http://www.rtbf.be/musiq3/" target="_blank" alt="MusiQ3" /></map>')
   .css({
       "padding-top":"60px",
       "clear":"both"
   });
    
});
