	var imagesid = 'blendimage';
	var millisec = 500;
	var timeout = 4000;
	var isPaused = true;
	var xmlDoc;
	var nodes;
	var imgID = 0;
	var ie=false;
	var moz=false;
  	var speed = Math.round(millisec / 100);
	var path='';

function navNext(navtype)
{		
	
	if(navtype == 'next'){
		imgID++;	
		if(imgID == nodes.length)imgID =0;			
	}else{//prev
		imgID--;
		if(imgID < 0)imgID=nodes.length-1;
	}	
					
	var nextNode = getFullPath(imgID);						
	blending(nextNode);	
}

function Status(myParent, myMessage){
	this.parent = myParent;
	this.message = myMessage;
	this.mystatus = false;
	this.onload;
	statuswin = document.createElement('div');
	statuswin.setAttribute('id','status');
	statuswin.innerHTML = "loading"
	statuswin.style.display ="block";
	//statuswin.style.top = getTop(anObject.firstChild)+anObject.firstChild.offsetHeight+2+'px';
	//statuswin.style.left = getLeft(anObject.firstChild)-100+'px';
	myParent.appendChild(statuswin);
this.statuswin = statuswin;
	
}
function done(aString){
	this.mystatus = true;
	this.parent.removeChild(this.statuswin);
}


function blending(navID)
{	
	oldImage = document.getElementById('oldImage');
	if (oldImage != null )niParent.removeChild(oldImage);
	curImage = document.getElementById(imagesid);	
	curImage.id="oldImage";	
	niParent = curImage.parentNode;	
	ni = new Image();	
	changeOpacObject(0,ni.style);	
	ni.src = navID;
	ni.id = imagesid;
	ni.style.position ="absolute";
	
			
	if(ie)
	{	
		if (ni.readyState == 'complete') showImage();
		else ni.onreadystatechange = function(){
				if (ni.readyState == 'complete') showImage()
			};	
	}else{
		ni.onload = showImage;
	}
	niParent.appendChild(ni);

	
}

function showImage(){
	
	var timer = 1; 
	for(i = 1; i <= 100; i++) {				
		setTimeout("changeOpac(" + i + ",'" + imagesid +"')",(timer * speed));		
		timer++;
		
	}	
}
function changeOpac(opacity, id) 
{
	var object = document.getElementById(id).style;	
    changeOpacObject(opacity,object);
}
function changeOpacObject(opacity,anObject){
	anObject.opacity = (opacity / 100);
    anObject.MozOpacity = (opacity / 100);
    anObject.KhtmlOpacity = (opacity / 100);
    anObject.filter = "alpha(opacity="+ opacity +")"; 
}

function photoSlideshow()
{
	if(isPaused==false){		
		isPaused=true;		
	}else{		
		isPaused = false;		
	} 		
	slidit();
}

function slidit()
{		
	if(isPaused==false){
		document.getElementById('slide_button').src = "../../images/stopslide.jpg";						
	}else{		
		document.getElementById('slide_button').src = "../../images/startslide.jpg";
		return;
	}	
	navNext('next');	
	setTimeout("slidit();",timeout);
}

function initAlbum(){
	
	strings = document.URL.split("?");
	loadXML(strings[1]);
}

function loadXML(xmlFileName){
	
	filename_sep_index = xmlFileName.lastIndexOf("/");
	if(filename_sep_index>-1){		
		path = xmlFileName.substring(0,filename_sep_index+1);	
		
	}
	if(document.implementation && document.implementation.createDocument){
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = loadImages;	
		moz=true;
	}else if (window.ActiveXObject){
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function(){
			if (xmlDoc.readyState == 4) loadImages()
		};		
		ie=true;
	}else
	{
		alert('Your browser can\'t handle this script');
		return;
	}	
	
	xmlDoc.async="false";
	xmlDoc.load(xmlFileName);	
}
function setInfo(){
	var info;	
	try{
	aTitle = xmlDoc.getElementsByTagName('title');
	aTitleValue = aTitle.item(0).firstChild.nodeValue;
	info="<h2>"+aTitleValue+"</h2>";
	}catch(object){}
	
	try{
	aLocation = xmlDoc.getElementsByTagName('location');
	aLocationValue = aLocation.item(0).firstChild.nodeValue;
	info=info+aLocationValue+"<br>";
	}catch(object){}
	
	try{
	aDate = xmlDoc.getElementsByTagName('date');
	aDateValue = aDate.item(0).firstChild.nodeValue;
	info=info+aDateValue+"<br>";
	}catch(object){}
	
	
	document.getElementById(imagesid).innerHTML = info;
}
function loadImages(){
	setInfo();
	nodes = xmlDoc.getElementsByTagName('image');
	blending(getFullPath(0));
	var anImage;
	for( i=1;i<nodes.length;i++){
		anImage = new Image();
		anImage.src = getFullPath(i);
		anImage.style.display = "none";
		anImage.name = anImage.src;
		document.body.appendChild(anImage);
		
	}
		
}

function getFullPath(anIndex){
	return path+nodes.item(anIndex).firstChild.nodeValue;
}

