var PanelAlert = {
  timeout : 0,
  started: false,
  cont : '',
  bdCont : '',
  btn : '',
  obj : null,
  init : function(){
    PanelAlert.cont = document.createElement('div');
    $(PanelAlert.cont).html('<div class="hd">Alert Panel</div><div class="bd"><div class="PanelAlertText" style="margin-bottom:20px;"></div><button>Aceptar</button></div>');
    PanelAlert.obj = new YAHOO.widget.Panel(PanelAlert.cont,{width:"280px",visible:false,constraintoviewport:true,draggable:true,fixedcenter:true,zIndex:10});
    PanelAlert.obj.render(document.body);

    PanelAlert.bdCont = $(PanelAlert.cont).find('.PanelAlertText')[0];
    PanelAlert.btn = $(PanelAlert.cont).find('button')[0];

    PanelAlert.started = true;
  },
  show : function(title,body,hide){
    if(!PanelAlert.started)
      this.init();

    if(hide != undefined){
      $(PanelAlert.btn).hide();
      clearTimeout(PanelAlert.timeout);
      PanelAlert.timeout = setTimeout(PanelAlert.hide,hide);
    }
    else
      $(PanelAlert.btn).show();

    PanelAlert.obj.setHeader(title);
    $(PanelAlert.bdCont).html(body);
    $(PanelAlert.btn).click( PanelAlert.hide );
    PanelAlert.obj.show();
return;
   $(PanelAlert.cont).dialog('option','title',title);
   $(PanelAlert.cont).html(body);
  
    if(hide != undefined)
    {
      //$( PanelAlert.cont ).dialog( "option", "buttons", {} );
      clearTimeout(PanelAlert.timeout);
      PanelAlert.timeout = setTimeout(PanelAlert.hide,hide);
    }
    else
      $( PanelAlert.cont ).dialog( "option", "buttons",{ "Aceptar": function(){$(this).dialog('close');}} );


    $( PanelAlert.cont ).dialog('open');

    PanelAlert.cont.style.minHeight = '50px';
  },
  setBtnFunction : function(fn)
  {
    $(PanelAlert.btn).click( fn );
  },
  hide : function()
  {
    clearTimeout(PanelAlert.timeout);
    PanelAlert.obj.hide();
  }
}


var PanelConfirm = {
  started: false,
  obj : null,
  cont : null,
  txtBody : null,
  fnAction: null,
  btnConfirm : null,
  btnCancel : null,
  init : function(){
   /* PanelConfirm.cont = document.createElement('div');
    $(PanelConfirm.cont).dialog({ draggable : true, resizable : false,  autoOpen : false, modal: true, closeOnEscape : false,
      buttons : {
        "Aceptar": function(){ PanelConfirm.hide(); PanelConfirm.fnAction(PanelConfirm.fnParams);},
        "Cancelar": function(){PanelConfirm.hide();}
      }});
    PanelConfirm.started = true;*/



    PanelConfirm.cont = document.createElement('div');
    $(PanelConfirm.cont).html('<div class="hd">Confirm Panel</div><div class="bd"><div class="PanelConfirmText" style="margin-bottom:20px;"></div><button>Aceptar</button><button>Cancelar</button></div>');
    PanelConfirm.obj = new YAHOO.widget.Panel(PanelConfirm.cont,{width:"280px",visible:false,constraintoviewport:true,draggable:true,fixedcenter:true,zIndex:10});
    PanelConfirm.obj.render(document.body);

    PanelConfirm.bdCont = $(PanelConfirm.cont).find('.PanelConfirmText')[0];
    PanelConfirm.btnConfirm = $(PanelConfirm.cont).find('button')[0];
    PanelConfirm.btnCancel = $(PanelConfirm.cont).find('button')[1];
    PanelConfirm.btnConfirm.onclick = function(){PanelConfirm.obj.hide(); PanelConfirm.fnAction(PanelConfirm.fnParams);};
    PanelConfirm.btnCancel.onclick = function(){PanelConfirm.hide(); };

    PanelConfirm.started = true;
  },
  show : function(title,body,fnAction,fnParams){
    if(!PanelConfirm.started)
      PanelConfirm.init();

    PanelConfirm.obj.setHeader(title);
    $(PanelConfirm.bdCont).html(body);
    PanelConfirm.fnAction = fnAction;
    PanelConfirm.fnParams = fnParams;

    PanelConfirm.obj.show();

  return true;
    $(PanelConfirm.cont).dialog('option','title',title);
    $(PanelConfirm.cont).html(body);
    PanelConfirm.fnAction = fnAction;
    PanelConfirm.fnParams = fnParams;

    $( PanelConfirm.cont ).dialog('open');

    PanelConfirm.cont.style.minHeight = '50px';
  },
  setButtons : function(oButtons)
  {
    //$( PanelConfirm.cont ).dialog( "option", "buttons", oButtons );
  },
  hide : function()
  {
    PanelConfirm.obj.hide();
  }
}

var PanelLoading = {
  started: false,
  cont : null,
  obj: null,
  cont: null,
  init : function(){
    PanelLoading.cont = document.createElement('div');
    $(PanelLoading.cont).html('<div class="hd">Procesando</div><div class="bd"><img src="/img/preloader.gif"/><br/>Procesando por favor espere...</div>');
    PanelLoading.obj = new YAHOO.widget.Panel(PanelLoading.cont,{width:"280px",visible:false,constraintoviewport:true,draggable:false,modal:true,fixedcenter:true,close:false,zIndex:10});
    PanelLoading.obj.render(document.body);

    PanelLoading.started = true;
  },
  show : function(){
    if(!PanelLoading.started)
      PanelLoading.init();

    PanelLoading.obj.show();
  },
  hide : function()
  {
    PanelLoading.obj.hide();
  }
}
