function carica(){
    gestLink();
    try{initImageGallery('slideshow1');}catch(e){}
    try{auxload()}catch(e){}
    try{evidenziaTr()}catch(e){}
    setCerca();
}
function onContent(f){
var b=navigator.userAgent,d=document,w=window,
c="__onContent__",e="addEventListener",o="opera",r="readyState",
s="<scr".concat("ipt defer src='/","/:' on",r,"change='if(this.",r,"==\"complete\"){this.parentNode.removeChild(this);",c,"()}'></scr","ipt>");
w[c]=(function(o){return function(){w[c]=function(){};f(o?o():o)}})(w[c]);
if(d[e])d[e]("DOMContentLoaded",w[c],false);
if(/WebKit|Khtml/i.test(b)||(w[o]&&parseInt(w[o].version())<9))
(function(){/loaded|complete/.test(d[r])?w[c]():setTimeout(arguments.callee,1)})();
else if(/MSIE/i.test(b))d.write(s);
};
function gesterrore(msg, url, lno){
return true;
}
function gestLink() {
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
        var a = anchors[i];
        //a.target="_top";
        var rel=a.getAttribute("rel");
        if(rel){
            if(rel.indexOf("altpopup")!=-1) {
                a.target="_blank";
            }
            if(rel.indexOf("blank")!=-1||rel.indexOf("external")!=-1) {
                a.target="_blank";
                if (a.title){
                    a.title += " [Il link apre una nuova finestra]";
                }else{
                    a.title = "Il link apre una nuova finestra";
                }
            }
        }
    }
}
//
function aggEventi(ogg,evnt,func){
    if(ogg.attachEvent){
        ogg.attachEvent("on"+evnt,func);
    }else{
        ogg.addEventListener(evnt,func,false);
    }
}
function setCerca(){
    var qs=id2obj("q");
    if(qs){
         aggEventi(qs,'focus',function tip(e){
                if(!e)e=window.event;
                str='';
                var t;
                if(e.target){t=e.target;}else if(e.srcElement){t=e.srcElement;};
                if(t.value=="cerca" || t.value=="search"){
                    t.value="";
                }
            }
        );
         aggEventi(qs,'blur',function tip(e){
                if(!e)e=window.event;
                str='';
                var t;
                if(e.target){t=e.target;}else if(e.srcElement){t=e.srcElement;};
                if(t.value==""){
                    if(t.getAttribute("lang")=="it"){
                        t.value="cerca";
                    }else{
                        t.value="search";
                    }
                }
            }
        );
    }
}
//Popup
function popup(url,nome,w,h,r){
    var l=(screen.width-w)/2;
    var t=(screen.height-h)/2;
    var ogg=window.open(url,nome,'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars=1,resizable='+r+',menubar=0,toolbar=0,location=0,statusbar=1');
    ogg.window.focus();
    return false
}
function id2obj(id){
	return document.all?document.all[id]:document.getElementById?document.getElementById(id):undefined;
}
 function utf8decode(utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
}
function showhideurl(id){
    //alert(id2obj("urlshow"+id).style.display);
    id2obj("urlshow"+id).style.display=id2obj("urlshow"+id).style.display=="none"?"block":"none";
}
//window.onload=carica;
onContent(carica);
//indow.onerror=gesterrore;
