$(document).ready(function(){
	
	//======Image Map==========
	$('#imgmap').css('opacity','0.01');
	
	$('#map area').each(function(){
		var id = $(this).attr('id');
		var cl = 'map_'+id+'_highlight';
	
		$(this).hover(
			function(){
				$('#imgmap_overlay').addClass(cl);
				console.debug("addClass:"+cl);
			},
			function(){
				$('#imgmap_overlay').removeClass(cl);
				console.debug("removeClass:"+cl);
			}
		);
	}); 
	
	//======Image Map End==========
	

	
	$(function() {
		$(window).scroll(function() {
			if($(this).scrollTop() != 0) {
				$('.backtotop').fadeIn();
			} else {
				$('.backtotop').fadeOut();
			}
		});
		
		$('.backtotop').click(function() {
			$('body,html').animate({scrollTop:0},800);
		});
	}); 
	
	
	//============ menu ===========
	$("#menu ul li").hover(
		function(){
			var li = this;
			var dropdown = $(this).find("div.holder_alt");
			if($(dropdown).length == 1){
				var w1 = $(dropdown).width();
				var w2 = $(li).width();
				var offset = w1-w2;
				var left = -offset+'px';
				$(dropdown).css('left',left);
				
				/*console.debug("w1:"+w1);
				console.debug("w2:"+w2);
				console.debug("offset:"+offset);*/
			}
		},
		function(){
			var dropdown = $(this).find("div.holder_alt");
			if($(dropdown).length == 1){
				$(dropdown).css('left','-9999px');
			}
		}
	);
	
});
