// Necessary try...catch for IE that trips on console.log()
try { console.log('init console... done'); } catch(e) { console = { log: function() {} } };
// this is to shorten the use of the logging : log('my stuff')
var log = function(message) { console.log(message) }

function ff2() {
  return navigator.userAgent.indexOf("Firefox/2") != -1;
}

/* ===========================>> PerPageScripts <<=========================== */
    
    /* =menu ================================ */
        Event.observe(window, "load", function() {
          $$('.menu ul ul').each(function(submenu) {
            var menuLink = submenu.parentNode.getElementsByTagName('A')[0];
            var isCurrentMenu = Element.hasClassName(menuLink, 'current');
            Event.observe(submenu.parentNode, 'mouseover', function(event) {
              Element.show(submenu);
              if (!isCurrentMenu) {
                Element.addClassName(menuLink, 'current');
              }
            });
            Event.observe(submenu.parentNode, 'mouseout', function(event) {
              Element.hide(submenu);
              if (!isCurrentMenu) {
                Element.removeClassName(menuLink, 'current');
              }
            });
          });
          
          if($("animation-tur")) {
            var so = new SWFObject("/flashs/animation-tur.swf", "animation-tur", "736", "231", "7");
            so.addParam("wmode", "transparent");
            so.write("animation-tur");
          }
          
          $$('.way').each(function(el) { Event.observe(el, "click", function(e) { 
            Event.stop(e); alert("Recherche d’itinéraire en cours d’amélioration et disponible prochainement") }) });
        });
        

/* ===========================>> PerPageScripts <<=========================== */
    
    /* =home ================================ */
        // pageInit("trip_plans/new", function() {
        //     TripPlansNew.init();
        // });




/* ===========================>> Library <<=========================== */

    /* =loadScript ================================ */
        function loadScript(url) {
          var s = document.createElement('script');
          s.type = 'text/javascript';
          s.src = url;
          document.getElementsByTagName('head')[0].appendChild(s);
        }


    /* =pageInit ================================ */
        function pageInit (urlRegExp, funct) {
            page_url_reg_exp = new RegExp(urlRegExp);
            if(window.location.toString().match(page_url_reg_exp)){
                Event.observe(window, 'load', function() { funct.call() });
            }
        }
