displayNotification();

/*@cc_on
	 @if (@_jscript_version <= 5.6 && @_jscript_version >= 3.0)
		window.onscroll = legacySetBar;
		window.onresize = legacySetBar;
	 /*@end
@*/	


function legacySetBar(bar)
{
	if (!bar)
	{
		bar = document.getElementById('ieInfoBar'); 
	}

	if (bar)
	{ 
		if (document.documentElement && document.documentElement.clientWidth)
		{
	        bar.style.width = document.documentElement.clientWidth;
	    }
		else if (document.body && document.body.clientWidth)
		{
    		bar.style.width = document.body.clientWidth;
		}


		if (document.documentElement && document.documentElement.scrollTop)
		{
	        bar.style.top = document.documentElement.scrollTop;
	    }
		else if (document.body && document.body.scrollTop)
		{
    		bar.style.top = document.body.scrollTop;
		}

	};

};


function getIeVersion()
{
	var ieVersion = null;

	/*@cc_on
		 @if   (@_jscript_version > 5.8)   ieVersion = 9;
		 @elif (@_jscript_version == 5.8)  ieVersion = 8;
		 @elif (@_jscript_version == 5.7)  ieVersion = 7;
		 @elif (@_jscript_version == 5.6)  ieVersion = 6;
		 @elif (@_jscript_version == 5.5)  ieVersion = 5.5;
		 @elif (@_jscript_version == 5.0)  ieVersion = 5;
		 @elif (@_jscript_version == 5.01) ieVersion = 5;
		 @elif (@_jscript_version == 3.0)  ieVersion = 4;
		 @elif (@_jscript_version == 1.0)  ieVersion = 3;
		 @else @*/                     //  ieVersion = null;
	   /*@end
	@*/

	if (ieVersion == 7 && !window.XMLHttpRequest)
	{
		ieVersion = 6;
	}

	return ieVersion;
}


function displayNotification() 
{

	var ieVersion = getIeVersion();

	switch (queryStringParameterValue('test'))
	{
		case '9': ieVersion = 9; break;
		case '8': ieVersion = 8; break;
		case '7': ieVersion = 7; break;
		case '6': ieVersion = 6; break;
		case '5': ieVersion = 5; break;
		case '4': ieVersion = 4; break;
		case '3': ieVersion = 3; break;
		default: break;
	}

	var u = navigator.userAgent; 
	var isIEMobile = ( (u.indexOf("IEMobile") > -1)     || 
					   (u.indexOf("Windows CE") > -1) ||
					   (u.indexOf("WM5 PIE") > -1)
					 ); 
	var isIE = (ieVersion && !isIEMobile)

	if (!isIE)
	{	
		return;
	}		

	if (document.cookie.indexOf('notificationdisplayed=true') == -1 || queryStringParameterValue('shownotificationbar') == 'always')
	{
		if (ieVersion == 8)
		{
			if (navigator.userAgent.indexOf('Windows NT 5.1') == -1)
			{
				var notificationBar = new ieInfoBar({message: 'Neugierig auf die n&auml;chste Internet Explorer Version? Installieren Sie jetzt <a href="http://windows.microsoft.com/de-DE/internet-explorer/products/ie/home" target="_blank"><strong>Internet Explorer&nbsp;9</strong></a>! Mit IE9 wird das Internet schneller, einfacher und ansprechender.', icon: 'http://www.microsoft.com/germany/msdn/components/ie/question.gif'});
				notificationBar.show(50);
				createDocumentCookie('notificationdisplayed', 'true', 7 * 24);		
			}
		}
				
		if (ieVersion == 7)
		{
				var notificationBar = new ieInfoBar({message: 'Diese Version des Internet Explorers wird nicht unterstützt. Wollen Sie eine korrekte Darstellung der Website haben, installieren Sie <strong><u>jetzt</u></strong> den kostenlosen Internet Explorer 9 oder einen anderen Browser- schneller, einfacher und sicherer!', icon: 'http://www.microsoft.com/germany/msdn/components/ie/alert.gif'});
				notificationBar.show(50);
				createDocumentCookie('notificationdisplayed', 'true', 6);			
		}
				
		if (ieVersion <= 6 && ieVersion >= 4)
		{
				var notificationBar = new ieInfoBar({message: 'Diese Version des Internet Explorers wird nicht unterstützt. Wollen Sie eine korrekte Darstellung der Website haben, installieren Sie <strong><u>jetzt</u></strong> den kostenlosen Internet Explorer 9 oder einen anderen Browser - schneller, einfacher und sicherer!', icon: 'http://www.microsoft.com/germany/msdn/components/ie/alert.gif'});
				notificationBar.show(50);
				createDocumentCookie('notificationdisplayed', 'true', 6);
		}
	}
	
}


