var ie6d = new Object();

ie6d.currentOnload = window.onload;
ie6d.imgPath = 'http://imperiumojca.pl/res/img/ie6destoyer/';

ie6d.showInfo = function() {
	var inf = document.createElement('div');
	var bg = document.createElement('div');
	
	var html = document.getElementsByTagName('html')[0];
	html.style.overflow='hidden';
	html.scrollTop=0;
	
	var body = document.getElementsByTagName('body')[0];
	
	bg.id='ie6InfoBg';
	bg.style.position='absolute';
	bg.style.top=0;
	bg.style.left=0;
	bg.style.width='100%';
	bg.style.height=html.offsetHeight;
	bg.style.background='#000';
	bg.style.zIndex='9999';
	bg.style.opacity=0.5;
	bg.style.filter='alpha(opacity=50)';
	
	body.appendChild(bg);
	
	inf.id = 'ie6Info';
	inf.style.position='absolute';
	inf.style.top='50%';
	inf.style.left='50%';
	inf.style.width='620px';
	inf.style.height='434px';
	inf.style.marginTop='-230px';
	inf.style.marginLeft='-330px';
	inf.style.background='url('+this.imgPath+'bg.gif) no-repeat';
	inf.style.zIndex='10000';
	inf.style.filter='shadow(color:black, strength:10, direction:135)';
	inf.style.textAlign='center';
	inf.style.padding='15px';
	inf.style.fontSize='11px';
	
	body.appendChild(inf);
	
	var info = '<div style="width: 308px; height: 210px; margin: 25px 14px 0 0; float: right; text-align: left; display: inline;"><h2 style="color: #d90303; font-family: Times New Roman; font-size: 39px; padding: 0; font-weight: bold !important; margin-bottom: 6px;">Żegnamy IE 6!</h2>';
	info += '<p style="margin:0; padding: 0; font-family: Arial; font-size: 12px; color: #747474; line-height: 18px">Twoja przeglądarka - IE 6 - jest już bardzo stara i nie odpowiada współczesnym technologiom.<br />Korzystanie z niej jest niebezpieczne, a także niewygodne, gdyż IE 6 nie potrafi poprawnie wyświetlić niektórych elementów stron.</p><p style="margin:11px 0 0 0; padding: 0; font-family: Arial; font-size: 12px; color: #747474; line-height: 18px; font-weight: bold;">Aby w pełni korzystać z naszego serwisu, zmień przeglądarkę.</p></div><div style="clear: both; height: 1px; overflow: hidden;"></div>';
	info += '<h3 style="color: #cb0000; font-family: Times New Roman; font-size: 15px; padding: 0; font-weight: bold !important; margin: 9px 0;">Samodzielnie zaktualizuj swoją przeglądarkę albo pobierz jedną z poniższych:</h3>';

	info += '<table cellpadding="0" cellspacing="0" align="center" style="margin: 20px 0 10px 0; width: 530px;"><tr>';
	
	var browser = new Array();
	browser[0]='<a href="http://www.mozilla-europe.org/pl/firefox/" style="font-family: Arial; font-size: 11px;color: #747474; font-weight: normal;"><img src="'+this.imgPath+'browsers/firefox.jpg" /><span style="display: block; clear: both;margin-top: 3px;">Firefox 3.6</span></a>';
	browser[1]='<a href="http://www.apple.com/pl/safari/" style="font-family: Arial; font-size: 11px;color: #747474; font-weight: normal;"><img src="'+this.imgPath+'browsers/safari.jpg" /><span style="display: block; clear: both;margin-top: 3px;">Safari 4</span></a>';
	browser[2]='<a href="http://www.opera.com/" style="font-family: Arial; font-size: 11px;color: #747474; font-weight: normal;"><img src="'+this.imgPath+'browsers/opera.jpg" /><span style="display: block; clear: both;margin-top: 3px;">Opera 10</span></a>';
	browser[3]='<a href="http://www.microsoft.com/poland/windows/internet-explorer/" style="font-family: Arial; font-size: 11px;color: #747474; font-weight: normal;"><img src="'+this.imgPath+'browsers/ie.jpg" /><span style="display: block; clear: both;margin-top: 3px;">IE 8</span></a>';	
	browser[4]='<a href="http://www.google.com/chrome/" style="font-family: Arial; font-size: 11px;color: #747474; font-weight: normal;"><img src="'+this.imgPath+'browsers/chrome.jpg" /><span style="display: block; clear: both; margin-top: 3px;">Chrome 4</span></a>';
	
	
	browser = this.shuffle(browser);
	
	for(a=0; a<browser.length; a++) {
		info += '<td style="font-size: 10px; text-align: center; vertical-align: top;">'+browser[a]+'</td>';
	}
	
	info += '</tr></table>';
	info += '<div style="float: left; margin-left: 30px; margin-top: 11px"><input type="checkbox" id="stopNotifyIE6" name="stopNotifyIE6"> <label for="stopNotifyIE6" style="font-family: Arial; font-size: 11px; color: #9e9d9d;">Chcę zignorować ten komunikat i nie oglądać go więcej</label></div>';
	info += '<div style="float: right; margin-right: 30px; margin-top: 11px"><a href="javascript:void(0)" onclick="ie6d.closeInfo()"><img src="'+this.imgPath+'button.gif" alt="" title="" /></a></div><div style="clear: both;"></div>';
	
	inf.innerHTML = info;
	
}

ie6d.shuffle = function(o){ //v1.0
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};


ie6d.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.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			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"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// 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.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

ie6d.closeInfo = function() {
	
	if(document.getElementById('stopNotifyIE6').checked==true) {
		ie6d.stopNotify();
	}
	
	document.getElementById('ie6InfoBg').style.display = 'none';
	document.getElementById('ie6Info').style.display = 'none';
	
}

ie6d.stopNotify = function() {
	
	document.cookie="ie6lover=1;expires=Sat, 12 Mar 2014 09:16:26 GMT";	
	
}

ie6d.BrowserDetect.init();

if(ie6d.BrowserDetect.browser.indexOf('Explorer')>-1 && ie6d.BrowserDetect.version<="6") {
	
	if(document.cookie.length>0 && document.cookie.indexOf("ie6lover")==-1) {
		
		window.onload = function(e) {
			if(ie6d.currentOnload) {
				ie6d.currentOnload(e);
			}
			ie6d.showInfo();
		}
	}
	
}


