﻿<!--
/*
	HTML Flickers 8
	Code: Ivar Uibo <ivar.uibo@kuldnebors.ee>
	(c) AS Sanoma Baltics 2009
*/
	
var iCurrentPage = -1;
var iSkipPostIndex = -1;
var bAutoFlip = true;
var iAutoFlipDelay = 5000; // ms
var iAutoFlipId = null;

function focusPost(iIndex)
{
	setAutoFlip(false);

	var dImage = document.getElementById('image_' + iIndex);
	var aLink = document.getElementById('link_' + iIndex);
	var tdContainer = document.getElementById('td_' + iIndex);
	dImage.style.border = '1px solid #e80f0e';
	aLink.style.color = '#e80f0e';
	aLink.style.textDecoration = 'underline';
	tdContainer.style.cursor = 'hand';
}

function blurPost(iIndex)
{
	var dImage = document.getElementById('image_' + iIndex);
	var aLink = document.getElementById('link_' + iIndex);
	var tdContainer = document.getElementById('td_' + iIndex);
	dImage.style.border = '1px solid #cac276';
	aLink.style.color = '#000000';
	aLink.style.textDecoration = 'none';
	tdContainer.style.cursor = 'none';
}

function showPost(iIndex)
{
	if (iIndex != iSkipPostIndex)
	{
		var aLink = document.getElementById('link_' + iIndex);
		window.open(aLink);
	}
	else
	{
		iSkipPostIndex = -1;
	}
}

function showPage(iIndex)
{
	if (iIndex != iCurrentPage)
	{
		if (iCurrentPage > -1)
		{
			var dCurrentPage = document.getElementById('page_' + iCurrentPage);
			dCurrentPage.style.visibility = 'hidden';
			var imgCurrentScroller = document.getElementById('scroller_' + iCurrentPage);
			imgCurrentScroller.style.border = '1px solid transparent';
			imgCurrentScroller.style.backgroundColor = '';
		}
		var dNewPage = document.getElementById('page_' + iIndex);
		dNewPage.style.visibility = 'visible';
		var imgNewScroller = document.getElementById('scroller_' + iIndex);
		imgNewScroller.style.border = '1px solid #000000';
		imgNewScroller.style.backgroundColor = '#e80f0e';
		iCurrentPage = iIndex;
	}

	if (bAutoFlip)
		iAutoFlipId = setTimeout('flipPage(1)', iAutoFlipDelay);
}

function setAutoFlip(bState)
{
	bAutoFlip = bState;

	if (bAutoFlip)
		iAutoFlipId = setTimeout('flipPage(1)', iAutoFlipDelay);
	else if (!bAutoFlip && (iAutoFlipId != null))
		clearTimeout(iAutoFlipId);
}

function flipPage(iDirection)
{
	var iPage = iCurrentPage + iDirection;

	if (iPage == -1)
	{
		iPage = 0;
	}
	else if (iPage == 8)
	{
		if (bAutoFlip)
			iPage = 0;
		else
			iPage = 7;
	}

	showPage(iPage);
}

function skipPost(iIndex)
{
	iSkipPostIndex = iIndex;
}
	
//-->