function createDocumentCookie(name, value, hours)
{

	if (hours)
	{
		var date = new Date();
		date.setTime(date.getTime() + hours * 60 * 60 * 1000);
		var expires = '; expires=' + date.toGMTString();
	}
	else
	{
		var expires = '';
	}
	document.cookie = name + '=' + value + expires + '; path=/';
}


function queryStringParameterValue(parameterName)
{
	var retVal = '';
	var hRef = window.location.href;

	if (hRef.indexOf('?') > -1)
	{
		var queryString = hRef.substr(hRef.indexOf('?')).toLowerCase();
		var queryStringArray = queryString.split('&');
		for (var i = 0; i < queryStringArray.length; i++)
		{
			if (queryStringArray[i].indexOf(parameterName + '=') > -1)
			{
				var aParam = queryStringArray[i].split('=');
				retVal = aParam[1];
				break;
			}
		}
	}

	return retVal;
}

		
function ieInfoBar(params)
{

	var ieVersion = getIeVersion();

	if (!document.createElement || !ieVersion)
	{
		return;
	}

	if(!params)
	{
		params = {};
	}


	var infoBarTag = document.createElement('div');
	infoBarTag.id = 'ieInfoBar';
	infoBarTag.style.cssText ='position: absolute; padding-top: 3px; padding-bottom: 3px; display: block; z-Index: 50000; left: 0; right: 0; border-bottom: 1px black groove; width:100%;';
	infoBarTag.style.backgroundColor = params.backColor || '#ffffe1';
	infoBarTag.style.fontColor = params.foreColor || '#000000';
	if (ieVersion <= 6 && ieVersion >= 4)
	{
		if (document.documentElement && document.documentElement.clientWidth)
		{
	        infoBarTag.style.width = document.documentElement.clientWidth;
	    }
		else if (document.body && document.body.clientWidth)
		{
	       	infoBarTag.style.width = document.body.clientWidth;
	   	}
	};

	var iconTag = document.createElement('img');
	iconTag.style.cssText = 'width: 14px; height: 16px; float: left; border: 0px; margin-right: 5px; margin-left: 7px;';
	iconTag.src = params.icon || 'http://www.microsoft.com/germany/msdn/components/ie/alert.gif'; 

	var textTag = document.createElement('div');
	textTag.innerHTML = params.message || '';
	textTag.style.cssText ='text-align:left; padding-left: 26px; padding-right: 24px; font-family: Arial;font-size: small; cursor: default;';
	
	var closeTag = document.createElement('img');
	closeTag.style.cssText = 'width: 18px; height: 18px; float: right; border: 0px; margin-right: 7px; cursor: default;';
	closeTag.src = 'http://www.microsoft.com/germany/msdn/components/ie/x.gif';
	closeTag.onclick = function()
	{
		infoBarTag.style.display = 'none';
	};
	
	infoBarTag.appendChild(closeTag);
	infoBarTag.appendChild(iconTag);
	infoBarTag.appendChild(textTag);

	this.InfoBar = infoBarTag;
	document.body.insertBefore(infoBarTag, document.body.firstChild);
	infoBarTag.style.top = document.body.scrollTop - parseInt(this.InfoBar.offsetHeight) + 'px';
	

	this.show = function(speed)
	{
		var me=this;
		if (parseInt(this.InfoBar.style.top) < 0)
		{
			infoBarTag.style.top = parseInt(infoBarTag.style.top) + 2 + 'px';
			setTimeout(function(){me.show(speed)}, speed || 50);
		}
		else
		{
			if (ieVersion <= 6 && ieVersion >= 4)
			{
				this.InfoBar.style.top = (document.compatMode == 'CSS1Compat') ? document.documentElement.scrollTop + 'px' : body.scrollTop + 'px';
			}
			else
			{
				this.InfoBar.style.top = 0;
				if (document.compatMode != 'BackCompat')
				{
					this.InfoBar.style.position = "fixed";
				}
			}

		}
		
	}

}
