var thumbToOpen = -1;
var thumbToClose = -1;

function openThumbs(selected){
	var thumbs = $$('.thumbnailContainer');
	var thumbFx = new Fx.Elements(thumbs, {wait: false, duration: 400, transition: Fx.Transitions.quadOut, onComplete: nextThumbs});
	var thumbFx2 = new Fx.Elements(thumbs, {wait: false, duration: 400, transition: Fx.Transitions.quadIn, onComplete: nextThumbs});
	
	var hxd;
	
	if (thumbs[selected] != undefined){
		//alert(thumbs[selected].id);
		switch (thumbs[selected].id){
		case 'Landscape': hxd=275; break;
		case 'people': hxd=460; break;
		case 'nature': hxd=140; break;		
		case 'urban': hxd=275; break;		
		case 'abstract': hxd=650; break;
		case 'servicios': hxd=440; break;
		default: hxd=275;
		}	
	}
	
	thumbToOpen = selected;
	//thumbToClose = open;
	
	var obj = {};
	
	// ? selected
	
	if(selected == -1){
		obj[thumbToClose] = {
			'height': [thumbs[thumbToClose].getStyle('height').toInt(), 0]
		};
		thumbFx.start(obj);
		//thumbToClose = -1;
	}else{
		if(thumbToClose == -1){
			thumbs[selected].setStyle('display', 'block');
			obj[selected] = {
				'height': [thumbs[selected].getStyle('height').toInt(), hxd]
			};
			thumbFx.start(obj);
			thumbToClose = selected;
		}else{
			obj[thumbToClose] = {
				'height': [thumbs[thumbToClose].getStyle('height').toInt(), 0]
			};
			thumbFx2.start(obj);
			//thumbToClose = -1;
		}
	}
}

function nextThumbs(){
	var thumbs = $$('.thumbnailContainer');
	var thumbFx = new Fx.Elements(thumbs, {wait: false, duration: 400, transition: Fx.Transitions.quadOut});

	var hxd;
	
	if (thumbs[thumbToOpen] != undefined){
		//alert(thumbs[thumbToOpen].id);	
		switch (thumbs[thumbToOpen].id){
			case 'Landscape': hxd=275; break;
			case 'people': hxd=460; break;
			case 'nature': hxd=140; break;		
			case 'urban': hxd=274; break;		
			case 'abstract': hxd=650; break;		
			case 'servicios': hxd=440; break;
			default: hxd=275;
		}
	}

	if(thumbToClose != -1){
		thumbs[thumbToClose].setStyle('display', 'none');
		thumbToClose = -1;
	
	if(thumbToOpen != -1){
		thumbs[thumbToOpen].setStyle('display', 'block');
		var obj = {};
		obj[thumbToOpen] = {
			'height': [thumbs[thumbToOpen].getStyle('height').toInt(), hxd]
		};
		thumbFx.start(obj);
		thumbToClose = thumbToOpen;
	}
	}
}
