

var display_text_min_height = 70;
var display_text_max_height = 380;
var display_text_diff = 35;
var display_text_opacity_invisible = 0;
var display_text_opacity_visible = 90;
var fade_time = 1000;


function resize_display_text_scrollable(){
    temp_height = $('#display_text_scrollable_inner').height();
	
	if (temp_height < display_text_min_height - display_text_diff){
		$('.jScrollPaneContainer').height(display_text_min_height);
	}
	else if (temp_height > display_text_max_height - display_text_diff){
		$('.jScrollPaneContainer').height(display_text_max_height);
	}
	else{
		$('.jScrollPaneContainer').height(temp_height + display_text_diff);
    }
}


$(document).ready(function() {
    //initialize display_text* size
	$('#display_text_scrollable').jScrollPane({scrollbarWidth:20, showArrows:true});
	resize_display_text_scrollable();
	$('#display_text_scrollable').jScrollPane({scrollbarWidth:20, showArrows:true});
	
	
	$('#display_text_close_a').click(function(event){
			$('#display_text').fadeOut(fade_time);
			event.preventDefault();
		});
	
	
	resize_display_text_scrollable();
	
	

	$('#display_image').serialScroll({
		items:'li',
		duration:400,
		stop:true,
		lock:false,
		constant:false,
		cycle:true
	});
	
	
	$('#wrapper_content_menu_categories a', this).click(function(event){
		if ($(this).hasClass('menu_a_selected')){
			$('#display_text').fadeIn(fade_time);
			
			event.preventDefault();
			}
	});
	
	
	$('#wrapper_content_menu_gallery a', this).click(function(event){
			$('#wrapper_content_menu_gallery a').removeClass('menu_a_selected');
			$(this).addClass('menu_a_selected');
			
			info = $(this).attr('title');
			index = $('#wrapper_content_menu_gallery a').index(this);
			//alert(index);
			$('#display_image').trigger('goto', [index]);
			//$('#display_image').scrollTo('li:eq(2)', {duration:1000});
			$('#display_info_text').html(info);
			
			$('#display_text').fadeOut(fade_time);
			
			//siblings = $(this).parent().nextAll();
			
			siblings = $(this).parent().nextAll().each(function (i){
					if ($(this).hasClass('detail')){
						//alert($(this).html());
						$(this).slideDown(1000);
					}
					else {
						return false;
					}
				});
			
			event.preventDefault();
		});
	
	
	gallery_images_count = $('#wrapper_content_menu_gallery a', this).length;
	random = parseInt(gallery_images_count * Math.random());
	
	info = $('#wrapper_content_menu_gallery a').eq(0).attr('title');
	$('#display_info_text').html(info);
	$('#wrapper_content_menu_gallery a').eq(0).addClass('menu_a_selected');
	
	$('#wrapper_content_menu_gallery a').eq(0).parent().nextAll().each(function (i){
					if ($(this).hasClass('detail')){
						//alert($(this).html());
						$(this).slideDown(1000);
					}
					else {
						return false;
					}
				});
				
	//$('#wrapper_content_menu_gallery a').eq(random).click();
	//$('#wrapper_content_menu_gallery a').eq(random).click();
	//alert('asd');

	
});

