        $(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();
                $("#result").html("Selected value is: " + getSelectedValue("sample"));
            });
                        
            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();
            });


            $("#flagSwitcher").click(function() {
                $(".dropdown img.flag").toggleClass("flagvisibility");
            });
			
			
			
			
            $(".dropdown2 img.flag").addClass("flagvisibility");

            $(".dropdown2 dt a").click(function() {
                $(".dropdown2 dd ul").toggle();
            });
                        
            $(".dropdown2 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown2 dt a span").html(text);
                $(".dropdown2 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample2"));
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

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


            $("#flagSwitcher").click(function() {
                $(".dropdown2 img.flag").toggleClass("flagvisibility");
            });
			
			
			
			
            $(".dropdown3 img.flag").addClass("flagvisibility");

            $(".dropdown3 dt a").click(function() {
                $(".dropdown3 dd ul").toggle();
            });
                        
            $(".dropdown3 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown3 dt a span").html(text);
                $(".dropdown3 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample3"));
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

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


            $("#flagSwitcher").click(function() {
                $(".dropdown3 img.flag").toggleClass("flagvisibility");
            });
			
			
			
			          $(".dropdown4 img.flag").addClass("flagvisibility");

            $(".dropdown4 dt a").click(function() {
                $(".dropdown4 dd ul").toggle();
            });
                        
            $(".dropdown4 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown4 dt a span").html(text);
                $(".dropdown4 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample4"));
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

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


            $("#flagSwitcher").click(function() {
                $(".dropdown4 img.flag").toggleClass("flagvisibility");
            });
			
			
			
			          $(".dropdown5 img.flag").addClass("flagvisibility");

            $(".dropdown5 dt a").click(function() {
                $(".dropdown5 dd ul").toggle();
            });
                        
            $(".dropdown5 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown5 dt a span").html(text);
                $(".dropdown5 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample5"));
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

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


            $("#flagSwitcher").click(function() {
                $(".dropdown5 img.flag").toggleClass("flagvisibility");
            });
			
			
			
						          $(".dropdown6 img.flag").addClass("flagvisibility");

            $(".dropdown6 dt a").click(function() {
                $(".dropdown6 dd ul").toggle();
            });
                        
            $(".dropdown6 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown6 dt a span").html(text);
                $(".dropdown6 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample6"));
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

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


            $("#flagSwitcher").click(function() {
                $(".dropdown6 img.flag").toggleClass("flagvisibility");
            });
			
			
			
								          $(".dropdown7 img.flag").addClass("flagvisibility");

            $(".dropdown7 dt a").click(function() {
                $(".dropdown7 dd ul").toggle();
            });
                        
            $(".dropdown7 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown7 dt a span").html(text);
                $(".dropdown7 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample7"));
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

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


            $("#flagSwitcher").click(function() {
                $(".dropdown7 img.flag").toggleClass("flagvisibility");
            });
			
			
			
			
											          $(".dropdown8 img.flag").addClass("flagvisibility");

            $(".dropdown8 dt a").click(function() {
                $(".dropdown8 dd ul").toggle();
            });
                        
            $(".dropdown8 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown8 dt a span").html(text);
                $(".dropdown8 dd ul").hide();
                $("#result").html("Selected value is: " + getSelectedValue("sample8"));
            });
                        
            function getSelectedValue(id) {
                return $("#" + id).find("dt a span.value").html();
            }

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


            $("#flagSwitcher").click(function() {
                $(".dropdown8 img.flag").toggleClass("flagvisibility");
            });
        });
