var	togglestyle			=	'in';
var	myHorizontalSlide	=	null;

window.addEvent('domready', function() {
	
	myHorizontalSlide = new Fx.Slide('horizontal-slide', {mode: 'horizontal'});
	
	$('h-toggle').addEvent('click', function(e){
		e.stop();
		myHorizontalSlide.toggle();
		
		if (togglestyle == 'in') {
			togglestyle	=	'out';
		}
		else {
			togglestyle	=	'in';
		}
		
		window.setTimeout("$('h-toggle').style.background	=	'bottom url(' + serverpath + 'cms/smarties/sys_gallery/templates/images/info-' + togglestyle + '.png)'", 500);
	});
	
	
	$('text-content').innerHTML	=	$$('span.image-captions')[0].innerHTML;
	
	
	container	=	$('big-image');	
	size		=	container.getSize();
	
	slider_height	=	size.y - 60;
	
	// Set sizes of slider
	$('horizontal-slide').setStyle('height', slider_height + 'px');
	$('text-content').setStyle('height', slider_height + 'px');
	$('h-toggle').setStyle('height', slider_height + 'px');
	
	// When Horizontal Slide ends its transition, we check for its status
	// note that complete will not affect 'hide' and 'show' methods
	myHorizontalSlide.addEvent('complete', function() {
		//$('horizontal_status').set('html', status[myHorizontalSlide.open]);
	});
	
	window.setTimeout("myHorizontalSlide.toggle();", 500);
});

function smartie_sys_gallery_switch_image ( link, smartie_ID, image_ID ) {

	//element		=	$('sys-gallery-image-' + smartie_ID);
	container	=	$('big-image');	
	size		=	container.getSize();
	
	// Switch image
	var	nurl	=	serverpath + 'cms/media/thumbnail_' + image_ID + '_w_' + size.x + '_h_' + size.y + '.jpg';
	container.setStyle('background', 'url(' + nurl +')');
	
	
	// Switch classes
	links	=	$$('a.numbers');
	for (i = 0; i < links.length; ++i) {
		mylink	=	links[i];
		mylink.removeClass('active');
	}
	
	link.addClass('active');
	
	
	// Try to switch caption text
	if (text = $('caption-' + image_ID).innerHTML) {
		$('text-content').innerHTML	=	text;	
	}
}

