// Thanks for doing your part to liber(IE)t the world from IE6!
// Original copy written by Jonathan Howard (jon@StaringIsPolite.com)
//
// GNU LGPL License v3
// SevenUp is released into the wild under a GNU LGPL v3
//
// Browser sniffing technique lovingly adapted from http://www.thefutureoftheweb.com/
// Simple CSS Lightbox technique adapted equally lovingly from http://www.emanueleferonato.com/
// Go read their blogs :)

// Constructor technique advocated by Doug Crockford (of LSlint, JSON) in his recent Google tech talk.
	var sevenUp = function () {
// Define private vars here.
	var downloadLink = "http://www.google.fr/toolbar/ie7/";
	var needUpgrade = /(MSIE 6|MSIE 5.(\d+))/i.test(navigator.userAgent); // is IE6??
	var overlayColor  = "#d40000";  // Change these to fit your color scheme.
	var lightboxColor = "#ffffff";  // " "
	var borderColor   = "#ffa800";  // " "
// Hate to define CSS this way, but trying to keep to one file.
// I'll keep it as pretty as possible.
  var overlayCSS =
    "display:block; position: absolute; top:0%; left:0%;" +
    "width:100%; height:100%; background-color: " + overlayColor + "; " +
    "z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80);";
  var lightboxCSS = 
    "display:block; position:absolute;top:25%; left:25%; width:50%; " +
    "height:320px; padding: 16px; border: 8px solid " + borderColor + "; " +
    "background-color:" + lightboxColor + "; " +
    "z-index:1002; overflow: auto;";
  var lightboxContents =
    "<div style='width:100%; height:95%'>" +
      "<h1 style='text-align:center;'>Votre navigateur est OBSOL&#200;TE et <br>ne prend pas en charge avec les standards actuels</h1>" +
      "<div style='text-align:center;'>" +
      "Vous pouvez facilement mettre &agrave; niveau vers la derni&egrave;re version en cliquant " +
      "<a style='color:#0000EE' href='" + downloadLink + "'><b>ICI</b></a><br>" +
	  "Ou, ex&eacute;cuter une mise &agrave; jour de votre syst&egrave;me pour installer la version actuelle d'Internet Explorer" +
      "</div>" +
      "<h3 style='margin-top:40px'>Pourquoi devrais-je mettre &agrave; jour mon navigateur ?</h3>" +
	  
      "<ul><li><b>&#149; Acc&eacute;l&eacute;rer le chargement des sites Web</b>, souvent le double de la vitesse de cette version...</li>" +
      "<li><b>&#149; Am&eacute;lioration de l'apparence</b> avec plus de respect pour les standards du Web...</li>" +
      "<li><b>&#149; Prot&eacute;ger votre navigation</b> avec protection contre le phishing...</li>" +
	  "<li><b>&#149; Plus de s&eacute;curit&eacute;</b> avec protection contre les virus, les logiciels espions et publicit&eacute;s...</li>" +
	  "<li><b>&#149; Protection de la vie priv&eacute;e</b> d&acute;un simple clic, &eacute;radiquer toutes les donn&eacute;es personnelles, de l'historique...</li>" +
	  "<li><b>&#149; Et bien plus encore...</b></li>" +
	  
      "</ul>" +
    "</div>" +
    "<div style='font-size:11px; text-align:right;'>" +
      "<a href='#' onclick='sevenUp.quitBuggingMe();'" +
          "style='color: #0000EE'>" +
        "FERMER CET AVERTISSEMENT SANS CORRIGER MON NAVIGATEUR !?" +
      "</a>" +
    "</div>";
  function isCookieSet() {
    if (document.cookie.length > 0) {
      var i = document.cookie.indexOf("sevenup=");
      return (i != -1);
    }
    return false;
  }
  
  return {  // Return object literal and public methods here.
  	test: function(allowSkip) {
  	  if (needUpgrade && !isCookieSet()) {
  	    // Write layer into the document.
  	    var layerHTML =
  	      "<div id='sevenUpOverlay' style='" + overlayCSS + "'>" +
  	        "<div style='" + lightboxCSS + "'>" +
              lightboxContents +
            "</div>" +
  		    "</div>";
        var layer = document.createElement('div');
        layer.innerHTML = layerHTML;
  	    document.body.appendChild(layer);
  	  }  
  	},
    setLightboxContents: function(newContents) {
      lightboxContents = newContents;
    },
    quitBuggingMe: function() {
      var exp = new Date();
      exp.setTime(exp.getTime()+(7*24*3600000));
      document.cookie = "sevenup=dontbugme; expires="+exp.toUTCString();
      this.close();
    },
    close: function() {
      var overlay = document.getElementById('sevenUpOverlay');
      if (overlay !== undefined) {
        overlay.style.display = 'none';
      }
    }
  };
}();

