/* use to load functions after loading page - jquery util*/
$(document).ready(function() {
	
	
	$('img.smallGallery').each(function(index) {
		var _fadeTo = $(this).is('.active') ? '1' : '0.6';
		$(this).css('display','block').css('opacity', '0').fadeTo(1000, _fadeTo);
		
		$(this).mouseover(function(){
			$(this).addClass('active').fadeTo('fast', 1);
		});
		$(this).mouseout(function(){
			$(this).removeClass('active').fadeTo('fast', 0.6);
		});
	});
	
	$('.lightbox').lightBox({
		fixedNavigation:true,
		imageBtnPrev: 'images/index/lightbox-btn-prev-'+$('input#getLang').val()+'.gif',
		imageBtnNext: 'images/index/lightbox-btn-next-'+$('input#getLang').val()+'.gif',
		imageBtnClose: 'images/index/lightbox-btn-close-'+$('input#getLang').val()+'.gif'
	});
}
);

function loadData(url, divId, txt) {
	$('div#'+divId).html(txt);
	$.ajax({
		type: "GET",
		url: url,
		async: true,
		success: function(msg) {
			$('div#'+divId).html(msg);
		}
	});
}

function makegalleria() {
	$('ul.galleria').galleria({
		history: true,
		insert: "#galleria_cont",
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(1000);
				}
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)
			}
	});
}
