//ロールオーバー用JavaScript
/*
v0.1
update 2008.10.27
*/

var ie = false;
//ie6判定
if (typeof document.documentElement.style.maxHeight != "undefined") {
    // IE 7.0 以上 または Gecko などモダンブラウザー
    ie = false;
}
else {
    // IE 6.0 以下
    ie = true;
}

//イベントハンドラを設定
function rollOver() {
    var allimg = document.getElementsByTagName("img");
    for (i = 0; i < allimg.length; i++) {
        if (allimg[i].src.indexOf('_off') >= 0) {
            preloadImg(allimg[i].src.replace('_off', '_on'));
            allimg[i].onmouseover = function() {
                this.setAttribute("src", this.src.replace('_off', '_on'));
            }
            allimg[i].onmouseout = function() {
                this.setAttribute("src", this.src.replace('_on', '_off'));
            }
        }
    }
    if (ie) {
        for (i = 0; i < allimg.length; i++) {
            if (allimg[i].src.indexOf('.png') >= 0) {
                IEPNGFIX.hover(document.getElementById(allimg[i].id), allimg[i].src.replace('_off', '_on'));
            }
        }
    }
}

//プリロードイメージ
function preloadImg(o) {
    var i = new Image;
    i.src = o;
}

//背景マウスオーバー画像のプリロード用配列
var bgimg = Array(
'common/images/bg_contents.png',
'common/images/atab_01_l_t.png',
'common/images/atab_01_l_ty.png',
'common/images/atab_01_l_y.png',
'common/images/atab_02_l_t.png',
'common/images/atab_02_l_ty.png',
'common/images/atab_02_l_y.png',
'common/images/atab_03_l_t.png',
'common/images/atab_03_l_ty.png',
'common/images/atab_03_l_y.png'
);

var move = 0;

window.onload = function() {
    rollOver();
    for (i in bgimg) {
        preloadImg(i);
    }
}

//初期状態
function allwhite() {
    $("#product").hide();
    $("#company").hide();
    $("#contact").hide();
    $("#atab01l").css("background-image", "url(common/images/atab_01_l_w.png)");
    $("#atab01c").css("background-image", "url(common/images/atab_c_w.png)");
    $("#atab01r").css("background-image", "url(common/images/atab_r_w.png)");
    $("#atab02l").css("background-image", "url(common/images/atab_02_l_w.png)");
    $("#atab02c").css("background-image", "url(common/images/atab_c_w.png)");
    $("#atab02r").css("background-image", "url(common/images/atab_r_w.png)");
    $("#atab03l").css("background-image", "url(common/images/atab_03_l_w.png)");
    $("#atab03c").css("background-image", "url(common/images/atab_c_w.png)");
    $("#atab03r").css("background-image", "url(common/images/atab_r_w.png)");
    $("#atab01").css("cursor", "pointer");
    $("#atab02").css("cursor", "pointer");
    $("#atab03").css("cursor", "pointer");
    if (ie) {$("#atabhead").pngFix();}
}

//メインタブ　ロールオーバー処理
function tabOver(n) {
    if ($("#atabbody").is(":hidden")) {
        switch (n) {
            case 1: $("#atab01l").css("background-image", "url(common/images/atab_01_l_y.png)");
                if (ie) {$("#atabhead").pngFix();} break;
            case 2: $("#atab02l").css("background-image", "url(common/images/atab_02_l_y.png)");
                if (ie) {$("#atabhead").pngFix();} break;
            case 3: $("#atab03l").css("background-image", "url(common/images/atab_03_l_y.png)");
                if (ie) {$("#atabhead").pngFix();} break;
        }
    } else {
        switch (n) {
            case 1:
                if (!$("#product").is(":visible")) {
                    $("#atab01l").css("background-image", "url(common/images/atab_01_l_ty.png)");
                    if (ie) {$("#atabhead").pngFix();}
                }
                break;
            case 2:
                if (!$("#company").is(":visible")) {
                    $("#atab02l").css("background-image", "url(common/images/atab_02_l_ty.png)");
                    if (ie) {$("#atabhead").pngFix();}
                }
                break;
            case 3:
                if (!$("#contact").is(":visible")) {
                    $("#atab03l").css("background-image", "url(common/images/atab_03_l_ty.png)");
                    if (ie) {$("#atabhead").pngFix();}
                }
                break;
        }
    }
}

