/*--------------------------------------------------
Loads insanely simple error message if using IE6.
Based on "end6": http://www.end6.org/

created: 26-03-2010
author: Freddy Kelly ~ GlobalGraphics Associates Ltd.
email: webmaster@globalgraphics.co.uk
website: http://www.globalgraphics.co.uk/
--------------------------------------------------*/

function ieVersion() {

  var rv = -1;
  if (navigator.appName == 'Microsoft Internet Explorer') {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;

}

var version = ieVersion();

if ((navigator.appName=="Microsoft Internet Explorer") && (version < 7) && readCookie('ie6_error') != '1') {
	
	makeWindow(); 
	
}

function closeLayer() {
	
	document.getElementById('ie6_error').style.display="none";
	createCookie('ie6_error',1,14400);
	
}


function createCookie(name,value,minutes) {
	
	var minutes = minutes;
	if (minutes) {
		var date = new Date();
		date.setTime(date.getTime()+(minutes*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
	
}


function readCookie(the_name) {
	
	var nameEQ = the_name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
	
}

function makeWindow() {
	
	var html = '';
	
	html = '<style type="text/css">';
	html += '#ie6_error { background: #ffe0e0; color: #000; border-bottom: 1px solid #ff9393; padding: 20px; margin-bottom: 5%; height: 140px; font: 12px/150% Verdana, Arial, Helvetica, sans-serif; overflow: hidden; }';
	html += '#ie6_error * { margin: 0; padding: 0; }';
	html += '#ie6_error a, #ie6_error a:hover, #ie6_error a:active, #ie6_error a:visited { background: none; color: #000; text-decoration: none; border-bottom: 1px dotted #000; outline: 0 none; }';
	html += '#ie6_error h6 { font-size: 12px; font-weight: bold; margin-bottom: 5px; color: #000; }';
	html += '#ie6_error div { width: 960px; margin: 0 auto; text-align: left; position: relative; }';
	html += '#ie6_error p { margin-bottom: 20px; }';
	html += '#ie6_error p#ie6_info { font-size: 0.9em; margin: 0; position: absolute; bottom: 0; right: 0; }';
	html += '#ie6_error a#ie6_close { position: absolute; top: 0; right: 0; width: 20px; height: 20px; background: url(http://www.globalgraphics.co.uk/ie6/img/close.gif); text-indent: -99999px; border: 0 none !important; }';
	html += '#ie6_error ul { height: 80px; list-style: none; }';
	html += '#ie6_error ul li, #ie6_error ul li a { float: left; }';
	html += '#ie6_error ul li { margin-right: 20px; }';
	html += '#ie6_error ul li a { width: 75px; height: 75px; display: block; text-indent: -99999px; border: 0 none !important; }';
	html += '#ie6_error ul li a:hover { margin-top: 5px; }';
	html += '#ie6_error ul li#ie6_icon_ff a { background: url(http://www.globalgraphics.co.uk/ie6/img/firefox.gif); }';
	html += '#ie6_error ul li#ie6_icon_ie a { background: url(http://www.globalgraphics.co.uk/ie6/img/ie.gif); }';
	html += '#ie6_error ul li#ie6_icon_safari a { background: url(http://www.globalgraphics.co.uk/ie6/img/safari.gif); }';
	html += '#ie6_error ul li#ie6_icon_chrome a { background: url(http://www.globalgraphics.co.uk/ie6/img/chrome.gif); }';
	html += '#ie6_error ul li#ie6_icon_opera a { background: url(http://www.globalgraphics.co.uk/ie6/img/opera.gif); }';
	html += '</style>';
	html += '<div id="ie6_error">';
	html += '<div>';
	html += '<h6>You are using an outdated browser!</h6>';
	html += '<p>For a better experience using this site, please upgrade to a modern web browser.</p>';
	html += '<ul>';
	html += '<li id="ie6_icon_ff"><a href="http://www.firefox.com/">Firefox</a></li>';
	html += '<li id="ie6_icon_ie"><a href="http://www.browserforthebetter.com/download.html">Internet Explorer</a></li>';
	html += '<li id="ie6_icon_safari"><a href="http://www.apple.com/safari/download/">Safari</a></li>';
	html += '<li id="ie6_icon_chrome"><a href="http://www.google.com/chrome/">Google Chrome</a></li>';
	html += '<li id="ie6_icon_opera"><a href="http://www.opera.com/browser/">Opera</a></li>';
	html += '</ul>';
	html += '<p id="ie6_info">Browser icons by <a href="http://morcha.blogbus.com/logs/30886671.html">Morcha</a></p>';
	html += '<a href="#" onclick="closeLayer();return false;" id="ie6_close">Close</a>';
	html += '</div>';
	html += '</div>';
	
	// write to document
	document.write(html);

}
