/* clear */

$(document).ready(function(){
		var els = document.getElementsByTagName('div');
		for (i=0; i<els.length; i++){
		if (els[i].className == 'focusContent'){
			var clearDiv = document.createElement('div');
			clearDiv.className = 'clearLeft';
			els[i].appendChild(clearDiv);
			}
		}
	});

/*
JSTarget function by Roger Johansson, www.456bereastreet.com
*/
var JSTarget = {
	init: function(att,val,warning) {
		if (document.getElementById && document.createElement && document.appendChild) {
			var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
			var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
			var strWarning = ((typeof warning == 'undefined') || (warning == null)) ? ' (opens in a new window)' : warning;
			var oWarning;
			var arrLinks = document.getElementsByTagName('a');
			var oLink;
			var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
			for (var i = 0; i < arrLinks.length; i++) {
				oLink = arrLinks[i];
				if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {
					oWarning = document.createElement("em");
					oWarning.appendChild(document.createTextNode(strWarning));
					oLink.appendChild(oWarning);
					oLink.onclick = JSTarget.openWin;
				}
			}
			oWarning = null;
		}
	},
	openWin: function(e) {
		var event = (!e) ? window.event : e;
		if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;
		else {
		    var oWin = window.open(this.getAttribute('href'), '_blank');
			if (oWin) {
				if (oWin.focus) oWin.focus();
				return false;
			}
			oWin = null;
			return true;
		}
	},
	/*
	addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	*/
	addEvent: function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn]( window.event );}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};
JSTarget.addEvent(window, 'load', function(){JSTarget.init("rel","external","");});


/* popup accessibile ======================================================= 
 *
 * pop up di dimensione 640x480: applicare al link la classe "popWindow";
 *
 * pop up di altezza e larghezza desiderate: applicare al link la classe "popParamWindow" e utilizzare nell'url
 * i parametri height=xyz&width=xyz
 * esempio: pagina.aspx?height=480&width=640
 */

// funzione per aprire la finestra specificando altezza e larghezza 
function popUp(destination,param){
var poppedUp = window.open(destination, "popWin", param);
//poppedUp.focus();
}

// esegue la funzione principale solo quando il DOM è completo
window.onload = prepareLinks;

// funzione principale che chiama la funzione popup
function prepareLinks(){
	var links = document.getElementsByTagName("a");
	for (var i=0; i<links.length; i++){
		if (links[i].className == "popWindow"){
			links[i].onclick = function (){
				popUp(this.getAttribute("href"),"height=480, width=640, scrollbars=1, resizable=1");
				return false;}
		}
		//modificato per sito exponential: aggiunto 'imgLeft' altrimenti non riusciva a trovare la classe 'popParamWindow'
		if (links[i].className == "popParamWindow imgLeft"){
			links[i].onclick = function (){
				var p = (this.getAttribute("href").substr(this.getAttribute("href").indexOf('height'))).split('&');
				var param = p[0]+', '+p[1]+', scrollbars=1, resizable=1';
				popUp(this.getAttribute("href"),param);
				return false;}
		}
	
	}
}