var goright_tag, goright_tag2, goright_incr, goright_timeout;
var goleft_tag, goleft_tag2, goleft_incr, goleft_timeout;
var gologo_tag, gologo_timeout, gologo_timeout_logo;
var gologo_images = new Array(5)

var t_left, t_right, t_logo;
var striscia_paused;

t_right = null;
t_left = null;
t_logo = null;

gologo_images[0] = new Image();
//gologo_images[0].src = 'images/HI5_Aurea_Flat_InnerBevel_Sloped_Burn.gif';
gologo_images[0].src = 'images/HI5_Aurea_Flat_Sfumato_Ombra.jpg';
gologo_images[1] = new Image();
gologo_images[1].src = 'images/Slogan5.jpg';
gologo_images[2] = new Image();
gologo_images[2].src = 'images/Slogan4.jpg';
gologo_images[3] = new Image();
gologo_images[3].src = 'images/Slogan3.jpg';
gologo_images[4] = new Image();
gologo_images[4].src = 'images/Slogan2.jpg';

function moveright(tag,tag2,incr,timeout)
{
	var nlpos;

	// tolgo gli a capo all'inizio e alla fine
	
	nlpos = tag.innerHTML.indexOf('<');
	if (nlpos != -1) {
		tag.innerHTML = tag.innerHTML.substr(nlpos);
	}
	nlpos = tag.innerHTML.lastIndexOf('>');
	if (nlpos != -1) {
		tag.innerHTML = tag.innerHTML.substr(0,nlpos);
	}

	// ripeto fino a riempimento del div contenitore
	
	while (tag.scrollHeight < tag.parentNode.clientWidth) {
		tag.innerHTML += tag.innerHTML;
	}
	
	tag2.innerHTML = tag.innerHTML;

	var curleft = tag.scrollHeight * -1;
	var curwidth = tag.scrollHeight;
	var curheight = tag.scrollWidth;

	var curleft2 = tag2.scrollHeight * -1 + curleft;
	var curwidth2 = tag2.scrollHeight;
	var curheight2 = tag2.scrollWidth;

	tag.style.left = curleft + 'px';
	tag.style.width = curwidth + 'px';
	tag.style.height = curheight + 'px';

	tag2.style.left = curleft2 + 'px';
	tag2.style.width = curwidth2 + 'px';
	tag2.style.height = curheight2 + 'px';

	goright_tag = tag;
	goright_tag2 = tag2;
	goright_incr = incr;
	goright_timeout = timeout;
	
	goright();
}

function moveleft(tag,tag2,incr,timeout)
{
	var nlpos;

	// tolgo gli a capo all'inizio e alla fine
	
	nlpos = tag.innerHTML.indexOf('<');
	if (nlpos != -1) {
		tag.innerHTML = tag.innerHTML.substr(nlpos);
	}
	nlpos = tag.innerHTML.lastIndexOf('>');
	if (nlpos != -1) {
		tag.innerHTML = tag.innerHTML.substr(0,nlpos);
	}

	// ripeto fino a riempimento del div contenitore
	
	while (tag.scrollHeight < tag.parentNode.clientWidth) {
		tag.innerHTML += tag.innerHTML;
	}
	
	tag2.innerHTML = tag.innerHTML;
	
	var curleft = tag.parentNode.clientWidth;
	var curwidth = tag.scrollHeight;
	var curheight = tag.scrollWidth;

	var curleft2 = tag2.parentNode.clientWidth + curwidth;
	var curwidth2 = tag2.scrollHeight;
	var curheight2 = tag2.scrollWidth;

	tag.style.left = curleft + 'px';
	tag.style.width = curwidth + 'px';
	tag.style.height = curheight + 'px';

	tag2.style.left = curleft2 + 'px';
	tag2.style.width = curwidth2 + 'px';
	tag2.style.height = curheight2 + 'px';

	goleft_tag = tag;
	goleft_tag2 = tag2;
	goleft_incr = incr;
	goleft_timeout = timeout;
	
	goleft();
}

