var Config = new function()
{

  this.init = function(page_options)
  {

    // initialisation du scope
    jQuery.maplage = jQuery.maplage || {};
      
    // configuration
    jQuery.maplage.defaults =
    {
      // urls http des requêtes Ajax
      urls:
      {
        lieuSetPosition:    "lieu/setPosition",
        visioSetPosition:   "visio/setPosition",
        ajaxLogin:          "main/ajaxLogin",
		eventCalendar:		"event/calendar",
		eventAgenda:		"event/agenda",
        communesForSelect:  "commune/communesForSelect",
        home:               ""
      },
      modal:                false,        // popup affichant un message au chargement de la page
      i18n:
      {
      },
      image_dir:            "images/",
      images_to_preload:                  // images qui seront préchargées
      [
      ],
      tooltip:
      {
        track:              true,
        delay:              0,
        showURL:            false,
        showBody:           " | ",
        fixPNG:             false
      },
      widget:
      {
        delay:              500
      },
      seo_user:             false
    };
    jQuery.maplage.defaults = jQuery.extend(jQuery.maplage.defaults, page_options);
    
    if (page_options.gmap_active)
    {
			var icon_dir = jQuery.maplage.defaults.relative_url_root+jQuery.maplage.defaults.image_dir+"gmap/";
			
      // Icônes Gmap
      var baseIcon = new GIcon();
      //baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
      baseIcon.iconSize = new GSize(32, 32);
      baseIcon.shadowSize = new GSize(0, 0);
      baseIcon.iconAnchor = new GPoint(9, 34);
      baseIcon.infoWindowAnchor = new GPoint(9, 2);
      baseIcon.infoShadowAnchor = new GPoint(18, 25);
      
      var communeIcon = new GIcon(baseIcon);
      
      var plageIcon = new GIcon(baseIcon);
      plageIcon.image = icon_dir+"ico-plage.png";
      //plageIcon.shadow = icon_dir+"ico-plage-ombre.png";
      plageIcon.iconSize = new GSize(28, 29);
      //plageIcon.shadowSize = new GSize(57, 45);
      
      var portIcon = new GIcon(baseIcon);
      portIcon.image = icon_dir+"ico-port.png";
      //portIcon.shadow = icon_dir+"ico-port-ombre.png";
      portIcon.iconSize = new GSize(28, 29);
      //portIcon.shadowSize = new GSize(57, 45);
      
      var panoramaIcon = new GIcon(baseIcon);
      panoramaIcon.image = icon_dir+"ico-panorama.png";
      //panoramaIcon.shadow = icon_dir+"ico-panorama-ombre.png";
      panoramaIcon.iconSize = new GSize(28, 29);
      //panoramaIcon.shadowSize = new GSize(57, 45);
      
      var lieuIcon = new GIcon(baseIcon);
      lieuIcon.image = icon_dir+"ico-puce.png";
      //lieuIcon.shadow = icon_dir+"gmap/ico-panorama.png";
      lieuIcon.iconSize = new GSize(28, 29);
      
      var communeIcon = new GIcon(baseIcon);
      communeIcon.image = icon_dir+"ico-communes.png";
      //lieuIcon.shadow = icon_dir+"gmap/ico-panorama.png";
      communeIcon.iconSize = new GSize(20, 24);
      
      var visioIcon = new GIcon(baseIcon);
      visioIcon.image = icon_dir+"ico-puce.png";
      //lieuIcon.shadow = icon_dir+"gmap/ico-panorama.png";
      visioIcon.iconSize = new GSize(28, 29);
      
      jQuery.maplage.defaults.gmap =
      {
        rayon:                    40,
        zoom:                     8,
        url:                      false,
        mapType:                  "hybrid",
        mapDimensions:            [400, 400],
        language:                 "fr",
        // Options: "large", "small", "none"
        mapControlSize:           "large",
        // Zoom"
        mapZoom:                  12,
        // Initialise type of map control
        mapShowType:              true,
        // Initialise small map overview
        mapShowOverview:          false,
        // Enable map dragging when left button held down
        mapEnableDragging:        true,
        // Enable map info windows
        mapEnableInfoWindows:     true,
        // Enable double click zooming
        mapEnableDoubleClickZoom: false,
        // Enable zooming with scroll wheel
        mapEnableScrollZoom:      false,
        // Enable smooth zoom
        mapEnableSmoothZoom:      true,
        // Enable Google Bar
        mapEnableGoogleBar:       false,
        marker_opacity:           70,
        marker_tooltip_class:     "marker_tooltip",
        icons:
        {
          commune:             communeIcon,
          lieu:                lieuIcon,
          plage:               plageIcon,
          port:                portIcon,
          panorama:            panoramaIcon,
          visio:               visioIcon
        }
      }
    }
    
    // configuration de jQuery
    jQuery.ajaxSetup({
      global:     false,
      timeout:    9000,
      type:       "POST"
    });
    
    // validation des formulaires
    if (jQuery.validator)
    jQuery.validator.messages = 
    {
        required:   "Cette information est nécessaire.",
        email:      "Merci d'entrer une adresse mail valide.",
        url:        "Merci d'entrer une url valide.",
        number:     "Merci d'entrer un nombre valide."
    };
          
    //initialisation de thickbox
//    if (jQuery.thickbox)
//    jQuery.thickbox.defaults({
//      i18n: {
//        close: { text: 'Fermer', title: 'Fermer cette fenêtre' },
//        count: { text: 'Image #{image} / #{count}' },
//        next: { text: 'Suivant', title: 'Voir l\'image suivante' },
//        prev: { text: 'Précédent', title: 'Voir l\'image précédente' }
//      }
//    });
  }
}

// configuration des cluetips
if (jQuery.fn.cluetip)
jQuery.fn.cluetip.defaults = jQuery.extend(jQuery.fn.cluetip.defaults,
{
  attribute:      'href',
  fx: {             
    open:         'show', // can be 'show' or 'slideDown' or 'fadeIn'
    openSpeed:    0
  }, 
  local:          true,
  cluetipClass:   'jtip',
  arrows:         true,
  width:          400
});

// configuration du tiny
if (false && typeof(tinyMCE) != "undefined")
  tinyMCE.init({
    mode : "textareas",
    theme : "advanced",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    plugins : "filemanager,imagemanager",
    content_css : "css/content.css"
  });