$(function(){
    $('#Alert a').click(function() {
        McdMessage.hideAlert();
    });
    $('#Error a').click(function() {
        //McdMessage.hideError();
    });

});


var McdMessage = {
    showAlert: function(msg){
        var l = Math.floor(($(window).width() - $("#Alert").width()) / 2); 
        var t = Math.floor(($(window).height() - $("#Alert").height()) / 2); 
        if(msg !=  undefined){
            $("#Alert ul li:eq(0)").text(msg);
            $("#Alert ul li:eq(1)").text("");
        }else {
            if( $("#Alert ul li:eq(1)").text().length == 0 ){
                $("#Alert ul li:eq(0)").text("キーワードを見直す");
                $("#Alert ul li:eq(1)").text("絞り込み検索の項目を見直す");
            }
        }
        $("#Alert").css({top:t, left:l}).show();
        //$("#Alert").css({top:t, left:l}).fadeIn("middle");
        //$("#Alert").css({ "top": t, "left": l, "opacity": 0 }).animate({opacity: "1"},{queue: true, duration: 4000, easing: "linear", complete: function(){} });
    },
    hideAlert: function(){
        $("#Alert").hide();
        //$("#Alert").fadeOut("middle");
    },
    showError: function(knd, type, func){
        if( knd != undefined || type!= undefined || func!= undefined){
            $("#Error p.ErrorCode").text("エラーコード：" + McdShopError._setErrorCode(knd, type, func));
        }
        var l = Math.floor(($(window).width() - $("#Error").width()) / 2); 
        var t = Math.floor(($(window).height() - $("#Error").height()) / 2); 
        $("#Error").css({top:t, left:l}).show();
        // JQeryのfedeIn+透過ファイルは透過IEで透過部分が黒くなってしまうため、未使用
        //$("#Error").css({top:t, left:l}).fadeIn("middle");
        //$("#Error").css({ "top": top, "left": left, "opacity": 0 }).animate({opacity: "1"},{queue: true, duration: 4000, easing: "linear", complete: function(){} });
    },
    hideError: function(){
        $("#Error").hide();
        //$("#Error").fadeOut("middle");
    }
};

var McdShopError  = {
    // エラーコード1桁
    errKnd : {
        "js"    : "0",
        "mcdapi": "1",
        "zdcapi": "2",
        "api"   : "3",
        "pages" : "4"
	},

    // エラーコード2桁
    /*
    errOccur : {
        'display'   : "0",
        'railway'   : "1",
        'shops'     : "2",
        'landmarks' : "3",
        'stations'  : "4",
        'detail'    : "5",
        'printmap'  : "6",
        'other'     : "9"
	};
    */

    // エラーコード3桁
    errType  : {
        "input"     : "0",
        "connect"   : "1",
        "apierror"  : "2",
        "other"     : "9"
    },

    // APIメソッド
    errFunc : {
        "none"              : "0",
        "shopSearch"        : "1",  // mcdapi
        "stationSearch"     : "3",  // mcdapi,api
        "landmarkSearch"    : "4",  // mcdapi,api
        "genreList"         : "5",  // mcdapi
        "aroundshop"        : "6",  // api
        "other"             : "9"   // zcdapi
    },

    _setErrorCode: function(knd, type, func){
            var kyou = new Date();
            var yy = kyou.getFullYear();
            var mm = kyou.getMonth() + 1;
            var dd = kyou.getDate();
            var hh = kyou.getHours();
            var mi = kyou.getMinutes();
            var ss = kyou.getSeconds();
            var code  = ""+yy + mm + dd + hh + mi + ss +"-";
            code  += this.errKnd[knd];

	        if(window.location.pathname.indexOf("shops") >= 0){
                code  += "2";
            } else if (window.location.pathname.indexOf("railway") ){
                code  += "1";
            } else if (window.location.pathname.indexOf("landmarks") ){
                code  += "3";
            } else if (window.location.pathname.indexOf("stations") ){
                code  += "4";
            } else if (window.location.pathname.indexOf("map.php") ){
                code  += "5";
            } else if (window.location.pathname.indexOf("printmap") ){
                code  += "6";
            } else {
                code  += "0";
            }

            code  += this.errType[type];
            code  += (this.errFunc[this.func]) ? this.errFunc[func] : this.errFunc['none'];
            return code;
    }
}

function IconWindow(){
    var url = "/shop/map/abouticon.html";
    window.open(url,'_blank','width=456,height=380,scrollbars=no,resizable=no');
}

