// jQuery Based ClossFading Plugin.
$.fn.crossFade = function(){
	if(this.length==0) return;
	var s, o, t, f, a=[], h=[], c=0, l=this.length - 1, p='cross_fade_target';
	
	// Fade Span
	s = (arguments.length > 0)? arguments[0]: 6000;
	
	// Periodical Cross Fading
	f = function(){
		if(l==0) return;
		a[c].animate({"opacity":"0"}, 800);
		c = (c==l) ? 0: c+1;
		a[c].animate({"opacity":"1"}, 800);
		a[l].attr('href', h[c]);
	};
	t = setInterval(f, s);
	
	// MouseOver Handler
	$(this[0]).parent()
		.mouseover(function(e) {
			clearInterval(t);
			$(this).find('.'+p+c.toString()).animate({"opacity":"0.85"}, 200);
		})
		.mouseout(function() {
			t = setInterval(f, s);
			$(this).find('.'+p+c.toString()).animate({"opacity":"1"}, 200);
		});
	
	// Adding AscendingOrder ClassName
	return this.each(function(i, val){
		$(this).addClass(p+i.toString());
		a.push($(this));
		h.push($(this).attr('href'));
		if(i==l) $(this).attr('href', h[0]);
	});
};
