function dynaCat(cat, state){
	var catlink = cat + 'a';
	if (state == 'a'){
		document.getElementById(catlink).style.borderColor = '#f00';
	} else {
		document.getElementById(catlink).style.borderColor = '#fff';
	}
}
var current_pop = '';

function ShowPopout(id){
return(Popout(id, '-25px'));
}
function HidePopout(id){
	document.getElementById(id).style.display="none";
	current_pop = "";
return(false);
}


function Popout(id, top){
	if (current_pop != '') { 
		HidePopout(current_pop); 
	}
	if (id){
		document.getElementById(id).style.display="block";
	}
	current_pop = id;
return(false);
}

function hide_reveal(idh, idd){
document.getElementById(idh).style.display = 'none';
	if (document.getElementById(idd)){
		document.getElementById(idd).style.display = 'block';
	} else {
		document.getElementById('W1').style.display = 'block';	
	}
}
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, imagefile, millisec) {
	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 startPools(){
	rotatePool('Pool1');
}

function startPool(pool, ic){
	window.clearTimeout(timers[pool]);
	var target = 'Div' + pool;
	if (pool == 'Pool1') { parray = Pool1; }
	if (pool == 'Pool2') { parray = Pool2; delay = 7000}
	if (pool == 'Pool3') { parray = Pool3; delay = 3000}		
	if (pool == 'Pool4') { parray = Pool4; delay = 6000}		

	pCtr[pool] = ic;

	
	document.getElementById(target).innerHTML = document.getElementById('holder').innerHTML

	document.getElementById(pool).src = parray[ic].src;


	document.getElementById('slideControl').style.display = 'block';
	if (parray[ic].title) desc = desc + '<h1>' + parray[ic].title + '</h1>';

	if (parray[ic].description) desc = desc + parray[ic].description;

	document.getElementById('PhotoDescription').innerHTML = desc;
	var ic = ic + 1;
	
	document.getElementById('slideCount').innerHTML = 'Image ' + ic + ' of ' + parray.length;
	delay = 0;
	rotatePool(pool);
	return(false);
}

var timers = Array();

var pCtr = Array();

var delay = default_delay = 30000;
function rotatePool(pool){


var fade_speed = 1000;

	if (document.images){
		if (document.images){
			var image_counter = pCtr[pool];
			if (pool == 'Pool1') { parray = Pool1; }
			if (pool == 'Pool2') { parray = Pool2; delay = 7000}
			if (pool == 'Pool3') { parray = Pool3; delay = 3000}		
			if (pool == 'Pool4') { parray = Pool4; delay = 6000}		
			
			if (parray.length > 1){
				if (parray[image_counter].src == '') {
					parray[image_counter].src = parray[image_counter].loadsrc;
				}
				var pdiv = 'Div' + pool;

				blendimage(pdiv, pool, parray[image_counter].src, fade_speed);
				document.getElementById(pool).title = parray[image_counter].title;

				var desc = '';

				if (parray[image_counter].title) desc = desc + '<h1>' + parray[image_counter].title + '</h1>';
				var ic = image_counter + 1;
				if (parray[image_counter].description) desc = desc + parray[image_counter].description;
				
				document.getElementById('PhotoDescription').innerHTML = desc;
				document.getElementById('slideCount').innerHTML = 'Image ' + ic + ' of ' + parray.length;


				image_counter++;
				if (image_counter == parray.length){
					image_counter = 0;
				}
				pCtr[pool] = image_counter;

				timers[pool]=window.setTimeout('rotatePool("'+pool+'")',delay);
				if (parray[image_counter].src == '') {
					parray[image_counter].src = parray[image_counter].loadsrc;
				}
				delay = default_delay;
			}
		}
	}
}
function npPool(pool,direction){
var fade_speed = 500;
	window.clearTimeout(timers[pool]);
	if (document.images){
		if (document.images){
			image_counter = pCtr[pool];

			if (pool == 'Pool1') { parray = Pool1; }
			if (pool == 'Pool2') { parray = Pool2; delay = 7000}
			if (pool == 'Pool3') { parray = Pool3; delay = 3000}		
			if (pool == 'Pool4') { parray = Pool4; delay = 6000}		
			
			if (parray.length > 1){
				var pdiv = 'Div' + pool;
				if (direction == 'prev'){
					image_counter = image_counter-=2;
					if (image_counter < 0){
						image_counter = parray.length;
					}				
				} 
				pCtr[pool] = image_counter;
				if (parray[image_counter].src == '') {
					parray[image_counter].src = parray[image_counter].loadsrc;
				}
				timers[pool]=window.setTimeout('rotatePool("'+pool+'")',0);
			}
		}
	}
}


function pausePool(pool){
	window.clearTimeout(timers[pool]);
	document.getElementById('slideControl').style.backgroundImage="url(Images/go_bg.png)";	
}
function togglePool(pool){
	if (timers[pool]){ 
		window.clearTimeout(timers[pool]);
		timers[pool] = false;
		document.getElementById('slideControl').style.backgroundImage="url(Images/go_bg.png)";	
	} else {
		rotatePool('Pool1');	
		document.getElementById('slideControl').style.backgroundImage="url(Images/pause_bg.png)";	

	}
}


function replace_image (el, image){
document.getElementById(el).src = image;
return(false);
}


function rotatePoolOld(pool){

    var delay = 4000;
	if (document.images){
		
	
		if (document.all) {	
			document.getElementById(pool).style.filter="blendTrans(duration=2)";
			document.getElementById(pool).style.filter="blendTrans(duration=crossFadeDuration)";
			document.getElementById(pool).filters.blendTrans.Apply();
		}
	
		if (document.images){
			image_counter = pCtr[pool];
			if (pool == 'Pool1') { parray = Pool1; }
			if (pool == 'Pool2') { 
				parray = Pool2; 
				delay = 4000;
			}
			if (pool == 'Pool3') { parray = Pool3; delay = 3000}		
			if (pool == 'Pool4') { parray = Pool4; delay = 6000}		
			
			if (parray.length > 1){
				document.getElementById(pool).src = parray[image_counter].src;
	
		
				if (document.all) {
					document.getElementById(pool).filters.blendTrans.Play();
				}
		
				image_counter++;
				if (image_counter == parray.length){
					image_counter = 0;
				}
				pCtr[pool] = image_counter;

				timers[pool]=window.setTimeout('rotatePool("'+pool+'")',delay);
			}
			
		}
	}
}

function replace_image (el, image){
document.getElementById(el).src = image;
return(false);
}

SwapLimage.current = "LeftImage0";
function SwapLimage(id){
	id = 'LeftImage' + id;
document.getElementById(SwapLimage.current).style.display = "none";
document.getElementById(id).style.display = "block";
SwapLimage.current = id;
}

function thumbnailView(pool, url){
	window.clearTimeout(timers[pool]);
	var target = 'Div' + pool;
	document.getElementById('holder').innerHTML = document.getElementById(target).innerHTML

	var request = HTTP.newRequest();
	request.onreadystatechange = function() {
		if (request.readyState==4) { 
			if (request.status == 200){
				var x = request.responseText.indexOf("<body");
				x = request.responseText.indexOf(">", x);    
				var y = request.responseText.lastIndexOf("</body"); 
				var item = request.responseText.slice(x + 1, y);
				document.getElementById(target).style.backgroundImage = "url()";
				document.getElementById('PhotoDescription').innerHTML = '';
				document.getElementById('slideControl').style.display = 'none';

				document.getElementById(target).innerHTML = item;
			}
		}
	}
	request.open("GET", url, true);
	request.setRequestHeader("User-Agent", "XMLHttpRequest");
	request.send(null);



return(false);


}


function debugMsg(msg){
	document.getElementById('debug').style.display = 'block';
	document.getElementById('debug').innerHTML = document.getElementById('debug').innerHTML + msg + '<br />' ;

}
