var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false
var dom=(document.getElementById && !document.all)? true:false
var isMac = (navigator.appVersion.indexOf("Mac") != -1); // 
var isOver='si' //   variabile  per  vedere se  sono su un layer oppure no
var timerID=10

image1 = new Image();
image1.src = "/site/images/en/bottling_on.gif";
image2 = new Image();
image2.src = "/site/images/extra_on.gif";
image3 = new Image();
image3.src = "/site/images/after_on.gif";
image4 = new Image();
image4.src = "/site/images/it/after_on.gif";
image5 = new Image();
image5.src = "/site/images/it/extra_on.gif";
image6 = new Image();
image6.src = "/site/images/box_on_p.gif";
image7 = new Image();
image7.src = "/site/images/box_on_p.gif";

//  funzioni show/hide
function nascondo(quale) {
  if (ie4) {document.all[quale].style.visibility="hidden"}
  if (ns4) {document.layers[quale].visibility="hide"}
  if (dom) {document.getElementById(quale).style.visibility="hidden"}
}

function vedo(quale) { 
  clearTimeout(timerID);
  timerId=null;
  if (ns4) {document.layers[quale].visibility="show" }
  if (ie4) {document.all[quale].style.visibility="visible"}
  if(dom) {document.getElementById(quale).style.visibility="visible"}
  
}  
      
// funzione  scrivi in un layer    
function scrivi(quale,stringa) {

  if (ie4) {document.all[quale].innerHTML=stringa}
  else if (ns4) {
     with (document.layers[quale].document) {
      open();
      write(stringa);
      close();
    }  
	}
	else {document.getElementById(quale).innerHTML=stringa}
	
}

// per muovere un layer
function moveTo(quale,x,y) {
  if(ie4) {
    document.all[quale].style.left = x+1;
    document.all[quale].style.top = y;
  }
  else if(ns4) {
    document.layers[quale].left = x+1;
    document.layers[quale].top = y;
  }
  else {
    document.getElementById(quale).style.left = x+1;
    document.getElementById(quale).style.top = y;
  }
}



function layerWidth(quale,what) {
  if (dim==1) {dim="auto"}
  if (ie4) {document.all[quale].style.width=dim}
  else if (ns4) {document.layers[quale].document.width=dim}
  else {document.getElementById(quale).style.width=dim}
}
  



 
function getIdProperty( id, property )
{
    if (dom)
    {
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            if (styleObject[property])
            {
                return styleObject[ property ];
            }
        }
        styleObject = getStyleBySelector( "#" + id );
        return (styleObject != null) ?
            styleObject[property] :
            null;
    }
    else if (ns4)
    {
        return document[id][property];
    }
    else
    {
        return document.all[id].style[property];
    }
}

/*
 *
 * Given an id and a property (as strings), set
 * the given property of that id to the value provided.
 *
 * The property is set directly on the tag, not in the
 * stylesheet.
 *
 */
function setIdProperty( id, property, value )
{
    if (dom)
    {
        var styleObject = document.getElementById( id );
        if (styleObject != null)
        {
            styleObject = styleObject.style;
            styleObject[ property ] = value;
        }
        
    }
    else if (ns4)
    {
        document[id][property] = value;
    }
    else if (ie4)
    {
         document.all[id].style[property] = value;
    }
}



function getStyleBySelector( selector )
{
    if (!dom)
    {
        return null;
    }
    var sheetList = document.styleSheets;
    var ruleList;
    var i, j;

    /* look through stylesheets in reverse order that
       they appear in the document */
    for (i=sheetList.length-1; i >= 0; i--)
    {
        ruleList = sheetList[i].cssRules;
        for (j=0; j<ruleList.length; j++)
        {
            if (ruleList[j].type == CSSRule.STYLE_RULE &&
                ruleList[j].selectorText == selector)
            {
                return ruleList[j].style;
            }   
        }
    }
    return null;
}


