$(document).ready(function(){

	//$('#MenuBar1 li ul').hide();
	var ie6 = false;
	var useragent = navigator.userAgent;
	
	if (useragent.indexOf('MSIE 6.0') > 0){
	//	safari2 = true;
	ie6 = true;
	}

	if (!ie6){
	$('#MenuBar1 li.main_item ul.submenu').mouseleave(function(){
	//alert('yo');													   
		$(this).hide();
		$(this).css('top','');
	});
	}
	$('#MenuBar1 li.main_item a.MenuBarItemSubmenu').mouseenter(function(){
		$('#MenuBar1 li.main_item ul').css('top','').hide();
	});

	$('a.MenuBarItemSubmenu, a.MenuBarItemSubmenuNoLink').mouseenter(function(){
		$wheretogo = $(this).siblings('ul').attr('id');
		$('#MenuBar1 li.main_item ul').each(function(i, val){
			if ($wheretogo != $(this).attr('id')) {
				$(this).css('top','').hide();	
			}
		});
		
		//$(this).siblings('ul').show().children('li').children('a').uncorner();
		$(this).siblings('ul').show().children('li').children('a').removeClass('botlink');
		top_pos = $(this).siblings('ul').height() + 29;

		if ($(window).height() < 630){
			//$(this).siblings('ul').show().children('li').eq(0).children('a').corner('top');
			//$(this).siblings('ul').show().children('li').eq(0).children('a').addClass('botlink');
			$(this).siblings('ul').css('top','-'+top_pos+'px');
		} else {
			var noof = $(this).siblings('ul').show().children('li').length;
			//$(this).siblings('ul').show().children('li').eq(noof-1).css('border-bottom','0px').children('a').corner('bottom');
			$(this).siblings('ul').show().children('li').eq(noof-1).css('border-bottom','0px').children('a').addClass('botlink');
		}
					
		$(this).addClass('menu_open');		
	});

});