function MM_reloadPage(init) { // reloads the window if Nav4 resized
	if (init == true)
		with (navigator) {
			if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
				document.MM_pgW = innerWidth;
				document.MM_pgH = innerHeight;
				onresize = MM_reloadPage;
			}
		}
	else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH)
		location.reload();
}
MM_reloadPage(true);
function MM_findObj(n, d) { // v4.0
	var p, i, x;
	if (!d)
		d = document;
	if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}
	if (!(x = d[n]) && d.all)
		x = d.all[n];
	for (i = 0; !x && i < d.forms.length; i++)
		x = d.forms[i][n];
	for (i = 0; !x && d.layers && i < d.layers.length; i++)
		x = MM_findObj(n, d.layers[i].document);
	if (!x && document.getElementById)
		x = document.getElementById(n);
	return x;
}
function UB_showHideObject() {
	var i, p, v, obj, args = UB_showHideObject.arguments;
	for (i = 0; i < (args.length - 1); i += 2) {
		if ((obj = MM_findObj(args[i])) != null) {
			v = args[i + 1];
			if (obj.style) {
				obj = obj.style;
				v = (v == 'off') ? 'none' : (v == 'on') ? 'block' : v;
			}
			;
			obj.display = v;
		}
	}
}
function UB_changeClass() {
	var i, myObj, myClass, args = UB_changeClass.arguments;
	for (i = 0; i < (args.length - 1); i += 2) {
		myObj = MM_findObj(args[i]);
		myObj.className = args[i + 1];
	}
}
function UB_genPop(myUrl, myWinName, myWidth, myHeight, myPars) {
	var winLeft = (screen.availWidth - myWidth) / 2;
	var winTop = (screen.availHeight - myHeight) / 2;
	var winParameters = myPars + '';
	if (winParameters == '') {
		winParameters = ',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
	}
	;
	newWin = window.open(myUrl, myWinName, 'width=' + myWidth + ',height='
			+ myHeight + ',left=' + winLeft + ',top=' + winTop + winParameters);
	newWin.focus();
}
var activeMNU, subTimeoutID, activeELM;
function UB_subMNUoff(myMNU) {
	if (subTimeoutID)
		clearTimeout(subTimeoutID);
	UB_showHideObject(myMNU, 'off');
	subTimeoutID = '';
	activeMNU = '';
	subTimeoutID = '';
	activeMNU = '';
	if (activeELM) {
		activeELMclassName = activeELM.firstChild.className;
		activeELM.firstChild.className = activeELMclassName.substring(0,
				activeELMclassName.length - 7);
		activeELM = '';
	}
}
function UB_timeout(myMNU, myTimeout) {
	myTimeout = myTimeout ? myTimeout : 123;
	subTimeoutID = setTimeout("UB_subMNUoff('" + myMNU + "')", myTimeout);
}
function UB_subMNUon(myMNU, myElement) {
	if (myMNU == activeMNU) {
		if (subTimeoutID) {
			clearTimeout(subTimeoutID)
		}
		;
		subTimeoutID = '';
		return;
	}
	;
	if (activeMNU) {
		UB_subMNUoff(activeMNU)
	}
	;
	activeMNU = myMNU;
	UB_showHideObject(myMNU, 'on');
	if (myElement) {
		myElement.firstChild.className = myElement.firstChild.className + ' active';
		activeELM = myElement;
	}
}
var activeTab = 1, activeClass;
function UB_swapTab(myTab) {
	if (myTab == activeTab)
		return;
	if (activeTab && !activeClass)
		activeClass = MM_findObj('lnk-int-' + activeTab).className.substring(0,
				MM_findObj('lnk-int-' + activeTab).className.length - 7);
	myTabClass = MM_findObj('lnk-int-' + myTab).className;
	UB_changeClass('lnk-int-' + activeTab, activeClass, 'lnk-int-' + myTab,
			myTabClass + ' active');
	UB_showHideObject('tab-int-' + activeTab, 'off', 'tab-int-' + myTab, 'on');
	activeTab = myTab;
	activeClass = myTabClass;
}
function UB_bookmarkSite(myTitle, myURL) {
	if (!myTitle || !myURL) {
		myTitle = document.title;
		myURL = document.location.href;
	}
	;
	if (document.all) {
		window.external.AddFavorite(myURL, myTitle);
	} else if (window.sidebar) {
		window.sidebar.addPanel(myTitle, myURL, '');
	} else {
		alert('ATTENZIONE!\nIl tuo browser non supporta questa funzionalita\'.');
	}
}
var activeColor = 'clr1';
function UB_swapColor(myObj) {
	if (myObj.id == activeColor)
		return;
	if (activeColor) {
		UB_changeClass(activeColor, '', myObj.id, 'prod-col-active');
		activeColor = myObj.id;
	}
}
function UB_deleteChartElm(myObj) {
	$(myObj).parent().hide('blind', 223).remove();
	chartelements--;
	if (chartelements == 0) {
		$('#info-carrello').show('blind', 223);
		$('#contatta-consulente').hide('blind', 223);
	}
	;
	return false;
}
/* popup */
function UB_init() {
	for ( var i = 0; i < document.links.length; i++) {
		a = document.links[i];
		if (a.href && a.rel.substring(0, 2) == 'UB') {
			a.onclick = function() {
				UB_relPop(this);
				return false;
			}
		}
	}
}
var container, containerStyle, windowWidth, windowHeight;
function UB_settaDimSchermo() {
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement
			&& document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}
