function IEPinningAlert(siteName) {
	// non supporta la pinning bar, oppure è già applicata
	if (navigator.userAgent.indexOf("Windows NT 6") == -1) { return; }
	var baseUrl = "http://static.videogame.it/static/";
	window._BODYSKINOFFSET = 46;
	if (!siteName) {
		var l = window.location.host.toLowerCase();
		siteName = 'questo sito';
		if (l.indexOf("videogame") != -1) { siteName = 'Videogame.it'; }
		else if (l.indexOf("telefonino") != -1) { siteName = 'Telefonino.net'; window._BODYSKINOFFSET = 40; }
		else if (l.indexOf("turistipercaso") != -1) { siteName = 'TuristiPerCaso'; }
		else if (l.indexOf("punto-informatico") != -1) { siteName = 'Punto Informatico'; }
		else if (l.indexOf("film-review") != -1) { siteName = 'Film Review'; }
		else if (l.indexOf("piusanipiubelli") != -1) { siteName = 'Più Sani Più Belli'; }
		else if (l.indexOf("newstreet") != -1) { siteName = 'Newstreet.it'; }
		else if (l.indexOf("i-dome") != -1) { siteName = 'PMI-Dome'; }
	};
	var canPin = true;
	try { if (window.external.msIsSiteMode() == true) { canPin = true; } }
	catch (e) { canPin = false; }
	// alert già mostrato
	if (document.cookie.indexOf("IEPinningAlert") != -1) return;
	var el = document.createElement('div');
	el.id = "IEPinningAlert";
	el.style.position = "relative";
	el.style.height = "15px";
	el.style.lineHeight = "15px";
	el.style.left = "0px";
	el.style.top = "0px";
	el.style.padding = "9px 40px";
	el.style.backgroundImage = 'url('+baseUrl+'iepinbar_bg.jpg)';
	el.style.font = "bold 11px Arial, Helvetica, sans-serif";
	el.style.textAlign = 'left';
	el.style.cursor = "pointer";
	if (canPin) {
		el.onclick = function() {
			window._gaq.push(["_trackEvent", "IE9Pinning", "PinnedToStartMenu"]);
			window.external.msAddSiteMode();
		}
	} else {
		el.onclick = function() {
			window._gaq.push(["_trackEvent", "IE9Pinning", "DownloadedIE9"]);
			window.location.href = "http://www.labellezzadelweb.it/scarica-internet-explorer/";
		}
	}
	var msg = (navigator.userAgent.indexOf("Windows NT 6.0") > -1) ? "Clicca qui per aggiungi "+siteName+" al menù Avvio di Windows" : siteName+" supporta Internet Explorer 9: trascina l'icona del sito sulla taskbar di Windows! Oppure clicca qui per aggiungerlo al Menu Start";
	if (!canPin) { msg = "Clicca qui per scaricare Internet Explorer 9 e avere "+siteName+" direttamente sul tuo desktop"; }
	else { msg += '&nbsp;&nbsp;<img src="'+baseUrl+'iepinbar_add.png" style="vertical-align: middle">'; }
	var closeBtn = '<img src="'+baseUrl+'iepinbar_close.png" onclick="var e=arguments[0] || window.event; IEPinningClose(1); e.cancelBubble=true; if (e.stopPropagation) e.stopPropagation(); if (e.preventDefault) e.preventDefault();" style="position: absolute; right: 5px; top: 0px; z-index: 10;">';
	var html = '<img src="'+baseUrl+'iepinbar_ie.jpg" class="msPinSite" style="position: absolute; left: 5px; top: 0px"> '+msg+closeBtn+'</div>';
	if (canPin) { el.className = 'msPinSite'; el.style.cursor = 'move'; }
	el.innerHTML = html;
	//document.body.insertBefore(el, document.getElementById("all"));
	document.body.insertBefore(el, document.body.firstChild);
	//if (window.jQuery) window.jQuery("#IEPinningAlert").slideDown(400);
	var skinY = window._BODYSKINOFFSET+33;
	document.body.style.backgroundPosition = 'center '+skinY+'px';
	if (!window._gaq) { window._gaq = []; }
	window._gaq.push(["_trackEvent", "IE9Pinning", "AlertBarShowed"]);
	setTimeout("IEPinningClose();", 20000);
	setTimeout('IEPinningSetCookie("IEPinningAlert", "1", 1);', 5000);
}

function IEPinningClose(stayClosedForDays) {
	if (!document.getElementById("IEPinningAlert")) return;
	if (!window._gaq) { window._gaq = []; }
	if (stayClosedForDays) {
		window._gaq.push(["_trackEvent", "IE9Pinning", "AlertBarClosed"]);
		//IEPinningSetCookie("IEPinningAlert", "1", parseInt(stayClosedForDays));
	}
	if (window.jQuery) { $("#IEPinningAlert").slideUp(400); }
	else { var el = document.getElementById("IEPinningAlert"); el.parentNode.removeChild(el); }
	document.body.style.backgroundPosition = 'center '+window._BODYSKINOFFSET+'px';
	return false;
}

function IEPinningSetCookie(cName, cValue, days) {
	if (!days) { days = 1; }
	var startDate = new Date(); var utime = startDate.getTime();
	startDate.setHours(0); startDate.setMinutes(0); startDate.setSeconds(0);
	var expDate = new Date(startDate.getTime()+(86400 * 1000 * days));
	var max_age = parseInt((expDate.getTime()- utime) / 1000);

	// build the cookie string
	var c = cName+"="+escape(cValue)+"; max-age="+max_age+"; expires="+expDate.toGMTString()+"; path=/;";
	document.cookie = c;
	return true
}

IEPinningAlert();
