$(document).ready(function(){
    
    $("#p_region_id").change(function(){
        $.ajax({
            type: "POST",
            url: base_url+"backend/ajax_controller/get_countries",
            data: "region_id="+this.value,
            success: function(data){
                $("#p_country_id").html(data);
            }
        });

    });

    $("#region_id").change(function(){
        $.ajax({
            type: "POST",
            url: base_url+"backend/ajax_controller/get_countries",
            data: "region_id="+this.value,
            success: function(data){
                $("#country_id").html(data);
            }
        });

    });

    $(".leftnavmenu li").each(function() {
        if ($(this).children(".subnav") && $(this).children(".subnav").length > 0){
            var show_icon = $(this).find("#subshow");
            show_icon.css("cursor", "pointer");
            var current = $(this);
            show_icon.click(function() {
                if(current.find(".subnav").css("display") == "none") {
                    current.css("height", "auto");
                    current.children(".subnav").slideDown("normal");
                    current.addClass("current");
                    show_icon.attr({
                        src : base_url+"/web/design/arrow_top.png"
                    });
                }
                else{
                    current.children(".subnav").slideUp("normal", function() {
                        current.css("height", "20px");
                        current.removeClass("current");
                        show_icon.attr({
                            src : base_url+"/web/design/arrow_down.png"
                        });
                    });
                }
            });
        }
        return true;
    });

});

function set_file_url(fileUrl){
    //$(".cke_dialog_ui_hbox_first").next('input').val('sss');
    //alert(1);
    //$(".cke_dialog_ui_input_text").val(fileUrl);
    //object.value = fileUrl;
   // alert($("span:contains('URL')").html);
   //var the_url = $("td").find("span:contains('URL')").;
   //alert(the_url.val());
   //the_url.nextAll('input').val('aaaa');
//alert($(".cke_dialog_ui_input_text").find("input:contains('_textInput')").val());
    //$("td").find("span:contains('URL')").next('input .cke_dialog_ui_input_text').val(fileUrl);
    $("#170_textInput").val(fileUrl);
    $("#329_textInput").val(fileUrl);
    $("#331_textInput").val(fileUrl);
    $("#88_textInput").val(fileUrl);
    $("#168_textInput").val(fileUrl);
    $("#87_textInput").val(fileUrl);
   
}

