var _c = _h = 0;
var PH_LENGTH = cnt=0;

$(function(){
	$(".play > a").click(function(){
		var i = $(this).attr("alt") - 1;
		_c = i;
		change(i);        
	})
})

$(function init(){
	$(".stop > a:eq(1)").hide();
	PH_LENGTH=$(".pic a").length;
	$(".change_img .pic a").hide(0,function(){
		$(".change_img .pic a.stay").fadeIn(1000);
	});
	play();
	
});


/****************************
controller stop play
*****************************/
$(function(){
	$(".stop > a:eq(0)").click(function(){
		$(this).hide();
		$(".stop > a:eq(1)").show();
			clearInterval(_h);
	})
	$(".stop > a:eq(1)").click(function(){
		$(this).hide();
		$(".stop > a:eq(0)").show();
		play();
	})
})

function play(){_h = setInterval("auto()", 5500);}

function change(i){
	$(".play a").removeClass("stay");
	$(".play a").eq(i).addClass("stay").blur();
	
	$(".stop > a:eq(1)").hide();
	$(".stop > a:eq(0)").show();
	
	$(".pic a").hide().eq(i).fadeIn(1500);
	clearInterval(_h);
	play();
}


function auto(){    
	_c = _c > PH_LENGTH-2 ? 0 : _c + 1;
	change(_c);
}
