/**************************************
*  GUI functions tool kit (non obscruptive js)

*  required jQuery
*      
* author:  erational(http://www.erational.org)
* version: 0.1
* date:    2008.09.25 (alexandra minus one)
* licence: GPL 2.0    
***********************************/


$(document).ready(function(){
   
    // Font resizer
    // doc: http://www.shopdev.co.uk/blog/text-resizing-with-jquery/

    // Increase Font Size
    $(".increaseFont").click(function(){
      var currentFontSize = $('html').css('font-size');
      var currentFontSizeNum = parseFloat(currentFontSize, 10);
      var newFontSize = currentFontSizeNum*1.2;
      $('html').css('font-size', newFontSize);
      return false;
    });
    // Decrease Font Size
    $(".decreaseFont").click(function(){
      var currentFontSize = $('html').css('font-size');
      var currentFontSizeNum = parseFloat(currentFontSize, 10);
      var newFontSize = currentFontSizeNum*0.8;
      $('html').css('font-size', newFontSize);
      return false;
    });

    // #Font resizer
    
    // Printer
    $(".printer").click(function(){
        window.print();
        return false;
    });
    // #Printer
    
    // indiquer le nombre d'offre   
    if ($('.menulrub_28')) {
         var nb_mp = $('#count-mp').html(); 
         nb_mp =  jQuery.trim(nb_mp);        
         $('.menulrub_28').append("&nbsp;("+nb_mp+")");
    }
    if ($('.menulrub_36')) {
         var nb_mp = $('#count-drh').html(); 
         nb_mp =  jQuery.trim(nb_mp);        
         $('.menulrub_36').append("&nbsp;("+nb_mp+")");
    }   
    
    //
    
    // map    
    var zone_sticky = 0; 
    
    $('#map_ard area').bind("mouseover",function(e){  // mouseover: affichage zone
        var id_zone = $(this).attr("id");
        if (id_zone) {
          id_zone = ".carte_"+id_zone.substr(1); 
          if (zone_sticky ==0) {         
            $(".carte_ard").hide();
            $('.map_close').hide();
            $(id_zone).show();
          }          
        }
    
    });
    
    $('#map_ard area').bind("click",function(e){  // click: blockage
       
        if (zone_sticky == 0) {
          var id_zone = $(this).attr("id");
          if (id_zone) {
            id_zone = ".carte_"+id_zone.substr(1); 
            zone_sticky  = id_zone;  
            $('.map_close').show();             
          } 
        } else {
          zone_sticky = 0;
        }
  
    });
    
    // bouton fermer
    $('.map_close').click(function(){ 
          zone_sticky = 0;
          $(".carte_ard").hide();
    });
    
    // #map

    
        
});

