var dialog = {}
dialog.context = ''
dialog.show = function(_args,_pointer){
   var http = HttpClient.instance()
//    http.setData({title:_title,html:_message},'application/json')
   var uri = _args.context+'/dialog'
   http.setHeader('dom',_args.title)
   if (_args.uri.match(/=/)){
      _args.uri = _args.uri.split(/=/)[1]
   }
   http.setHeader('uri',_args.uri)
   http.get(uri,function(x){
      $('.jxmodal').remove()
       jx.modal.show({html:x.responseText,id:'body'})
       if(jx.dom.exists('dialog-message') && _args.message != null){
          jx.dom.set.value('dialog-message',_args.message)
         
       }
       
      //
      // In order to perhaps execute any js script that should have been executed on load ...
      //
      
      var scripts = $('.jxmodal script')
      jx.utils.patterns.visitor(scripts,function(_item){
         if(_item.text.trim().length > 0){
            var _routine = eval(_item.text)
            //
            //@TODO:
            // Find a way to add the running function into the page to enable scripts to work
            //
         }
      })
      if (_pointer !=null){
         _pointer()
      }
     
   })
}

if (! qcms){
   var qcms = {}
}
qcms.dialog = dialog