
/*==============================================
	Onload function Module
==============================================*/


/* rollover Module -----------------*/

/* マウスダウン付きのロールオーバー -----------------*/
function moduleStart(){
SimpleLib.bind( "init_button", function(){  
    $(function(){  
        $(".btn-roll").button( { over:true, down:true, selected:true, fade:false } );  
        $(".btn-roll").click( function(){  
            $(this).button("down" );  

        });  
    });  
}, true );  

/* 透過を利用したロールオーバー -----------------*/

$(function() {
	var opacity_image=new Object();
	$('.roll img, input:image').not("[src*='_on.']").each(function(i){
//		var i=$(this).attr('class');
		if (!($(this).hasClass('no_rollover') || $(this).hasClass('map_area_js'))) {
//		if(i!='no_rollover' || i!='map_area_js'){
			$(this).hover(function(){
				$(this).css({cursor:'pointer',opacity:'0.90'});
			},function(){
				$(this).css({cursor:'default',opacity:'1'});
			});
		}
	});

/* fontsize Module -----------------*/
$('.mojisize li').hover(function(){
		$(this).css({cursor:'pointer'});
	},function(){
		$(this).css({cursor:'default'});
});

/* mainimage fade Module -----------------*/
	$('head').append('<style type="text/css">#headmain img{display:none;}</style>');
	$(function(){
    $('#headmain img').fadeIn(2000);	
	});

});


/* form Module -----------------*/
/*
$(function(){
	$('form').jqTransform({imgPath:'jqtransformplugin/img/'});
});


;
*/


/* image_carousel Module -----------------*/
$(function(){
$("#foo2").carouFredSel({
    curcular: false,
    infinite:  false,
    auto :  true,
    prev : {   
        button  : "#foo2_prev",
        key     : "left"
    },
    next : {
        button  : "#foo2_next",
        key     : "right"
    },
    pagination  : "#foo2_pag"
});
});
}








/* smoothScroll -------------------*/
var smoothScroll = {};
smoothScroll.scrolling = false;
smoothScroll.start = function(targetId,easing,callbackFunc) {
	smoothScroll.scrolling = true;
	var $element = $('#'+targetId)[0];
	var easing = easing || 0.14;
	var interval = 30;
	var st = $(document).scrollTop();
	var sl = $(document).scrollLeft();
	var ww = $(window).width();
	var wh = $(window).height();
	var dw = $(document).width();
	var dh = $(document).height();
	var tX = 0; var tY = 0;
	var myTimer, moveX, moveY;
	while($element) {
	   tX += $element.offsetLeft;
	   tY += $element.offsetTop;
	   $element = $element.offsetParent;
	}
	if (dw > (tX + ww)) {
		var toX = tX - sl;
	} else {
		var toX = dw - sl - ww;
	}
	if (dh > (tY + wh)) {
		var toY = tY - st;
	} else {
		var toY = dh - st - wh;
	}
	function windowScroll() {	
		if (0 > toX) {
			moveX = Math.floor(toX*easing);
		} else {
			moveX = Math.ceil(toX*easing);
		}		
		if (0 > toY) {
			moveY = Math.floor(toY*easing);
		} else {
			moveY = Math.ceil(toY*easing);
		}		
		sl += moveX;
		st += moveY;
		window.scrollTo(sl, st);
		toX -= moveX;
		toY -= moveY;
		myTimer = setTimeout(windowScroll,interval);
		if (moveX == 0 && moveY == 0) {
			smoothScroll.scrolling = false;
			clearTimeout(myTimer);
			if ($.isFunction(callbackFunc)) { callbackFunc; }
		}
	}
	windowScroll();	
};
smoothScroll.setup = function() {
	var
		allLinks = document.links,
		lnk = "",
		targetId;
	for(var i = 0 ; i < allLinks.length; i++) {
		lnk = allLinks[i];
		if ((lnk.href && lnk.href.indexOf('#') != -1) && ((lnk.pathname == location.pathname) || ('/'+lnk.pathname == location.pathname)) && $(lnk).hasClass("scroll")) {
			lnk.onclick = function() {
				if (smoothScroll.scrolling) { return; }
				targetId = this.hash.replace(/#/g,"");
				if (document.getElementById(targetId)) {
					smoothScroll.start(targetId);
					return false;
				}
			};
		}
	}
};
//$(document).ready(smoothScroll.setup);
