$(document).ready(function() {
    // COUNTRY DROPDOWN
    $(".countrydropdown dt a").click(function() {
        $(".countrydropdown dd ul").toggle();
    });
    $(".countrydropdown dd ul li a").click(function() {
        var text = $(this).html();
        $(".countrydropdown dt a span").html(text);
        $(".countrydropdown dd ul").hide();
        //alert( "Selected value is: " + getSelectedValue("language") );
        //$("#result").html("Selected value is: " + getSelectedValue("sample"));
    });
    $(document).bind('click', function(e) {
        var $clicked = $(e.target);
        if (! $clicked.parents().hasClass("countrydropdown"))
            $(".countrydropdown dd ul").hide();
    });

    // HOTEL DROPDOWN
    $(".hoteldropdown dt a").click(function() {
        $(".hoteldropdown dd ul").toggle();
    });
    $(".hoteldropdown dd ul li a").click(function() {
        var text = $(this).html();
        $(".hoteldropdown dt a span").html(text);
        $(".hoteldropdown dd ul").hide();
        //alert( "Selected value is: " + getSelectedValue("hotel") );
        //$("#result").html("Selected value is: " + getSelectedValue("sample"));
    });
    $(document).bind('click', function(e) {
        var $clicked = $(e.target);
        if (! $clicked.parents().hasClass("hoteldropdown"))
            $(".hoteldropdown dd ul").hide();
    });

    // GET THE SELECTED DROPDOWN OPTION
    function getSelectedValue(id) {
        return $("#" + id).find("dt a span.value").html();
    }
});
