
	//
	// hack per il TARGET='_blank' vietato in XHTML
	//
	// cverond - mar 2004 / sep 2005
	//

function InArray(a, el) {

	for (var i in a)
		if (a[i] == el)
			return true;
			
	return false;
}

function OpenInBlankPage(url) {

	window.open(url, 'TBH');
}

var gTBKeyCode = [13, 32];

function TargetBlankHack() {

	for (i = 0; i < document.links.length; i++) {

		if (document.links[i].className.indexOf('target_blank') != -1) {

//				document.links[i].setAttribute('target', '_blank');
			document.links[i].title += gAppConfigure.kBlankLinkMessage;

// IE Win:
// return: 13
// spazio: 32
// tab: non intercettato

// mozilla:
// return: 13
// spazio: 0
// tab: 9

			var fn;
			if (window.event) {
			
				fn = function () {
				
					var e = window.event;
					
					if (InArray(gTBKeyCode, e.keyCode)) {

						//window.open(this.href, 'popupwindow');
						OpenInBlankPage(this.href);

						//return false;
						window.event.returnValue = false;
					}
				}

			} else {
			
				fn = function (e) {
				
//					alert(e.keyCode);

					if (InArray(gTBKeyCode, e.keyCode)) {
					
						//window.open(this.href, 'popupwindow');
						OpenInBlankPage(this.href);

						return false;
					}
				}
			}

			document.links[i].onkeypress = fn;

			document.links[i].onclick = function () { OpenInBlankPage(this.href); return false; };
		}
	}
}
