////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	dHTML Picture Wiper
//	dhtmlpicwipe.js, version 1.02.02
//	Copyright (c) 2000 Elements Interactive BV
//	All rights reserved
//
//	MIME-type: application/x-javascript
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var NS = document.layers;
var IE = document.all;
var CLIP_TOP = 0;
var CLIP_RIGHT = 1;
var CLIP_BOTTOM = 2;
var CLIP_LEFT = 3;
var lastyachtclip = new Array(0, 0, 0, 0);
var thisyachtclip = new Array(0, 0, 0, 0);

if(NS)
{
	init_innerWidth		= window.innerWidth;
	init_innerHeight	= window.innerHeight;
	window.onresize		= ns_myresize; // Netscape CSS resize bugfix

	for(i=0; i<PICS; i++)
		wipegetdiv('randomyacht_' + (i)).top = (SIZEY/2) - (wipegetdiv('randomyacht_' + (i)).clip.height) / 2;
}
else if(IE)
{
	for(i=0; i<PICS; i++)
	{
		//wipegetdiv('randomyacht_' + (i)).pixelTop = ((SIZEY/2) - (eval('document.all.randomyacht_' + (i)).offsetHeight / 2));
		ie_setclip('randomyacht_' + (i), 0, SIZEX, SIZEY, 0)
	}
}


function displayphoto(nr)
{
	if(nr - 1 >= 0)
		hidenr = nr - 1;
	else
		hidenr = PICS - 1;

	wipegetdiv('randomyacht_' + (nr)).visibility = 'visible';
	wipegetdiv('randomyacht_' + (nr)).zIndex = 999;
	wipegetdiv('randomyacht_' + (hidenr)).zIndex = 0;

	if(NS)
	{
		with(wipegetdiv('randomyacht_' + (nr)).clip)
		{
			top		= SIZEY / 2;
			bottom	= SIZEY / 2;
			left	= SIZEX / 2;
			right	= SIZEX / 2;
		}
	}
	else if(IE)
	{
		// Reset to default
		ie_setclip('randomyacht_' + (nr), SIZEY/2, SIZEX/2, SIZEY/2, SIZEX/2)

		// Get values
		thisyachtclip = ie_getclip(eval('document.all.randomyacht_' + (nr)).style.clip);
		lastyachtclip = ie_getclip(eval('document.all.randomyacht_' + (hidenr)).style.clip);
	}

	// Wipe!
	wipe(nr, hidenr);

	nr++;
	if(nr >= PICS)
		nr = 0;

	displaytimer = setTimeout('displayphoto(' + (nr) + ')', INTERVAL);
}

function wipe(nr, hidenr)
{
	var stoptimer = 0;
	if(NS)
	{
		with(wipegetdiv('randomyacht_' + (nr)).clip)
		{
			top		-= WIPE_IN_STEP;
			left	-= WIPE_IN_STEP;
			right	+= WIPE_IN_STEP;
			bottom	+= WIPE_IN_STEP;

			with(wipegetdiv('randomyacht_' + (hidenr)).clip)
				if(right >= 0)
				{
					top+=WIPE_OUT_STEP;
					left+=WIPE_OUT_STEP;
					right-=WIPE_OUT_STEP;
					bottom-=WIPE_OUT_STEP;
				}

			if(left <= 0)
				stoptimer = 1;
		}
	}
	else if(IE)
	{
		thisyachtclip[CLIP_TOP]		-= WIPE_IN_STEP;
		thisyachtclip[CLIP_LEFT]	-= WIPE_IN_STEP;
		thisyachtclip[CLIP_RIGHT]	= parseInt(thisyachtclip[CLIP_RIGHT]) + WIPE_IN_STEP;
		thisyachtclip[CLIP_BOTTOM]	= parseInt(thisyachtclip[CLIP_BOTTOM]) + WIPE_IN_STEP;
		
		if(lastyachtclip[CLIP_RIGHT] > 0)
		{
			lastyachtclip[CLIP_TOP]		= parseInt(lastyachtclip[CLIP_TOP]) + WIPE_OUT_STEP;
			lastyachtclip[CLIP_LEFT]	= parseInt(lastyachtclip[CLIP_LEFT]) + WIPE_OUT_STEP;
			lastyachtclip[CLIP_RIGHT]	-= WIPE_OUT_STEP;
			lastyachtclip[CLIP_BOTTOM]	-= WIPE_OUT_STEP;
		}
		
		ie_setclip('randomyacht_' + (nr), thisyachtclip[CLIP_TOP], thisyachtclip[CLIP_RIGHT], thisyachtclip[CLIP_BOTTOM], thisyachtclip[CLIP_LEFT])
		ie_setclip('randomyacht_' + (hidenr), lastyachtclip[CLIP_TOP], lastyachtclip[CLIP_RIGHT], lastyachtclip[CLIP_BOTTOM], lastyachtclip[CLIP_LEFT])

		if(thisyachtclip[CLIP_LEFT] <= 0)
			stoptimer = 1;
	}

	if(!stoptimer)
		wipetimer = setTimeout('wipe(' + (nr) + ',' + (hidenr) + ')', 25);
	else
		wipegetdiv('randomyacht_' + (hidenr)).visibility = 'hidden';
}


function ie_setclip(layername, top, right, bottom, left)
{
	var obj = eval('document.all.' + (layername)).style.clip = 'rect(' + (top) + 'px,' + (right) + 'px,' + (bottom) + 'px,' + (left) + 'px)';
}


function wipegetdiv(objname)
{
	if(NS)
		return(document.layers['randomyachtholder'].document.layers[objname]);
	else
		if(eval('document.all.' + (objname)))
			return(eval('document.all.' + (objname) + '.style'));
}

function ie_getclip(mystr)
{
	var clipvalue = new Array('', '', '', '');
	var rec = 0;
	var counter = 0;
	for(var i=0; i<mystr.length; i++)
	{                       
		token = mystr.substring(i, i+1);
		if(token == 'p')
		{
			rec = 0;
			counter++;
		}
		if(rec == 1)
			clipvalue[counter] += token;
		if (token == "(" || token == " ")
			rec = 1;
	}

	return clipvalue;
}

function ns_myresize()
{
	if(init_innerWidth != window.innerWidth || init_innerHeight	!= window.innerHeight)
		document.location = document.location;
}

