// JavaScript Document


//　page top 
$(function(){
     $("#toTop a").click(function(){
     $('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
     return false;
     })
});


// 画像ロールオーバー（切り替え）
$(function(){
     $('a img').hover(function(){
        $(this).attr('src', $(this).attr('src').replace('_off', '_on'));
          }, function(){
             if (!$(this).hasClass('currentPage')) {
             $(this).attr('src', $(this).attr('src').replace('_on', '_off'));
        }
   });
});


// TOPページの画像切り替えスクリプト
//　http://cssglobe.com/post/6023/simple-way-to-random-display-or-rotate-content-using

this.randomtip = function(){
	var length = $("#tips li").length;
	var ran = Math.floor(Math.random()*length) + 1;
	$("#tips li:nth-child(" + ran + ")").fadeIn(3000);
};

$(document).ready(function(){	
	randomtip();
});



// フローティングウィンドウ（TOPのfairで使用）


$(function(){
    $("a.open").click(function(){
        $("#floatWindow").fadeIn("fast");
        return false;
    })
    
    $("#floatWindow a.close").click(function(){
        $("#floatWindow").fadeOut("fast");
        return false;
    })
    $("#floatWindow dl dt").mousedown(function(e){
        
        $("#floatWindow")
            .data("clickPointX" , e.pageX - $("#floatWindow").offset().left)
            .data("clickPointY" , e.pageY - $("#floatWindow").offset().top);
        
        $(document).mousemove(function(e){
            $("#floatWindow").css({
                top:e.pageY  - $("#floatWindow").data("clickPointY")+"px",
                left:e.pageX - $("#floatWindow").data("clickPointX")+"px"
            })
        })
        
    }).mouseup(function(){
        $(document).unbind("mousemove")
        
    })
})



// lightbox

    $(function() {
        $('#gallery a').lightBox();
    });
   

