
lastImageNo = 0;
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imageNo, millisec) {
	folderName = ddBox[ddBox.selectedIndex].text;
	thumbs=ddBox[ddBox.selectedIndex].value;
	if(imageNo<=thumbs){
		imagefile="_images/activities-gallery/"+folderName+"/"+folderName+imageNo+".jpg";
		lastImageNo = imageNo;
	}else{
		imagefile="_images/activities-gallery/"+folderName+"/"+folderName+lastImageNo+".jpg";
	}
	
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function imgGallery(){
	ddBox = document.getElementById('clientList');
	tempBigImage = document.getElementById('blendimage');
	thumb1 = document.getElementById('dThumb1');
	thumb2 = document.getElementById('dThumb2');
	thumb3 = document.getElementById('dThumb3');
	thumb4 = document.getElementById('dThumb4');
	
	folderName = ddBox[ddBox.selectedIndex].text;
	thumbs=ddBox[ddBox.selectedIndex].value;
	url="_images/activities-gallery/"+folderName+"/"+folderName+"1.jpg";
	tempBigImage.src=url;
	
	if(thumbs==1){
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"1_thumb.jpg";
		thumb1.src=thumbURL;
		thumbURL="_images/activities-gallery/gray-thumb.JPG";
		thumb2.src=thumbURL;
		thumb3.src=thumbURL;
		thumb4.src=thumbURL;
	}else if(thumbs==2){
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"1_thumb.jpg";
		thumb1.src=thumbURL;
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"2_thumb.jpg";
		thumb2.src=thumbURL;
		thumbURL="_images/activities-gallery/gray-thumb.JPG";
		thumb3.src=thumbURL;
		thumb4.src=thumbURL;
	}else if(thumbs==3){
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"1_thumb.jpg";
		thumb1.src=thumbURL;
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"2_thumb.jpg";
		thumb2.src=thumbURL;
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"3_thumb.jpg";
		thumb3.src=thumbURL;
		thumbURL="_images/activities-gallery/gray-thumb.JPG";
		thumb4.src=thumbURL;		
	}else if(thumbs==4){
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"1_thumb.jpg";
		thumb1.src=thumbURL;
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"2_thumb.jpg";
		thumb2.src=thumbURL;
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"3_thumb.jpg";
		thumb3.src=thumbURL;
		thumbURL="_images/activities-gallery/"+folderName+"/"+folderName+"4_thumb.jpg";
		thumb4.src=thumbURL;
	}else if(thumbs==0){
		thumbURL="_images/activities-gallery/gray-thumb.JPG";
		thumb1.src=thumbURL;		
		thumb2.src=thumbURL;
		thumb3.src=thumbURL;
		thumb4.src=thumbURL;
		url="_images/activities-gallery/gray-img.JPG";
		tempBigImage.src=url;
	}
}

function showBig(thumbNo){
	thumbs=ddBox[ddBox.selectedIndex].value;
	if(thumbNo<=thumbs){
		url="_images/activities-gallery/"+folderName+"/"+folderName+thumbNo+".jpg";
		tempBigImage.src=url;
	}
}

function getGallery(){
	//imgURL = document.getElementById('slide1');
	//alert(imgURL.src);
	window.open('activities-gallery.html','_blank','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=758,height=619,left=200,top=200');
}