﻿// JavaScript Document

/* Overriding Javascript's Alert Dialog */

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

$().ready(function() {
  $('#alert').jqm({overlay: 0, modal: true, trigger: false});
  
  // trigger an alert whenever links of class alert are pressed.
  $('a.alert').click(function() { 
    alert('You Have triggered an alert!'); 
    return false;
  });
});


/* Overriding Javascript's Confirm Dialog */

// NOTE; A callback must be passed. It is executed on "cotinue". 
//  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 == 'yes')
          (typeof callback == 'string') ?
            window.location.href = callback :
            callback();
        $('#confirm').jqmHide();
      });
}


$().ready(function() {
  $('#confirm').jqm({overlay: 88, modal: true, trigger: false});
  
  // trigger a confirm whenever links of class alert are pressed.
  $('a.confirm').click(function() { 
    confirm('You are about to visit: '+this.href+'. You are now leaving the Flora Bank &amp; Trust web site. Flora Bank &amp; Trust is not responsible for the content outside our site, including the accuracy or reliability of any information, data, opinions, advice or statements made on these linked sites.',this.href); 
    return false;
  });
  
  // trigger a confirm whenever email links of class alert are pressed.
  $('a.mailconfirm').click(function() { 
    confirm('You are about to write an email. Do not send any confidential information such as account numbers or social security numbers by way of this email address.',this.href); 
    return false;
  });
});
