// JavaScript Document
/* Overriding Javascript's Alert Dialog */

function alert(msg) {
  $('#alert')
    .jqmShow()
    .find('div.jqmAlertContent')
    .html(msg);
}

$().ready(function() {
  $('#alert').jqm({
  	overlay: 40, 
  	modal: true, 
  	trigger: false
  });
});


/* Overriding Javascript's Confirm Dialog */

// NOTE; A callback must be passed. It is executed on "continue". 
//  This differs from the standard confirm() function, which returns
//   only true or false!

// If the callback is a string, it will be considered a "URL", and
//  followed.

// If the callback is a function, it will be executed.


function confirm(msg,callback) {
  $('#confirm')
    .jqmShow()
    .find('p.jqmConfirmMsg')
      .html(msg)
    .end()
    .find(':submit:visible')
      .click(function(){
        if(this.value == 'Oui')
          (typeof callback == 'string') ?
            window.location.href = callback :
            callback();
        $('#confirm').jqmHide();
      });
}


$().ready(function() {
  $('#confirm').jqm({overlay: 40, modal: true, trigger: false});
  
});

