<!--

function getRealLeft (obj)
{
	return obj.offsetLeft + (obj.offsetParent ? getRealLeft (obj.offsetParent) : 0);
}

function getRealTop (obj)
{
	return obj.offsetTop + (obj.offsetParent ? getRealTop (obj.offsetParent) : 0);
}

function float_in (stringa) {  return parseFloat (stringa.replace ('.', '').replace (',', '.'));  }
function float_out (decimale)
{
	decimale = (decimale * 100).toString ();
	return decimale.substr (0, decimale.length - 2) + ',' + decimale.substr (decimale.length - 2);
}

function t_animator_1 ()
{
	this.alto = null;
	this.iAlto = null;
	this.destra = null;
	this.iDestra = null;

	this.alto_x0 = null;
	this.alto_y0 = null;
	this.destra_x0 = null;
	this.destra_y0 = null;

	this.alto_dx = null;
	this.alto_dy = null;
	this.destra_dx = null;
	this.destra_dy = null;

	this.alto_x1 = 292;
	this.alto_y1 = 152;
	this.destra_x1 = 720;
	this.destra_y1 = 300;

	this.alto_w0 = 240;
	this.alto_w1 = 120;
	this.alto_dw = 0;

	this.destra_w0 = 240;
	this.destra_w1 = 80;
	this.destra_dw = 0;

	this.steps = 200;
	this.actual = 0;

	this.instanceName = null;

	this.nomi = new Array ();
	this.nomi [1] = 'magic';
	this.nomi [2] = 'yugioh';

	this.primo = null;
	this.secondo = null;

	this.start_up = function (instanceName)
	{
		this.instanceName = instanceName;
		this.setup ();
	}

	this.setup = function ()
	{
		var oDiv = null, oImg = null;

		if (oImg = document.getElementById ('base_1'))
		{
			oDiv = document.getElementById ('spazio_1');
			oDiv.style.left = getRealLeft (oImg) - 1;
			oDiv.style.top = getRealTop (oImg) - 1;
			oDiv.style.visibility = 'visible';

			oImg.src = '/1.gif';

			oImg = document.getElementById ('base_2');

			oDiv = document.getElementById ('spazio_2');
			oDiv.style.left = getRealLeft (oImg) - 1;
			oDiv.style.top = getRealTop (oImg) - 1;
			oDiv.style.visibility = 'visible';

			oImg.src = '/1.gif';
		}

		oImg = document.getElementById ('base_alto')
		this.alto_x1 = getRealLeft (oImg);
		this.alto_y1 = getRealTop (oImg);

		oImg = document.getElementById ('base_destra')
		this.destra_x1 = getRealLeft (oImg) + 22;
		this.destra_y1 = getRealTop (oImg) + 8;
	}

	this.muovi = function (primo, secondo)
	{
		if ((primo != null)  &&  (secondo != null))
		{
			this.primo = primo;
			this.secondo = secondo;

			this.alto = document.getElementById ('spazio_' + primo);
			this.destra = document.getElementById ('spazio_' + secondo);

			this.iAlto = document.getElementById ('immagine_' + primo);
			this.iDestra = document.getElementById ('immagine_' + secondo);

			this.alto.style.zIndex = 3;
			this.destra.style.zIndex = 2;

			this.alto_x0 = parseInt (this.alto.style.left);
			this.alto_y0 = parseInt (this.alto.style.top);

			this.destra_x0 = parseInt (this.destra.style.left);
			this.destra_y0 = parseInt (this.destra.style.top);

			this.alto_dx = (parseFloat (this.alto_x1) - parseFloat (this.alto_x0)) / this.steps;
			this.alto_dy = (parseFloat (this.alto_y1) - parseFloat (this.alto_y0)) / this.steps;

			this.destra_dx = (parseFloat (this.destra_x1) - parseFloat (this.destra_x0)) / this.steps;
			this.destra_dy = (parseFloat (this.destra_y1) - parseFloat (this.destra_y0)) / this.steps;

			this.alto_w0 = parseInt (this.iAlto.width);
			this.alto_dw = (parseFloat (this.alto_w1) - parseFloat (this.alto_w0)) / this.steps;

			this.destra_w0 = parseInt (this.iDestra.width);
			this.destra_dw = (parseFloat (this.destra_w1) - parseFloat (this.destra_w0)) / this.steps;

			this.actual = 1;
		}

		if (this.actual <= this.steps)
		{
			this.alto.style.left = this.alto_x0 + (this.alto_dx * this.actual);
			this.alto.style.top = this.alto_y0 + (this.alto_dy * this.actual);

			this.destra.style.left = this.destra_x0 + (this.destra_dx * this.actual);
			this.destra.style.top = this.destra_y0 + (this.destra_dy * this.actual);

			this.iAlto.width = this.alto_w0 + (this.alto_dw * this.actual);
			this.iDestra.width = this.destra_w0 + (this.destra_dw * this.actual);

			if (this.actual == this.steps)
			{
				//document.getElementById ('titolo_alto').style.visibility = 'visible';
				//document.getElementById ('titolo_destra').style.visibility = 'visible';

				//this.iAlto.src = '/img/' + this.nomi [this.primo] + 'grande.jpg';
				//this.iDestra.src = '/img/' + this.nomi [this.secondo] + '.jpg';

				loading ();

				setTimeout ('document.location = "cartesciolte.asp?tipo=' + this.nomi [this.primo] + '";', 10);

				return;
			}

			this.actual = this.actual + 1 + Math.sin (((this.actual / this.steps) + 0.7) * 1.8) * 8;
			if (this.actual > this.steps) this.actual = this.steps;

			setTimeout (this.instanceName + '.muovi ();', 0);
		}
	}

	this.mossa = function (primo, secondo)
	{
		this.primo = primo;
		this.secondo = secondo;

		this.alto = document.getElementById ('spazio_' + primo);
		this.destra = document.getElementById ('spazio_' + secondo);

		this.iAlto = document.getElementById ('immagine_' + primo);
		this.iDestra = document.getElementById ('immagine_' + secondo);

		this.alto.style.left = this.alto_x1;
		this.alto.style.top = this.alto_y1;

		this.destra.style.left = this.destra_x1;
		this.destra.style.top = this.destra_y1;

		this.iAlto.width = this.alto_w1;
		this.iDestra.width = this.destra_w1;

		this.iAlto.src = '/img/' + this.nomi [this.primo] + 'grande.jpg';
		this.iDestra.src = '/img/' + this.nomi [this.secondo] + '.jpg';

		this.alto.style.visibility = 'visible';
		this.destra.style.visibility = 'visible';

		var tmp = null;
		if (tmp = document.getElementById ('tmp_alto')) tmp.src = "/1.gif";
	}

	this.resizing = function ()
	{
		if (this.alto)
		{
			var oImg = null;

			oImg = document.getElementById ('base_alto')
			this.alto_x1 = getRealLeft (oImg);
			this.alto_y1 = getRealTop (oImg);

			this.alto.style.left = this.alto_x1;
			this.alto.style.top = this.alto_y1;

			oImg = document.getElementById ('base_destra')
			this.destra_x1 = getRealLeft (oImg) + 22;
			this.destra_y1 = getRealTop (oImg) + 8;

			this.destra.style.left = this.destra_x1;
			this.destra.style.top = this.destra_y1;
		}
		else this.setup ();
	}
}

