/* $Id: common.js 102 2009-12-17 20:55:11Z horizonit $ */

// common site-wide js stuff
$(document).ready(function(){
  
  // handle external links
  $("a[href^=http]").each(function(){
    if (this.href.indexOf(location.hostname) == -1) {
      $(this).attr('target', '_blank');
      $(this).click(function(){
        alert('By clicking OK the link will take you away from the Shoreline Bank website, all opinions expressed in these pages are those of the web author, and not Shoreline Bank.');
      });
    }
  });

  
  // linkers
  $('#header .logo').css('cursor', 'pointer');
  $('#header .logo').click(function(){
    document.location = rooturl;
  });
  
  $('#internetbanking').css('cursor', 'pointer');
  $('#internetbanking').click(function(){
    document.location = 'https://online.eshorelinebank.com/';
  });

  $('#market1').click(function(){
	document.location = 'products/other/special.php';
  });
  $('#market2').click(function(){
	document.location = 'fdic/fdic.php';
  });
  
  // handle product popups
  $.extend($.modal.defaults, {
    onOpen: function(dialog){
      dialog.overlay.fadeIn('slow', function () {
        dialog.data.hide();
        dialog.container.fadeIn(100, function () {
          dialog.data.fadeIn(100);
        });
      });
    },
    onClose: function(dialog){
      dialog.data.fadeOut(100, function () {
        dialog.overlay.fadeOut(100, function () {
          $.modal.close();
        });
      });
    }
  });
  
  // replace titles
    $('a.product-popup[title]').each(function() {
    $.data(this, 'title', $(this).attr('title'));
    $(this).removeAttr('title');
    });
  $('a.product-popup').click(function(){
    var name = $(this).html();
    var desc = $(this).data('title').split('|');
    $.modal('<div><h1>' + name + '</h1>' + desc + '</div>');
    return false;
  });
  
});	
