var selectcountrywin;

function setLocationValue(obj) {
    document.getElementById('selval').value = obj.id;
    document.getElementById('curloc').innerHTML = '<strong>Selected Location: ' + obj.innerHTML + '</strong>'
}

function changeCountry() {
    
    selectcountrywin = dhtmlwindow.open("selectcountrybox", "iframe", "index.php?view=popup&name=countries&action=display", "Select Your Country", "width=600px,height=400px,resize=1,scrolling=0,center=1", "recal");

    /*
    $(document).ready(function() {
        var pg = 0;
        var qrystr = new String(window.location.search.substring(1));
        if(qrystr.indexOf('user_panoramas') > 0) pg = 1; 
        var query = "index.php?view=ajax&action=countrylist&pg=" + pg;
        $.get(query, function(data) {
            var $dialog = $('<div id="dialog-form" title=\"Select Your Country\"></div>');
            $dialog.html(data);
            $dialog.dialog({
                autoOpen: false,
                height: 380,
                width: 480,
                show: "blind",
                hide: "blind",
                modal: true,
                buttons: {
                    'Ok': function() {                    
                        $(this).dialog('close');    
                    },
                    'Cancel': function() {
                        $("#selval").val("");
                        $(this).dialog('close');
                    }
                },
                open: function() {
                    if($.browser.msie) {
                        height: 580;
                    }
                    $("#change-country").treeview({
                        collapsed: true,
                        unique: true
                    });
                },
                beforeclose: function() {
                    var keys = $("#selval").val();
                    if(keys != '') {
                        var key = keys.split('~');
                        var query = "index.php?view=ajax&action=setcountry" +
                            "&country=" + key[0] +
                            "&region=" + key[1] +
                            "&city=" + key[2];
                        
                        $.ajax({
                            url: query,
                            data: data,
                            success: function(data) {
                                var items = data.split('~');
                                var html = "<img src='images/flags/png/" + items[1] + "' border=0>" +
                                    " " + items[2] + " <font id='country-change'>(<a href='#' id='" +
                                    items[0] + "' onclick='changeCountry();'>Change Country</a>)" +
                                    "</font>";    
                                $("#country-text").attr('innerHTML', html);
                                document.location.reload();
                            },
                            dataType: 'text' 
                        });
                    }
                    return(true);
                },
                close: function() {

                }
            });
            $dialog.dialog('open');
        });
    });
    */
}
