//*****Replace align attribute with class**************************************************//
function replaceAlign() {
  if (!document.getElementsByTagName('img')) return false;
  $('img[align="left"]').addClass('left').removeAttr('align');
	$('img[align="right"]').addClass('right').removeAttr('align');
	$('img[align="middle"]').addClass('middle').removeAttr('align');
}
//*****Replace target attribute with class**************************************************//
function replaceTarget() {
  if (!document.getElementsByTagName('a')) return false;
  $('a[target]').addClass('newwindow').removeAttr('target');
}
//*****The following function make it possible to have web standard popups**************************************************//
function strictNewWindow() {
  if (!document.getElementsByTagName('a')) return false;
  $('a.newwindow').click(function() {
		window.open($(this).attr('href'));
    return false;
	});
}
//*****Add swfobject flash call**************************************************//
function initializeFlash() {
	if (!document.getElementById('flash-content')) return false;
	var flashvars = {};
	var params = {wmode: 'transparent'};
	var attributes = {};
	attributes.id = "flash";
	swfobject.embedSWF("swf/JBT-home.swf", "flash-content", "700", "272", "8.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
}
//*****The following function make it possible to have web standard popups**************************************************//
function initializeCycle() {
	if (!$('ul.pics').length > 0) return false;
  $('ul.pics').cycle('fade');
}
function confirmWindow(){
	if($('body#fdicinsurancecoverage').length){
		$('a.confirm').click(function(){
			var goto = $(this).attr('href');
			var msg = "Would you like to leave Jefferson Bank and Trust to visit " + goto + "?";
			var bool = confirm(msg);
			if(bool){
				window.open(goto);
			}
			return false;
		});
	}
	if($('body#locations').length){
		$("a[href^='mailto:']").click(function(){
			var goto = $(this).attr('href');
			var msg = "NOTE: Please do not submit confidential, account-related information because this e-mail communication is NOT SECURE.";
			var bool = confirm(msg);
			if(bool){
				window.open(goto);
			}
			return false;
		});
	}
}
//*****Load all functions**************************************************//
$(document).ready(function(){
  replaceAlign();
  replaceTarget();
  strictNewWindow();
  initializeFlash();
  initializeCycle();
	confirmWindow();
});
