/*
Script Description:
	This script contains variables and functions needed by the photo gallery.

Author:
	Néstor Romero

Version:
	1.0
	
Project:
	Lucita - Asian Institute of Medical Studies
	April 2007

*/


/****   Variable Initialization   *****/

var backImg = new Image( 89, 70 );
backImg.src = 'photos/back.gif';

var nextImg = new Image( 89, 70 );
nextImg.src = 'photos/next.gif';

var largeImg = new Array();
var smallImg = new Array();
var captions = new Array();

initLargeImg();
initSmallImg();
initCaptions();

var page = 0;
var i =0;

/****   Variable Initialization   *****/

/****   Script Functions   *****/
function initLargeImg(){
	var prefix = "photos/image_00";
	var postfix = ".jpg";
	for( i=0;i<8;i++ ){
		largeImg[i] = new Image( 461, 352 );
		largeImg[i].src = prefix + (i+1) + postfix;
	}
}

function initSmallImg(){
	var prefix = "photos/image_00";
	var postfix = "_a.jpg";
	for( i=0;i<8;i++ ){
		smallImg[i] = new Image( 89, 70 );
		smallImg[i].src = prefix + (i+1) + postfix;
	}
}

function initCaptions(){
	
	captions[0] = 	"Congratulations to the Masters graduating class of 2006!<br>Left to right: Keith Zabik, Sheh Adams, Stefanie Lischer, John Lucky Blue, Amy Ringdahl, Beth Yust";
	
	captions[1] = 	"Congratulations to the Masters graduating class of 2005!<br>Left to right: Tim Blee, Aline Schwarz, Sheilah Keppler, Jean Carr, Nancy Barton, Catherine Lumenello, Sue Lemmon";
	
	captions[2] = 	"Calligraphy of the Five Elements as done by our Board Chair, Zen Roshi Johndennis Govert. <br>This work hangs prominently in the reception area.  His excellent book, “Feng Shui—Art and Harmony of Place,” can be purchased in our bookstore.";
	
	captions[3] = 	"Alex Holland, President of AIMS, with Andrew Weil, M.D., when Andy stopped by to visit the school.<br>AIMS has an ongoing relationship with Andy's Program in Integrative Medicine (PIM) at the University of Arizona School of Medicine. Alex is the primary Preceptor in TCM for the Program in Integrative Medicine.";
	
	captions[4] = 	"Instructor and practitioner David Price, L.Ac., lecturing to his class on the therapeutic uses of Asian Nutrition. At the end of the quarter, David and the class prepare a potluck feast for all to enjoy.";
	
	captions[5] = 	"Diane Eggleston, L.Ac., supervises John and Sheh as they compassionately perform Tuina / Qigong on a client.";
	
	captions[6] = 	"John performing Tuina / Qigong on an elderly client at Via Elegante. The utilization of compassionate intention is a primary healing modality that AIMS fosters in our students.";
	
	captions[7] = 	"Sheh performing Tuina at Via Elegante.";
	
}

/*
* 	This method executes the logic and graphic changes required to fix and unfix an image.
*	This method is called by the onClick event on a thumbnail.
*/
function showPhoto( index_p ){
	
	var index = index_p + (page)*4;
	var imgIndex = 'img_t'+index_p;
	
	document.getElementById( 'screen' ).src = largeImg[index].src;
	document.getElementById( 'caption' ).innerHTML = "" + captions[index] + "";
	//document.getElementById( imgIndex ).border = "1";
	
}

/*
* 	This method executes the logic and graphic changes required to toggle images.
*	This method is called by the mouseOver event on a thumbnail.
*/

function togglePhoto( index_p ){
	
	var index = index_p + (page)*4;
	var imgIndex = 'img_t'+index_p;
	
	document.getElementById( 'screen' ).src = largeImg[index].src;
	document.getElementById( 'caption' ).innerHTML = "";
}

function nextP(){
	
	var prefix = "img_t";
	var imgIndex = "";
	var arrayIndex = 0;
	var screenFlag = false;
	
	if( page == 0 ){
		
		for( i=0;i<4;i++){
			imgIndex = prefix + i;
			arrayIndex = 4 + i;
			document.getElementById( imgIndex ).src = smallImg[ arrayIndex ].src;
			if( !screenFlag ){
				document.getElementById( 'screen' ).src = largeImg[ arrayIndex ].src;
				screenFlag = true;
			}
		}
		
		page = 1;
		
		document.getElementById( 'back_t' ).src = backImg.src;
		document.getElementById( 'next_t' ).src = 'photos/spacer.gif';
				
	}
	
}

function backP(){
	
	var prefix = "img_t";
	var imgIndex = "";
	var arrayIndex = 0;
	var screenFlag = false;
	
	if( page == 1 ){
		
		for( i=0;i<4;i++){
			imgIndex = prefix + i;
			arrayIndex = i;
			document.getElementById( imgIndex ).src = smallImg[ arrayIndex ].src;
			if( !screenFlag ){
				document.getElementById( 'screen' ).src = largeImg[ arrayIndex ].src;
				screenFlag = true;
			}
		}
		
		page = 0;
		
		document.getElementById( 'back_t' ).src = 'photos/spacer.gif';
		document.getElementById( 'next_t' ).src = nextImg.src;
		
	}
	
}