$(document).ready(function() {
	$(".dropdown img.flag").addClass("flagvisibility");
	$(".dropdown dt a").click(function() {
		$(".dropdown dd ul").toggle();
	});
	$(".dropdown dd ul li a").click(function() {
		var text = $(this).html();
		/*$(".dropdown dt a span").html(text);
		$(".dropdown dd ul").hide();*/
		window.location=$(this).attr("clink");
	});

				

	function getSelectedValue(id) {
		return $("#" + id).find("dt a span.value").html();
	}

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdown"))
			$(".dropdown dd ul").hide();
	});

	$(document).bind('mouseout', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdown"))
			$(".dropdown dd ul").hide();
	});

/* dropdown 2 */

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);

}; 

	$(".dropdownhmw img.flag").addClass("flagvisibility");
	$(".dropdownhmw dt a").click(function() {
		$(".dropdownhmw dd ul").fadeToggle();
		$(this).addClass("selected");
	});
	$(".dropdownhmw dd ul li a").click(function() {
		var text = $(this).html();
		window.location=$(this).attr("clink");
	});
	
	$(".dropdownhmw").mouseleave(function() {
		$(".dropdownhmw dd ul").slideUp(300).delay(100).fadeOut(400);
		$(".dropdownhmw dt a").removeClass("selected");
				return false; //Prevent the browser jump to the link anchor
	}); 

				

	function getSelectedValue(id) {
		return $("#" + id).find("dt a span.value").html();
	}

	$(document).bind('mouseout', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdownhmw"))
			$(".dropdownhmw dd ul").hide();
	});

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("dropdownhmw"))
			$(".dropdownhmw dd ul").hide();
	});

});
