
$(document).ready(function(){
	// checks if gallery exist
	if((".content_gallery").length){
		var counter=0;
		var tempHTML="";
		
		// initialize setting
		$(".content_gallery > ul.panels > li").each(function(){
			counter++;
			if(counter>1){
				$(this).addClass("content_gallery_slide_hide");
				tempHTML+="<li class=\"nav_button_"+counter+"\"><a href=\""+$(this).find("a").attr("href")+"\"><span>"+$(this).find("h2").html()+"</span></a></li>";
			}
		});
		tempHTML="<div class=\"content_gallery_animator\"></div><ul class=\"panel_nav\">"+tempHTML+"</ul>";
		$('.content_gallery').append(tempHTML);
		$(".content_gallery .content_gallery_animator").css("display","none")
		
		
		// animation
		$(".panel_nav > li").each(function(){
			$(this).mouseover(function(){
			
			if($(".content_gallery > .panels").hasClass(this.className.replace("nav_button_","content_gallery_slide_show_"))){
				return false;
			}
				
			$(".panel_nav > li").each(function(){
				$(".content_gallery > .panels").removeClass(this.className.replace("nav_button_","content_gallery_slide_show_"));
			});
			$(".content_gallery > .panels").addClass(this.className.replace("nav_button_","content_gallery_slide_show_"));
			
			var animation = $(".content_gallery .content_gallery_animator").fadeIn(300,function(){
				$(".content_gallery .panels li").addClass("content_gallery_slide_hide");
				$(".content_gallery .panels").each(function(){
				$(".content_gallery ."+this.className.replace("panels ","").replace("_show","")).removeClass("content_gallery_slide_hide");
				});
				this.parentNode.className
				$(".content_gallery .content_gallery_animator").fadeOut(300,function(){});
			});
			});
		});
	}
});