function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
  function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
  function MM_findObj(n, d) { //v4.0
    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 && document.getElementById) x=document.getElementById(n); return x;
    }
  function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
	
	
	function apri(URL,name,w,h) {
	
 	  var main_opts = "location=0,scrollbars=0,status=1,resizable=0,directories=0,menubar=0"; 
      var this_opts = main_opts + ',width=' + w + ',height=' + h ;
      var this_win = open(URL,name,this_opts) ;
      	if (window.focus ) {
   			this_win.focus();
  		}
	}
	
	
	
	// show due imma
	function showImmaHome(num,sez,box) {
	
	    if (document.images) {
         document.images["box"+num].src = "/site/images/"+box+".gif";
	     document.images["sez"+num].src = "/site/images/"+sez+".gif";
        return true;
	   }
    }
	
	
// becco  piu posozioni
function getPos() {
  
  curHold="holdspace"
  if (ie4) { 
    xPos=document.images[curHold].offsetLeft;
    yPos=document.images[curHold].offsetTop;
  }
  else if (ns4) { 
    xPos=document.images[curHold].x;
    yPos=document.images[curHold].y;
  }
  else if (dom) { 
    el = document.getElementById(curHold);
    xPos=el.offsetLeft;
    yPos=el.offsetTop;
  }
  return xPos;yPos;
}
	
	
	// variabili per determinare la dimensione disponibile della finestra
var myWidth = 0
var myHeight = 0;

function getWinSize() {
   if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
    }
  }
  return myWidth;myHeight;
}



function vai(){
    index=document.scelta.lingua.selectedIndex
	dove=document.scelta.lingua.options[index].value
    location.href=dove+"index.htm"
}

function vaiPhp(){
    index=document.scelta.lingua.selectedIndex
	dove=document.scelta.lingua.options[index].value
    location.href=dove
}
function area(){
    index=document.scelta.lingua.selectedIndex
	dove=document.scelta.lingua.options[index].value
    location.href=dove
}
function getWidth(quale) { 
if(document.getElementById) {
  curW=document.getElementById(quale).offsetWidth
}
if(ns4)curW=document.layers[quale].document.width
return curW
}
function getHeight(quale) { 
if(document.getElementById) {
	curH=document.getElementById(quale).offsetHeight 
return curH 
}
} 


// funzione che serve per scrivere un immagine in un pop-up
function scriviWin(tit,imma,w,h) {
  var win_opts = "location=0,scrollbars=0,status=0,resizable=0,directories=0,menubar=0"; 
  var all_opts = win_opts + ',width=' + w + ',height=' + h ;
  var win = open("","immaWin",all_opts) ;
  with (win.document) {
    open("text/html", "replace");
    write("<HTML><HEAD><TITLE>"+tit+"</TITLE></HEAD><BODY marginwidth=\"0\" marginheight=\"0\" leftmargin=\"0\" topmargin=\"0\" bottommargin=\"0\" rightmargin=\"0\"><img src='"+imma+"' border='0'></BODY></HTML>");
    close();
  }
}




function openDati(w,h,path) {
  var win_opts = "location=0,scrollbars=0,status=0,resizable=0,directories=0,menubar=0,top="+0+",left="+0+",screenY="+0+",screenX="+0; 
  var all_opts = win_opts + ',width=' + w + ',height=' + h ;
  var win = open(path,"immaWin",all_opts) ;
 }
 
 
 //stampa  pagina
 function printPage() {
  var agt=navigator.userAgent.toLowerCase();
  if (window.print) {
    setTimeout('window.print();',200);
	}
	else if (agt.indexOf("mac") != -1) {
    alert("Press 'Cmd+p' on your keyboard to print article.");
	}
	else {
    alert("Press 'Ctrl+p' on your keyboard to print article.")
	}
}
  
  
function goTo(brand,subP){
  location.href='/site/'+brand+'/modelli.php?brand='+brand+'&page=prodotti&sub='+subP+'&lang='+lang
}



function openPop(brand,subP){



  var win_opts = "location=0,scrollbars=auto,status=0,resizable=0,directories=0,menubar=0,width=300,height=250,top="+0+",left="+0+",screenY="+0+",screenX="+0; 
  path="/site/"+brand+"/pop.php?brand="+brand+"&page=pop&sub="+subP+"&lang="+lang
  var win = open(path,"immaWin",win_opts) ;
 }




