//	alert('Apologies for irritating Javascript boxes while a little maintenance occurs. Wont be long. Promise');

CategoryNames= new Array("People","Portrait","Interior","Wildlife","Travel","Corporate","BandW","Lifestyle","Hotels");
CATy=SplitTheHref();

//	alert('CATy : '+CATy);

PicHigh=284
PicWide=422

// alert(CategoryNames[0]);
// FirstLoad();
// alert("CATy : "+CATy);

// DebugCode

function TellMeYoureHere(From)	{

	//	alert('JSLoad : '+From+' : recently');

}

// =============================

//  This runs the page initialisation and
// needs to be called from the CONTENT page

function FirstLoad(HowMany)

	{     // preload pics R+V "02" for first show

		PagePix=HowMany;
		ShowPicNo=0;
		ButtonCheck();
		ThisWindowButton();
			//	alert('ThisWindowButton called from : FirstLoad');

		setButtons();
		
		preloadImages();
	}

// =============================
//  this sets the Fwd / Back Buttons

function setButtons()

	{

		if (ShowPicNo <1)

		{

		document.Back.src='../NavPics/spacer.gif';

		} 

		if (ShowPicNo >0)

		{

		document.Back.src='../NavPics/Back.gif';

		document.Fwd.src='../NavPics/Fwd.gif';

		}

		if (ShowPicNo >(AllPix-2))

		{

		document.Fwd.src='../NavPics/spacer.gif';

		}

	}



// =============================
//  this splits the HREF using the "/"
//  Assumes that the SECTION IS the current folderName
//  for the CALLER

// it returns SECTION to the caller 



function SplitTheHref(GetLocation) {



	var TheString=(window.location.href);

	var TheSplit=TheString.split("/");

	var TheNumberOfSplits=(TheSplit.length)-2;

    if (TheSplit[TheNumberOfSplits] != 'Frames');

	    {
	    
		    Section=TheSplit[TheNumberOfSplits];
		
		}
	
	
/*
	if(GetLocation==101) {

		var TheString=(document.pic.src);

		var TheSplit=TheString.split("/");

		var TheNumberOfSplits=(TheSplit.length);

		var TheHREF = TheSplit[TheNumberOfSplits-1];

		var TheFileName = TheHREF.split("."); 

		var ThePic= TheFileName[0];

		return ThePic;
*/

/*		for (loop=0; loop<TheNumberOfSplits; loop++)

		{

		alert("TheSplit[loop] : "+loop+" : "+TheSplit[loop]);

		// var LocationFolder=LocationFolder+TheSplit[loop];
		// var LocationFolder=LocationFolder+"/";

		}
		// alert("LocationFolder : "+LocationFolder);
		// return LocationFolder;

	}

	else {
*/

	return Section;

	}

// }



// =============================
//  This runs a timer to replay the buttonCheck

function ButtonCheck()

	{

	ATimer=setTimeout("ThisWindowButton();",2500);
		//	alert('ThisWindowButton : called from  timer in ButtonCheck');
	}

// =============================
//  This hilights the category button
//  using CatNav as the Nav FRAME NAME
//  and using CATy, set from the CALLING page
//  as the category
//  and assumed that CATY+"-down.gif" = as the button Name

function ThisWindowButton() {

if (parent.CatNav) {

	if (parent.CatNav.document.images[CATy]) {

//	alert('ThisWindowButton');

		for (loop=0; loop<CategoryNames.length; loop++)

			{
				TheCategory=(CategoryNames[loop]);

//				alert("TheCategory : "+TheCategory);

				if((parent.CatNav.document.images[TheCategory])&&(TheCategory!=CATy))
				
				{
				(parent.CatNav.document.images[TheCategory].src="../NavPics/"+TheCategory+".gif");

//				alert("TheCategory : "+TheCategory);
//					alert("CATy : " + CATy);
//					alert("CATy : "+CATy+" : "+" is'sŠ "+(top.CatNav.document.images[CATy])!=1);
//				()

				}
			}

	if((parent.CatNav.document.images[CATy].src="../NavPics/"+CATy+"-down.gif")!== 1) { 

		if(ATimer) {
						clearTimeout(ATimer);
						ButtonCheck();
						
					}

         // this means the appt button is NOT hilighted

	var CategoryButton="../NavPics/"+CATy+"-down.gif"

	parent.CatNav.document.images[CATy].src=CategoryButton; 

			}

		}

	}

}



// =============================

// This is the buttonswapper

function newImage(arg) {

	if (document.images) {

		rslt = new Image();

		rslt.src = arg;

		return rslt;

	}

}

function changeImages() {

	if (document.images && (preloadFlag == true)) {

		for (var i=0; i<changeImages.arguments.length; i+=2) {

			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];

		}

	}

}

// =============================

/* function FlipPic(WhichWay)

	{

	var PicNo=ShowPicNo+WhichWay;

	var TheNextPic="images/"+PicNo+".jpg";

	var TheNewPic=newImage(PicHigh,PicWide);

	TheNewPic.src=TheNextPic; 

	

	ShowPicNo=ShowPicNo+WhichWay;

	// document.pic.height=ImgHeight

	// document.pic.width=imgWidth

	document.pic.src=TheNewPic.src;

	alert("wakey");

	setButtons();

	}

*/

// =============================
function popStatus()

	{

	//   alert("waaaaaa");
	//   window.status=("oops i ddd did it again") return true;;

	}


// =============================
function GetPic(WhichPic)

	{

	var PicNo=WhichPic;

	var TheNextPic="images/"+PicNo+".jpg";

	var TheNewPic=newImage(PicHigh,PicWide);

	TheNewPic.src=TheNextPic; 

	document.pic.src=TheNewPic.src;

	ShowPicNo=PicNo;

	return TheNewPic;

	}

// =============================
//  this opens a pic from the LightBox page

function OpenPic(ChoosePic)

	{

	if (ChoosePic< AllPix)

		{
	
		ShowPicNo=ChoosePic;
		ThePic=GetPic(ChoosePic);
		document.pic.src=ThePic.src;

		window.scrollTo(0,0);

		setButtons();

		}

	}



// =============================
//  this is for preloads
//  but it is the only hook into the pagescript

function RunPreLoader(Direction)

	{

	// ButtonCheck();
	// LoadPic(ShowPicNo+Direction);

	}



