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



//  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 = eval(x);
   
    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];
    }
}

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 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) ;
}

function openDatiCent(w,h,t,path) {
    l=(screen.availWidth-w-30)/2
  
	var win_opts = "location=0,scrollbars=0,status=0,resizable=0,directories=0,menubar=0,top="+t+",left="+l+",screenY="+t+",screenX="+l; 
	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) ;
}

function openMap(brand){

  	w=screen.availWidth-10
	h=screen.availHeight-58
	if(w>1200)ratio=1.97
	else ratio=1.75
	h=w/ratio

    
	openDati(w,h,'/crm/report/rete/reteFast.php?web=1&brand='+brand)
}
function rollout(obj) {
	obj.className=obj.className.replace(new RegExp(" sfhover\\b"), "");
}

function rollon (obj){
	obj.className +=" sfhover";
}