/*
 GoToCataloguePage:
 Date Created: 12/05/06
 Updated: 18/7/06 - changed catalogue prefix codes from AB/NG to AC/PA
 Author: SW
 Description:
	Goes to a catalogue page. 
	Because of the use of window.parent This function should be called from
	within an iframe of Default.asp.
 Arguments:
	catalogue - either "AC" or "PG" 
	pageNumber - The page to go to
*/
function GoToCataloguePage(catalogue, pageNumber,zHighlight)
{

	var p = window.parent;
	

	//If the catalogue has changed we also need to change the metrics (e.g. last page number)
	var lCatCodeIndex = arrayIndexOf(p.zfCatalogue_Array,catalogue);	
	if (catalogue!=p.zfCurrent_Catalogue){


		//If found change catalogues
		if (lCatCodeIndex!=-1){
	
			p.zfCurrent_Catalogue=catalogue;
			
			p.lfCurrent_FirstPage = p.lfFirstPage_Array[lCatCodeIndex];
			p.lfCurrent_LastPage =  p.lfLastPage_Array[lCatCodeIndex];
			p.lfCurrent_PageWidth = p.lfPageWidth_Array[lCatCodeIndex];
			p.lfCurrent_PageHeight= p.lfPageHeight_Array[lCatCodeIndex];

			//Update variables in the Flash viewer
			p.frames.iframeCatalogueViewer.SetVariable("lNG_FirstPage", p.lfCurrent_FirstPage);	
			p.frames.iframeCatalogueViewer.SetVariable("lNG_LastPage", p.lfCurrent_LastPage);	
			p.frames.iframeCatalogueViewer.SetVariable("lDefaultPageWidth", p.lfCurrent_PageWidth);	
			p.frames.iframeCatalogueViewer.SetVariable("lDefaultPageHeight", p.lfCurrent_PageHeight);	
			


		}else{
			//alert(catalogue + ' not found.');
		}

	}

	//If it is the catalogue selection page then set it to the first panel
	//ONLY if left hand panel is visible

	if (p.document.getElementById("LeftPane").innerHTML != ''){
		if (lCatCodeIndex==0)lCatCodeIndex=1;	
		//p.frames.iframeCatalogueContents.togglePanel(lCatCodeIndex);
				
	}
	if (zHighlight==undefined) zHighlight='';
/////////////
	p.frames.iframeCatalogueViewer.SetVariable("zTextHighlighted", zHighlight);
/////////////
	p.frames.iframeCatalogueViewer.SetVariable("zCatalogue", catalogue);	
	p.frames.iframeCatalogueViewer.SetVariable("lCurrentPage", pageNumber);
	p.SetLastPageLabel();
	p.EnablePagingControls(pageNumber);
}

function arrayIndexOf(zpArray,zpSearchFor){
	for(var i=0;i<zpArray.length;i++){
		if (zpArray[i]==zpSearchFor) return i;
	}
	//none found
	return -1;

}



