$(function(){
(function($){
	$.extend({
		jsForFlash:function(){
 var $runSite = 0;
 var interval;
$li = $(".galleryBox li");
$li.each(function(i,d){
	$(d).click(function(){
		var boolAnchor = ( $(this).css("z-index") )
		$runSite = $(this).index() 
		CurrentPic()
			if ( !( boolAnchor==10) )
			{
				return false;
			}
	});
})
CurrentPic()
function CurrentPic()
{
	var num,num2,num2$,num3,num3$;
	var obj,obj2,obj2$,obj3,obj3$;
	num = $runSite;
	num2  = (num+1) > 4 ? num - 4: num+1;
	num3  = (num+2) > 4 ? num - 3: num+2;
	num2$ = (num-1) < 0 ? num + 4: num-1;
	num3$ = (num-2) < 0 ? num + 3: num-2;
	obj = $($li.get(num));
	obj2 = $($li.get(num2));
	obj3 = $($li.get(num3));
	obj2$ = $($li.get(num2$));
	obj3$ = $($li.get(num3$));

				obj.css({'z-index':'10'});
				obj2.css({'z-index':'8'});
				obj2$.css({'z-index':'8'});
				obj3.css({'z-index':'0'});
				obj3$.css({'z-index':'0'});

				obj.animate({width:"431px",height:"323px",left:"264px",top:'0'},600);
				obj2.animate({width:"340px",height:"260px",left:"491px",top:"43px","zindex":'8' },600);
				obj3.animate({width:"266px",height:"204px",left:"665px",top:"71px","zindex":'5'},600);
				obj3$.animate({width:"266px",height:"204px",left:"28px",top:"71px","zindex":'5'},600);
				obj2$.animate({width:"340px",height:"260px",left:"128px",top:"43px","zindex":'8'},600);
				
				obj.find("img").animate({width:"431px",height:"323px"},600);
				obj2.find("img").animate({width:"340px",height:"260px"},600);
				obj3.find("img").animate({width:"266px",height:"204px"},600);
				obj3$.find("img").animate({width:"266px",height:"204px"},600);
				obj2$.find("img").animate({width:"340px",height:"260px"},600);

				setWord( obj.attr("class"));
		$(".ctrl_bar a").each(function(index,domEle){
			if ( index == $runSite )
			{
				$(domEle).attr("class","current");
			}else
			{ $(domEle).removeAttr("class")}
		})
		$runSite++
		$runSite = $runSite == 5 ? 0 : $runSite;
}

 
	function setWord(classNm)
	{
		$(".wordPos").each(function(){
			var $p = $(this).children("p");
			
			if ( $(this).parent("li").attr("class")==classNm )
			{
				$p.show()
				$p.css({opacity:0.5})
				//$p.fadeIn("normal",function(){ $(this).css({opacity:0.5})});
			}
			else{
				if ( $p.is(":visible")  )
				{
					$p.fadeOut();
				}
			}
		});
	}
 	$(".ctrl_bar a").each(function(index,domEle){
		$(domEle).mouseover(function(){
			clearInterval( interval );
		});
		$(domEle).click(function(){
			$runSite = parseInt( $(this).attr("rel") );
			CurrentPic();	
		});
		$(domEle).mouseout(function(){
			setRun()
		});
	})
	$(".galleryBox img").each(function(index,domEle){
		$(domEle).mouseover(function(){
			clearInterval( interval );
		});
		$(domEle).mouseout(function(){
			setRun()
		});
	});
	function setRun(){interval = setInterval(CurrentPic,3500);}
	setRun()
		}
	});
})(jQuery)

 var jq =  jQuery.noConflict();
 jq.jsForFlash();
 
 })
