function b3_centerImg(t) {
	t.style.position='relative';
	t.style.top=-(t.height-t.parentNode.parentNode.offsetHeight)/2+'px';
	t.style.left=-(t.width-t.parentNode.parentNode.offsetWidth)/2+'px';
	}

function submitSearch() {
	var q=document.getElementById('searchQ').value;
	window.location=BASEDIR+"it/search/"+escape(q);
	}

function searchKeyUp(e) {
   var KeyID=(window.event)?event.keyCode:e.keyCode;
   if(KeyID==13) submitSearch(); //invio
   }
  
/* AJAX */
kAjax=function() {
	var onSuccess=function(txt) {};;
	var onFail=function(txt) {};;
	var ajaxObj=null;
	var method="get";
	var uri="";
	var vars="";

	this.send=function(vmethod,vuri,vvars) {
		method=vmethod.toLowerCase();
		uri=vuri;
		vars=vvars;
		ajaxSend();
		}
	this.onSuccess=function(func) { onSuccess=func }
	this.onFail=function(func) { onFail=func; }

	function createXMLHttpRequest() {
		var XHR=null;
		if(typeof(XMLHttpRequest)==="function"||typeof(XMLHttpRequest)==="object") XHR=new XMLHttpRequest(); //browser standard
		else if(window.ActiveXObject&&!kBrowser.IE4) { //ie4, BLOCCATO
			if(kBrowser.IE5) XHR=new ActiveXObject("Microsoft.XMLHTTP"); //ie5.x: metodo diverso
			else XHR=new ActiveXObject("Msxml2.XMLHTTP"); //ie6: metodo diverso
			}
		return XHR;
		}
	function onStateChange() {
		if(ajaxObj.readyState===4) {
			if(ajaxObj.status==200) onSuccess(ajaxObj.responseText,ajaxObj.responseXML);
			else onFail(ajaxObj.status);
			}
		}
	function ajaxSend() {
		ajaxObj=createXMLHttpRequest();
		if(method=="get") {
			uri+="?"+vars;
			ajaxObj.open(method,uri,true);
			ajaxObj.onreadystatechange=onStateChange;
			ajaxObj.send(null);
			}
		else if(method=="post") {
			ajaxObj.open(method,uri,true);
			ajaxObj.setRequestHeader("content-type","application/x-www-form-urlencoded");
			ajaxObj.setRequestHeader("connection","close");
			ajaxObj.onreadystatechange=onStateChange;
			ajaxObj.send(vars);
			}
		delete ajaxObj;
		}	
	}


/* menu */
kMenu=function() {
	var container=null;
	var menu=null;
	var ulMenu=null;
	var home=null;
	var pointer=null;
	var easeStep=0;
	var easeFrom=0;
	var easeTo=0;
	var widthFrom=0;
	var widthTo=0;
	var timer=null;

	this.setContainer=function(id,menuid) {
		container=document.getElementById(id);
		menu=document.getElementById(menuid);
		}
	this.init=function() {
		ulMenu=menu.getElementsByTagName('UL')[0];
		mouseHandlers(ulMenu);
		for(var i=0;ulMenu.childNodes[i];i++) {
			elm=ulMenu.childNodes[i];
			if(elm.tagName=='LI'&&(elm.className=='sel'||elm.className=='ancestor')) home=elm;
			}
		pointer=document.createElement('DIV');
		pointer.id='pointer';
		pointer.style.left='0px';
		pointer.style.width='0px';
		pointer.style.height=menu.offsetHeight+'px';
		container.style.width=menu.offsetWidth+'px';
		container.style.height=menu.offsetHeight+'px';
		container.appendChild(pointer);
		if(home) {
			pointer.style.width=home.offsetWidth+'px';
			pointer.style.left=home.offsetLeft+(home.offsetWidth-pointer.offsetWidth)/2+'px';
			}
		kAddEvent(window,"onload",function() {
			if(home) {
				pointer.style.width=home.offsetWidth+'px';
				pointer.style.left=home.offsetLeft+(home.offsetWidth-pointer.offsetWidth)/2+'px';
				}
			container.style.width=menu.offsetWidth+'px';
			});
		}
	function goHere() {
		if(timer) clearInterval(timer);
		moveTo(this.offsetLeft,this.offsetWidth);
		}
	function goHome() {
		if(timer) clearInterval(timer);
		if(home) moveTo(home.offsetLeft,home.offsetWidth);
		else moveTo(0,0);
		}
	function moveTo(to,wTo) {
		easeStep=0;
		easeFrom=parseInt(pointer.style.left);
		easeTo=to;
		widthFrom=parseInt(pointer.offsetWidth);
		widthTo=parseInt(wTo);
		timer=setInterval(moveNextStep,20);
		}
	function moveNextStep() {
		var newpos=easeFrom+easeInOut(easeTo-easeFrom,10,easeStep,5);
		var newwidth=widthFrom+easeInOut(widthTo-widthFrom,10,easeStep,5);
		pointer.style.left=newpos+'px';
		pointer.style.width=newwidth+'px';
		easeStep++;
		if(easeStep>10) {
			clearInterval(timer);
			easeStep=0;
			}
		}
	function mouseHandlers(elm) {
		for(var i=0;elm.getElementsByTagName('LI')[i];i++) {
			elm.getElementsByTagName('LI')[i].getElementsByTagName('A')[0].onmouseout=mouseOutHandler;
			if(elm.getElementsByTagName('LI')[i].getElementsByTagName('UL').length>0) {
				mouseHandlers(elm.getElementsByTagName('LI')[i].getElementsByTagName('UL')[0]);
				}
			elm.getElementsByTagName('LI')[i].onmouseover=goHere;
			elm.getElementsByTagName('LI')[i].onmouseout=goHome;
			}
		}
	function mouseOutHandler() {
		}
	}
function kMenuInit(id,menu) {
	var kMainMenu=new kMenu;
	kMainMenu.setContainer(id,menu);
	kMainMenu.init();
	}

function easeInOut(value,totalSteps,actualStep,pwr) { 
	totalSteps=Math.max(totalSteps,actualStep,1);
	var p1=Math.ceil(totalSteps/2);
	var p2=totalSteps-p1;
	var p1a=Math.min(actualStep,p1);
	var p2a=actualStep-p1a;
	var step=Math.pow(((1/p1)*p1a),pwr)*(value/2);
	if(p2a>0) step+=value/2-(Math.pow(((1/p2)*(p2-p2a)),pwr)*(value/2));
	return Math.ceil(step);
	}