function compari (nome)
{
	if (obj = document.getElementById ('cuscino')) obj.src = '/images/' + nome;
	setTimeout ("if (obj = document.getElementById ('coperta')) obj.style.visibility = 'visible';", 50);
}

function scompari ()
{
	if (obj = document.getElementById ('coperta')) obj.style.visibility = 'hidden';
	if (obj = document.getElementById ('cuscino')) obj.src = '/images/loading_new.gif';
}

function loading () {  compari ('loading_new.gif');  }

function azzera_form (f)
{
	f.f0.value = '';
	f.f1.selectedIndex = 0;
	f.f2.selectedIndex = 0;
	f.f3.selectedIndex = 0;
	f.f4.selectedIndex = 0;
	f.f5.selectedIndex = 0;
}

function obbligo (campo, nome)
{
	if (campo && campo.value == '')
	{
		window.alert ("Attenzione: tutti i campi sono obbligatori\n\nPer completare devi inserire il  " + nome + "");
		campo.focus ();
		return false;
	}
	return true;
}

function isEmail (email)
{
	var punta_in = email.indexOf ('<');
	var punta_out = email.lastIndexOf ('>');

	if (punta_in < 0)
	{
		if (punta_out >= 0) return false;
	}
	else
	{
		if (punta_in > punta_out) return false;
		else email = email.substring (punta_in + 1, punta_out);
	}

	if (email.indexOf (' ') >= 0) return false;
	if (email.indexOf ('.') <= 0) return false;
	if (email.indexOf ('@') <= 0) return false;
	if (email.indexOf ('..') >= 0) return false;
	if (email.indexOf ('.@') >= 0) return false;
	if (email.indexOf ('@.') >= 0) return false;

	var tmp1 = email.split ('@');
	if (tmp1.length != 2) return false;

	var tmp2 = tmp1 [1].split ('.');
	if (tmp2.length < 2) return false;

	if (tmp2 [tmp2.length - 1].length < 2) return false;

	return true;
}

function valida (f)
{
	if (player.cesta.items.length == 0)
	{
		window.alert ("Attenzione: il tuo carrello è vuoto ! \n Per prenotare devi prima scegliere gli articoli che desideri.");
		return;
	}

	if (!obbligo (f.nome, 'tuo nome')) return;
	if (!obbligo (f.cognome, 'tuo cognome')) return;
	if (!obbligo (f.provincia, 'nome della tua provincia')) return;
	if (!obbligo (f.paese, 'nome del tuo paese')) return;
	if (!obbligo (f.indirizzo, 'tuo indirizzo')) return;
	if (!obbligo (f.email, 'tuo indirizzo e-mail')) return;
	if (!obbligo (f.telefono, 'tuo numero di telefono')) return;

	if (!isEmail (f.email.value))
	{
		window.alert ("Attenzione: l' indirizzo e-mail che hai inserito non è corretto.");
		f.email.focus ();
		return;
	}

	if (!window.confirm ("Stai per effettuare la prenotazione degli articoli\n\nConfermi l' invio ?")) return;

	f.action = 'conferma.asp';
	f.submit ();
}

// -->
