
jQuery.SlideImage = function(select, options) {
	
	var $select = select;
	var $index = 0;
	var $nextindex = 1;
	var $maxImages = jQuery('img', $select).length;
	
	jQuery('img', $select).slice(1).each(function(){
		jQuery(this).hide();
	});
	
	if($maxImages > 1){
		startAnimation();
	}
	
	function startAnimation(){
		t = setTimeout(function(){
			jQuery('img', $select).eq($index).animate({opacity: 'hide'}, 2000, nextImage);
			jQuery('img', $select).eq($nextindex).animate({opacity: 'show'}, 2000);
		 },5000);
	}
	function nextImage(){
		$index++;
		$nextindex++;
		if($index == $maxImages){
			$index = 0;	
		}
		if($nextindex == $maxImages){
			$nextindex = 0;
		}
		startAnimation();
	}
};

jQuery.fn.SlideImage = function(options) {	
	options = options || {};
	var select = this;
	new jQuery.SlideImage(select, options);
};


jQuery(document).ready(function() {
	
	jQuery(".kv_area").SlideImage( {});
	
});
