f1_id 		= 'f1_';
f1_count 		= 25;

f2_id 		= 'f2_';
f2_count 		= 24;

f3_id 		= 'f3_';
f3_count 		= 21;

f4_id 		= 'f4_';
f4_count 		= 22;

blankCount			= 2; //number of blank pictures at the start and end of the portfolio
visibleSlots 		= 9; 

displayAreaWidth 		= 680;

stripWidthWithArrows 	= 590;
widthOfArrows		= 58;	
thumbnailWidth		= 50;
thumbnailGap		= 4;
thumbnailsShown 		= 9;

stripWidthWithArrows 	= thumbnailsShown * (thumbnailWidth + thumbnailGap) + widthOfArrows;

stripWidth			= stripWidthWithArrows - widthOfArrows;

// these are the image/html names assocaited with each position, this complication added because client kept changing order of images!
// the format of the html name is fn_iii.htm where 'n' = folio name 'iii' = image name
// the format of the thumbnail name is fn_iiit.jpg where 'n' = folio name 'iii' = image name
  
var f1_page	= new Array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25');
var f2_page	= new Array('1','2','3','4','5','6','7','8','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25');
var f3_page	= new Array('1','2','3','4','5','3716','7','8','9','10','11','12','13','14','15','16','19','21','22','24','25');
var f4_page	= new Array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25');


//no changes required from here on

var f1_slot	= new Array();
var f2_slot	= new Array();
var f3_slot	= new Array();
var f4_slot	= new Array();

var f_page	= new Array();

var currentSlot;

blankCount2 = visibleSlots - blankCount -1;

window.onload = setImageArrays;

temp = Math.floor(stripWidth / (thumbnailWidth + thumbnailGap));

stripWidth = (temp * (thumbnailWidth + thumbnailGap)) - (thumbnailGap / 2);


// FUNC --------------------------------------------------------------------------------extractFileName
function extractFileName(fullPath)
{
	var lastSlash 			// the position of the last slash in the path
	var fileName  			// the name of the file
	lastSlash	= fullPath.lastIndexOf("/")
	fileName 	= fullPath.substring(lastSlash+1,fullPath.length)
	return fileName
} 


// FUNC --------------------------------------------------------------------------------nextScreen
function nextScreen(seriesId,moveDirection,maxCount)
{
	pageId = getPageId(seriesId);
	
	if (moveDirection == "left")
		{
		nextPage = pageId - 1;
		if (nextPage < 1)
			{
			document.location.href = seriesId + maxCount + ".htm";
			}
		else
			{
			document.location.href = seriesId + nextPage + ".htm";
			}
		}
	else
		{
		nextPage = pageId + 1;
		if (nextPage > maxCount)
			{
			document.location.href = seriesId + "1.htm";
			}
		else
			{
			document.location.href = seriesId + nextPage + ".htm";
			}
		}
}

// FUNC --------------------------------------------------------------------------------writeScrollStrip
function writeScrollStrip()
{

	cs=0;currentSlot=0+blankCount;
	seriesId = getPageName().substr(0,3);

	pageId = getPageId(seriesId);

	switch (seriesId)
		{
		case f1_id:
			maxCount	= f1_count;
			break;
		case f2_id:
			maxCount 	= f2_count;
			break;
		case f3_id:
			maxCount	= f3_count;
			break;
		case f4_id:
			maxCount 	= f4_count;
			break;
		}

	leftPos	= ((displayAreaWidth - stripWidthWithArrows) / 2) - 5;
	
	thisDiv     = 'strippos';
	
	dom        	= findDOM(thisDiv,1);
	dom.left   	= parseInt(leftPos) + "px";

	inLine  = '<table border="0" cellpadding="0" cellspacing="0" width="' + stripWidthWithArrows + '">';
	inLine += '<tr>';

	inLine += '<td align="center" valign="middle"><a href="javascript:scrollBack();"><img src="i/arrowleft.gif" alt="prev" border="0" width="29" height="17" /></a></td>';

	inLine += '<td align="center" valign="middle"><iframe id="scrollstrip" width="' + stripWidth + '" height="' + thumbnailWidth + '" src="' + seriesId + 'scrollstrip.htm" frameborder="0" scrolling="no" name="framnav" id="framnav"></iframe></td>';

	inLine += '<td align="center" valign="middle"><a href="javascript:scrollNext();"><img src="i/arrowright.gif" alt="next" border="0" width="29" height="17" /></a></td>';
	inLine += '</tr>';
	inLine += '</table>';

	document.write(inLine);
}


