var intervalCounter;
var currentSize;
var currentHeight;
var tempContent;
var totalHeight;

var onlyOnImages = true;
var isIE5 = document.all && document.getElementById;  // IE 5 or higher
var isMoz = !isIE5 && document.getElementById;  // Mozilla/Firefox

function cancelContextMenu(e)
{
	// Here you can add additional code that is executed when the context menu
	// is blocked. For instance you can use the following code to display a
	// message to the user:
	//alert("Please respect our copyright. Thank you!");

	if (e && e.stopPropagation)
	{
		e.stopPropagation();
	}
	return false;
}

function onContextMenu(e)
{
	if (!onlyOnImages || (isIE5 && event.srcElement.tagName.toLowerCase() == "img") || (isMoz && e.target.tagName.toLowerCase() == "img"))
	{
		return cancelContextMenu(e);
	}
}

window.onload = function()
{
	document.oncontextmenu = onContextMenu;
}

function rotateImage()
{
	if(totalHeight == null)
	{
		totalHeight = 0;
		for(var i = 1; i < divCount; i++)
		{
			totalHeight += document.getElementById("news" + i).clientHeight;
		}
	}

	if(totalHeight >= document.getElementById("homeNewsContainer").clientHeight)
	{
		//initialise the cleared div required height;
		if(currentHeight == null)
		{
			currentHeight = document.getElementById("news1").clientHeight;
			tempContent = document.getElementById("news1").innerHTML;
		}

		document.getElementById("news1").innerHTML = " ";
		document.getElementById("news1").style.height = currentHeight + "px";
		currentHeight-= 2;

		if(currentHeight <= 0 || divCount < 2)
		{
			for(var i = 2; i <= divCount; i++)
			{
				document.getElementById("news" + (i - 1)).innerHTML = document.getElementById("news" + i).innerHTML;
			}
			document.getElementById("news" + divCount).innerHTML = tempContent;

			document.getElementById("news1").style.height = "auto";

			currentHeight = null;
			window.setTimeout('rotateImage()',6000);
			return;
		}

		window.setTimeout('rotateImage()',5);
	}
}

