/*   special offers boxes scroll up to hide offer scroll down to show next off   */

var current_box = 'special-1';
var total_no_boxes = 20;
var count = 2;

function on_load()
{
	// loop through each special offer box and hide it
	for (var i = 2; i <= total_no_boxes; i++)
	{
		// if we have a special offer box
		if (document.getElementById('special-'+i))
		{
			// hide special off box
			document.getElementById('special-'+i).style.display = 'none';
		}
	}
	
	// if we have only one box then don't run show_hide
	// else if we have more than one special offer box run show_hide
	if (document.getElementById('special-2'))
	{
		setTimeout("show_hide('special-2');", 6500);
	}
}

function show_hide(div_id)
{
	// if we have a special offer box
	if (document.getElementById(div_id))
	{
		// remove current box
		document.getElementById(current_box).style.display = 'none';
		
		// display new box
		document.getElementById(div_id).style.display = 'block';
		
		// set current box to new box
		current_box = div_id;
		
		// increase box number
		count++;
	}
	
	// if the count is greater than the number of boxes
	// or we don't have a special offer box then reset the count to the first box
	if (count > total_no_boxes || !document.getElementById(div_id))
	{
		count = 1;
	}
	
	// set the timer to loop to the next box every 20 seconds
	setTimeout("show_hide('special-'+count);", 6500);
}

Behaviour.addLoadEvent(function() {on_load()});
