/**
 *
 * areaは以下のとおり
 * tohoku(北海道・東北),kyusyu（九州沖縄）
 *
 *
 *
 * ロールオーバー用画像は頭にov_(edPref.id).gifとする
 *
 */

var openArea = '';
var edPrefs = new Array();
var areaOvFlug = true;


function edPref(id, display , coords , area ,ov_top,ov_left,ov_coords) {
	this.id = id;				// 識別ID urlと同じにしておく
	this.display = display;		// 表示名
	this.coords = coords;		// 都道府県選択用areaタグcoords
    this.area = area; // エリアグループ

    this.ov_top  = ov_top
    this.ov_left = ov_left
    this.ov_coords = ov_coords;
}

edPrefs.push(
	new edPref(
		'hokkaido'
		,'北海道'
		,'295,64,429,64,429,132,295,132,295,64'
        ,'tohoku'
        ,'64px'
        ,'295px'
        ,''
	)
);

edPrefs.push(
	new edPref(
		'aomori'
		,'青森'
		,'295,141,410,141,410,161,295,161,295,141'
        ,'tohoku'
        ,'141px'
        ,'295px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'akita'
		,'秋田'
		,'295,161,360,161,360,185,326,185,326,182,295,182,295,161'
        ,'tohoku'
        ,'161px'
        ,'295px'
        ,'0,0,65,0,65,24,31,24,31,21,0,31,0,0'
	)
);



edPrefs.push(
	new edPref(
		'iwate'
		,'岩手'
		,'360,161,410,161,410,185,360,185,360,161'
        ,'tohoku'
        ,'161px'
        ,'360px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'yamagata'
		,'山形'
		,'326,185,360,185,360,210,326,210,326,185'
        ,'tohoku'
        ,'185px'
        ,'326px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'miyagi'
		,'宮城'
		,'360,185,410,185,410,210,360,210,360,185'
        ,'tohoku'
        ,'185px'
        ,'360px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'fukushima'
		,'福島'
		,'326,210,410,210,410,231,326,231,326,210'
        ,'tohoku'
        ,'210px'
        ,'326px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'gunma'
		,'群馬'
		,'241,66,303,66,303,93,241,93,241,66'
        ,'kanto'
        ,'66px'
        ,'241px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'tichigi'
		,'栃木'
		,'303,66,370,66,370,93,303,93,303,66'
        ,'kanto'
        ,'66px'
        ,'303px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'saitama'
		,'埼玉'
		,'241,93,370,93,370,121,241,121,241,93'
        ,'kanto'
        ,'93px'
        ,'241px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'tokyo'
		,'東京'
		,'268,121,370,121,370,154,268,154,268,121'
        ,'kanto'
        ,'121px'
        ,'268px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'kanagawa'
		,'神奈川"'
		,'268,154,370,154,370,183,268,183,268,154'
        ,'kanto'
        ,'154px'
        ,'268px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'ibaragi'
		,'茨城'
		,'370,66,415,66,415,138,370,138,370,66'
        ,'kanto'
        ,'66px'
        ,'370px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'chiba'
		,'千葉'
		,'370,138,415,138,415,228,370,228,370,138'
        ,'kanto'
        ,'138px'
        ,'370px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'ishikawa'
		,'石川'
		,'159,82,195,82,195,110,159,110,159,82'
        ,'hokushinetsu'
        ,'82px'
        ,'159px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'fukui'
		,'福井'
		,'159,110,195,110,195,137,159,137,159,110'
        ,'hokushinetsu'
        ,'110px'
        ,'159px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'toyama'
		,'富山'
		,'195,82,236,82,236,137,195,137,195,82'
        ,'hokushinetsu'
        ,'82px'
        ,'195px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'niigata'
		,'新潟'
		,'236,82,311,82,311,67,357,67,357,137,236,137,236,82'
        ,'hokushinetsu'
        ,'67px'
        ,'236px'
        ,'75,15,75,0,121,0,121,70,0,70,0,15,75,15'
	)
);


edPrefs.push(
	new edPref(
		'nagano'
		,'長野'
		,'236,137,313,137,313,202,290,202,290,227,236,227,236,137'
        ,'hokushinetsu'
        ,'137px'
        ,'236px'
        ,'0,0,77,0,77,65,54,65,54,90,0,90,0,0'
	)
);


