function xbGetWindowWidth(windowRef)
{
  var width = 0;
  if (!windowRef)
  {
    windowRef = window;
  }
 
  if (typeof(windowRef.innerWidth) == 'number')
  {
    width = windowRef.innerWidth;
  }
  else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number')
  {
    width = windowRef.document.body.clientWidth;  
  }
    
  return width;
}

function xbGetWindowHeight(windowRef)
{
  var height = 0;
  
  if (!windowRef)
  {
    windowRef = window;
  }

  if (typeof(windowRef.innerWidth) == 'number')
  {
    height = windowRef.innerHeight;
  }
  else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number')
  {
    height = windowRef.document.body.clientHeight;    
  }
  return height;
}

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

function viewFoto(img){
  width=foto1.width+30;
  height=foto1.height+30;
  
  if (window.screen && window.screen.width) {
	  stringa="width="+Math.min(window.screen.width - 100, width)+",height="+Math.min(window.screen.height-100, height)+',scrollbars=yes,resizable=yes';
  } else {
	  stringa="width="+width+",height="+height;
  }
  finestra=window.open(img,"",stringa);
}

