$(document).ready(function() {
	
	$('#menu2 li ul').hide(0);
	
	var timer;
	
	$('#menu2>li:has(ul)').hover(
		function() {
			$(this).parent().children('li').not($(this)).children('ul').animate({ height: 'hide' }, 300);
			$(this).parent().children('li').not($(this)).removeClass('hovered');
			if (!$(this).hasClass('hovered')) {
				$(this).children('ul').css({ display: 'none' });
				$(this).children('ul').animate({ height: 'show' },300);
				$(this).addClass('hovered');
			}
			clearTimeout(timer);
		},
		function() {
			timer = setTimeout(
				function() { 
					$('li.hovered').children('ul').animate({ height: 'hide' }, 300); 
					$('li.hovered').removeClass('hovered'); 
				}, 1000
			);
		}
	);
	
	function openWin (theURL) {
		w = Math.round(screen.width * 0.7);
		h = Math.round(screen.height * 0.7);
		l = (screen.width/2) - (w/2);
		t = (screen.height/2) - (h/2);
		newwin = window.open (theURL,'image'+Math.round(Math.random()*1000000),"width="+w+",height="+h+",left="+l+",top="+t);
		//return false;
	}
	
	$('#footer a, #privacy').each(function(){
		if ($(this).attr('href').indexOf('privacy-policy')>1) {
			$(this).click(function(){
				openWin($(this).attr('href'));
				return false;
			});
		}
	});

});