var fade, fadein, fadeout;
function UB_fadein() {
	if (fadein <= fadeout) {
		UB_overlayer.style.opacity = fadein / 10;
		UB_overlayer.style.filter = 'alpha(opacity=' + fadein * 10 + ')';
		fadein += .5;
		fadeTiming = setTimeout("UB_fadein();", 1);
	} else {
		clearTimeout(fadeTiming);/* UB_popOverlayer.style.opacity=0;UB_popOverlayer.style.filter='alpha(opacity=0)';fade=0; */
		UB_popOverlayer.style.visibility = 'visible';/* UB_fadepop(); */
	}
}
function UB_fadepop() {
	if (fade <= 10) {
		UB_popOverlayer.style.opacity = fade / 10;
		UB_popOverlayer.style.filter = 'alpha(opacity=' + fade * 10 + ')';
		fade += .5;
		fadeTiming = setTimeout("UB_fadepop();", 1);
	} else {
		clearTimeout(fadeTiming);
	}
}
function UB_fadeout() {
	if (fadeout > 0) {
		UB_overlayer.style.opacity = fadeout / 10;
		UB_overlayer.style.filter = 'alpha(opacity=' + fadeout * 10 + ')';
		fadeout -= .5;
		fadeTiming = setTimeout("UB_fadeout();", 1);
	} else {
		clearTimeout(fadeTiming);
		document.body.removeChild(UB_overlayer);
	}
}
function UB_ObjCenter() {
	UB_popOverlayer.style.left = parseInt((windowWidth - UB_popOverlayer.offsetWidth) / 2) + 'px';
	if (windowHeight > UB_popOverlayer.offsetHeight) {
		UB_popOverlayer.style.top = parseInt((windowHeight - UB_popOverlayer.offsetHeight) / 2) + 'px';
	} else {
		UB_popOverlayer.style.top = '0px';
	}
}
var UB_overlayer, IDoverlayer, UB_popOverlayer, IDpopOverlayer;
function UB_relPop(myLink, myWidth, myHeight, myBgcolor, myFade) {
	if (myLink.rel) {
		prmtrs = myLink.rel.split(',');
		myLink = myLink.href;
		myWidth = prmtrs[1];
		myHeight = prmtrs[2];
		myBgcolor = prmtrs[3];
		myFade = prmtrs[4];
	}
	;
	UB_settaDimSchermo();
	UB_overlayer = document.createElement('div');
	IDoverlayer = document.createAttribute('id');
	IDoverlayer.nodeValue = 'UB_overlayer';
	UB_overlayer.setAttributeNode(IDoverlayer);
	UB_overlayer.style.height = windowHeight + 'px';
	UB_overlayer.style.background = myBgcolor;
	UB_overlayer.className = 'UB_overlayerClass';
	UB_overlayer.style.opacity = 0;
	UB_overlayer.style.filter = 'alpha(opacity=0)';
	document.body.appendChild(UB_overlayer);
	fadein = 0;
	fadeout = myFade;
	UB_popOverlayer = document.createElement('div');
	IDpopOverlayer = document.createAttribute('id');
	IDpopOverlayer.nodeValue = 'UB_popOverlayer';
	UB_popOverlayer.setAttributeNode(IDpopOverlayer);
	UB_popOverlayer.className = 'UB_popOverlayerClass';
	UB_popOverlayer.innerHTML = '<div class="popContent"><iframe src="'
			+ myLink
			+ '" style="width:'
			+ myWidth
			+ 'px;height:'
			+ myHeight
			+ 'px;" class="UB_frame" name="UB_frame" id="UB_frame" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto"></iframe></div>';
	document.body.appendChild(UB_popOverlayer);
	UB_ObjCenter();
	UB_fadein();
}
function UB_closePopOverlayer() {
	document.body.removeChild(UB_popOverlayer);
	UB_fadeout();
}
function UB_onResize() {
	if (document.getElementById('UB_popOverlayer')) {
		UB_settaDimSchermo();
		var UB_overlayer = document.getElementById('UB_overlayer');
		UB_overlayer.style.height = windowHeight + 'px';
		UB_ObjCenter('UB_popOverlayer');
	}
}
window.onload = UB_init;
window.onresize = UB_onResize;

/* jQuery extend */
$.extend( {
	getUrlVars : function() {
		var vars = [], hash;
		var splitCode = (window.location.href.indexOf('&amp;') > 0) ? '&amp;'
				: '&';
		var hashes = window.location.href.slice(
				window.location.href.indexOf('?') + 1).split(splitCode);
		for ( var i = 0; i < hashes.length; i++) {
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		;
		return vars;
	},
	getUrlVar : function(name) {
		return $.getUrlVars()[name];
	}
});
/* jQuery common */
jQuery().ready(function() {
	$("input[type=checkbox], input[type=radio]").focus(function() {
		$(this).blur()
	});
	$("select").change(function() {
		$(this).blur()
	});

	var myTab = $.getUrlVar('tab');
	if (parseInt(myTab) > 1) {
		$(".tab-nav .tabs a#tab-" + myTab + "-lnk").click();
	} else {
		$(".tab-nav .tabs a#tab-1-lnk").click();
	}
});
