// 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://go.microsoft.com/?linkid=9634188";
	var needUpgrade = /(MSIE 6|MSIE 5.(\d+))/i.test(navigator.userAgent); // is IE6??
	var overlayColor  = "#DDDDDD";  // Change these to fit your color scheme.
	var lightboxColor = "#ffffff";  // " "
	var borderColor   = "#6699ff";  // " "
  // 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 + "; " +
    "background-image: url(/malaysia/misc/detectie6/gray.gif); background-repeat: repeat-x; background-position: top left;";
    //"z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80);";
  var lightboxCSS = 
    "display: block; position: absolute; top: 25%; left: 25%; width: 720px; " +
    "height: 200px; " +
    "z-index:1002; overflow: auto;";
  var lightboxContents =
    "<div style='width /**/: 690px; width: 720px !important; height: 200px; padding: 15px; background-image: url(/malaysia/detectie6/background.gif); background-repeat: none; font-family:Arial, Helvetica, sans-serif; font-size:11px;'>" +
"<a href='#' onclick='sevenUp.quitBuggingMe();'>" +
"<img src='/malaysia/detectie6/close.gif' alt='Close this message' border='0' align='right' width='139' height='22' /></a>" +
"<div style='margin: 10px 15px 15px 280px; width: 400px;'>" +
"<h1 style='font-family:Arial, Helvetica, sans-serif; font-size:16px; font-weight: bold; color:#0033CC; padding-top: 9px;'>" +
"Upgrading Your Browser</h1>" +
"<em>You appear to be using an old version of Internet Explorer.</em><br /><br />" +
"We recommend upgrading to <strong>Internet Explorer 8</strong>" +
" for optimal viewing of this site, and to gain the latest functionality and security benefits.<br /><br />" +
"<a href='http://go.microsoft.com/?linkid=9634188' target='_blank' onclick='sevenUp.quitBuggingMe();'>" +
"<img src='/malaysia/detectie6/download.gif' alt='Download Internet Explorer 8' border='0' /></a>" +
"</div></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';
      }
    }
  };
}();

