// Developed by www.matijabozic.com
// Feel free to use, view and improve the code of IE6Notification
// If you improve this code, or create a new theme, contact me: mail@matijabozic.com

window.onload = function() {
	
	// Change this to custumize your IE6 notification
	var headerText = "Je browser is verouderd.";
	var notificationInfo = "Je gebruikt Internet Explorer 6 of een eerdere versie.";
	//var notificationText = "Your current browser is slow, unsecure and it doesn't render web pages correctly. You can choose from many free web browsers that are easy to install, fast, secure and that render web pages correctly for your better browsing experience. Feel free to explore them:";
	var notificationText = "Deze website is niet voor jouw browser geoptimaliseerd. TKMST.nl wordt daarom mogelijk niet goed weergegeven. Wij raden je aan om een nieuwe browser te installeren. Je kunt kiezen uit vele gratis web-browsers die gemakkelijk te installeren zijn. Hieronder een aantal van deze gratis browsers:";
	
	
	/////////////////////////////
	///// Detecting Browser /////
	/////////////////////////////
	
	var userAgent = navigator.userAgent.toLowerCase();
	var browser = "";
	if (userAgent.indexOf('msie 6.1') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 6.0') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 6.01') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 6.0b') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 5.5') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 5.0') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 4.5') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 4.01') != -1) { browser = "IE"; }
	if (userAgent.indexOf('msie 4.0') != -1) { browser = "IE"; }
	
	if ( browser == "IE" ) {

		//////////////////////////////
		///// Cookie Value Check /////
		//////////////////////////////
		
		var cookieName = "IE6Notification";
		var cookieValue = "";
		var cookieAll = document.cookie;
		var cookieArray = cookieAll.split(';');
		for ( n = 0; n < cookieArray.length; n++ ) {
			var cookie = cookieArray[n];
				if (cookie.indexOf(cookieName) != -1) {
				var cookieNameEnd = cookie.indexOf("=") + 1;
				cookieValue = cookie.substring(cookieNameEnd);
			}
		}
		
		if ( cookieValue != 'dontShow' ) {
			
			///////////////////
			///// Global  /////
			///////////////////
			
			var HTMLbody = document.getElementsByTagName('body')[0];
			var HTMLhead = document.getElementsByTagName('head')[0];
			
			///////////////////////////
			///// Adding CSS file /////
			///////////////////////////
			
			//CSS can be added dynamically, joust uncomment this and there's no need to include IE6Notification.css in header 
			
//			var css = document.createElement('link');
//			css.setAttribute('rel', 'stylesheet');
//			css.setAttribute('type', 'text/css');
//			css.setAttribute('href', 'IE6Notification/IE6Notification.css');
//			HTMLhead.appendChild(css);
			
			/////////////////////////////
			///// Building Notifier /////
			/////////////////////////////
			
			var IE6NotificationWrapper = document.createElement('div');
			IE6NotificationWrapper.setAttribute('id', 'IE6NotificationWrapper');
			HTMLbody.appendChild(IE6NotificationWrapper);
			
			var IE6NotificationHeader = document.createElement('h1');
			var IE6NotificationHeaderText = document.createTextNode(headerText);
			IE6NotificationHeader.setAttribute('id', 'IE6NotificationHeader');
			IE6NotificationHeader.appendChild(IE6NotificationHeaderText);
			IE6NotificationWrapper.appendChild(IE6NotificationHeader);
			
			var IE6NotificationInfo1 = document.createElement('p');
			var IE6NotificationInfo1Text = document.createTextNode(notificationInfo);
			IE6NotificationInfo1.setAttribute('id', 'IE6NotificationInfo1');
			IE6NotificationInfo1.appendChild(IE6NotificationInfo1Text);
			IE6NotificationWrapper.appendChild(IE6NotificationInfo1);
			
			var IE6NotificationInfo2 = document.createElement('p');
			var IE6NotificationInfo2Text = document.createTextNode(notificationText);
			IE6NotificationInfo2.setAttribute('id', 'IE6NotificationInfo2');
			IE6NotificationInfo2.appendChild(IE6NotificationInfo2Text);
			IE6NotificationWrapper.appendChild(IE6NotificationInfo2);
			
			var browserFirefox = document.createElement('a');
			browserFirefox.setAttribute('id', 'browserFirefox');
			browserFirefox.setAttribute('href', 'http://www.firefox.com');
			browserFirefox.setAttribute('target', '_blank');
			IE6NotificationWrapper.appendChild(browserFirefox);
			
			var browserChrome = document.createElement('a');
			browserChrome.setAttribute('id', 'browserChrome');
			browserChrome.setAttribute('href', 'http://www.google.nl/chrome');
			browserChrome.setAttribute('target', '_blank');
			IE6NotificationWrapper.appendChild(browserChrome);
			
			var browserSafari = document.createElement('a');
			browserSafari.setAttribute('id', 'browserSafari');
			browserSafari.setAttribute('href', 'http://www.apple.nl/safari/');
			browserSafari.setAttribute('target', '_blank');
			IE6NotificationWrapper.appendChild(browserSafari);
			
			var browserOpera = document.createElement('a');
			browserOpera.setAttribute('id', 'browserOpera');
			browserOpera.setAttribute('href', 'http://www.opera.com/');
			browserOpera.setAttribute('target', '_blank');
			IE6NotificationWrapper.appendChild(browserOpera);
			
			var browserIE = document.createElement('a');
			browserIE.setAttribute('id', 'browserIE');
			browserIE.setAttribute('href', 'http://www.microsoft.com/netherlands/windows/internet-explorer/');
			browserIE.setAttribute('target', '_blank');
			IE6NotificationWrapper.appendChild(browserIE);
		
			/////////////////////////
			///// Kill Notifier /////
			/////////////////////////
			
			var killIE6Notification = document.createElement('a');
			var killIE6NotificationText = document.createTextNode("Sluiten en niet meer weergeven");
			killIE6Notification.setAttribute('id', 'killIE6Notification');
			killIE6Notification.setAttribute('href', 'javascript:killIE6Notification()');
			killIE6Notification.appendChild(killIE6NotificationText);
			IE6NotificationWrapper.appendChild(killIE6Notification);
			
			//killIE6Notification.onclick = function() {

				///////////////////////////
				///// Setting Cookie //////
				///////////////////////////
				
			//	var date = new Date();
			//	var milisecunds = date.getTime();
			//	var future = milisecunds + (1000 * 60 * 60 * 24 * 30);
			//	exp = new Date(future);
			//	exp = exp.toGMTString();
			//	document.cookie = "IE6Notification=dontShow; expires=" + exp;
				
			//	HTMLbody.removeChild(IE6NotificationWrapper);
			//	return false;
			
			//};
			
			//////////////////////////
			///// Close Notifier /////
			//////////////////////////
			
			var closeIE6Notification = document.createElement('a');
			var closeIE6NotificationText = document.createTextNode('Sluiten');
			closeIE6Notification.setAttribute('id', 'closeIE6Notification');
			closeIE6Notification.setAttribute('href', "javascript:closeIe6Notification()");
			closeIE6Notification.appendChild(closeIE6NotificationText);
			IE6NotificationWrapper.appendChild(closeIE6Notification);
			
			//closeIE6Notification.onclick = function() {
			//	HTMLbody.removeChild(IE6NotificationWrapper);
			//	return false;
			//};
			
		}
	}
};

function closeIe6Notification() {
	document.getElementsByTagName('body')[0].removeChild(document.getElementById('IE6NotificationWrapper'));
}

function killIE6Notification() {
	var date = new Date();
	var milisecunds = date.getTime();
	var future = milisecunds + (1000 * 60 * 60 * 24 * 30);
	exp = new Date(future);
	exp = exp.toGMTString();
	document.cookie = "IE6Notification=dontShow; expires=" + exp;
				
	document.getElementsByTagName('body')[0].removeChild(document.getElementById('IE6NotificationWrapper'));
	
}