(function(){
	var w = window, d = w.document;
	
	w.showPage=function(page_name,win_name,pos_x,pos_y,win_width,win_height){
		if(page_name=="") {
			return;
		}
		if(pos_x==-1) {
			pos_x=parseInt(screen.width/2, 10)-(win_width/2);
		}
		if(pos_y==-1) {
			pos_y=parseInt(screen.height/2, 10)-(win_height/2);
		}
		var optionstr, win, options = {
			resizable:'no',
			scrollbars:'yes'
		}, optnames = ['resizable', 'scrollbars'], i, v;
		if(typeof arguments[6]=='object') {
			if(arguments[6].resizable) {
				options.resizable=arguments[6].resizable;
			}
			if(arguments[6].scrollbars) {
				options.scrollbars=arguments[6].scrollbars;
			}
		}
		optionstr='';
		for(i=0; i<optnames.length; ++i) {
			v=optnames[i];
			optionstr += ','+v+'='+options[v];
		}
		win=w.open(page_name,win_name,"width="+win_width+",height="+win_height+",left="+pos_x+",top="+pos_y+optionstr);
		if(win) {
			win.focus();
		}
		return win;
	};
	w.openPop=function(a,n,wd,ht){
		w.showPage(a.protocol+'//'+a.host+(a.port!=0 && a.port!=80 && a.host.indexOf(':')===-1?':'+a.port:'')+(a.pathname.substring(0,1)!=='/'?'/':'')+a.pathname+a.search+(a.search.length===0?'?':'&')+'popup='+a.hash,n,-1,-1,wd,ht);
	};
	//thanks to addtoany.com
	w.addBookmark=function(url,name){
		if(w.sidebar && w.sidebar.addPanel) {
			w.sidebar.addPanel(name,url,'');
		}
		else if(w.opera && w.print) { 
			var e=d.createElement('a');
			e.setAttribute('href',url);
			e.setAttribute('title',name);
			e.setAttribute('rel','sidebar');
			e.click();
		}
		else if(w.external) {
			try {
				w.external.AddFavorite(url,name);
			}
			catch(ex){}
		}
		else {
			alert("Questa funzione \xE8 automatica solo su alcuni browser. Per inserirci nel tuo Bookmark premi Ctrl+D su Windows, o Comando(Mela)+D su Macintosh, con Safari e Netscape Navigator. Per altri browser riferisciti alla documentazione se non sai come fare.");
		}
	};
	//by quirksmode.org
	w.createCookie=function(name,value,days){
		var date, expires;
		if (days){
			date=new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			expires="; expires="+date.toGMTString();
		}
		else {
			expires="";
		}
		d.cookie=name+"="+escape(value)+expires+"; path=/";
	};
	w.readCookie=function(name){
		var nameEQ=name+"=", ca=d.cookie.split(';'), i, c;
		for(i=0; i<ca.length; i++) {
			c=ca[i];
			while (c.charAt(0)===' ') {
				c=c.substring(1,c.length);
			}
			if (c.indexOf(nameEQ)===0) {
				return c.substring(nameEQ.length,c.length);
			}
		}
		return null;
	};
	w.eraseCookie=function(name){
		createCookie(name,"",-1);
	};
	w.initLpbar=function(sec){
		var navRoot, i, node, dat;
		
		function f00(x){
			if(x<=9) {
				return '0'+x;
			}
			return x;
		}
		
		function lpbtime(){
			var pcs,dt,l=d.getElementById('lpbtime');
			pcs=/(\d+)\/(\d+)\s+(\d+):(\d+)/.exec(l.innerHTML);
			dt=new Date();dt.setMonth(parseInt(pcs[2],10)-1);dt.setDate(parseInt(pcs[1],10));dt.setHours(parseInt(pcs[3],10)); dt.setMinutes(parseInt(pcs[4],10)+1,10);dt.setSeconds(0);
			l.innerHTML=f00(dt.getDate())+'/'+f00(dt.getMonth()+1)+' '+f00(dt.getHours())+':'+f00(dt.getMinutes());
			setTimeout(lpbtime, 6e4-dt.getSeconds()*1e3-dt.getMilliseconds());
		}
		
		if(d.all&&d.getElementById&&(!navigator.vendor||navigator.vendor!='iCab')){
			navRoot=d.getElementById("lpbar").getElementsByTagName("LI");
			for(i=0;i<navRoot.length;++i){
				node=navRoot[i];
				node.onmouseover=function(){
					this.className+=" over";
				};
				node.onmouseout=function(){
					this.className=this.className.replace(" over","");
				};
			}
		}
		dat=new Date();
		if(dat.getSeconds()>=sec) {
			setTimeout(lpbtime, 6e4-dat.getSeconds()*1e3-dat.getMilliseconds());
		}
		else {
			lpbtime();
		}
	};
	if(w.calllpinit){
		w.calllpinit();
		w.calllpinit = null;
	}
})();