
var cartwindow = '';
var mapwindow = '';
var profilewindow = '';
var zoomwindow = '';
var ftpwindow = '';
var newwindow = '';

function popitup(obj,url,name,setup)
{
	newwindow = obj;
	
	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,name,setup);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

function ftp()
{
  return popitup(ftpwindow,url_ftp,"cart","scrollbars=yes,menubar=no,resizable=yes,width=500,height=400,top=50,left=100")
}

function cart()
{
  return popitup(cartwindow,url_cart,"cart","scrollbars=yes,menubar=no,resizable=yes,width=600,height=450,top=50,left=400")
}

function map()
{
  return popitup(mapwindow,url_map,"map","scrollbars=yes,menubar=no,resizable=yes,width=600,height=500,top=50,left=400")
}

function profile()
{
  return popitup(profilewindow,url_profile,"profile","scrollbars=yes,menubar=no,resizable=yes,width=400,height=250,top=150,left=100")
}

/*
function zoom(id)
{
  return popitup(zoomwindow,url_zoom + id,"zoom","scrollbars=yes,menubar=no,resizable=yes,width=650,height=750,top=30,left=200")
}
*/

//modificato per aprire sempre in una finestra diversa
function zoom(id)
{
  return popitup(zoomwindow,url_zoom + id,id,"scrollbars=yes,menubar=no,resizable=yes,width=650,height=750,top=30,left=200")
}

function getInnerHeight(win) {
  var winHeight;
  if (win.innerHeight) {
    winHeight = win.innerHeight;
  }
  else if (win.document.documentElement && win.document.documentElement.clientHeight) {
    winHeight = win.document.documentElement.clientHeight;
  }
  else if (win.document.body) {
    winHeight = win.document.body.clientHeight;
  }
  return winHeight;
}

function setIframeHeight(iframeName,h) {

  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  
  if ( iframeEl && iframeWin && h>100) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
	iframeEl.style.height = h  + "px";
  }
}

function loadIframe(iframeName, url) {
    window.frames[iframeName].location = url;   
}

var timer_id;
function scroll_iframe(frm,inc,dir) {
  if (timer_id) clearTimeout(timer_id);
  if (window.frames[frm]) {
    if (dir == "v") window.frames[frm].scrollBy(0, inc);
    else window.frames[frm].scrollBy(inc, 0);
    timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20);
  }
}

function stopScroll() { if (timer_id) clearTimeout(timer_id); }


