//	JS ENHANCEMENTS

$ = jQuery.noConflict();

$(function(){
	$('#wwc_sshow').sshow({
		slideTime: 800,
		fadeTime: 1000,
		delayTime: 8000
	});
	$('p.btn').fbtn({
		fadeTime: 300
	});
});

(function($) {

	$.fn.dummy = function(){
		if (this.length == 0){
			return $(this);
		}
		return $(this);
	}

	$.fn.fbtn = function(param){
		if (this.length == 0){
			return $(this);
		}
		var loc = {
			fadeTime: 300
		}
		loc = $.extend(loc, param);
		for (i=0; i<this.length; i++){
			var $a = $(this).eq(i).find('a');
			var $b = $a.clone().addClass('hv');
			$a.parent().append($b.hide());
		}
		var hvon = function(){
			$(this).find('a.hv').stop(true, true).fadeIn(loc.fadeTime);
		}
		var hvof = function(){
			$(this).find('a.hv').stop(true, true).fadeOut(loc.fadeTime);
		}
		$(this).hover(hvon, hvof);
		return $(this);
	}

	$.fn.sshow = function(param){
		if (this.length == 0){
			return $(this);
		}
		var loc = {
			fadeTime: 800,
			slideTime: 400,
			delayTime: 10000
		};
		loc = $.extend(loc, param);

		loc.int = '';
		loc.count = 0;
		var $slides = $(this).find('div.slide');

		ssfn = function(){
			setInterval(function(){
				$slides.eq(loc.count).children('div.desc').animate({
					marginTop: 280
				}, loc.slideTime, function(){
					$(this).parent().fadeOut(loc.fadeTime);
				});
				loc.count++;
				if (loc.count == $slides.length){
					loc.count = 0;
				}
				setTimeout(function(){
					$slides.eq(loc.count).fadeIn(loc.fadeTime, function(){
						$(this).children('div.desc').animate({
							marginTop: 0
						}, loc.slideTime);
					});
				}, loc.slideTime + loc.fadeTime);
			}, loc.delayTime + (loc.slideTime + loc.fadeTime)*2);
		}
		ssfn();
		return $(this);
	}

//	LOGGING FUNCTIONS FOR TROUBLESHOOTING

	$.fn.log = function(){
		if (window.console){
			console.log($(this));
		}
		return $(this);
	}

	$.log = function(inp){
		if (window.console){
			console.log(inp);
		}
		return inp;
	}

})(jQuery);

