function addToFavorites(link, title){
  browserName = navigator.appName;
  if (browserName == "Microsoft Internet Explorer")
    window.external.AddFavorite(link, title);
  else if (browserName == 'Netscape')
    window.sidebar.addPanel(title, link, "");
  else if (browserName == 'Opera')
   alert('Vous utilisez Opéra. Pour ajouter ce lien à vos favoris, faites la combinaison de touches [CLTR] + D');
  else 
    alert('Pour ajouter ce lien à vos favoris, faites la combinaison de touches [CMD] + D');
}

var BrowserDetect = {
  init: function () {
    this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
    this.version = this.searchVersion(navigator.userAgent)
      || this.searchVersion(navigator.appVersion)
      || "an unknown version";
    this.OS = this.searchString(this.dataOS) || "an unknown OS";
  },
  searchString: function (data) {
    for (var i=0;i<data.length;i++) {
      var dataString = data[i].string;
      var dataProp = data[i].prop;
      this.versionSearchString = data[i].versionSearch || data[i].identity;
      if (dataString) {
        if (dataString.indexOf(data[i].subString) != -1)
          return data[i].identity;
      }
      else if (dataProp)
        return data[i].identity;
    }
  },
  searchVersion: function (dataString) {
    var index = dataString.indexOf(this.versionSearchString);
    if (index == -1) return;
    return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
  },
  dataBrowser: [
    {
      string: navigator.vendor,
      subString: "Apple",
      identity: "Safari"
    },
    {
      prop: window.opera,
      identity: "Opera"
    },
    {
      string: navigator.vendor,
      subString: "iCab",
      identity: "iCab"
    },
    {
      string: navigator.vendor,
      subString: "KDE",
      identity: "Konqueror"
    },
    {
      string: navigator.userAgent,
      subString: "Firefox",
      identity: "Firefox"
    },
    {   // for newer Netscapes (6+)
      string: navigator.userAgent,
      subString: "Netscape",
      identity: "Netscape"
    },
    {
      string: navigator.userAgent,
      subString: "MSIE",
      identity: "Explorer",
      versionSearch: "MSIE"
    },
    {
      string: navigator.userAgent,
      subString: "Gecko",
      identity: "Mozilla",
      versionSearch: "rv"
    },
    {     // for older Netscapes (4-)
      string: navigator.userAgent,
      subString: "Mozilla",
      identity: "Netscape",
      versionSearch: "Mozilla"
    }
  ],
  dataOS : [
    {
      string: navigator.platform,
      subString: "Win",
      identity: "Windows"
    },
    {
      string: navigator.platform,
      subString: "Mac",
      identity: "Mac"
    },
    {
      string: navigator.platform,
      subString: "Linux",
      identity: "Linux"
    }
  ]

};
BrowserDetect.init();

function addToHomepage(obj, link) {
  switch(BrowserDetect.browser) {
    case "Firefox":
      alert ('Utilisateur de Firefox, glissez l\'îcone à gauche de l\'adresse url dans la petite maison de démarrage' );
      break;

    case "Opera":
      alert ('Utilisateur d\'Opéra, tapez [CLTR] F12 puis tapez l\'adresse                ' + link + ' dans le champs prévu à cet effet' );
      break;
    
    case "Safari":
      alert ('Utilisateur de Safari, glissez l\'îcone à gauche de l\'adresse url dans la petite maison de démarrage' );
      break;
      
    default:
       obj.style.behavior="url(#default#homepage)";
       obj.setHomePage(link);
       break;
  }
}



function getPageSize(){
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function openPopup(url, title, w, h) {
	var ns4 = (document.layers)? true:false;
	var ie4 = (document.all)? true:false;
	var dom = (document.getElementById) ? true:false;
	var xMax, yMax, xOffset, yOffset;  
	if (ie4 || dom) {
		xMax = screen.width;
		yMax = screen.height;
  } else if (ns4) {
		xMax = window.outerWidth;
		yMax = window.outerHeight;
	} else {
		xMax = 1024;
		yMax = 768;
	}
	xOffset = (xMax - w) / 2;
	yOffset = (yMax - h) / 2;
	window.open(url, title,'width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=no,resizable=no');
}

function getPageScroll(){
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	//arrayPageScroll = new Array('',yScroll) 
	//return arrayPageScroll;
	return yScroll;
}