//トップへ戻る
function pageTop() {
	var sc1 = sc2 = sc3 = 0;
	if (document.documentElement) {
		sc1 = document.documentElement.scrollTop || 0;
	}
	if (document.body) {
		sc2 = document.body.scrollTop || 0;
	}
	sc3 = window.scrollY || 0;
	var sc = Math.max(sc1, Math.max(sc2, sc3));
	window.scrollTo(0, Math.floor(sc / 1.1));
	if (sc > 0) {
		window.setTimeout("pageTop()", 10);
	}
}

//実行
$(function(){

	//画像リンクフェード
	$(document).ready(function(){
		$("a img").hover(function(){
			$(this).fadeTo(200, 0.3);
		},function(){
			$(this).fadeTo(300, 1.0);
		});
	});
	
	//スライドショー部分スライド
	$('#slideshow').cycle({
		fx:     'scrollHorz',
		timeout: 7000,
		next:   '#rarr',
		prev:   '#larr'
	});
	
	$('#larr, #rarr').hide();
	$('.slideshow').hover(
		function(){
			$('#larr, #rarr').show();
		}, function(){
			$('#larr, #rarr').hide();
		}
	);
	
	//lightbox
	$("#itemDetail a[rel='lightbox[group]']").lightBox();
	
	/*** Dropdown menu ***/
        
    var timeout    = 200;
    var closetimer = 0;
    var ddmenuitem = 0;

    function dd_open() {
        dd_canceltimer();
        dd_close();
        var liwidth = $(this).width();
        ddmenuitem = $(this).find('ul').css({'visibility': 'visible', 'width': liwidth});
        ddmenuitem.prev().addClass('dd_hover').parent().addClass('dd_hover');
    }

    function dd_close() {
        if(ddmenuitem) ddmenuitem.css('visibility', 'hidden').prev().removeClass('dd_hover').parent().removeClass('dd_hover');
    }

    function dd_timer() {closetimer = window.setTimeout(dd_close, timeout);
    }

    function dd_canceltimer() {
        if (closetimer) {
            window.clearTimeout(closetimer);
            closetimer = null;
        }
    }
    document.onclick = dd_close;

    $('#dd > li').bind('mouseover', dd_open);
    $('#dd > li').bind('mouseout',  dd_timer);

    $('#larr, #rarr').hide();
    $('.slideshow').hover(
        function(){
            $('#larr, #rarr').show();
        }, function(){
            $('#larr, #rarr').hide();
        }
    );

    
});
