/************************************************************************************************************
Ajax dynamic content
Copyright (C) November, 2005  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/	
var slideshow2_noFading1 = false;
var slideshow2_timeBetweenSlides1 = 1000;	// Amount of time between each image(1000 = 1 second)
var slideshow2_fadingSpeed1 = 10;	// Speed of fading	(Lower value = faster)


var slideshow2_stats1 = new Array();

var slideshow2_slideIndex1 = new Array();	// Index of current image shown
var slideshow2_slideIndexNext1 = new Array();	// Index of next image shown
var slideshow2_imageDivs1 = new Array();	// Array of image divs(Created dynamically)
var slideshow2_currentOpacity1 = new Array();	// Initial opacity
var slideshow2_imagesInGallery1 = new Array();	// Number of images in gallery
var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
function createParentDivs1(imageIndex,divId)
{
	if(imageIndex==slideshow2_imagesInGallery1[divId]){	
		showGallery1(divId);
	}else{
		var imgObj = document.getElementById(divId + '_' + imageIndex);	
		if(Opera)imgObj.style.position = 'static';
		if(!slideshow2_imageDivs1[divId])slideshow2_imageDivs1[divId] = new Array();
		slideshow2_imageDivs1[divId][slideshow2_imageDivs1[divId].length] =  imgObj;

		imgObj.style.visibility = 'hidden';	
		imageIndex++;
		createParentDivs1(imageIndex,divId);	
	}		
}

function showGallery1(divId)
{
	if(slideshow2_slideIndex1[divId]==-1)slideshow2_slideIndex1[divId]=0; else slideshow2_slideIndex1[divId]++;	// Index of next image to show
	if(slideshow2_slideIndex1[divId]==slideshow2_imageDivs1[divId].length)slideshow2_slideIndex1[divId]=0;
	slideshow2_slideIndexNext1[divId] = slideshow2_slideIndex1[divId]+1;	// Index of the next next image
	if(slideshow2_slideIndexNext1[divId]==slideshow2_imageDivs1[divId].length)slideshow2_slideIndexNext1[divId] = 0;

	
	slideshow2_currentOpacity1[divId]=100;	// Reset current opacity

	// Displaying image divs
	slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.visibility = 'visible';
	if(Opera)slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.display = 'inline';
	if(navigator.userAgent.indexOf('Opera')<0){
		slideshow2_imageDivs1[divId][slideshow2_slideIndexNext1[divId]].style.visibility = 'visible';
	}
	
	if(document.all){	// IE rules
		slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.filter = 'alpha(opacity=100)';
		slideshow2_imageDivs1[divId][slideshow2_slideIndexNext1[divId]].style.filter = 'alpha(opacity=1)';
	}else{
		slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs1[divId][slideshow2_slideIndexNext1[divId]].style.opacity = 0.01;
	}		
	

	setTimeout('revealImage1("' + divId + '")',slideshow2_timeBetweenSlides1);		
}

function revealImage1(divId)
{

	if(slideshow2_noFading1){
		slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.visibility = 'hidden';
		if(Opera)slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.display = 'none';
		showGallery1(divId);
		return;
	}
	slideshow2_currentOpacity1[divId]--;
	if(document.all){
		slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.filter = 'alpha(opacity='+slideshow2_currentOpacity1[divId]+')';
		slideshow2_imageDivs1[divId][slideshow2_slideIndexNext1[divId]].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity1[divId])+')';
	}else{
		slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.opacity = Math.max(0.01,slideshow2_currentOpacity1[divId]/100);	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs1[divId][slideshow2_slideIndexNext1[divId]].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity1[divId]/100)));
	}
	if(slideshow2_currentOpacity1[divId]>0){
		setTimeout('revealImage1("' + divId + '")',slideshow2_fadingSpeed1);
	}else{
		slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.visibility = 'hidden';	
		if(Opera)slideshow2_imageDivs1[divId][slideshow2_slideIndex1[divId]].style.display = 'none';		
		showGallery1(divId);
	}
}

function initImageGallery1(divId)
{
	var slideshow2_galleryContainer1 = document.getElementById(divId);
	//alert(slideshow2_galleryContainer1);
	
	slideshow2_slideIndex1[divId] = -1;
	slideshow2_slideIndexNext1[divId] = false;
	
	var galleryImgArray = slideshow2_galleryContainer1.getElementsByTagName('IMG');
	
	for(var no=0;no<galleryImgArray.length;no++)
	{
		galleryImgArray[no].id = divId + '_' + no;
		//alert(galleryImgArray[no].id);
	}
	
	slideshow2_imagesInGallery1[divId] = galleryImgArray.length;
	createParentDivs1(0,divId);		
	
}