// FUNC --------------------------------------------------------------------------------writeNavStrip
function writeNavStrip()
{

	seriesId = getPageName().substr(0,3);

	pageId = getPageId(seriesId);

	switch (seriesId)
		{
		case f1_id:
			maxCount	= f1_count;
			f_page 	= f1_page;
			break;
		case f2_id:
			maxCount 	= f2_count;
			f_page 	= f2_page;
			break;
		case f3_id:
			maxCount	= f3_count;
			f_page 	= f3_page;
			break;
		case f4_id:
			maxCount 	= f4_count;
			f_page 	= f4_page;
			break;
		}

	tabWidth	= (maxCount + (2 * blankCount)) * thumbnailWidth;

tabWidth = tabWidth *2;	
	
	inLine  = '<table border="0" cellpadding="0" cellspacing="0" height="' + thumbnailWidth + '" width="' + tabWidth + '">';
	inLine += '<tr><td>';

	for (var j=1; j < (blankCount + 1); j++)
		{
		inLine += '<img src="i/x.gif" width="' + thumbnailWidth + '" height="' + thumbnailWidth + '" hspace="2" alt="" />';
		}

	for (var j=0; j < (maxCount); j++)
		{

		//inLine += '<a href="' + seriesId + j + '.htm" target="foliodetail"><img id="' + seriesId + j + '" src="i/' + seriesId + j + 't.jpg" width="' + thumbnailWidth + '" height="' + thumbnailWidth + '" hspace="2" alt="' + j + '" /></a>';
		inLine += '<a href="' + seriesId + f_page[j] + '.htm" target="foliodetail"><img id="' + seriesId + f_page[j] + '" src="i/' + seriesId + f_page[j] + 't.jpg" width="' + thumbnailWidth + '" height="' + thumbnailWidth + '" hspace="2" alt="' + f_page[j] + '" /></a>';
		
		}

	for (var j=1; j < (blankCount + 1); j++)
		{
		inLine += '<img src="i/x.gif" width="' + thumbnailWidth + '" height="' + thumbnailWidth + '" hspace="2" alt="" />';
		}

	inLine += '</td></tr>';
	inLine += '</table>';
//prompt(1,inLine);
	document.write(inLine);

}

// FUNC --------------------------------------------------------------------------------getPageId
function getPageId(seriesId)
{
	pageId=getPageName();
	
	eval("pageId= pageId.replace(/" + seriesId + "/g,'')");
	pageId	= pageId.replace(/.htm/g,'');	
	pageId	= parseInt(pageId);

	return pageId;
}



// FUNC --------------------------------------------------------------------------------getPageName
function getPageName()
{
	framURL	= document.location.href;
	pageName	= extractFileName(framURL);
	return pageName;
}



// FUNC --------------------------------------------------------------------------------opacity
function opacity(id, opacStart, opacEnd, millisec) 
	{
    	//speed for each frame
    	var speed = Math.round(millisec / 100);
    	var timer = 0;

    	//determine the direction for the blending, if start and end are the same nothing happens
    	if(opacStart > opacEnd) 
		{
        	for(i = opacStart; i >= opacEnd; i--) 
			{
            	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            	timer++;
        		}
    		}
	else if(opacStart < opacEnd) 
		{
        	for(i = opacStart; i <= opacEnd; i++)
            	{
            	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            	timer++;
        		}
    		}
	}



// FUNC --------------------------------------------------------------------------------changeOpac
//change the opacity for different browsers
function changeOpac(opacity, id) 
	{
    	var object = document.getElementById(id).style;
    	object.opacity = (opacity / 100);
    	object.MozOpacity = (opacity / 100);
    	object.KhtmlOpacity = (opacity / 100);
    	object.filter = "alpha(opacity=" + opacity + ")";
	} 


// FUNC --------------------------------------------------------------------------------shiftOpacity
function shiftOpacity(id, millisec) 
	{
   	//if an element is invisible, make it visible, else make it ivisible
    	if(document.getElementById(id).style.opacity == 0) 
		{
        	opacity(id, 0, 100, millisec);
    		} 
	else
		{
        	opacity(id, 100, 0, millisec);
    		}
	} 


// FUNC --------------------------------------------------------------------------------fadeInObject
function fadeInObject(id, millisec) 
	{
  	imageId	= id;
  	image 	= document.getElementById(imageId);

	changeOpac(0,imageId); 				//blank it first

  	image.style.visibility = 'visible';
      opacity(id, 0, 100, millisec);
	}


// FUNC --------------------------------------------------------------------------------fadeOutObject
function fadeOutObject(id, millisec) 
	{
  	imageId 	= id;
  	image 	= document.getElementById(imageId);

  	image.style.visibility = 'visible';
      opacity(id, 100, 0, millisec);
	}





