﻿$(document).ready(function () {
    $("#headerMenu li").css({ opacity: "1" });
	$("#headerMenu li").mouseover(function () {
        $(this).css({ opacity: "0.5" });
    });
    $("#headerMenu li").mouseout(function () {
        $(this).css({ opacity: "1" });
    });
	$("#mainMenu li a").mouseover(function () {
        $(this).animate({ opacity: 0 }, 100);
    });
    $("#mainMenu li a").mouseout(function () {
        $(this).animate({ opacity: 1 }, 300);
    });
    //$(#"#titleFade title02").css({ opacity: "1" });
	$(".title00").css({ opacity: "1" }).delay(300);
	$(".title00").animate({ opacity: 0 }, 700);
	$(".title01").css({ opacity: "1" }).delay(2000);
	$(".title01").animate({ opacity: 0}, 800);

    //$("#titleFade").innerfade({
    //    speed: 4000,
    //   timeout: 5000,
    //    type: 'sequence',
    //    containerheight: '140px'
    //});

    // common -----------------------
    $("#w300").click(function () {
        $(".shoppinglist .item").css('width', '300px')
        });
    $("#w400").click(function () {
        $(".shoppinglist .item").css('width', '400px')
    });
    $("#backpagetop").click(function () {
        $('html,body').animate({ scrollTop: 0 }, 'fast');
    });
    // include liblary ---------------------------
    
    /* This is basic - uses default settings */

    $("a#single_image").fancybox();

    /* Using custom settings */

    $("a#inline").fancybox({
        'hideOnContentClick': true
    });

    /* Apply fancybox to multiple items */

    $("a.group").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'none',
        'speedIn': 400,
        'speedOut': 100,
        'overlayShow': false
    });
    // imagemenu href ---------------------------------
    $("#sm1").click(function () {
        location.href = "bull.aspx";
    });
    $("#sm2").click(function () {
        location.href = "ssru.aspx";
    });
    $("#sm3").click(function () {
        location.href = "weathering.aspx";
    });
    $("#sm4").click(function () {
        location.href = "originalparts.aspx";
    });
    $("#sm5").click(function () {
        location.href = "rsp.aspx";
    });
    // getUserAgent ------------------------------
    myBsr = navigator.appName;                     // ブラウザ名取得
    myAgent = navigator.userAgent;                   // ユーザーエージェント取得
    myTop = myAgent.indexOf("Opera", 0);
    if (myTop == -1) {
        myTop = myAgent.indexOf("MSIE", 0);
        if (myTop == -1) {
            myTop = myAgent.indexOf("Mozilla/", 0);
            if (myTop == -1) {
                myVersion = "";
            } else {
                myLast = myAgent.indexOf(" ", myTop);
                myVer = myAgent.substring(myTop + 8, myLast);
            }
        } else {
            myLast = myAgent.indexOf(";", myTop);
            myVer = myAgent.substring(myTop + 5, myLast);
        }
    } else {
        myBsr = "Opera";
        myLast = myAgent.indexOf(" ", myTop + 6);
        myVer = myAgent.substring(myTop + 6, myLast);
    }
    // IE7 z-index bugfix -------------------------------------------
    if (myVer == "7.0") {
        var zIndexNumber = 1000;
        $('div').each(function () {
            $(this).css('zIndex', zIndexNumber);
            zIndexNumber -= 10;
        });
    }
    // IE6 update ----------------------------------------------------
    else if (myVer == "6.0") {
        $("#header").before("<p class=\"ie6\">IE6以下はサポートしておりません。正しく表示させるにはお使いのブラウザを最新版にアップデートしてください。 <a href=\"http://www.microsoft.com/japan/windows/products/winfamily/ie/function/default.mspx\">最新版をダウンロードする</a>(http://www.microsoft.com/japan/windows/products/winfamily/ie/function/default.mspx)</p>");
    }
    // css control ----------------------------------------------------
    $(".hm li").mouseover(function () {
        $(this).css('background', 'white');
        $(this).css({ opacity: "0.3" });
    });
    $(".hm li").mouseout(function () {
        $(this).css('background', '');
        $(this).css({ opacity: "1" });
    });

    // banner -------------------------------------------------------
    $("#btn_banner_next").css({ opacity: "0.2" });
    $("#btn_banner_prev").css({ opacity: "0.2" });
    $(".banner").css({ opacity: "0.75" });
    var sc_pos = $('.banner').size() - 3;
    var sc_mpos = sc_pos;
    if (sc_pos > 0) {
        $("#btn_banner_next").css({ opacity: "1" });
    }
    $("#btn_banner_next").click(function () { next() });
    $("#btn_banner_prev").click(function () { prev() });
    $("#btn_banner_next").mouseover(function () {
        next()
    });
    $("#btn_banner_prev").mouseover(function () {
        prev()
    });
    function next() {
        if (0 < sc_pos) {
            $("#banner_content").animate({ left: "-=202px" }, 100);
            $("#btn_banner_prev").fadeTo("fast", 1);
            sc_pos -= 1;
            if (0 == sc_pos) { $("#btn_banner_next").fadeTo("fast", 0.2); }
        }
    }
    function prev() {
        if (sc_mpos > sc_pos) {
            $("#banner_content").animate({ left: "+=202px" }, 100);
            $("#btn_banner_next").fadeTo("fast", 1);
            sc_pos += 1;
            if (sc_mpos == sc_pos) { $("#btn_banner_prev").fadeTo("fast", 0.2); }
        }
    }
    $(".banner").mouseover(function () {
        $(this).queue([]);
        $(this).fadeTo("fast", 1);
    });
    $(".banner").mouseout(function () { $(this).fadeTo("fast", 0.75); });

    // titleImg -----------------------------------------------------
    $("ul#title_bg").innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '130px'
    });
    // DDmenu -------------------------------------------------------
    $(".button").mouseover(function () { $(".panel").fadeOut(150); });

    $("#hm1").mouseover(function () {
        $("#hm1_panel").slideDown(150);
        $("#hm1").css("background", "url(img/header_button_product1-a.gif)");
        $("#hm2").css("background", "url(img/header_button_product2.gif)");
        $("#hm3").css("background", "url(img/header_button_guide.gif)");
    });
    $("#hm2").mouseover(function () {
        $("#hm2_panel").slideDown(150);
        $("#hm1").css("background", "url(img/header_button_product1.gif)");
        $("#hm2").css("background", "url(img/header_button_product2-a.gif)");
        $("#hm3").css("background", "url(img/header_button_guide.gif)");
    });
    $("#hm3").mouseover(function () {
        $("#hm3_panel").slideDown(150);
        $("#hm1").css("background", "url(img/header_button_product1.gif)");
        $("#hm2").css("background", "url(img/header_button_product2.gif)");
        $("#hm3").css("background", "url(img/header_button_guide-a.gif)");
    });
    $("#hm4").mouseover(function () {
        $("#hm3_panel").slideDown(150);
        $("#hm1").css("background", "url(img/header_button_product1.gif)");
        $("#hm2").css("background", "url(img/header_button_product2.gif)");
        $("#hm3").css("background", "url(img/header_button_guide.gif)");
    });
    $("#hm5").mouseover(function () {
        $("#hm3_panel").slideDown(150);
        $("#hm1").css("background", "url(img/header_button_product1.gif)");
        $("#hm2").css("background", "url(img/header_button_product2.gif)");
        $("#hm3").css("background", "url(img/header_button_guide.gif)");
    });
    $("#shead").mouseover(function () {
        $(".panel").fadeOut(150);
        $("#hm1").css("background", "url(img/header_button_product1.gif)");
        $("#hm2").css("background", "url(img/header_button_product2.gif)");
        $("#hm3").css("background", "url(img/header_button_guide.gif)");
    });
    $("#content").mouseover(function () {
        $(".panel").fadeOut(150);
        $("#hm1").css("background", "url(img/header_button_product1.gif)");
        $("#hm2").css("background", "url(img/header_button_product2.gif)");
        $("#hm3").css("background", "url(img/header_button_guide.gif)");
    });
    $("#sm1").mouseover(function () {
        quereset();
        $("#sm1").animate({ height: 300 }, "fast");
        $("#sm2").animate({ height: 25 }, "fast");
        $("#sm3").animate({ height: 25 }, "fast");
        $("#sm4").animate({ height: 25 }, "fast");
        $("#sm5").animate({ height: 25 }, "fast");
    });
    $("#sm2").mouseover(function () {
        quereset();
        $("#sm1").animate({ height: 25 }, "fast");
        $("#sm2").animate({ height: 300 }, "fast");
        $("#sm3").animate({ height: 25 }, "fast");
        $("#sm4").animate({ height: 25 }, "fast");
        $("#sm5").animate({ height: 25 }, "fast");
    });
    $("#sm3").mouseover(function () {
        quereset();
        $("#sm1").animate({ height: 25 }, "fast");
        $("#sm2").animate({ height: 25 }, "fast");
        $("#sm3").animate({ height: 300 }, "fast");
        $("#sm4").animate({ height: 25 }, "fast");
        $("#sm5").animate({ height: 25 }, "fast");
    });
    $("#sm4").mouseover(function () {
        quereset();
        $("#sm1").animate({ height: 25 }, "fast");
        $("#sm2").animate({ height: 25 }, "fast");
        $("#sm3").animate({ height: 25 }, "fast");
        $("#sm4").animate({ height: 300 }, "fast");
        $("#sm5").animate({ height: 25 }, "fast");
    });
    $("#sm5").mouseover(function () {
        quereset();
        $("#sm1").animate({ height: 25 }, "fast");
        $("#sm2").animate({ height: 25 }, "fast");
        $("#sm3").animate({ height: 25 }, "fast");
        $("#sm4").animate({ height: 25 }, "fast");
        $("#sm5").animate({ height: 300 }, "fast");
    });
    $("#imageMenu").mouseout(function () {
        quereset();
        $("#sm1").animate({ height: 77 }, "fast");
        $("#sm2").animate({ height: 77 }, "fast");
        $("#sm3").animate({ height: 77 }, "fast");
        $("#sm4").animate({ height: 77 }, "fast");
        $("#sm5").animate({ height: 77 }, "fast");
    });
    // button effect --------------------------------------------------------
//    $(".button").mouseover(function () {
//        $(this).fadeTo(120, 0.80);
//    });

//    $(".button").mouseout(function () {
//        $(this).fadeTo(40, 1);
//    });
});


 
// animate refresh -------------------------------------------------------
function quereset(){
										$("#sm1").queue([]);
										$("#sm2").queue([]);
										$("#sm3").queue([]);
										$("#sm4").queue([]);
										$("#sm5").queue([]);
					}
