function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function() {
		if (oldonload) {
			oldonload();
		}
		func();
		}
	}
}

/* slideshow configuration */
var photoSrcs = new Array();
var imgFrame;
var imgIndex = 0;
var	imgCount = 0;
var imgsContainer = 'galery_images_container'; //hidden div ID where we gona place all images for the slide show
var slideShowContainer = 'slide_show_container';
var imgFrameId = 'galery_slide_show_frame'; //img tag ID for the slide show frame
var imgFrame; //img tag object variable
var imgFrameW = 849; //slide show frame width
var imgFrameH = 637; //slide show frame heigth
var imgDelay = 3000; //ms to delay between images 

/* slideshow configuration */

function runGalerySlideShow(){		
	var imgContainer = document.getElementById(imgsContainer);
	var tempObj;
	
	if(imgContainer){
		for(var i = 0; i < imgContainer.childNodes.length; i++){
			tempObj = imgContainer.childNodes[i];
			if(tempObj.nodeName == 'IMG'){
				photoSrcs.push(tempObj.getAttribute('src'));
			}
		}			
	}
	imgCount = photoSrcs.length;
	if(imgCount > 0){
		drawSlideShowFrame();
		imgFrame = document.getElementById(imgFrameId);
		if(imgFrame){			
			startGalerySlideShow();
		}
	}
}
	
function startGalerySlideShow(){
	if(imgFrame){
		imgFrame.setAttribute('src', photoSrcs[imgIndex]);
		var t = setTimeout("startGalerySlideShow()", imgDelay);
		imgIndex++;
		if(imgCount == imgIndex){
			imgIndex = 0;
		}
	}
}

function drawSlideShowFramePreLoad(){
	var slideCont = document.getElementById(slideShowContainer);
	if( slideCont ){		
		slideCont.innerHTML = '<div style="width:'+imgFrameW+'px; height:'+imgFrameH+'px; text-align: center;"><div style="padding-top: '+((imgFrameH/2)-22)+'px;">Slide Show Loading...</div></div>';	
	}
}

function drawSlideShowFrame(){
	var slideCont = document.getElementById(slideShowContainer);
	if( slideCont ){
		slideCont.innerHTML = '<img id="galery_slide_show_frame" width="'+imgFrameW+'" height="'+imgFrameH+'" src="'+photoSrcs[0]+'"/>';
	}
}

function doNothing(src){
		var bim;
}
	
addLoadEvent(runGalerySlideShow);
