$(function(){
	/*-----------------------------------
		map change
	-----------------------------------*/
	// default
	$('.worldmapArea').hide();
	$('#wmap_default').show();

	// map click event
	$('#worldMap #worldMap_01').click(function(){ mapChange( $('#wmap_europe') );  return false;  });
	$('#worldMap #worldMap_02').click(function(){ mapChange( $('#wmap_america') );  return false;  });
	$('#worldMap #worldMap_03').click(function(){ mapChange( $('#wmap_mideast') );  return false;  });
	$('#worldMap #worldMap_04').click(function(){ mapChange( $('#wmap_asia') );  return false;  });
	$('#worldMap #worldMap_05').click(function(){ mapChange( $('#wmap_africa') );  return false;  });

	// close button click
	$('.worldmapArea .btnClose').click(function(){ mapChange( $('#wmap_default') );  return false;  });

	function mapChange(showItem){
		$('.worldmapArea').hide();
		showItem.show();
	}


	/*-----------------------------------
		overlayer image
	-----------------------------------*/
	// country hover event
	$('.worldList ul li a').hover(function(){
		var country = $(this).text();
		var imgTag = '<img class="overlayerImg" src="/tecfiles/img/worldwide/common/map_hover/' + country + '.png" />'
		$('body').append(imgTag);

		// coordinate
		var offset = $(this).offset();
		//ブラウザのサイズ(幅)を取得
		var bodyWidth = 0;
		if ( window.innerWidth ) {
			bodyWidth = window.innerWidth;
		} else if ( document.documentElement && document.documentElement.clientWidth != 0 ) {
			bodyWidth = document.documentElement.clientWidth;
		} else if ( document.body ) {
			bodyWidth = document.body.clientWidth;
		}
		//座標補正
		//計算式
		//（ブラウザのサイズ-htmlのbodyサイズ）/2
		//htmlの左端の位置が出る
		var bodyLeft = 0;
		bodyLeft = (bodyWidth - 780) / 2;
		
		var x = offset.top + 30 + 'px';
		var y = offset.left - bodyLeft + 20 + 'px';
		$('.overlayerImg').css({'position':'absolute', 'top': x, 'left': y });

	}, function(){
		$('.overlayerImg').remove();
	});

});

