var thumbToOpen = -1;
var thumbToClose = -1;

function openThumbs(selected,open){
	var thumbs = $$('.thumbnailContainer');
	var thumbFx = new Fx.Elements(thumbs, {wait: false, duration: 600, transition: Fx.Transitions.backOut, onComplete: nextThumbs});
	var thumbFx2 = new Fx.Elements(thumbs, {wait: false, duration: 600, transition: Fx.Transitions.backIn, onComplete: nextThumbs});
	var theight = 288;

	thumbToClose = thumbToOpen;
	thumbToOpen = selected;
	if( thumbToOpen == 7 ) theight = 320; else theight = 288;
	
	var obj = {};
	if(thumbToClose == -1){
		thumbs[thumbToOpen].setStyle('display', 'block');
		obj[thumbToOpen] = {
			'height': [thumbs[thumbToOpen].getStyle('height').toInt(), theight]
		};
		thumbFx.start(obj);
	}else{
		obj[thumbToClose] = {
			'height': [thumbs[thumbToClose].getStyle('height').toInt(), 0]
		};
		thumbFx2.start(obj);
	}
}

function nextThumbs(){
	var thumbs = $$('.thumbnailContainer');
	var thumbFx = new Fx.Elements(thumbs, {wait: false, duration: 600, transition: Fx.Transitions.backOut});
	var theight = 288;

	if( thumbToOpen == 7 ) theight = 320; else theight = 288;
	
	if(thumbToClose != -1){
		thumbs[thumbToClose].setStyle('display', 'none');
	
		if(thumbToOpen != -1){
			thumbs[thumbToOpen].setStyle('display', 'block');
			var obj = {};
			obj[thumbToOpen] = {
				'height': [thumbs[thumbToOpen].getStyle('height').toInt(), theight]
			};
			thumbFx.start(obj);
		}
	}
}
