/**
 *--------------------------------------------------------------------
 * wakabadai init js
 *--------------------------------------------------------------------
 **/

$(function(){

    //ロールオーバーのjsがie6でエラー吐くので読み込まない。
    //opactyじゃなく拡張の方使えばいけるか？
    if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6){
    } else {
        var script_tag     = document.createElement("script");
        script_tag.type    = "text/javascript";
        script_tag.src     = "/common/js/flashroll.js";
        script_tag.charset = "utf-8";
        $("body").append(script_tag);
    }

    //とりあえず隠してる
    //$("#side_nav_box ul li ul").hide();

    //電話帳は外す。
    var windHash = window.location.hash;
    //ページ内スクロール
	$("a[href^=#]").click(function(){
        if(windHash.match(/#book/g)){
        } else {
    		var Hash = $(this.hash);
    		var HashOffset = $(Hash).offset().top;
    		$("html,body").animate({
    			scrollTop: HashOffset
    		}, 'slow');
    		return true;
        }
	});


    //奇数行偶数行で色分け
    $("#busroute_timetable_block tbody tr:odd").css("background-color","#f5f5f5");
    $(".constructNews .constructList li:odd").css("background-color","#f5f5f5");
    $(".center_news_list .items .item:odd").css("background-color","#f5f5f5");


    //お問合わせ
    $("#inquiry_form .row:even").css("background-color","#f5f5f5");
    $("#inquiry_form .row input").focus(function(){
        $(this).css("background-color","#FFF5D6");
        $(this).css("border-color","#FF9900");
    });
    $("#inquiry_form .row input").blur(function(){
        $(this).css("background-color","#ffffff");
        $(this).css("border-color","inherit");
    });
    $("#inquiry_form .row textarea").focus(function(){
        $(this).css("background-color","#FFF5D6");
        $(this).css("border-color","#FF9900");
    });
    $("#inquiry_form .row textarea").blur(function(){
        $(this).css("background-color","#ffffff");
        $(this).css("border-color","inherit");
    });
    $("#inquiry_form .row select").focus(function(){
        $(this).css("background-color","#FFF5D6");
        $(this).css("border-color","#FF9900");
    });
    $("#inquiry_form .row select").blur(function(){
        $(this).css("background-color","#ffffff");
        $(this).css("border-color","inherit");
    });




/*サイドナビ
------------------------------------------------------------*/
$("#side_nav_box li.active").addClass("active_parent");
$("#side_nav_box ul .active").parent().parent().addClass("active_parent");
$("#side_nav_box ul li .active").parent().parent().parent().parent().addClass("active_parent");


var pageUrl = window.location.pathname;
str = pageUrl;
if (
str.match(/serviceNews6/g)
) {
    $("#side_nav_box ul #parent2").addClass("active_parent");
}
else if (
str.match(/renovation/g) ||
str.match(/serviceNews1/g) ||
str.match(/serviceNews2/g) ||
str.match(/serviceNews6/g)
) {
    $("#side_nav_box ul #parent3").addClass("active_parent");
}
else if (
str.match(/lifeSupport/g) ||
str.match(/construction/g) ||
str.match(/phoneBook/g) ||
str.match(/serviceNews3/g) ||
str.match(/serviceNews4/g) ||
str.match(/serviceNews5/g) ||
str.match(/serviceNews7/g)
) {
    $("#side_nav_box ul #parent4").addClass("active_parent");
}


});

