function loadXMLDoc(dname) 
{
	var xmlDoc;
	window.i=0;
	window.dofade=1;
	if (window.XMLHttpRequest)
  	{
  	xmlDoc=new window.XMLHttpRequest();
  	xmlDoc.open("GET",dname,false);
  	xmlDoc.send("");
  	return xmlDoc.responseXML;
  	}
// IE 5 and IE 6
	else if (ActiveXObject("Microsoft.XMLDOM"))
  	{
  	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  	xmlDoc.async=false;
  	xmlDoc.load(dname);
  	return xmlDoc;
  	}
	alert("Error loading document");
	return null;
}

function next()
{
	if (window.i<window.x.length-1)
  	{
  	window.i++;
  	}else{
	window.i=0;
	}
	
	 //display();
	 showbig(window.i);
}

function previous()
{
	if (window.i>0)
  	{
  	window.i--;
  	}else{
	window.i=window.x.length-1;
	}
	
	//display();
	showbig(window.i);
}

function getxml(dname,myroot){
	
  window.xmlDoc=loadXMLDoc(dname);	
  window.x=xmlDoc.getElementsByTagName(myroot);
  display();
  displaythumbs();
}

function getxmlthumbs(dname,myroot){
	
  window.xmlDoc=loadXMLDoc(dname);	
  window.x=xmlDoc.getElementsByTagName(myroot);
  displaythumbs();
}

function showbig(nodenum){
	
	
	bigpic=getnodevalue("BIG",nodenum);
	mytitle=getnodevalue("TITLE",nodenum);
	medium=getnodevalue("MEDIUM",nodenum);
	size=getnodevalue("SIZE",nodenum);
	myedition=getnodevalue("EDITION",nodenum);
	window.i=nodenum;
	mywalltag="<div id='walltag'><span class='bigtitle'>\""+mytitle+"\"</span><br><span class='smalltitle'>"+medium+"<br>"+size+"<br>"+myedition+"</span></div>";

	mycontrol="<tr><td align=center class='controltext'><br><a class='myclick' onclick='window.dofade=0;previous();'>&lt; previous</a> &nbsp;&nbsp;  <a class='myclick' onclick='hidebig();'>(close)</a>  &nbsp;&nbsp; <a class='myclick' onclick='window.dofade=0;next();'>next &gt;</a><br><br></td><td>&nbsp;</td><td>&nbsp;</td></tr>";
	document.getElementById("bigpicholder").innerHTML="<center><table><tr><td><a class='myclick' onclick='hidebig();'><img id='imagebig' src="+bigpic+" border=0 align='middle' ></a></td><td>&nbsp;</td><td>"+mywalltag+"</td></tr>"+mycontrol+"</table></center>";
	
	
	if(window.dofade==1){
		document.getElementById("bigpicholder").style.opacity=0.0;
		document.getElementById("bigpicholder").style.filter="alpha(opacity=0)";
		window.mySlide = window.setInterval("fadeup('bigpicholder')",20);
		window.fadeamount=0;
	}
	showhidethumb('thumbholder',window.dofade);
}
function hidebig(){
	window.dofade=1;
	showhidethumb('thumbholder',1);
	document.getElementById("bigpicholder").innerHTML="";
	
}
function showhidethumb(whichdiv,visamount){
	document.getElementById(whichdiv).style.opacity=visamount;
	document.getElementById(whichdiv).style.filter="alpha(opacity="+visamount*100+")";
}

function fadeup(whichdiv){
	window.fadeamount++;
	temp=window.fadeamount;
	document.getElementById(whichdiv).style.opacity=temp*.1;
	document.getElementById(whichdiv).style.filter="alpha(opacity="+temp*10+")";
	//+"px";//document.getElementById("bigpicholder").style.width;

	
	if(temp==10){
		

		clearInterval(window.mySlide);
	}
//setTimeout("document.all['table1'].style.filter=alpha(opacity=20)",2000)	
}
function displaythumbs(){
	
	thumbnames="";
	rowmax=3;
	currentcol=0;
	
	mythumbs="";
	rownail="";
    for(t=0;t<window.x.length;t++){
		mytest=window.x.length+" O";
	
 		mytitle=getnodevalue("TITLE",t);
		series=getnodevalue("SERIES",t);
		medium=getnodevalue("MEDIUM",t);
		size=getnodevalue("SIZE",t);
		bigpic=getnodevalue("BIG",t);
		thumb=getnodevalue("THUMB",t);
		about=getnodevalue("ABOUT",t);
		edition=getnodevalue("EDITION",t);

		mythumbs+="<div id='thumbdiv'><center><a class='myclick' onclick='showbig("+t+");window.dofade=1;'><img src='"+thumb+"' border='0'></a></center></div>";
		currentcol++;
		if(currentcol>rowmax-1){
			currentcol=0;	
			rownail+="<div id='rows'>"+mythumbs+" </div>";
			mythumbs="";
		}

		
	}
	document.getElementById("thumbholder").innerHTML=rownail;
	//
	document.getElementById("bigpicholder").style.opacity=0.0;
	document.getElementById("bigpicholder").style.filter="alpha(opacity=0)";
	window.mySlide = window.setInterval("fadeup('thumbholder')",50);
	window.fadeamount=0;
	
}

function getnodevalue(whichnode, whichnum){
	myvalue="";
	temp=window.x[whichnum].getElementsByTagName(whichnode)[0].childNodes.length;
	if(temp>0){
 		myvalue=(window.x[whichnum].getElementsByTagName(whichnode)[0].childNodes[0].nodeValue);
	}
	
	
	return myvalue;
	
}
function display()
{
	mytest=window.x.length+" O";
	
 		title=getnodevalue("TITLE");
		series=getnodevalue("SERIES");
		medium=getnodevalue("MEDIUM");
		size=getnodevalue("SIZE");
		bigpic=getnodevalue("BIG");
		thumb=getnodevalue("THUMB");
		about=getnodevalue("ABOUT");

	document.getElementById("thumbholder").innerHTML="<span class='title'>"+title+"</span><br/>"+series+"<br/>"+about;
	//document.getElementById("picholder").innerHTML="<img src='"+pic+"' align=bottom/>";
	//document.getElementById("mywhere").innerHTML=where;
	
	//document.getElementById("copy").innerHTML=title+" "+series+" "+where+" "+about+" "+pic;


}
