$(document).ready(function(){
	//if($('#slider').length>0)
	//{
		var $slider=null;
		var $slider=$('#slider');
		$('#slider')
			.before('<div id="slider_nav">')
			.cycle({
			fx:     'blindY',
			speed:  350,
			timeout: 6000,
			//pager:  '#slider_nav',
			//startingSlide: 1,
			//autostop: 4,
			pause: 1,
			pagerEvent: 'mouseover',
			before:   anime_text_update,
			after:   anime_text_update
		});
	//}

	var bc = $('#slider_nav');
	$slider.children().each(function(i) {
    // create input
    $('<a href="" class="" id="add_btn_'+(i+1)+'" ></a>')
        // append it to button container
        .appendTo(bc)
        // bind click handler
       	.mouseover(function() {
            // cycle to the corresponding slide
            $slider.cycle(i);
			$slider.cycle('pause');
            return false;
        })
		.mouseout(function() {
			 $slider.cycle('resume');
		})
	});
});


function anime_text_update() {
	//alert(this.className);
	//alert(this.className);
	k=0;
	$('#slider_nav').children().each(function(i) {
		// if ($(this).className)!=$('#slider_nav #'+this.className)) {
			//this.removeClass(this.className);
		// }
		k=i+1;
		$(this).css("background","transparent url(/wp-content/themes/default/images/btn"+k+"_off.jpg) no-repeat");
	})

	//$('#slider_nav #'+this.className).addClass("test");
	$('#slider_nav #'+'add_btn_'+this.className).css("background","transparent url(/wp-content/themes/default/images/btn"+this.className+"_on.jpg) no-repeat");
	$('#slider_nav #'+'add_btn_'+this.className).css("height","56px");
	/* $('#anime_output').html('<h3>' + this.title + '</h3>'); */
}
