$(document).ready(function(){
	var timer='';
	$().mousemove(function(e){
		$('html').data('M_X',e.pageX);
		$('html').data('M_Y',e.pageY);
	})
	jQuery.fn.extend({
		main_menu:function(id){
			$(this).css('cursor','pointer');
			$(this).hover(function(){
					clearTimeout(timer);	
				//setTimeout(function(){
					var btn_off=$(this).offset();
					var btn_L=btn_off.left;
					var btn_T=btn_off.top;
					var btn_R=btn_L + $(this).width();
					var btn_D=btn_T + $(this).height();
					var M_X=$('html').data('M_X');
					var M_Y=$('html').data('M_Y');
					var btn_B=105;
					if (id=='submenubg'){
						var S_W=$(window).width();
						var P_W=$('#'+id).width()-40;
						var P_L=((S_W-P_W)/2)-50;
					} else if (id=='designproductmenubox'){
						var P_off=$('.header').offset();
						var P_L=P_off.left+18;
					}
					if ($('#submenubg').css('display')=='block'){
						$('#submenubg').hide();
					}else if($('#designproductmenubox').css('display')=='block') {
						$('#designproductmenubox').hide();
					}
					//if (M_X>btn_L && M_X<btn_R && M_Y>btn_T && M_Y<btn_D){
						$('#'+id).css({
							'position':'absolute',
							'top':btn_B,
							'left':P_L,
							'z-index':1000
						})
						$('#'+id).show();
					//}
				//}, 500);
			}, function(){
				timer=setTimeout("$('#"+id+"').hide();",1000);
			})
			$('#'+id).hover(function(){
				clearTimeout(timer);
			}, function(){
				clearTimeout(timer);
				timer=setTimeout("$('#"+id+"').hide();",500);
			})
		}
	})
	$('#hlnkBusinessType').main_menu('submenubg');
	$('#hlnkProductType').main_menu('designproductmenubox');
})