<!--
/*BOF5678901234567890123456789012345678901234567890123456789012345678901234567*/
/*******************************************************************************
    Project       : P308237
    File          : PictureSeriesFunctions.js
    Path          : DOCROOT/inc/js
    Creation Date : 2009-01-01
    Last Update   : 2009-01-01
    Status        : productive
    Version       : 1.0
    (c) Copyright : All rights reserved by Codewalk ICT Consulting.
                    In particular, partial or complete copying or usage
                    of the following content requires prior written approval
                    of Codewalk ICT Consulting.
*******************************************************************************/
/*------------------------------------------------------------------------------
	installs the picture series client controller
------------------------------------------------------------------------------*/
window.addEventListener?window.addEventListener('load',initialisiereBereich,false):window.attachEvent('onload',initialisiereBereich);
var dias = new Array();
var leftAlign = new Array();
var current = 0, count = 0, pos = 0;
var pushDistance = 5;
var leftMarginOverlap = 0;
/*----------------------------------------------------------------------------*/
function initialisiereBereich()
{
	handleWindowResizeEvent();
	dias = document.getElementById('PictureSeriesSection').getElementsByTagName('img');
	count = dias.length;
	if ( count < 2 ) return;
	for ( i = 0; i < count; i++ )
	{
		dias[i].style.position = 'absolute';
		dias[i].style.left = '1000px';
		dias[i].style.top = '0px';
		dias[i].style.zIndex = 3;
		leftAlign[i] = 0;
	}
	setTimeout(wechseleDia,0);
}
/*----------------------------------------------------------------------------*/
function wechseleDia()
{
	pos -=pushDistance;
	if ( pos >= -leftMarginOverlap )
	{
		dias[current].style.left = pos+'px';
		setTimeout(wechseleDia,20);
	}
	else
	{
		pos = 1000;
		dias[current].style.left = '-'+leftMarginOverlap+'px';
		dias[current].style.zIndex = 3;
		if ( current == 0 ) dias[count -1].style.left = '1000px';
		else dias[current -1].style.left = '1000px';
		if ( current == count -1) current = 0; else current++;
		dias[current].style.zIndex = 4;
		overlap(current);
		setTimeout(wechseleDia,10000);
	}
}
/*----------------------------------------------------------------------------*/
function overlap (index)
{
	/*
	percent = document.getElementById("PictureSeriesSection").style.width;
	leftMarginOverlap = parseInt(dias[index].width -
		window.innerWidth*(1 - parseInt(percent.substr(0,percent.indexOf("%")))/100)) * leftAlign[index];
	*/
	leftMarginStr  = document.getElementById("PictureSeriesSection").style.left;
	leftMargin     = parseInt(leftMarginStr.substr(0,leftMarginStr.indexOf("px")));
	rightMarginStr = document.getElementById("PictureSeriesSection").style.right;
	rightMargin    = window.innerWidth - parseInt(rightMarginStr.substr(0,rightMarginStr.indexOf("px")));
	leftMarginOverlap = (dias[index].width - rightMargin + leftMargin) * (1 - leftAlign[index]);
	if ( isNaN(leftMarginOverlap)) leftMarginOverlap = 0;
	if ( leftMarginOverlap < 0 ) leftMarginOverlap = 0;
	else leftMarginOverlap = parseInt(leftMarginOverlap/(2 - leftAlign[index]));
}
/*-------------------------------------------------------------------------EOF*/
-->