function tabOut(n) {
    if ($("#atabbody").is(":hidden")) {
        switch (n) {
            case 1: $("#atab01l").css("background-image", "url(common/images/atab_01_l_w.png)");
                if (ie) {$("#atabhead").pngFix();} break;
            case 2: $("#atab02l").css("background-image", "url(common/images/atab_02_l_w.png)");
                if (ie) {$("#atabhead").pngFix();} break;
            case 3: $("#atab03l").css("background-image", "url(common/images/atab_03_l_w.png)");
                if (ie) {$("#atabhead").pngFix();} break;
        }
    } else {
        switch (n) {
            case 1:
                if ($("#product").is(":visible")) {
                    $("#atab01l").css("background-image", "url(common/images/atab_01_l_w.png)");
                    if (ie) {$("#atabhead").pngFix();}
                } else {
                    $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
                    if (ie) {$("#atabhead").pngFix();}
                }
                break;
            case 2:
                if ($("#company").is(":visible")) {
                    $("#atab02l").css("background-image", "url(common/images/atab_02_l_w.png)");
                    if (ie) {$("#atabhead").pngFix();}
                } else {
                    $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
                    if (ie) {$("#atabhead").pngFix();}
                }
                break;
            case 3:
                if ($("#contact").is(":visible")) {
                    $("#atab03l").css("background-image", "url(common/images/atab_03_l_w.png)");
                    if (ie) {$("#atabhead").pngFix();}
                } else {
                    $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
                    if (ie) {$("#atabhead").pngFix();}
                }
                break;
        }
    }
}


//製品情報内btn　ロールオーバー処理
function btnOver(n) {
    switch (n) {
        case 1: $("#btn01")[0].setAttribute("src", $("#btn01")[0].src.replace('_of', '_on')); break;
        case 2: $("#btn02")[0].setAttribute("src", $("#btn02")[0].src.replace('_of', '_on')); break;
        case 3: $("#btn03")[0].setAttribute("src", $("#btn03")[0].src.replace('_of', '_on')); break;
        case 4: $("#btn04")[0].setAttribute("src", $("#btn04")[0].src.replace('_of', '_on')); break;
    }
}

function btnOut(n) {
    switch (n) {
        case 1: $("#btn01")[0].setAttribute("src", $("#btn01")[0].src.replace('_on', '_of')); break;
        case 2: $("#btn02")[0].setAttribute("src", $("#btn02")[0].src.replace('_on', '_of')); break;
        case 3: $("#btn03")[0].setAttribute("src", $("#btn03")[0].src.replace('_on', '_of')); break;
        case 4: $("#btn04")[0].setAttribute("src", $("#btn04")[0].src.replace('_on', '_of')); break;
    }
}

var fv = Array(
'#fproducts',
'#fnum',
'#fname',
'#ffurigana',
'#fcompany',
'#fpost',
'#ftel',
'#fmail',
'#ffax',
'#fmessage'
);

//---ウィンドウサイズ制御---
/*$(function() {
    //画像サイズ調節
    resizeImg();
    //ウィンドウのサイズ変化時処理
    $(window).resize(function() {
        resizeImg()
    });
});
var resizeImg = function() {
    var newHeight, newWidth, opObj, newHeight2;
    var frontImg, backImg;
    newHeight = $(window).height() - 258;
    newHeight2 = newHeight - 120;
    newWidth = $(window).width();
    opObj = { height: newHeight };
    $("#productbody").css('height', newHeight);
    $("#companybody").css('height', newHeight);
    $("#contactbody").css('height', newHeight);
    $("#product01").css('height', newHeight2);
    $("#product02").css('height', newHeight2);
    $("#product03").css('height', newHeight2);
    $("#product04").css('height', newHeight2);
    if (newWidth <= 930) {
        $("#footer").css('width', 930);
        $("body").css('width', 930);
    } else {
        $("#footer").css('width', "100%");
        $("body").css('width', "100%");
    }
}*/
//var resizeImg = function() {
//    var newHeight, newWidth, opObj;
//    var frontImg, backImg;
//    newHeight = $(window).height() - 288;
//    newWidth = $(window).width();
//    opObj = { height: newHeight };
//    $("#productbody").animate({ height: newHeight }, 100);
//    $("#companybody").animate({ height: newHeight }, 100);
//    $("#contactbody").animate({ height: newHeight }, 100);
//    if (newWidth <= 930) {
//        $("#footer").animate({ width: "930px" }, 100);
//    } else {
//    $("#footer").animate({ width: "100%" }, 100);
//    }
//}

