function GaleryContentIMG(e, type){
	if(window.start_galery === true){ return false; }
	window.start_galery = true;
	var temp = e.parent();
	var SELF = temp.parent();
	var IMG = SELF.find("a[class^='content_galery_']");
	var COUNT_IMG = IMG.size();
	var I = 0;
	var THIS_IMG;
	IMG.each(function(){
		I = I+1;
		if($(this).is(':visible')){ THIS_IMG = I; return;}
	})
	var NIMG = THIS_IMG;
	var TIMG = SELF.find("a.content_galery_" + THIS_IMG);
	
	if(type == 'next'){ NIMG++; }
	else if(type == 'prev'){ NIMG--; }
	
	if(NIMG < 1){ NIMG = COUNT_IMG; }
	else if(NIMG > COUNT_IMG){ NIMG = 1; }
	
	var IMG = SELF.find("a.content_galery_" + NIMG);
	var TITLE_IMG = IMG.find('img').attr("title");
	
	var P_TITLE = SELF.find('p');
	P_TITLE.animate({'opacity':0}, 1000, function(){
		P_TITLE.html(TITLE_IMG);
		P_TITLE.animate({'opacity':1}, 1000);
	})
	
	TIMG.animate({'opacity':0}, 1000, function(){
		TIMG.hide();
		IMG.css({'opacity':0}).show().animate({'opacity':1},1000, function(){ window.start_galery = false; });
		
	});
	SELF.find("span.current-photo").html(NIMG);
	
}


$(document).ready(function(){
	$('a.prev-photo').live('click',function(){
		GaleryContentIMG($(this), 'prev');
	})

	$('a.next-photo').live('click',function(){
		GaleryContentIMG($(this), 'next');
	})
})
