//PhotoGallery
function PrevFoto(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,100);
  }
}

function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+25;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}
//Show
function Show(id){
if(document.getElementById){
    document.getElementById(id).style.display="block";
}
}
//Hide
function Hide(id){
if(document.getElementById){
    document.getElementById(id).style.display="none";
    }
}
//Show&Hide
function ShowHide(id){
if(document.getElementById){
	var el=document.getElementById(id);
	el.style.display = (el.style.display=="block") ? "none" : "block";
}
}
/*FontSwitcher*/
function setFontSwitcher(){
size=getCookie("fontsize");             //reperisce il cookie
if(size!=null) SetFontSize(size);       //setta le impostazioni
}
function SetFontSize(s){
document.getElementsByTagName('body')[0].style.fontSize=s;
setCookie("fontsize",s,30);
}
function setCookie(name, value, expdays) {   //memorizza il cookie
var now = new Date();
var exp = new Date(now.getTime() + (1000*60*60*24*expdays));
document.cookie = name + "=" + escape(value) + ";" + "expires=" + exp.toGMTString() + ";" + "path=/";
}
function getCookie(name) {    //restituisce il cookie
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
    var start = dc.indexOf(cname);
    if (start != -1) {
        start += cname.length;
        var stop = dc.indexOf(";", start);
        if (stop == -1) stop = dc.length;
        return unescape(dc.substring(start,stop));
        }
    }
return null;
}
/*WriteEmailAddress*/
function sendmail(user, domain) {
  // protocol
  var p = "\u006d\u0061\u0069\u006c\u0074\u006f\u003a";
  // usename
  var u = user;
  // domain name (host name sans machine name)
  var d = domain ||
          location.host.substring(
            location.host.lastIndexOf(
              ".",
              location.host.lastIndexOf(".") - 1
            ) + 1
          );
  void(top.location = p + u + "\u0040" + d);
  return false;
}
/*Fade effects*/
function initImage(objId){
image = document.getElementById(objId);
setOpacity(image, 0);
image.style.visibility = 'visible';
fadeIn(objId,0);
}
function setOpacity(obj,opacity){
opacity=(opacity==100) ? 99.999 : opacity;
obj.style.filter = "alpha(opacity:"+opacity+")";// IE/Win
obj.style.KHTMLOpacity = opacity/100;// Safari&lt;1.2, Konqueror
obj.style.MozOpacity = opacity/100;// Older Mozilla and Firefox
obj.style.opacity = opacity/100;// Safari 1.2, newer Firefox and Mozilla, CSS3
}
function fadeIn(objId,opacity){
if(!document.getElementById) return;
obj = document.getElementById(objId);
//if(opacity <= 100){
setOpacity(obj,opacity);
//opacity += 10;
//window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);}
}
//la temporarizzazione e l' opacità finale sono state leggermente cambiate
function fadeOut(objId,opacity){
if(!document.getElementById) return;
obj = document.getElementById(objId);
//if(opacity >= 30){
setOpacity(obj,opacity);
//opacity -= 10;
//window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 50);}
}
//funzione aggiunta: fadeOut e fadeIn al passaggio del mouse
function setFade(objId){
el=document.getElementById(objId);
setOpacity(el,70);
el.onmouseout=function(){fadeOut(objId,70)};
el.onmouseover=function(){fadeIn(objId,100)};
}
//Dropdown menu
function setMenuList() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("primarymenulist");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
/*New Slideshow */
var mySlideShow1 = new SlideShow(mySlideList1, 'slide1', 4000, "mySlideShow1",2,13);
var mySlideShow2 = new SlideShow(mySlideList2, 'slide2', 4000, "mySlideShow2",2,3);
function SlideShow(slideList, image, speed, name, duration, slidetype)          
{
  this.slideList = slideList;
  this.image = image;
  this.duration = duration;
  this.slidetype = slidetype;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
}
SlideShow.prototype.play = SlideShow_play;  
function SlideShow_play()       
{
  with(this)
  {
    if(current++ == slideList.length-1) current = 0;
	 if (document.all){
	document.images[image].style.filter="revealTrans(duration="+duration+",transition="+slidetype+")";
	document.images[image].filters.revealTrans.Apply();
	 }
    switchImage(image, slideList[current]);
	//clearTimeout(timer);
	if (document.all){
	document.images[image].filters.revealTrans.Play()
	}
    timer = setTimeout(name+'.play()', speed);
  }
}
function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}
/*Page_Onload*/
function initialize(){
	//setMenuList()
	setFontSwitcher();
	/*if (document.images.ExtraSlideShow) SetExtraSlideShow();
	if (document.images.ExtraSlideShow) runExtraSlideShow();
	if (document.images.AssicurazioniSlideShow) SetAssicurazioniSlideShow();
	if (document.images.AssicurazioniSlideShow) runAssicurazioniSlideShow();
	if (document.getElementById) setFade("minibannerimg");*/
}
