function getWindowHeight(){
	if(usr.Mac && usr.checkObj == 1){
		return window.innerHeight;
	}else if(usr.Win && usr.checkObj == 1){
		return window.innerHeight - 16;
	}else if(usr.checkObj == 4){
		return window.innerHeight - 15;
	}else if(usr.OPERA || usr.checkObj == 2 || usr.checkObj == 3){
		return d.body.clientHeight;
	}
}

function getWindowXOffset(){
	if(usr.checkObj == 2 || usr.checkObj == 3){
		return d.body.scrollLeft;
	}else if(usr.checkObj == 1 || usr.checkObj == 4){
		return window.pageXOffset;
	}
}
function getWindowYOffset(){
	if(usr.checkObj == 2 || usr.checkObj == 3){
		return d.body.scrollTop;
	}else if(usr.checkObj == 1 || usr.checkObj == 4){
		return window.pageYOffset;
	}
}

function getDocHeight(){
	if(usr.checkObj == 1){
		return getTagTop('end') + 1;
	}else if(usr.checkObj == 2 || usr.checkObj == 3 || usr.checkObj == 4){
		return getTagTop('end');
	}
}

function getDistanceMaxY(){
	if(usr.allObj){
		return (getDocHeight() - getWindowHeight());
	}
}

function setObj(idName){
	return d.all ? d.all(idName) : d.getElementById ? d.getElementById(idName) : d.layers[idName];
}

function getTagTop(idName) {
	var obj = setObj(idName);
	var tagCoords = new Object();

	if(usr.OPERA && usr.Mac){
		return idName;
	} else if((usr.checkObj == 2) || (usr.checkObj == 3) || (usr.checkObj == 4)) {
		tagCoords.y = obj.offsetTop;
		while ((obj = obj.offsetParent) != null) {
			tagCoords.y += obj.offsetTop;
		}if(usr.Mac && usr.Moz){
			return tagCoords.y - 12;
		}else if((usr.Win && usr.Moz) || (usr.Mac && usr.SAFARI)){
			return tagCoords.y - 9;
		}else{
			return tagCoords.y;
		}
	} else if(usr.checkObj == 1) {
		tagCoords.y = d.anchors[idName].y;
		return tagCoords.y;
	}return idName;
}

/*PageScroller*/
var pageScrollTimer;
function pageScroll(toX,toY,frms,frX,frY) {
	if(pageScrollTimer) clearTimeout(pageScrollTimer);
	var spd = usr.Mac ? 14 :16;
	var actX = getWindowXOffset();
	var actY = getWindowYOffset();
	if(!toX || toX < 0) toX = 0;
	if(!toY || toY < 0) toY = 0;
	if(!frms) frms = usr.NN ? 10 :usr.Mac ? 4 :5;
	if(!frX) frX = 0 + actX;
	if(!frY) frY = 0 + actY;

	frX += (toX - actX) / frms;
	if (frX < 0) frX = 0;
	frY += (toY - actY) / frms;
	if (frY < 0) frY = 0;
	var posX = Math.ceil(frX);
	var posY = Math.ceil(frY);
	window.scrollTo(posX, posY);
	if((Math.floor(Math.abs(actX - toX)) < 1) && (Math.floor(Math.abs(actY - toY)) < 1)){
		clearTimeout(pageScrollTimer);
		window.scroll(toX,toY);
	}else if(posX != toX || posY != toY){
		pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+frX+","+frY+")",spd);
	}else{
		clearTimeout(pageScrollTimer);
	}
}

function jumpToAnchor(idName) {
	if(usr.allObj){
		if(!!idName){
			var anchorY = getTagTop(idName);
			var dMaxY = getDistanceMaxY();
			var setY = (anchorY<1)?0:(anchorY>dMaxY)?dMaxY:anchorY;
			if(anchorY>1){
				pageScroll(0,setY);
			}else if(anchorY<=1){
				pageScroll(0,0);
			}else{
				location.hash = idName;
			}
		}else{
			pageScroll(0,0);
		}
	}else{
		!!idName ? location.hash = idName : location.hash = "top";
	}
}
function jumpToPageTop() {
	if(usr.allObj){
		pageScroll(0,0);
	}else{
		!!idName ? location.hash = idName : location.hash = "top";
	}
}


function toggle( targetId ){
  if (document.getElementById){
  		target = document.getElementById( targetId );
  			if (target.style.display == "none"){
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

function togglehide( targetId ){
  if (document.getElementById){
  		target = document.getElementById( targetId );
		target.style.display = "none";
  }
}

<!--
function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- Il campo '+nm+' deve contenere una e-mail.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- Il campo '+nm+' deve contenere un numero.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- Il campo '+nm+' č necessario.\n'; }
  } if (errors) alert('Sono stati riscontrati questi errori:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->

function nospam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}

function showPic (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder')
  .src = whichpic.href;
  if (whichpic.title) {
   document.getElementById('desc')
  .childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('desc')
  .childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  return false;
 } else {
  return true;
 }
}

function showPic2 (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder2')
  .src = whichpic.href;
  if (whichpic.title) {
   document.getElementById('desc2')
  .childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('desc2')
  .childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  return false;
 } else {
  return true;
 }
}



function showPic3 (whichpic) {
 if (document.getElementById) {
  document.getElementById('placeholder3')
  .src = whichpic.href;
  if (whichpic.title) {
   document.getElementById('desc3')
  .childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('desc3')
  .childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  return false;
 } else {
  return true;
 }
}

function popUp(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
window.open(strURL, 'newWin', strOptions);
}