//ここから
$(function() {
    if (ie) {
        $("#atabhead").pngFix();
        $("#logo").pngFix();
    }
    //Rightナビ　btab開閉
    $("#btabhead").click(function() {
        if (ie == false) {
            $("#btabbody").slideToggle(200);
        }
    });

    //Rightナビ　HOMEボタンでatab閉
    $("#menuclose").click(function() {
        $("#atabbody").hide();
        $("#navi_side").css("bottom", 0);
        if (ie) {
            $("body").toggle();
            $("body").toggle();
        }
        allwhite();
        $("#btabbody").slideToggle(0.1);
        $("#btabbody").slideToggle(0.1);
    });

    //atab内closeボタン
    $(".closebtn").click(function() {
        $("#atabbody").hide();
        $("#navi_side").css("bottom", 0);
        if (ie) {
            $("body").toggle();
            $("body").toggle();
        }
        allwhite();
        $("#btabbody").slideToggle(0.1);
        $("#btabbody").slideToggle(0.1);
    });

    //ロゴクリックで閉じる
    $("#logo").click(function() {
        $("#atabbody").hide();
        $("#navi_side").css("bottom", 0);
        if (ie) {
            $("body").toggle();
            $("body").toggle();
        }
        allwhite();
        $("#btabbody").slideToggle(0.1);
        $("#btabbody").slideToggle(0.1);
    });

    //タブ表示ロールオーバー
    //atabマウスオーバー・マウスアウト
    $("#atab01").hover(function() { tabOver(1); }, function() { tabOut(1); });
    $("#atab02").hover(function() { tabOver(2); }, function() { tabOut(2); });
    $("#atab03").hover(function() { tabOver(3); }, function() { tabOut(3); });



    //タブ切り替え
    //atab 製品情報クリック
    $("#atab01").click(function() {
        if ($("#atabbody").is(":hidden")) {
            if (ie) {
                $("#atabbody").show();
                $("#navi_side").css("bottom", 0);
                $("body").toggle();
                $("body").toggle();
            } else {
                $("#atabbody").slideDown(200);
            }
            $("#btabbody").slideToggle(0.1);
            $("#btabbody").slideToggle(0.1);
            $("#company").hide();
            $("#contact").hide();
            $("#product").show();
            $("#atab01").css("cursor", "default");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "pointer");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#product01").scrollTop(0);
            $("#product02").scrollTop(0);
            $("#product03").scrollTop(0);
            $("#product04").scrollTop(0);
            $("#product01").show();
            $("#product02").hide();
            $("#product03").hide();
            $("#product04").hide();
            $("#h2_01").show();
            $("#h2_02").hide();
            $("#h2_03").hide();
            $("#h2_04").hide();
        } else {
            $("#product").fadeIn("fast");
            $("#company").hide();
            $("#contact").hide();
            $("#atab01").css("cursor", "default");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "pointer");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_w.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_w.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_w.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#product01").scrollTop(0);
            $("#product02").scrollTop(0);
            $("#product03").scrollTop(0);
            $("#product04").scrollTop(0);
            $("#product01").show();
            $("#product02").hide();
            $("#product03").hide();
            $("#product04").hide();
            $("#h2_01").show();
            $("#h2_02").hide();
            $("#h2_03").hide();
            $("#h2_04").hide();
        }
    });
    $("#menuproduct").click(function() {
        if ($("#atabbody").is(":hidden")) {
            if (ie) {
                $("#atabbody").show();
                $("#navi_side").css("bottom", 0);
                $("body").toggle();
                $("body").toggle();
            } else {
                $("#atabbody").slideDown(200);
            }
            $("#btabbody").slideToggle(0.1);
            $("#btabbody").slideToggle(0.1);
            $("#company").hide();
            $("#contact").hide();
            $("#product").show();
            $("#atab01").css("cursor", "default");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "pointer");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            if (ie) { $("#atabhead").pngFix(); }
            $("#product01").scrollTop(0);
            $("#product02").scrollTop(0);
            $("#product03").scrollTop(0);
            $("#product04").scrollTop(0);
            $("#product01").show();
            $("#product02").hide();
            $("#product03").hide();
            $("#product04").hide();
            $("#h2_01").show();
            $("#h2_02").hide();
            $("#h2_03").hide();
            $("#h2_04").hide();
        } else {
            $("#product").fadeIn("fast");
            $("#company").hide();
            $("#contact").hide();
            $("#atab01").css("cursor", "default");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "pointer");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_w.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_w.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_w.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            if (ie) { $("#atabhead").pngFix(); }
            $("#product01").scrollTop(0);
            $("#product02").scrollTop(0);
            $("#product03").scrollTop(0);
            $("#product04").scrollTop(0);
            $("#product01").show();
            $("#product02").hide();
            $("#product03").hide();
            $("#product04").hide();
            $("#h2_01").show();
            $("#h2_02").hide();
            $("#h2_03").hide();
            $("#h2_04").hide();
        }
    });

    //atab 会社情報クリック
    $("#atab02").click(function() {
        if ($("#atabbody").is(":hidden")) {
            if (ie) {
                $("#atabbody").show();
                $("#navi_side").css("bottom", 0);
                $("body").toggle();
                $("body").toggle();
            } else {
                $("#atabbody").slideDown(200);
            }
            $("#btabbody").slideToggle(0.1);
            $("#btabbody").slideToggle(0.1);
            $("#product").hide();
            $("#company").show();
            $("#contact").hide();
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "default");
            $("#atab03").css("cursor", "pointer");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#companybody").scrollTop(0);
        }
        else {
            $("#product").hide();
            $("#company").fadeIn("fast");
            $("#contact").hide();
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "default");
            $("#atab03").css("cursor", "pointer");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_w.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_w.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_w.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#companybody").scrollTop(0);
        }
    });
    $("#menucompany").click(function() {
        if ($("#atabbody").is(":hidden")) {
            if (ie) {
                $("#atabbody").show();
                $("#navi_side").css("bottom", 0);
                $("body").toggle();
                $("body").toggle();
            } else {
                $("#atabbody").slideDown(200);
            }
            $("#btabbody").slideToggle(0.1);
            $("#btabbody").slideToggle(0.1);
            $("#product").hide();
            $("#company").show();
            $("#contact").hide();
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "default");
            $("#atab03").css("cursor", "pointer");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            if (ie) { $("#atabhead").pngFix(); }
            $("#companybody").scrollTop(0);
        }
        else {
            $("#product").hide();
            $("#company").fadeIn("fast");
            $("#contact").hide();
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "default");
            $("#atab03").css("cursor", "pointer");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_w.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_w.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_w.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_t.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_t.png)");
            if (ie) { $("#atabhead").pngFix(); }
            $("#companybody").scrollTop(0);
        }
    });

    //atab お問合わせクリック
    $("#atab03").click(function() {
        if ($("#atabbody").is(":hidden")) {
            if (ie) {
                $("#atabbody").show();
                $("#navi_side").css("bottom", 0);
                $("body").toggle();
                $("body").toggle();
            } else {
                $("#atabbody").slideDown(200);
            }
            $("#btabbody").slideToggle(0.1);
            $("#btabbody").slideToggle(0.1);
            $("#product").hide();
            $("#company").hide();
            $("#contact").show();
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "default");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#contactbody").scrollTop(0);
        }
        else {
            $("#product").hide();
            $("#company").hide();
            $("#contact").fadeIn("fast");
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "default");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_w.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_w.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_w.png)");
            $("#contactbody").scrollTop(0);
        }
    });
    $("#menucontact").click(function() {
        if ($("#atabbody").is(":hidden")) {
            if (ie) {
                $("#atabbody").show();
                $("#navi_side").css("bottom", 0);
                $("body").toggle();
                $("body").toggle();
            } else {
                $("#atabbody").slideDown(200);
            }
            $("#btabbody").slideToggle(0.1);
            $("#btabbody").slideToggle(0.1);
            $("#product").hide();
            $("#company").hide();
            $("#contact").show();
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "default");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            if (ie) { $("#atabhead").pngFix(); }
            $("#contactbody").scrollTop(0);
        }
        else {
            $("#product").hide();
            $("#company").hide();
            $("#contact").fadeIn("fast");
            $("#atab01").css("cursor", "pointer");
            $("#atab02").css("cursor", "pointer");
            $("#atab03").css("cursor", "default");
            $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
            $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
            $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
            $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
            $("#atab03l").css("background-image", "url(common/images/atab_03_l_w.png)");
            $("#atab03c").css("background-image", "url(common/images/atab_c_w.png)");
            $("#atab03r").css("background-image", "url(common/images/atab_r_w.png)");
            if (ie) { $("#atabhead").pngFix(); }
            $("#contactbody").scrollTop(0);
        }
    });

    //お問合わせはこちらボタン
    $(".contactC").click(function() {
        $("#product").hide();
        $("#company").hide();
        $("#contact").fadeIn("fast");
        $("#atab01").css("cursor", "pointer");
        $("#atab02").css("cursor", "pointer");
        $("#atab03").css("cursor", "default");
        $("#atab01l").css("background-image", "url(common/images/atab_01_l_t.png)");
        $("#atab01c").css("background-image", "url(common/images/atab_c_t.png)");
        $("#atab01r").css("background-image", "url(common/images/atab_r_t.png)");
        $("#atab02l").css("background-image", "url(common/images/atab_02_l_t.png)");
        $("#atab02c").css("background-image", "url(common/images/atab_c_t.png)");
        $("#atab02r").css("background-image", "url(common/images/atab_r_t.png)");
        $("#atab03l").css("background-image", "url(common/images/atab_03_l_w.png)");
        $("#atab03c").css("background-image", "url(common/images/atab_c_w.png)");
        $("#atab03r").css("background-image", "url(common/images/atab_r_w.png)");
        $("#contactbody").scrollTop(0);
    });

    //マップ表示
    $("#btnmap").click(function() {
        if ($(".map").is(":hidden")) {
            $(".map").show();
        } else {
            $(".map").hide();
        }
    });


    //製品情報　切り替え
    $("#btn_01").hover(function() { btnOver(1); }, function() { btnOut(1); });
    $("#btn_02").hover(function() { btnOver(2); }, function() { btnOut(2); });
    $("#btn_03").hover(function() { btnOver(3); }, function() { btnOut(3); });
    $("#btn_04").hover(function() { btnOver(4); }, function() { btnOut(4); });

    $("#btn_01").click(function() {
        $("#product01").fadeIn("fast");
        $("#product02").hide();
        $("#product03").hide();
        $("#product04").hide();
        $("#h2_01").fadeIn("fast");
        $("#h2_02").hide();
        $("#h2_03").hide();
        $("#h2_04").hide();
        $("#product01").scrollTop(0);
    });

    $("#btn_02").click(function() {
        $("#product01").hide();
        $("#product02").fadeIn("fast");
        $("#product03").hide();
        $("#product04").hide();
        $("#h2_01").hide();
        $("#h2_02").fadeIn("fast");
        $("#h2_03").hide();
        $("#h2_04").hide();
        $("#product02").scrollTop(0);
    });

    $("#btn_03").click(function() {
        $("#product01").hide();
        $("#product02").hide();
        $("#product03").fadeIn("fast");
        $("#product04").hide();
        $("#h2_01").hide();
        $("#h2_02").hide();
        $("#h2_03").fadeIn("fast");
        $("#h2_04").hide();
        $("#product03").scrollTop(0);
    });

    $("#btn_04").click(function() {
        $("#product01").hide();
        $("#product02").hide();
        $("#product03").hide();
        $("#product04").fadeIn("fast");
        $("#h2_01").hide();
        $("#h2_02").hide();
        $("#h2_03").hide();
        $("#h2_04").fadeIn("fast");
        $("#product04").scrollTop(0);
    });


    //フォーム処理

    for (i in fv) {
        $(fv[i]).blur(function() { checkvalue($(this)); });
    }


    $("#sbtn").click(function() {
		fproducts = 	$("#fproducts").val();
		fnum = 	$("#fnum").val();
		fname = 	$("#fname").val();
		ffurigana = 	$("#ffurigana").val();
		fcompany = 	$("#fcompany").val();
		fpost = 	$("#fpost").val();
		ftel = 	$("#ftel").val();
		fmail = 	$("#fmail").val();
		ffax = 	$("#ffax").val();
		fmessage = 	$("#fmessage").val();		  
		
	var head = "必須項目のご入力をお願いします\n\n";
	var errors = '';
		if (fproducts == ""){
			errors += '　製品\n';}
		if (fnum == ""){
			errors += '　数量\n';}
		if (fname == ""){
			errors += '　お名前\n';}
		if (ffurigana == ""){
			errors += '　フリガナ\n';}
		if (fcompany == ""){
			errors += '　会社名\n';}
		if (fpost == ""){
			errors += '　部署名\n';}
		if (ftel == ""){
			errors += '　電話番号\n';}
		if (fmail == ""){
			errors += '　E-mail\n';}
		if (ffax == ""){
			errors += '　FAX\n';}
		if (fmessage == ""){
			errors += '　お問合わせ内容\n';}
		if (errors != "") {
			errors = head + errors;
			alert (errors);
			return false;
		}
		if(!(checkEmail(fmail))){
			return false;
		}

        //ラジオ判定
        frag = "non";
        frag1 = $("#contact1").attr("checked");
        frag2 = $("#contact2").attr("checked");
        frag3 = $("#contact3").attr("checked");
        if (frag1 == true) {
            frag = "TEL";
        } else if (frag2 == true) {
            frag = "E-MAIL";
        } else if (frag3 == true) {
            frag = "FAX";
        }
        //e or j判定
        url1 = location.pathname;
        checklang = url1.indexOf("index_e", 0);
        if (checklang == -1) {
            en = false;
        } else {
            en = true;
        }
        ESCproducts = EscapeSJIS($("#fproducts").val());
        ESCnum = EscapeSJIS($("#fnum").val());
        ESCname = EscapeSJIS($("#fname").val());

        if (en == false) {
            ESCfurigana = EscapeSJIS($("#ffurigana").val());
        }
        ESCcompany = EscapeSJIS($("#fcompany").val());
        ESCpost = EscapeSJIS($("#fpost").val());
        ESCcontact = EscapeSJIS(frag);
        ESCtel = EscapeSJIS($("#ftel").val());
        ESCmail = EscapeSJIS($("#fmail").val());
        ESCfax = EscapeSJIS($("#ffax").val());
        ESCmessage = EscapeSJIS($("#fmessage").val());

        if (en == false) {
            $.post('http://www.lotus-jp.net/cgi-bin/mail.cgi',
                   {
                       products: ESCproducts,
                       num: ESCnum,
                       name: ESCname,
                       furigana: ESCfurigana,
                       company: ESCcompany,
                       post: ESCpost,
                       contact: ESCcontact,
                       tel: ESCtel,
                       mail: ESCmail,
                       fax: ESCfax,
                       message: ESCmessage
                   }
                    , jQueryRequest);
        } else {
            $.post('http://www.lotus-jp.net/cgi-bin/mail_e.cgi',
                   {
                       products: ESCproducts,
                       num: ESCnum,
                       name: ESCname,
                       company: ESCcompany,
                       post: ESCpost,
                       contact: ESCcontact,
                       tel: ESCtel,
                       mail: ESCmail,
                       fax: ESCfax,
                       message: ESCmessage
                   }
                    , jQueryRequest);
        }
    });
    $("#confirm").click(function() {
        $("form").show();
        $("#confirm").hide();
    });
});
//ここまで
function checkvalue(t) {
    if ('' == t.val()) {
        t.css("border-color", "red");
    } else { t.css("border-color", "gray"); }
}
function jQueryRequest(message, status) {
    if (message == 1) {
        $("form").hide();
        $("#confirm").show();
        $("#fproducts").val("");
        $("#fnum").val("");
        $("#fname").val("");
        $("#ffurigana").val("");
        $("#fcompany").val("");
        $("#fpost").val("");
        $("#ftel").val("");
        $("#fmail").val("");
        $("#ffax").val("");
        $("#ffax").val("");
        $("#fmessage").val("");
    } else if (message == 2 || status == 'error') {
        alert('送信に失敗しました。\nもう一度送信をお試しになるか、直接お電話にてお問い合わせください。');
	}else if(message == 3){
	alert('送信に失敗しました。\入力内容をお確かめの上、もう一度送信をお試しになるか、直接お電話にてお問い合わせください。');
	}
}


function checkEmail(checkString){
	var newstr = "";
	var at = false;
	var dot = false;

	if (checkString.indexOf("@") != -1) {
		at = true;
	} else if (checkString.indexOf(".") != -1) {
		dot = true;
	}
	for (var i = 0; i < checkString.length; i++) {
		ch = checkString.substring(i, i + 1)
		if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
			|| (ch == "@") || (ch == ".") || (ch == "_")
			|| (ch == "-") || (ch >= "0" && ch <= "9")) {
			newstr += ch;
			if (ch == "@") {
				at=true;
			}
			if (ch == ".") {
				dot=true;
			}
		}
	}
	if ((at == true) && (dot == true)) {
		return newstr;
	} else {
		alert ("入力されたメールアドレスを確認してください。\n");
		return false;
	}
}
