/*
    Project: Updated Website
    Client:  learnforlifenepal.com
    Author:  Chigozie (The Cat) Nduanya
    Date-Created-File: February 04, 2009
    File-Name: processor.js
	File-Type: JavaScript Document
*/

/*
A) Functions
------------*/
var getSlideshowCounter=0, getSlideshowTimer=null;

/*
 author:   chigozie (the cat) nduanya
 function: getSlideshow(): iterates through an array of image-sources and captions; this function then updates the slideshow-image with the current source,
						   while updating its caption with the current caption. expects an image-source array and an image-caption array to be both populated.
						   tested and passed.*/
function getSlideshow()
{//Opening brace for the getSlideshow function
	document.getElementById('img_slideshow').src='images/guy_slideshow/'+imageSourceArray[getSlideshowCounter];
	writeText(document.getElementById('div_slideshow_caption'),imageCaptionArray[getSlideshowCounter]+'...');
	getSlideshowCounter++;
	if(getSlideshowCounter==imageSourceArray.length)getSlideshowCounter=0;
	getSlideshowTimer=setTimeout('getSlideshow()',4000);
}//Closing brace for the getSlideshow function

/*
 author:   chigozie (the cat) nduanya
 function: deleteContent(): deletes all the child nodes from the specifed parent object. requires a parent object.
							tested and passed.*/
function deleteContent(parentObject)
{//Opening brace for the deleteContent function
	if(parentObject!=null)
	{//Opening brace - Error checking...
		if(parentObject.childNodes)
		{//Opening brace - Element must have child nodes
			for(var i=0;i<parentObject.childNodes.length;i++)
			{//Opening brace - Loop that deletes child nodes
				var childNode=parentObject.childNodes[i]; 
				parentObject.removeChild(childNode);
			}//Closing brace - Loop that deletes child nodes
		}//Closing brace - Element must have child nodes
	}//Closing brace - Error checking...
}//Closing brace for the deleteContent function

/*
 author:   chigozie (the cat) nduanya
 function: writeText(): overwrites the text in an existing parent object with the specified text. requires an element-object and the 
						text to deposit in the element. 
						tested and passed.*/
function writeText(elementObject,text) 
{//Opening brace for the writeText function
	if(elementObject!=null) 
	{//Opening brace - Error checking...
		deleteContent(elementObject); 
		elementObject.appendChild(newNode=document.createTextNode(text));
	}//Closing brace - Error checking...
}//Closing brace for the writeText function
