comments = new Array();
captions = new Array();
var i = 1;
var j = 0;
var commentsXML;
var xmlDoc;
comments [0] = "images/comment0.gif";
comments [1] = "images/comment1.gif";
comments [2] = "images/comment2.gif";
comments [3] = "images/comment3.gif";
comments [4] = "images/comment4.gif";
comments [5] = "images/comment5.gif";
comments [6] = "images/comment6.gif";
comments [7] = "images/comment7.gif";


captions[0] = "images/ftkcap0.jpg";
captions[1] = "images/ftkcap1.jpg";
captions[2] = "images/ftkcap2.jpg";
captions[3] = "images/ftkcap3.jpg";
captions[4] = "images/ftkcap4.jpg";

function switchimg(id,img){
	eval('document.images.'+ id + '.src="'+ img + '"');
}
function slideimages(){
	//setInterval("slideComments()", 15000);			// This time specifies how long after the slide happens
	setInterval("slideCaptions()", 4500);
}
function slideCaptions(){
	document.images.captions.src = captions[j];
	j++;
	if (j > (captions.length-1)) {j = 0} 
}

function slideComments(xmlDoc){
	if(!xmlDoc || xmlDoc==null){
		loadXmlDocument(slideComments);
	}else{
		var docObj = xmlDoc.documentElement;
		var oNode =docObj.selectSingleNode("//Comments/comment[@id='"+i+"']");		
		if (oNode){
			var cmtText = oNode.text + ' <br/> <span class="Author" align="center">&nbsp;' + oNode.getAttribute('Author') + '</span>';
			document.getElementById('Comment').innerHTML=cmtText ;				//or oNode.nodeTypedValue
			//document.getElementById('Author').innerHTML= oNode.getAttribute('Author');
			i++;			
		}else{
			i = 1;
			slideComments(xmlDoc);
		}
	}
}
function loadXmlDocument(cbFun)
{
   var xmlFile = "comments.xml";
   if( window.ActiveXObject && /Win/.test(navigator.userAgent) )
   {
      xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");

      xmlDoc.async = false;
	  xmlDoc.load(xmlFile);
      cbFun(xmlDoc);

      return true;
   }
   else if( document.implementation && document.implementation.createDocument )
   {
      xmlDoc= document.implementation.createDocument("", "", null);
      xmlDoc.load(xmlFile);
      xmlDoc.onload = function()
      {
         cbFun(xmlDoc);
      }

      return true;
   }
   else
   {
      return false;
   }
}