edPrefs.push(
	new edPref(
		'yamanashi'
		,'山梨'
		,'290,202,313,202,340,202,340,227,290,227,290,202'
        ,'hokushinetsu'
        ,'202px'
        ,'290px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'aichi'
		,'愛知県'
		,'216,156,299,156,299,211,216,211,216,156'
        ,'tokai'
        ,'156px'
        ,'216px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'gifu'
		,'岐阜県'
		,'216,66,271,66,271,156,216,156,216,66'
        ,'tokai'
        ,'66px'
        ,'216px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'mie'
		,'三重県'
		,'174,131,216,131,216,228,174,228,174,131'
        ,'tokai'
        ,'131px'
        ,'174px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'shizuoka'
		,'静岡県'
		,'299,156,380,156,380,211,299,211,299,156'
        ,'tokai'
        ,'156px'
        ,'299px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'hyogo'
		,'兵庫'
		,'165,66,238,66,238,133,165,133,165,66'
        ,'kinki'
        ,'66px'
        ,'165px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'kyoto'
		,'京都'
		,'238,66,299,66,299,90,278,90,278,142,238,142,238,66'
        ,'kinki'
        ,'66px'
        ,'238px'
        ,'0,0,61,0,61,24,40,24,40,76,0,76,0,0'
	)
);


edPrefs.push(
	new edPref(
		'shiga'
		,'滋賀'
		,'278,90,314,90,314,142,278,142,278,90'
        ,'kinki'
        ,'90px'
        ,'278px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'osaka'
		,'大阪'
		,'200,133,238,133,238,192,200,192,200,133'
        ,'kinki'
        ,'133px'
        ,'200px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'nara'
		,'奈良'
		,'238,142,278,142,278,203,238,203,238,142'
        ,'kinki'
        ,'142px'
        ,'238px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'wakayama'
		,'和歌山'
		,'200,192,238,192,238,203,278,203,278,230,200,230,200,192'
        ,'kinki'
        ,'192px'
        ,'200px'
        ,'0,0,38,0,38,11,78,11,78,38,0,38,0,0'
	)
);


edPrefs.push(
	new edPref(
		'okayama'
		,'岡山県'
		,'254,99,307,99,307,132,254,132,254,99'
        ,'shikoku'
        ,'99px'
        ,'254px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'shimane'
		,'島根県'
		,'201,64,254,64,254,99,201,99,201,64'
        ,'shikoku'
        ,'64px'
        ,'201px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'kochi'
		,'高知県'
		,'167,187,246,187,246,230,167,230,167,187'
        ,'shikoku'
        ,'187px'
        ,'167px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'kagawa'
		,'香川県'
		,'246,143,324,143,324,187,246,187,246,143'
        ,'shikoku'
        ,'143px'
        ,'246px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'ehime'
		,'愛媛県'
		,'167,143,246,143,246,187,167,187,167,143'
        ,'shikoku'
        ,'143px'
        ,'167px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'tokushima'
		,'徳島県'
		,'246,187,324,187,324,230,246,230,246,187'
        ,'shikoku'
        ,'187px'
        ,'246px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'hiroshima'
		,'広島県'
		,'201,99,254,99,254,132,201,132,201,99'
        ,'shikoku'
        ,'99px'
        ,'201px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'yamaguchi'
		,'山口県'
		,'167,64,201,64,201,132,167,132,167,64'
        ,'shikoku'
        ,'64px'
        ,'167px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'tottori'
		,'鳥取県'
		,'254,64,307,64,307,99,254,99,254,64'
        ,'shikoku'
        ,'64px'
        ,'254px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'fukuoka'
		,'福岡県'
		,'287,65,373,65,373,116,314,116,314,132,287,132,287,65'
        ,'kyusyu'
        ,'65px'
        ,'287px'
        ,'0,0,86,0,86,51,27,51,27,67,0,67,0,0'
	)
);


edPrefs.push(
	new edPref(
		'nagasaki'
		,'長崎県'
		,'218,65,251,65,251,132,218,132,218,65'
        ,'kyusyu'
        ,'65px'
        ,'218px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'kumamoto'
		,'熊本県'
		,'262,132,314,132,314,203,262,203,262,132'
        ,'kyusyu'
        ,'132px'
        ,'262px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'oita'
		,'大分県'
		,'314,116,373,116,373,158,314,158,314,116'
        ,'kyusyu'
        ,'116px'
        ,'314px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'miyazaki'
		,'宮崎県'
		,'314,158,373,158,373,203,314,203,314,158'
        ,'kyusyu'
        ,'158px'
        ,'314px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'saga'
		,'佐賀県'
		,'251,65,287,65,287,132,251,132,251,65'
        ,'kyusyu'
        ,'65px'
        ,'251px'
        ,''
	)
);


edPrefs.push(
	new edPref(
		'kagoshima'
		,'鹿児島県'
		,'262,203,373,203,373,231,262,231,262,203'
        ,'kyusyu'
        ,'203px'
        ,'262px'
        ,''
	)
);



edPrefs.push(
	new edPref(
		'okinawa'
		,'沖縄県'
		,'120,169,251,169,251,231,120,231,120,169'
        ,'kyusyu'
        ,'169px'
        ,'120px'
        ,''
	)
);





