function div2html(divid, html) {
  if(Prototype.Browser.Gecko) {
    $(divid).innerHTML = "";
    var dummydiv = document.createElement('dummydiv');
    dummydiv.innerHTML = html;
    var children = dummydiv.childNodes;
    for(var i=0;i<children.length;i++) {
      $(divid).appendChild(children[i]);
    }
  }else {
    $(divid).innerHTML = html;
  }
}


function show_dialog(dialog, requestUrl, pars, dialogWidth, dialogHeight, dialogHeader, callback_func) {
  var params = "dialogWidth="+dialogWidth+"&dialogHeight="+dialogHeight+"&dialogHeader="+dialogHeader;
  if (pars){
    params = pars+"&"+params;
  }
  
  var req = new Object;
  req.url = requestUrl;
  req.pars = params;
  req.method = 'post';
  req.callback = function (req) {
    var json = getJsonResult(req);
    var dialogPannel = dialog;
    dialogPannel.body.style.width = json.dialogWidth;
    dialogPannel.body.style.height = json.dialogHeight;
    dialogPannel.setHeader(json.dialogHeader);
    dialogPannel.cfg.setProperty("underlay","none");
    try {
      div2html("dialog_content", json.content);
    }catch(e) {
      div2html("scroll_dialog_content", json.content);
    }
    dialogPannel.show();

    if (callback_func) {
      callback_func(req);
    }else {
      try{
        show_dialog_callback(req);
      }catch(e) {}
    }
  }
  request(req);
}


function create_button(button_id, button_script) {
  var btn = new YAHOO.widget.Button(button_id);
  btn.on("click", button_script);
}