// FUNC --------------------------------------------------------------------------------setImageArrays
function setImageArrays() 
	{

	speedPixelsPerCycle = 3; //forward or backward speed

	sizeOfPix		= thumbnailWidth;
	slotGap		= thumbnailGap;
	slotMidPos		= 0;

	for (i = 0; i < (f1_count + (2 * blankCount)); i = i+1)
 		{
 		f1_slot[i]	= slotMidPos;
 		slotMidPos	= slotMidPos + slotGap + sizeOfPix;
 		}

	slotMidPos		= 0;

	for (i = 0; i < (f2_count + (2 * blankCount)); i = i+1)
 		{
 		f2_slot[i]	= slotMidPos;
 		slotMidPos	= slotMidPos + slotGap + sizeOfPix;
 		}

	slotMidPos		= 0;

	for (i = 0; i < (f3_count + (2 * blankCount)); i = i+1)
 		{
 		f3_slot[i]	= slotMidPos;
 		slotMidPos	= slotMidPos + slotGap + sizeOfPix;
 		}

	slotMidPos		= 0;

	for (i = 0; i < (f4_count + (2 * blankCount)); i = i+1)
 		{
 		f4_slot[i]	= slotMidPos;
 		slotMidPos	= slotMidPos + slotGap + sizeOfPix;
 		}

}


// FUNC --------------------------------------------------------------------------------scrollNext
function scrollNext()
{

	seriesId = getPageName().substr(0,3);

	pageId = getPageId(seriesId);

	switch (seriesId)
		{
		case f1_id:
			var slot = f1_slot;
			numOfSlots		= f1_count;
			break;
		case f2_id:
			var slot = f2_slot;
			numOfSlots		= f2_count;
			break;
		case f3_id:
			var slot = f3_slot;
			numOfSlots		= f3_count;
			break;
		case f4_id:
			var slot = f4_slot;
			numOfSlots		= f4_count;
			break;
		}

	//numOfSlots  = numOfSlots + (2 * blankCount);

	firstRealSlot	= 0;
	lastRealSlot	= numOfSlots + blankCount - 1;
	nextSlot		= currentSlot+1;
//alert(lastRealSlot); alert(nextSlot);

	if (nextSlot > lastRealSlot - blankCount2 ) 
  		{}
  	else
  		{
  		startPoint	= slot[currentSlot];
  		endPoint	= slot[nextSlot];
  		for (currentPoint = startPoint; currentPoint <= endPoint; currentPoint = currentPoint + speedPixelsPerCycle)
  			{window.framnav.scroll(currentPoint,0);}
//alert(nextSlot);
  		currentSlot	= nextSlot;
  		}
}


// FUNC --------------------------------------------------------------------------------scrollBack
function scrollBack()
{

	seriesId = getPageName().substr(0,3);

	pageId = getPageId(seriesId);

	switch (seriesId)
		{
		case f1_id:
			slot = f1_slot;
			numOfSlots		= f1_count;
			break;
		case f2_id:
			slot = f2_slot;
			numOfSlots		= f2_count;
			break;
		case f3_id:
			slot = f3_slot;
			numOfSlots		= f3_count;
			break;
		case f4_id:
			slot = f3_slot;
			numOfSlots		= f4_count;
			break;
		}

	numOfSlots  = numOfSlots + (2 * blankCount);

	firstRealSlot	= 0;
	lastRealSlot	= numOfSlots  - 1;

  	nextSlot=currentSlot-1;

  	if (nextSlot < firstRealSlot)
  		{}
  	else
  		{
  		startPoint	= slot[currentSlot];
  		endPoint	= slot[nextSlot];
  		for (currentPoint = startPoint; currentPoint >= endPoint; currentPoint = currentPoint - speedPixelsPerCycle)
	 	 	{window.framnav.scroll(currentPoint,0)}
//alert(currentPoint);
  		currentSlot	= nextSlot;
  		}
}


//FUNC *************************************************************************        getWinSize
function getWinSize()
	{
	if( typeof( window.innerWidth ) == 'number' )
		{
		//Non-IE
		winWidth	= window.innerWidth;
		winHeight	= window.innerHeight;
		}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		{
		//IE 6+ in 'standards compliant mode'
		winWidth	= document.documentElement.clientWidth;
		winHeight	= document.documentElement.clientHeight;
		}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		{
		//IE 4 compatible
		winWidth	= document.body.clientWidth;
		winHeight	= document.body.clientHeight;
		}
	else
		{
		winWidth	= document.documentElement.clientWidth;
		winHeight	= document.documentElement.clientHeight;
		}

  	winX = document.all ? window.screenLeft : window.screenX;
  	winY = document.all ? window.screenTop : window.screenY;
	}


