jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};

function loadimage(id,src,width,height,callback) {
	if($(id+' img').length==0) {
		
		var img = new Image();
		
		$(img)
		.load(function () {
			
			$(this).hide();
			
			$(id)
				.removeClass('image_loading')
				.append(this);
			//$(this).fadeIn();
			$(this).show();
			if(callback) { setTimeout(callback,1); }
		})
		
		.error(function () {
		})
	
		.attr({src: src, width: width, height: height});
	}
}

function featured_goto(id,dir,callback) {
	var els=$(id+' .featured');
	var goto=0;
	
	if($(id+' .current-value').length==0) {
		$(id).append('<div class="current-value">0</div>');
	}
	
	var current=parseInt($(id+' .current-value').text());
	
	if(dir=='next') {
		if(current==(els.length-1)) {
			goto=0;
		} else {
			goto=current+1;
		}
	} else if(dir=='prev') {
		if(current==0) {
			goto=(els.length-1);
		} else {
			goto=current-1;
		}
	}
	
	for(var i=0;i<els.length;i++) {
		$(els[i]).show();
		if(i==goto) {
			$(els[i]).css('z-index','2');
		} else if(i==current) {
			$(els[i]).css('z-index','3');
			$(els[i]).fadeOut(750,function() { $(id+' .current-value').text(goto); if(callback) { setTimeout(callback,1); } });
		} else {
			$(els[i]).css('z-index','1');
		}
    }
	return goto;
}