imgHolder = new Array();
for(i=0;i<5;++i){
	imgHolder[i] = document.getElementById('actor' + (i + 1));
}

// set dimensions and transform coords

tDim = {w:62,h:91};
iDim = {w:259,h:384};
pos = new Array();
pos[0] = {x:-162,y:124};
pos[1] = {x:10,y:124};
pos[2] = {x:85,y:0};
pos[3] = {x:355,y:124};
pos[4] = {x:527,y:124};
trans = new Array();
trans[0] = {x:172};
trans[1] = {x:75,y:-124,w:197,h:293};
trans[2] = {x:270,y:124,w:-197,h:-293};
trans[3] = {x:172};

active = false;

function slidePics(dir){
	if(!active){
		// hide images_zoom div
		iZoom = document.getElementById("images_zoom");
		if(iZoom != false){
			iZoom.style.display = "none";
			
		}
		active = true;
		curDir = dir;
		// get and format newImg index (slice with no arguments = clone)
		imgArr = imgHolder.slice();
		t = trans.slice();
		if(dir < 0){
			imgArr.reverse();
			t.reverse();
		}
   		newImg = curImg + (dir * -1);
		if(newImg < 0){
			newImg += imgTotal;
		} else if(newImg >= imgTotal){
			newImg -= imgTotal;
		}
		if(ImageZoom && ImageZoom.flick){
			// adjust newImg for zoomImg offset
 			ImageZoom.elements["image"].src = "";
			if (!(ImageZoom.current - 1) in ImageZoom.images) {
				this.images[ ImageZoom.current ] = new Image();
				this.images[ ImageZoom.current ].src = highRes[ImageZoom.current];
			}
			ImageZoom.flick(newImg + 1);
		}
		// setup new full image
		imgArr[1].src = imgs[newImg]
		imgArr[1].style.width = tDim.w + "px";
		imgArr[1].style.height = tDim.h + "px";
		// animate
		doJQAnimation(imgArr[0], dir, t[0], {duration:1000,easing:"swing"});
		doJQAnimation(imgArr[1], dir, t[1], {duration:1000,easing:"swing"});
		doJQAnimation(imgArr[2], dir, t[2], {duration:1000,easing:"swing"});
		doJQAnimation(imgArr[3], dir, t[3], {duration:1000,easing:"swing",complete:function(){resetPics()}});
	}
}

function doJQAnimation(obj, dir, coords, options){
	props = new Object();
	if(coords.x){
 		props.left = "+=" + (coords.x * dir) + "px";
	}
	if(coords.y){
		props.top = "+=" + (coords.y * dir) + "px";
	}
	if(coords.w){ 
		props.width = "+=" + (coords.w * dir) + "px";
	}
	if(coords.h){
		props.height = "+=" + coords.h * dir + "px";
	}
	jQuery(obj).animate(props, options);
}

function resetPics(){
	// create image index array
	curImg -= curDir;
	
	indexArr = new Array();
	start = curImg - 2;
	for(i=0;i<5;++i){
		index = start + i;
		init = index;
		if(index < 0){
			index += imgTotal;
		} else if( index >= imgTotal){
			index -= imgTotal;
		}
		indexArr[i] = index;
	}
	curImg = indexArr[2];
	// set positions / sizes / images
	//newImg = new Array();
	for(i=0;i<5;++i){
		//newImg[i] = new Array();
		dims = tDim;
		src = thumbs[indexArr[i]];
		if(i == 2){
			dims = iDim;
			src = imgs[indexArr[i]];
		}
		imgHolder[i].style.left = pos[i].x + 'px';
		imgHolder[i].style.top = pos[i].y + 'px';
		imgHolder[i].style.width = dims.w + 'px';
		imgHolder[i].style.height = dims.h + 'px';
		imgHolder[i].src = src;
	}
	
	curDir = 0;
	
	// show images_zoom div
	
	iZoom = document.getElementById("images_zoom");
	if(iZoom != false){
		
		/*
		iZoomSmall = iZoom.getElementsByClassName("display");
		if(iZoomSmall[0] && iZoomSmall[0].src){
			iZoomSmall[0].src = imgs[curImg];
		}
		placeholder = document.getElementById("placeholder");
		if(placeholder != false){
			iZoomBig = placeholder.getElementsByClassName("display");
			if(iZoomBig[0] && iZoomBig[0].src){
				iZoomBig[0].src = high_res_hrefs[curImg];
			} 
		} */
		iZoom.style.display = "block";
	}
    active = false;
}