//**********************************************************************************************************
//**********************************************************************************************************
//OLD 
//**********************************************************************************************************
//**********************************************************************************************************

// FUNC --------------------------------------------------------------------------------setThumbnailSizeXXX
function setThumbnailSizeXXX()
{
	getWinSize();
	//alert(winHeight);
	if (winHeight < thumbnailWidth)
		{
		thumbnailWidth = winHeight;
		resizeThumbnails();
		}
} 

// FUNC --------------------------------------------------------------------------------resizeThumbnailsXXX
function resizeThumbnailsXXX()
{
	seriesId = getPageName().substr(0,3);

	pageId = getPageId(seriesId);

	switch (seriesId)
		{
		case f1_id:
			maxCount	= f1_count;
			break;
		case f2_id:
			maxCount 	= f2_count;
			break;
		case f3_id:
			maxCount	= f3_count;
			break;
		case f4_id:
			maxCount 	= f4_count;
			break;
		}
	for (var j=1; j < (maxCount + 1); j++)
		{
		thisID     = frames["scrollstrip"].seriesId + j;
	
		dom        	= findDOM(thisID,1);
		dom.height 	= parseInt(thumbnailWidth) + "px";
		dom.width 	= parseInt(thumbnailWidth) + "px";
		}

}


// FUNC --------------------------------------------------------------------------------writeStripxxx
function writeStripxxx()
{
	seriesId = getPageName().substr(0,3);

	pageId = getPageId(seriesId);

	switch (seriesId)
		{
		case f1_id:
			maxCount	= f1_count;
			break;
		case f2_id:
			maxCount 	= f2_count;
			break;
		case f3_id:
			maxCount	= f3_count;
			break;
		case f4_id:
			maxCount 	= f4_count;
			break;
		}

	tabWidth	= maxCount * thumbnailWidth;	
	leftPos	= (displayAreaWidth - tabWidth) / 2;

	if (tabWidth > displayAreaWidth)
		leftPos = 0; 
	
	thisDiv     = 'strippos';
	
	dom        	= findDOM(thisDiv,1);
	dom.left   	= parseInt(leftPos) + "px";

	inLine  = '<table border="0" cellpadding="0" cellspacing="0" width="' + tabWidth + '">';
	inLine += '<tr>';
	inLine += '<td><a href="javascript:nextScreen(\'' + seriesId + '\',\'left\',' + maxCount + ')" target="_self"><img border="0" src="i/arrowleft.gif" alt="next left" width="27" height="19" /></a></td>';

	for (var j=1; j < (maxCount + 1); j++)
		{
		if (j == pageId)
			inLine += '<td><a href="' + seriesId + j + '.htm" target="_self"><img name="' + seriesId + j + '" border="0" src="i/doton.gif" alt="" width="21" height="19" /></a></td>';
		else
			inLine += '<td><a href="' + seriesId + j + '.htm" target="_self"><img name="' + seriesId + j + '" border="0" src="i/dotoff.gif" alt="" width="21" height="19" /></a></td>';
		}

	inLine += '<td><a href="javascript:nextScreen(\'' + seriesId + '\',\'right\',' + maxCount + ')" target="_self"><img border="0" src="i/arrowright.gif" alt="next right" width="27" height="19" /></a></td>';

	inLine += '</tr>';
	inLine += '</table>';

	document.write(inLine);
}

// FUNC --------------------------------------------------------------------------------VARS for scrolling
sppc	=  3;
sop	= thumbnailWidth;
smp	= (sop/2) - 1;
nos	= 26;
frs	= 0;
lrs	= 17;
s 	= new Array();

for (i = 0; i < nos; i = i+1)
 {s[i]=smp;smp=smp + sop;}


// FUNC --------------------------------------------------------------------------------scrollNext
function scrollNextxxx()
{
  ns=cs+1;if (ns > lrs)
  {}else{sp=s[cs];ep=s[ns];for (cp = sp; cp <= ep; cp = cp + sppc)
  {window.framnav.scroll(cp,0);}cs=ns;}
}

// FUNC --------------------------------------------------------------------------------scrollBack
function scrollBackxxx()
{
  ns=cs-1;if (ns < frs)
  {}else{sp=s[cs];ep=s[ns];for (cp = sp; cp >= ep; cp = cp - sppc){window.framnav.scroll(cp,0)}
  cs=ns;}
}
 


