

// Liens externes --------------------------------------------------------------

function openSite(strLocationURL) {
  var siteWindow = null;
  siteWindow = window.open(strLocationURL);
}

function checkExternalLinks() {
  var objLinks = document.getElementsByTagName("a");
  for (i=0; i < objLinks.length; i++) {
    if (objLinks[i].href.length > 0) {
      if (objLinks[i].href.indexOf(document.domain) == -1 && objLinks[i].href.indexOf("javascript:") == -1 && objLinks[i].href.indexOf("mailto:") == -1) {
      objLinks[i].href = "javascript: openSite('" + objLinks[i].href + "');";
      }
    }
  }
}

try {
  window.addEventListener("load", checkExternalLinks, true);
}
catch(ex) {
  window.attachEvent("onload", checkExternalLinks);
}


// Afficher/Masquer (transparence) ---------------------------------------------

function Afficher() {
	var Obj;
  Obj = document.getElementById('transparence');
  if( Obj){
  
  	var yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			yScroll = document.body.scrollHeight;
		} else { 
			yScroll = document.body.offsetHeight;
		}

		var windowHeight;
		if (self.innerHeight) {	
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowHeight = document.body.clientHeight;
		}
    
    Obj.style.height = ((yScroll < windowHeight) ? windowHeight : yScroll)  + 'px';  
    
    with( Obj.style){
      display="block";
			var selects = document.getElementsByTagName('select');
  		for(var i = 0; i < selects.length; i++) {
  			selects[i].style.visibility = 'hidden';
  		}
    }
  }
}

function Masquer() {
	var Obj;
  Obj = document.getElementById('transparence');
  if( Obj){
    with( Obj.style){
      display="none";
			var selects = document.getElementsByTagName('select');
  		for(var i = 0; i < selects.length; i++) {
  			selects[i].style.visibility = 'visible';
  		}
    }
  }
}

// Connexion -------------------------------------------------------------------

/*
function addClass(element, className) {
  if (!hasClass(element, className)) {
    if (element.className) element.className += " " + className;
    else element.className = className;
  }
};

function removeClass(element, className) {
  var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
  element.className = element.className.replace(regexp, "$2");
};

function hasClass(element, className) {
  var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
  return regexp.test(element.className);
};

function AfficherConnexion(id) {
  connexion = document.getElementById('extranet');
  if(hasClass(connexion, "active")) {
    removeClass(connexion, "active");
    removeClass(connexion.parentNode, "active");
  } else {
    addClass(connexion, "active");
    addClass(connexion.parentNode, "active");
  }
}
*/


// Menu déroulant --------------------------------------------------------------

jQuery().ready(function() {
	jQuery('#leftmenu').accordion({
		active: false,
		header: 'h3',
		navigation: true,
		animated: 'slide',
		alwaysOpen: false,
		autoheight: false
	});
});

function initMenu() {
  //jQuery('#leftmenu .conteneur ul').show();
  jQuery("#leftmenu #selected").addClass("selected");
  jQuery("#leftmenu #selected h3").addClass("selected");
  jQuery('#leftmenu .conteneur').click(
    function() {
      jQuery("#leftmenu #selected h3").removeClass();
    }
  );
}
$(document).ready(function() {initMenu();});

// API GoogleMAP ---------------------------------------------------------------

window.onload = function() {
  if (window.onLoad) {
    onLoad();
    var base = new GIcon();
    base.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
    base.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
    base.iconSize = new GSize(12, 20);
    base.shadowSize = new GSize(22, 20);
    base.iconAnchor = new GPoint(6, 20);
    base.infoWindowAnchor = new GPoint(5, 1);
    var bleu = new GIcon(base);
 }
}