     $(document).ready(function() {
            $(".dropdown img.flag").addClass("flagvisibility");

            $(".dropdown dt a").click(function() {
                $(".dropdown dd div.cat_dd").toggle();
				$(".cat_arrow_down").attr('src', 'images/category_arrow_down.png');
            });
                        
            $(".dropdown dd ul li a").click(function() {
                var text = $(this).html();
				
                $(".dropdown dt a span").html(text);
                $(".dropdown dd div.cat_dd").hide();
				$(".cat_arrow_down").attr('src', 'images/category_arrow.png');
				
                $("#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 div.cat_dd").hide();
					$(".cat_arrow_down").attr('src', 'images/category_arrow.png');
					}
            });


            $("#flagSwitcher").click(function() {
                $(".dropdown img.flag").toggleClass("flagvisibility");
            });
			
			//////////////////////////////////////////////////////////////////
			
			$(".dropdown2 img.flag").addClass("flagvisibility");

            $(".dropdown2 dt a").click(function() {
                $(".dropdown2 dd div.cat_dd2").toggle();
				$(".popular_arrow_down").attr('src', 'images/category_arrow_down.png');
            });
                        
            $(".dropdown2 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown2 dt a span").html(text);
                $(".dropdown2 dd div.cat_dd2").hide();
				$(".popular_arrow_down").attr('src', 'images/category_arrow.png');
                $("#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("dropdown2")){
                    $(".dropdown2 dd div.cat_dd2").hide();
					$(".popular_arrow_down").attr('src', 'images/category_arrow.png');
					}
            });


            $("#flagSwitcher").click(function() {
                $(".dropdown2 img.flag").toggleClass("flagvisibility");
            });
        
				//////////////////////////////////////////////////////////////////
			
			$(".dropdown3 img.flag").addClass("flagvisibility");

            $(".dropdown3 dt a").click(function() {
                $(".dropdown3 dd div.cat_dd3").toggle();
				$(".filter_btn_a").attr('src', 'images/filter_arrow_down.png');
            });
                        
            $(".dropdown3 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown3 dt a span").html(text);
                $(".dropdown3 dd div.cat_dd3").hide();
				$(".filter_btn_a").attr('src', 'images/filter_arrow.png');
                $("#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("dropdown3")){
                    $(".dropdown3 dd div.cat_dd3").hide();
					$(".filter_btn_a").attr('src', 'images/filter_arrow.png');
					}
            });


            $("#flagSwitcher").click(function() {
                $(".dropdown3 img.flag").toggleClass("flagvisibility");
            });
        
		
			//////////////////////////////////////////////////////////////////
			
			$(".dropdown4 img.flag").addClass("flagvisibility");

            $(".dropdown4 dt a").click(function() {
                $(".dropdown4 dd div.cat_dd4").toggle();
				$(".res_arrow_down").attr('src', 'images/category_arrow_down.png');
            });
                        
            $(".dropdown4 dd ul li a").click(function() {
                var text = $(this).html();
                $(".dropdown4 dt a span").html(text);
                $(".dropdown4 dd div.cat_dd4").hide();
				$(".res_arrow_down").attr('src', 'images/category_arrow.png');
                $("#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("dropdown4")){
                    $(".dropdown4 dd div.cat_dd4").hide();
					$(".res_arrow_down").attr('src', 'images/category_arrow.png');
					}
            });


            $("#flagSwitcher").click(function() {
                $(".dropdown4 img.flag").toggleClass("flagvisibility");
            });
        });
