/* =====================================================================
*
*    utility.js
*
* =================================================================== */

jQuery.extend(jQuery.easing,
{
	easeInQuart: function (x, t, b, c, d)
	{
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d)
	{
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d)
	{
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	}
});

var Util = function()
{
	var init = function()
	{
		$(document).ready(function()
		{
			$('a[href^="#"]').click(function()
			{
				var ty = $($(this).attr("href")).position().top;
				$('html,body').animate({scrollTop: ty}, 1000, 'easeInOutQuint');
				return false;
			});
		});
	}();

	return{

	}
}();


/**
 * list slider
 * @param {Object} $
 */
(function($){
    $.fn.listLoop = function(options)
	{
		var defaults = {
			parent: this,
			viewTime: 3000,
			fadeDelay: 500,
			slideDelay: 1000,
			startDelay: 0
		};
		var options = $.extend(defaults, options);
		var timer, view = false;

		this.find("div.item").hover(function(e) {
				// mouseover
				var item = $(this);
				if (item.find('a')[0])
				{
					view = true;
					pause();
					window.status = item.find('a').attr('href');
					item.removeClass('item-normal').addClass('item-hover').animate({opacity:.7}, defaults.overDelay, "");
				}
			},
			function()
			{
				// mouseout
				var item = $(this);
				if (item.find('a')[0])
				{
					view = false;
					play();
					item.removeClass('item-hover').addClass('item-normal').animate({opacity:1}, defaults.outDelay, "");
				}
		});
		this.find("div.item").click(function(e) {
			var ele = $(this).find('a');
			if(ele[0]) location.href = ele.attr('href');
			//if(e.target.tagName != 'A')	ele.click();
		});
		var play = function(){
			if(timer) return;
			timer = setTimeout(execute, defaults.viewTime);
		};
		var pause = function(){
			clearTimeout(timer);
			timer = null;
		}
		var execute = function()
		{
			clearTimeout(timer);
			defaults.parent.find("li:first-child").animate({opacity:0}, defaults.fadeDelay, "", function(){
				$(this).slideUp(defaults.slideDelay, function(){
					var t = $(this);
					var th = t.height();
					defaults.parent.append(t);
					t.slideDown(0).animate({opacity:1}, defaults.fadeDelay, "", function(){});
					if(! view) timer = setTimeout(execute, defaults.viewTime);
				});
			});
		};
		var init = function()
		{
			setTimeout(play, defaults.startDelay);
		}();

		return this;
    };
	$.fn.itemHover = function(options)
	{
		var defaults = {
			overDelay: 100,
			outDelay: 270
		};
		var options = $.extend(defaults, options);

		$(this).hover(function(e) {
			if ($(this).find('a')[0])
			{
				window.status = $(this).find('a').attr('href');
				$(this).removeClass('item-normal');
				$(this).addClass('item-hover');
				$(this).animate({opacity:.7}, defaults.overDelay, "");
			}
		},
		function()
		{
			if ($(this).find('a')[0])
			{
				$(this).removeClass('item-hover');
				$(this).addClass('item-normal');
				$(this).animate({opacity:1}, defaults.outDelay, "");
			}
		});
		$('div.item').click(function(e) {
			var ele = $(this).find('a');
			if(ele[0]) location.href = ele.attr('href');
		});
		return this;
	};
})(jQuery);


/** =====================================================================
*
* Btn effect
*
* =================================================================== */
$(document).ready(function()
{
	$('.link1').hover(function()
	{
		$(this).stop();
        $(this).fadeTo(200, .7);
    },
    function()
	{
        $(this).fadeTo(300, 1.0);
    });
});



