$(document).ready(function(){

	$('#subscribe-link').click(function(){
		$('#subscribe-form').show();
		$.blockUI({
			message:'',
    			css: { 
		        	textAlign:      '', 
       				cursor:         'default',
				border: 'none'
   			},
			overlayCSS:  { 
				backgroundColor: '#ffffff', 
				opacity:         0.3 
			},
			centerY:false,
			centerX:false,
			bindEvents:false
		});
		$('.blockOverlay').click(function(){
			$.unblockUI();
			$('#subscribe-form').hide();
		});
		return false;
	});

	initMainMenu();
});
// end of dom load functions


function initMainMenu() {
	var mm = $("#mainmenu");
	var mmli = $("li:has(ul)", mm);
	mmli.each(function(){
		var a = $('a:eq(0)',$(this));
		var ul = $('ul',$(this));
		$('<img src="/i/1.gif" width="12" height="28" alt="" />').appendTo(a);
		var hover = false;
		var d = (ie && ie==7) ? 5 : 1;
		ul.show(1,function(){
			if (ul.width() < $(this).width()+d) ul.width($(this).width()+d);
			ul.width(200);
			ul.css({display:'none'});
		});
		a.bind('mouseenter',function(){
			hover = true;
			ul.show(1,function(){
				ul.unbind('.mmli');
				ul.bind('mouseenter.mmli', function(){
					hover = true
				});
				ul.bind('mouseleave.mmli', function(){
					hover = false;
					window.setTimeout(function(){
						if (!hover) ul.hide();
					},100);
				});
			});
		});
		a.bind('mouseleave',function(){
			hover = false;
			window.setTimeout(function(){
				if (!hover) ul.hide();
			},100);
		});
	});
}
