
function onBefore() { 
	$('#output').html("Scrolling image:<br>" + this.src); 
} 
function onAfter() { 
	$('#output').html("Scroll complete for:<br>" + this.src) 
		.append('<h3>' + this.alt + '</h3>'); 
}

(function($) {
    $.fn.simpleTab = function(options){
        options = options || {};
        return this.each(function(){
            var self = this,
            localOptions = $.extend({selectedClass: "tab-current"}, options);
            
            $(this).addClass('tabs-wrapper');
            $('div.tabbed-body div', this).hide();
            $('div.tabbed-body div:first', this).show();
            $('div.tabbed-head div.navigation a:first', this).addClass(localOptions.selectedClass);
            
            $('div.tabbed-head div.navigation a', this).click(function(){
                var href = $(this).attr('href');
                $('div.tabbed-body div', self).hide();
                $('div.tabbed-body div' + href, self).show();
                $('div.tabbed-head div.navigation', self).removeClass(localOptions.selectedClass);
                $(this).parent().addClass(localOptions.selectedClass);
                return false;
            });
        });
    };
    $.fn.simpleTab2 = function(options){
        options = options || {};
        return this.each(function(){
            var self = this,
            localOptions = $.extend({selectedClass: "tab-current"}, options);
            
            $(this).addClass('tabs-wrapper');
            $('div.tabbed-body div', this).hide();
            $('div.tabbed-body div:first', this).show();
            $('div.tabbed-head ul.tabs li:first', this).addClass(localOptions.selectedClass);
            
            $('div.tabbed-head ul.tabs li a', this).click(function(){
                var href = $(this).attr('href');
                $('div.tabbed-body div', self).hide();
                $('div.tabbed-body div' + href, self).show();
                $('div.tabbed-head ul.tabs li', self).removeClass(localOptions.selectedClass);
                $(this).parent().addClass(localOptions.selectedClass);
                return false;
            });
        });
    };
})(jQuery);
$(function() { 
    $('#menu-lavalamp').lavaLamp({
        fx: 'easeOutSine',
        speed: 800,
        homeTop:-1,
        homeLeft:-20
    });
    $('#menu-lavalamp li').hover(
        function(){
            $(this).children('ul').css({visibility:"visible", display:"none"}).slideDown('slow');
        },
        function(){
            $(this).children('ul').css({visibility:"hidden", display:"none"});
        }
    );
    $('.menu').click(function(){
        return false;
    });
 	$('#item_mall').innerfade({
		speed: 'slow',
		timeout: 5000,
		type: 'sequence'
	});
		
	$('#news_wrapper').simpleTab();
	$('#gallery_wrapper').simpleTab();
	$('#event_wrapper').simpleTab2({selectedClass:"tab-current-commu"});
    $('#items_wrapper').simpleTab2({selectedClass:"tab-current-items"});
	
    $('form').attr("AutoComplete", "off");
    
    
    var sagaMenuLiWidth =5;
    var sagaMenuWidth = $(".saga_menu_mid").width();
    var sagaMenuLiSize = $(".saga_menu_mid ul > li").length;
    var cssSagaMarginLeft = (sagaMenuWidth - (sagaMenuLiSize * sagaMenuLiWidth)) / (sagaMenuLiSize + 1);
    $(".saga_menu_mid ul li").css({"width":sagaMenuLiWidth, "margin-left":cssSagaMarginLeft});
    
	
	var boxy = $('.boxy').boxy({x: 150, y: 30});
	
	$("body").click(function(event){
		var targets = $(event.target);
		if (targets.is("img")) {
			targets = targets.parent();
		}
		if (targets.is("a[rel='linkInnerBoxy']")) {
			var href = targets.attr('href');
			var orTu = targets.parents(".boxy-content");
			orTu.empty();
			$.get(href, function(msg){
				orTu.append(msg);
				orTu.children('.boxyChild').removeClass('boxyChild');
			});
			return false;
		}
	});
	$(".tips").tooltip();
    $('#system-lavalamp').lavaLamp({
        fx: 'easeOutExpo',
        speed: 800,
        startItem: 0
    });

	
});		 

$(document).ready(function(){	
    $('#banner_content').cycle({
		fx:     'fade', 
		timeout: 5000, 
		pager:  '#ban_nav',
		before:  onBefore, 
		after:   onAfter
	});	
});
