//Index Fade
var i = 0;
var int = 0;
$(window).bind("load", function() {
	$('#wrapper,#wrapper_news').fadeIn(2500);
	var int=setInterval("sFade(i)",2500);
});
function sFade() {
	if (i >= 1) {
		clearInterval(int);
	}
	if (i == 0) {
		$('#navi').fadeIn(2500);
	}
	if (i == 0) {
		$('#logo').fadeIn(2500);
	}
    i++;
}



//Smoothscroll
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(document).ready(function(){
	jQuery('a[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({ scrollTop: targetOffset }, 1200, 'quart');
                return false;
            }
        }
    });
});



//Mainpanel
function slideSwitch() {
    var $active = $('#mainpanel img.active');
    if ( $active.length == 0 ) $active = $('#mainpanel img:last');
    var $next =  $active.next().length ? $active.next()
        : $('#mainpanel img:first');

    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2500, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 7000 );
});



//Pickup
var imageIndex=0;
$(function(){
   $("#pickup>a img").css({"position":"absolute","top":"0px"});
   $("#pickup>a img:gt(0)").hide();
   $("#arrow").click(function(){
      var oldIndex= imageIndex;
      imageIndex= ++imageIndex % $("#pickup>a img").size();
      $("#pickup>a img:eq("+oldIndex+")").fadeOut("slow");
      $("#pickup>a img:eq("+imageIndex+")").fadeIn("slow");
      });
});



//Newarrival
$(document).ready(function () {
	$('ul#pages a').click(function () {
		//reset all the items
		$('ul#pages a').removeClass('active');
		//set current item as active
		$(this).addClass('active');	
		//scroll it to the right position
		$('.mask').scrollTo($(this).attr('rel'), 1650);
		//disable click event
	    return false;		
	});
});