Event.observe(window, 'load', function(){

});







/**
 * 表示
 */
function selectArea( id )
{
    openArea = id;
    var imgElem = document.createElement('img');
    imgElem.id = 'map_'+openArea;
    imgElem.className = 'selectArea';
    imgElem.setAttribute('src','/images/zenmap/map_'+openArea+'.gif');
    imgElem.setAttribute('useMap','#map_'+ openArea);
    imgElem.style.display = 'none';
    $('areaMapBox').appendChild(imgElem);

    //BlindDown
    new Effect.Appear('map_'+ openArea ,{
        afterFinishInternal:areaStart
    });
}

/**
 * 消す
 */
function cancelArea()
{
    areaOvFlug = false;
    mout();
    //Element.show('zenmap_image');
    
    //BlindUp
    //Puff
    //Fade
    new Effect.Fade('map_'+ openArea ,{
        afterFinishInternal:function(){
            $('areaMapBox').innerHTML = '';
            areaOvFlug = true;
        }
    });
}



/**
 * Effect callback function
 */
function areaStart()
{
    //Element.hide('zenmap_image');

    var mapElem = document.createElement('map');
    mapElem.id = 'map_'+openArea;
    mapElem.setAttribute('name', 'map_'+openArea);

    areaElem = document.createElement('area');
    areaElem.title = '全国へ戻る';
    areaElem.setAttribute('alt','全国へ戻る');
    areaElem.setAttribute('shape', 'poly');
    areaElem.setAttribute('coords', '31,72,125,72,125,96,31,96,31,72');
    areaElem.href = "javascript:cancelArea()";
    mapElem.appendChild(areaElem);

    $('areaMapBox').appendChild(mapElem);

    for (var i = 0; i < edPrefs.length; i++) {
        if(openArea == edPrefs[i].area){

            areaElem = document.createElement('area');
            areaElem.id = 'area_'+ edPrefs[i].id;
            areaElem.href = '/'+edPrefs[i].id+'/';
            areaElem.setAttribute('alt',edPrefs[i].display);
            areaElem.setAttribute('shape', 'poly');
            areaElem.setAttribute('coords', edPrefs[i].coords);


            areaElem.setAttribute('onmouseover','mover(\''+edPrefs[i].id+'\')');

            //areaElem.setAttribute('onmouseover','function() { mover(\''+edPrefs[i].id+'\')}');
            //マウスオーバーイベントリスナー
//            Event.observe(mapElem, 'mouseover', function(){
//                mover(this.title);
//            });

            mapElem.appendChild(areaElem);


            var imgElem = document.createElement('img');
            imgElem.id = 'ov_'+edPrefs[i].id;
            imgElem.className = 'ov_img';
            imgElem.setAttribute('src','/images/zenmap/ov_'+edPrefs[i].id+'.gif');
            imgElem.setAttribute('alt',edPrefs[i].display);

            imgElem.style.display = 'none';
            imgElem.style.top = edPrefs[i].ov_top;  // + 'px';
            imgElem.style.left = edPrefs[i].ov_left;    // + 'px';
            imgElem.style.cursor = 'pointer';
            imgElem.style.zIndex = 30;


            if( !edPrefs[i].ov_coords ){
                //imgElem.setAttribute('onmouseout','mout(\''+edPrefs[i].id+'\')');
                imgElem.setAttribute('onmouseout','javascript:mout()');
                imgElem.setAttribute('onclick' , 'location.href=\'/'+edPrefs[i].id+'/\'');
                $('areaMapBox').appendChild(imgElem);

            }else{
                imgElem.setAttribute('useMap','#map_'+edPrefs[i].id);
                $('areaMapBox').appendChild(imgElem);
                
                prefmapElem = document.createElement('map');
                prefmapElem.id='map_'+ edPrefs[i].id;
                prefmapElem.setAttribute('name', 'map_'+ edPrefs[i].id);

                areaElem = document.createElement('area');
                areaElem.href = '/'+edPrefs[i].id+'/';
                areaElem.setAttribute('shape', 'poly');
                areaElem.setAttribute('coords', edPrefs[i].ov_coords);
                areaElem.setAttribute('onmouseout','javascript:mout()');
                prefmapElem.appendChild(areaElem);
                $('areaMapBox').appendChild(prefmapElem);
            }

            

        }
	}
}



function mover(area)
{
    if(!areaOvFlug){return;}
    mout();
    Element.show('ov_'+area);
}

function mout()
{
    var elements= document.getElementsByClassName('ov_img');
    var elems = $A(elements);
    elems.each(
        function(item){
            Element.hide(item.id);
        }
    );

    
}

