$(function() {
	flagDrop();
	fontResizer([14,16,18,20]);
	menu();
	sendGlobal(currentPage());
});

/**
 * Function to handle a language switcher drop down
 */
function flagDrop() {
	$('#language-list a').each(function() {
		$(this).attr('href', $(this).attr('href')+document.location.href.replace(baseurl, '').replace(/[a-z]{2}-[a-z]{2}\//, ''));
	});

	$('#current-language')
		.mouseleave(function() {
			clearFlagTimeout();
		 	$.data(this, 'timer', setTimeout(function() {
		 		$('#language-list').hide();
		 	}, 2000));
		})
		.mouseover(function() {
			clearFlagTimeout();
			$('#language-list').show();
		})
		.click(function() {
			clearFlagTimeout();
			if ($('#language-list').is(':visible')) {
				$.data(this, 'timer', setTimeout(function() {
					$('#language-list').hide();
			 	}, 500));
			} else {
				$('#language-list').show(); 
			}
			return false;
		});

	$('#language-list')
		.mouseleave(function() {
			clearFlagTimeout();
		 	$.data(this, 'timer', setTimeout(function() {
	 			$('#language-list').hide();
		 	}, 2000));
		})
		.mouseover(function() {
			clearFlagTimeout();
		});
}

function clearFlagTimeout() {
	clearTimeout($('#current-language').stop().data('timer'));
	clearTimeout($('#language-list').stop().data('timer'));
}
