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()
{
	if (isNaN(window.scrollY))
	{
		dimensioneSchermoW = document.body.clientWidth;
		dimensioneSchermoH = document.body.clientHeight;
	}
	else
	{
		dimensioneSchermoW = window.innerWidth;
		dimensioneSchermoH = window.innerHeight;
	}
	
	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()
{
	//immagine intro
	var divIntro = document.getElementById("divIntro");
	
	var dimensioneInternoW = 2000;
	var dimensioneInternoH = 1792;
	
	//alert(dimensioneInternoH + " - " + dimensioneSchermoH);
	
	divIntro.style.left = ((dimensioneSchermoW - dimensioneInternoW) / 2) + "px";
	/*
	if (dimensioneInternoH > dimensioneSchermoH)
		divIntro.style.top = "0px";
	else
	*/
		divIntro.style.top = "0px";//((dimensioneSchermoH - dimensioneInternoH) / 2) + "px";
}

//link sito bsd
function LinkBSD()
{
	window.open("http://www.bsdsoftware.it", "BSDSoftware");	
}

//ingresso al sito
function Entra(sito)
{
	if (sito)
		window.location.href = "./menu/home2010P.html";
	else
		window.open("http://www.germanozamashop.com", "GermanoZamaShop");	
}

//fan gz
function FanGZFB()
{
	window.open("http://www.facebook.com/pages/GERMANO-ZAMA/180429297233?ref=search&sid=1098437407.30861849..1", "FanGZFB");
}

function on_MouseMove(e) 
{
	
	if (!e) var e = window.event;

	alert(e.clientX);
	return false;
	
}

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;
	}
}