/***********************************************************************************************
	Copyright (c) 2005 - Alf Magne Kalleland post@dhtmlgoodies.com
	UPDATE LOG:
	March, 10th, 2006 : Added support for a message while large image is loading
	Get this and other scripts at www.dhtmlgoodies.com
	You can use this script freely as long as this copyright message is kept intact.
***********************************************************************************************/ 
	
var displayWaitMessage=true;	// Display a please wait message while images are loading?

var activeImage = false;
var imageGalleryLeftPos = false;
var imageGalleryWidth = false;
var imageGalleryObj = false;
var maxGalleryXPos = false;
var slideSpeed = 0;
var direction = '';
var sliderTimer = null;

function startSlide(e)
{
	if (document.all) e = event;
	// var img = this.getElementsByTagName('IMG')[0];
	// img.src = '/shared/pics/beautytalk/0209/make-up/'+img.name+'_akt.gif';
	direction = this.id;
	if (this.id=='arrow_right') {
		slideSpeedMultiply = Math.floor((e.clientX - 927) / 5) + 4;
		slideSpeed = Math.min(0,Math.max(-10,-slideSpeedMultiply));
	} else {			
		slideSpeedMultiply = 6 - Math.floor((e.clientX - 225) / 5);
		slideSpeed = Math.max(0,Math.min(10,slideSpeedMultiply));
	}
	if (!sliderTimer) sliderTimer = setInterval('gallerySlide();',25);
}

function releaseSlide()
{
	// var img = this.getElementsByTagName('IMG')[0];
	// img.src = '/shared/pics/beautytalk/0209/make-up/'+img.name+'.gif';
	slideSpeed=0;
	clearInterval(sliderTimer);
	sliderTimer = null;
}
	
function gallerySlide()
{
	if (slideSpeed!=0) {
		var leftPos = parseInt(imageGalleryObj.offsetLeft);
		leftPos += slideSpeed;
		if (leftPos<maxGalleryXPos) {
			leftPos = maxGalleryXPos;
			slideSpeed = 0;
		}
		if (leftPos>minGalleryXPos) {
			leftPos = minGalleryXPos;
			slideSpeed=0;
		}
		imageGalleryObj.style.left = leftPos + 'px';
	}
}

function showImage()
{
	this.style.opacity='0.8';
	this.style.filter='alpha(opacity=80)';
}
function fadeImage()
{
	this.style.opacity='1.0';
	this.style.filter='alpha(opacity=100)';
}

function initSlideShow()
{
	document.getElementById('arrow_left').onmousemove = startSlide;
	document.getElementById('arrow_left').onmouseout = releaseSlide;
	document.getElementById('arrow_right').onmousemove = startSlide;
	document.getElementById('arrow_right').onmouseout = releaseSlide;
	
	imageGalleryObj = document.getElementById('theImages');
	imageGalleryLeftPos = imageGalleryObj.offsetLeft;
	imageGalleryWidth = document.getElementById('galleryContainer').offsetWidth - 30;
	minGalleryXPos = imageGalleryObj.offsetLeft; 
	maxGalleryXPos = imageGalleryWidth - document.getElementById('slideEnd').offsetLeft + minGalleryXPos;
	$$('div.image').each(function(v) { v.onmouseover = showImage; v.onmouseout = fadeImage; v.onclick = showDuft; });
}

addOnLoad(initSlideShow);


