//programmed by Ron 28 March 08
//This function finds finds email links and attaches an email alert to specified domain email addresses.
//if you desire all email links to be tagged use protectedDomains= ['*']
//else use protectedDomains= ['yahoo.com', 'saturnodesign.com']
//Note: the domain does not actually have to be a domain. it is matching a sub string. ex 'saturno' would match saturnodesign.com


var Emails = function(opt){
  var o = opt;
  var load = function() {
    $A(o.selector).each(function(s) {
      $$(s).each(
        function(i) {
            if (i.protocol.toLowerCase() == 'mailto:')
            {
                if (o.protectedDomains)
                {
                    o.protectedDomains.each(
                    function(j) {
                        if (j=='*' || i.readAttribute('href').toLowerCase().indexOf(j.toLowerCase())>0)
                        {   
                            if (!i.onclick)
                            {
                                i.onclick = function() {return emailWarning();}
                            }
                        }
                    });
                }                
            }
        }
      );
    });
  };
  if(window.FastInit) {
  	FastInit.addOnLoad(load);
  } else {
  	Event.observe(window, 'load', load);
  }
}
Emails({
  selector : ['a'],
  protectedDomains : ['*']
});

function emailWarning(){
	var messageBody="Email correspondence with anyone at Gross, Minsky & Mogul, P.A. does not establish an attorney-client relationship. Any information you send will not be considered confidential or privileged unless Gross, Minsky & Mogul, P.A. has agreed to represent you.\n\n";
	messageBody = messageBody + "Information on this Web site should not be considered legal advice. It is for general use only.\n\n";
	messageBody = messageBody + "If you continue, you are confirming that you have read and understand this notice.";
	return window.confirm(messageBody); 
}
