var dimensioneSchermoW = 0;
var dimensioneSchermoH = 0;
var posX = 0;
var posY = 0;

var scostamento = 0;
var posIntroX = 0;
var posIntroY = 0;
var dimensioneIntroW = 0;
var dimensioneIntroH = 0;

window.onload = function()
{
	PosizionaElementi();
	window.status = "Germano Zama - bsdsoftware.it";
	
	VerificaVersioneFlash();	
	//document.onmousemove = GestisciFotoSchermo;
}

window.onresize = function()
{
	PosizionaElementi();
}

function VerificaVersioneFlash()
{
	if (! DetectFlashVer(10, 0, 0))
	{
		if (confirm("Attenzione: per un corretto funzionamento del sito e' necessaria l'installazione di Adobe Flash Player 10.\nSi desidera visitare la pagina di Adobe per il download del software?"))
		{
			window.open("http://get.adobe.com/it/flashplayer/", "AdobeFlashPlayer");
			return;
		}
	}
}

//ridimensiona e riposiziona gli elementi
function PosizionaElementi()
{
  if (isNaN(window.scrollY))
	{
		dimensioneSchermoW = document.body.clientWidth;
		dimensioneSchermoH = document.body.clientHeight;
	}
	else
	{
		dimensioneSchermoW = window.innerWidth;
		dimensioneSchermoH = window.innerHeight;
	}
	
	//immagine intro
	var divIntro = document.getElementById("divIntro");
	
	var dimensioneInternoW = 808;
	var dimensioneInternoH = 500;
	
	//alert(dimensioneInternoH + " - " + dimensioneSchermoH);
	
	divIntro.style.left = ((dimensioneSchermoW - dimensioneInternoW) / 2) + "px";
	if (dimensioneInternoH > dimensioneSchermoH)
		divIntro.style.top = "0px";
	else
		divIntro.style.top = ((dimensioneSchermoH - dimensioneInternoH) / 2) + "px";
}

//link sito bsd
function LinkBSD()
{
	window.open("http://www.bsdsoftware.it", "BSDSoftware");	
}

//ingresso al sito
function Entra(lingua)
{
  if (! DetectFlashVer(10, 0, 0))
  {
    switch (lingua)
    {
      case "it":
        if (confirm("Attenzione: per un corretto funzionamento del sito e' consigliata la presenza di Adobe Flash Player 10 installato.\nSi desidera visitare la pagina di Adobe per il download del software?"))
        {
          window.open("http://get.adobe.com/it/flashplayer/", "AdobeFlashPlayer");
          return;
        }
      break;
      case "en":
        if (confirm("Caution: for proper operation of the site is recommended the presence of the Adobe Flash Player 10 installed.\nDo you wish to visit Adobe site to download the software?"))
        {
          window.open("http://get.adobe.com/it/flashplayer/", "AdobeFlashPlayer");
          return;
        }
      break;
    }
    
  }
  
  
  
  
  window.location.href = "./menu/home2011AI.html?lang=" + lingua;
}

function GestisciFotoSchermo(e)
{
	var divIntro = document.getElementById("divIntro");
	var divFooter = document.getElementById("footer");
	
	if (divIntro == null)
		return;
	
	if (! e) 
		e = window.event;

	posX = (e.pageX) ? e.pageX : e.clientX;
	posY = (e.pageY)? e.pageY : e.clientY;
	
	if (posY >= dimensioneSchermoH - divFooter.clientHeight)
		return;
	
	scostamento = 0;
	posIntroX = parseInt(divIntro.style.left.replace("px", ""), 10);
	posIntroY = parseInt(divIntro.style.top.replace("px", ""), 10);
	dimensioneIntroW = divIntro.clientWidth;
	dimensioneIntroH = divIntro.clientHeight;
	
	if (posX > dimensioneSchermoW / 2)
	{
		scostamento = (posX - dimensioneSchermoW / 2) / 30;
		
		if (posIntroX - scostamento + dimensioneIntroW <= dimensioneSchermoW)
			divIntro.style.left = dimensioneSchermoW - dimensioneIntroW;
		else
			divIntro.style.left = posIntroX - scostamento;
	}
	else
	{
		scostamento = (dimensioneSchermoW / 2 - posX) / 30;
		
		if (posIntroX + scostamento >= 0)
			divIntro.style.left = "0px";
		else
			divIntro.style.left = posIntroX + scostamento;
	}
	
	if (posY > dimensioneSchermoH / 2)
	{
		scostamento = (posY - dimensioneSchermoH / 2) / 30;
		
		if (posIntroY - scostamento + dimensioneIntroH <= dimensioneSchermoH)
			divIntro.style.top = dimensioneSchermoH - dimensioneIntroH;
		else
			divIntro.style.top = posIntroY - scostamento;
	}
	else
	{
		scostamento = (dimensioneSchermoH / 2 - posY) / 30;
		
		if (posIntroY + scostamento >= 0)
			divIntro.style.top = "0px";
		else
			divIntro.style.top = posIntroY + scostamento;
	}
}

//fan gz
function FanGZFB()
{
	window.open("http://www.facebook.com/pages/GERMANO-ZAMA/180429297233?ref=search&sid=1098437407.30861849..1", "FanGZFB");
}