function goright()
{
	if(striscia_paused==1)
	{
		return
	}
	var maxleft = goright_tag.parentNode.clientWidth;
	var curleft = parseInt(goright_tag.style.left);
	curleft += goright_incr;
	goright_tag.style.left = curleft + 'px';

	// accodo il tag1 al tag2

	if (curleft > maxleft) {
		goright_tag.style.left = parseInt(goright_tag2.style.left) - parseInt(goright_tag.style.width) + 'px';
	}

	var maxleft2 = goright_tag2.parentNode.clientWidth;
	var curleft2 = parseInt(goright_tag2.style.left);
	curleft2 += goright_incr;
	goright_tag2.style.left = curleft2 + 'px';

	// accodo il tag2 al tag1

	if (curleft2 > maxleft2) {
		goright_tag2.style.left = parseInt(goright_tag.style.left) - parseInt(goright_tag2.style.width) + 'px';
	}

	t_right = setTimeout('goright()',goright_timeout);
}

function goleft()
{
	if(striscia_paused==1)
	{
		return
	}
	var maxleft = goleft_tag.clientWidth * -1;
	var curleft = parseInt(goleft_tag.style.left);
	curleft -= goleft_incr;
	goleft_tag.style.left = curleft + 'px';

	// accodo il tag1 al tag2

	if (curleft < maxleft) {
		goleft_tag.style.left = parseInt(goleft_tag2.style.left) + parseInt(goleft_tag2.style.width) + 'px';
	}

	var maxleft2 = goleft_tag2.clientWidth * -1;
	var curleft2 = parseInt(goleft_tag2.style.left);
	curleft2 -= goleft_incr;
	goleft_tag2.style.left = curleft2 + 'px';

	// accodo il tag2 al tag1

	if (curleft2 < maxleft2) {
		goleft_tag2.style.left = parseInt(goleft_tag.style.left) + parseInt(goleft_tag.style.width) + 'px';
	}

	t_left = setTimeout('goleft()',goleft_timeout);
}

function changelogo(tag,timeout,timeout_logo)
{
	gologo_tag = tag;
	gologo_timeout = timeout * 1000;
	gologo_timeout_logo = timeout_logo * 1000;
	gologo();
}

function gologo()
{
	var imagenumber = gologo_tag.getAttribute('imagenumber');
	var showlogo = gologo_tag.getAttribute('showlogo');
	
	if (showlogo == '1') {
		gologo_tag.innerHTML = '<a href="http://humaninside.spreadshirt.net"><img src="' + gologo_images[0].src +'" border="0" alt="" width="600"></a>';
	}
	else {
		imagenumber = parseInt(imagenumber) + 1;
		if (imagenumber >= gologo_images.length) {
			imagenumber = 1;
		}
		gologo_tag.innerHTML = '<a href="http://humaninside.spreadshirt.net"><img src="' + gologo_images[imagenumber].src + '" border="0" alt=""></a>';
	}

	showlogo = (showlogo=='1')?'0':'1';

	gologo_tag.setAttribute('showlogo',showlogo);
	gologo_tag.setAttribute('imagenumber',imagenumber);

	t_logo = setTimeout('gologo()',(showlogo=='1')?gologo_timeout:gologo_timeout_logo);
}

function startstriscia()
{
	var tagstrisciatop = document.getElementById('strisciatop');
	var tagstrisciatop2 = document.getElementById('strisciatop2');

	var tagstrisciabot = document.getElementById('strisciabot');
	var tagstrisciabot2 = document.getElementById('strisciabot2');

	striscia_paused = 0;
	moveright(tagstrisciatop,tagstrisciatop2,2,50);
	moveleft(tagstrisciabot,tagstrisciabot2,2,50);
}

function stopleftright()
{
	striscia_paused = 1;
	clearTimeout(t_left);
	clearTimeout(t_right);
}

function restartleftright()
{
	stopleftright();
	striscia_paused = 0;
	goright();
	goleft();
}

window.onfocus=function()
{
	stopleftright();
	restartleftright();
}

function showbig(prodid)
{
	var tagbigpic = document.getElementById('bigpic');
	tagbigpic.innerHTML = '<img src="http://spreadshirt.net/image.php?type=image&partner_id=613020&product_id=' + prodid + '&img_id=1&size=huge&bgcolor_images=transparent" border="0">';
	tagbigpic.style.visibility = 'visible';
}

function hidebig()
{
	var tagbigpic = document.getElementById('bigpic');
	tagbigpic.style.visibility = 'hidden';
}

