


function getHeightOfSponsors ()
{

	var dec = $('sponsorsquare_inner').immediateDescendants();
	
	return dec.length - 1;
}





function rotateSponsors (numSponsors)
{
	var elem = $('sponsorsquare_inner');
	
	var teller = 60;
	
	
	var steps = (numSponsors * 9) + 8;
	
	for (i = 0; i <= steps; i++)
	{
		if (i % 9 == 0 && i != 0)
		{
			teller += 7000;
			setTimeout("margintop()",teller);
		}
		
		setTimeout("margintop()",teller);
		
		teller += 60;
	}
	
	setTimeout("margintopis('-3')",teller+60);
	
	setTimeout("rotateSponsors("+numSponsors+")",teller+120);
	
}


function margintopis (margin)
{
	$('sponsorsquare_inner').style.marginTop = margin+"px";
}


function margintop ()
{
	var marTop = $('sponsorsquare_inner').style.marginTop;
	$('sponsorsquare_inner').style.marginTop = (marTop.substr(0,marTop.length - 2) - 4) + "px";
	
	
}










document.observe("dom:loaded", function () {
	
	setSponsorBottom();
	
	if ($('sponsorsquare'))
	{
		margintopis('-3');
		var heightSponsors = getHeightOfSponsors();
		rotateSponsors(heightSponsors);
	}
	
});



if (navigator.appVersion.indexOf("MSIE") != -1)
{
	window.onscroll=setSponsorBottom;
}
else
{
	Event.observe(document, 'scroll', function() {
		setSponsorBottom();
	});
}




function setSponsorBottom () {
	var y1 = $('thesponsorsquare').cumulativeScrollOffset();
	var y2 = document.viewport.getDimensions();
	var y = y1[1];
	var x = y2['height'];
	
	$('thesponsorsquare').style.marginTop = (x+y-44)+'px';
}





