//************************************************************************************************* 
// Design           	: FvdM Design Studio's 2003-2009
// Initial file date	: 10 May, 2003
// Function(s)			: Next and previous textpage functions
//						  Button preload functions
// Change history		:	Date		By		Revision	Description
//							10-03-2003	FvdM	1.0			Initial version
//
//							18-10-2003	FvdM	1.1			Function OpenWin added, used to start
//															popup screen after pressing mail button
//															on start page.
//							03-01-2004	FvdM	1.2			MainPhoto reference changed.
//                          22-12-2005  FvdM    1.3         MainPhoto reference removed, as it is
//                                                          not necessary anymore.
//							03-10-2006	FvdM	1.4			Script "PageRef.js" integrated in this
//															script. The "PageRef.js" script is not
//															necessary anymore and will be removed in
//															all "Textpage.html" files.
//							10-01-2007	FvdM	1.5			Script "PageInfo.js" integrated in this
//															script. The "PageInfo.js" script is not
//															necessary anymore and will be removed in
//															all "*.html" files.
//							14-05-2008	FvdM	1.6			Initial file for Uganda / Rwanda.
//*************************************************************************************************

//Initialisation of variables
FirstPageNmbr	=  1;
LastPageNmbr	= 22;

PopupActive 	= false;
StartString 	= "Textpage";
Extension   	= ".html";
Path			= location.href;
PathLength		= location.href.length;
StartPos		= PathLength - 15;
CurrentPage		= Path.substring(StartPos,PathLength);

//Global function; will be executed immediately after script startup!!
if (CurrentPage.substring(0,1) == 'T')
	 {
	 CurrentNmbrString= CurrentPage.substring(8,10);
	 }
else {
	 CurrentNmbrString= CurrentPage.substring(9,10);
	 }
SelectedPageNmbr= parseInt(CurrentNmbrString);

SelectedPage	= StartString + SelectedPageNmbr + Extension;

//Function definitions
function PrevPage()	{
		if (SelectedPageNmbr == FirstPageNmbr) {
			SelectedPageNmbr=FirstPageNmbr;
			}
		else {
			SelectedPageNmbr= SelectedPageNmbr - 1;
			SelectedPage= "Textpage" + SelectedPageNmbr + ".html";
			window.location.replace(SelectedPage);
			}
}

function NextPage()	{
		if (SelectedPageNmbr == LastPageNmbr) {
			SelectedPageNmbr=LastPageNmbr;
			}
		else {
			SelectedPageNmbr= SelectedPageNmbr + 1;
			SelectedPage= "Textpage" + SelectedPageNmbr + ".html";
			window.location.replace(SelectedPage);
			}
}

function DisplayMsg(MsgStr) {
	status=MsgStr;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		if (((SelectedPageNmbr == LastPageNmbr) || (SelectedPageNmbr == FirstPageNmbr)) &&
			(changeImages.arguments.length == 3)){
			i=2;
		}
		else {
			i=1;
		}	
		document[changeImages.arguments[0]].src = changeImages.arguments[i];
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		Header					= newImage("Images/Header.jpg");
		Shield					= newImage("Images/Shield.gif");
		
		PhotoPage_back			= newImage("Buttons/PhotoBack.gif");
		PhotoPage_next			= newImage("Buttons/PhotoNext.gif");
		PhotoPage_res			= newImage("Buttons/PhotoRes.gif");
		PhotoPage_stop			= newImage("Buttons/PhotoStop.gif");
		
		Footer					= newImage("Footer.gif");
		Footerwhite				= newImage("Footerwhite.gif");
		preloadFlag = true;
	}
}

function OpenWin( windowURL, windowName, windowFeatures ) { 
	if (PopupActive == false) {
		PopupActive = true;
		window.open( windowURL, windowName, windowFeatures ); 
	}
}