var $j=jQuery.noConflict();
var alertText = "Please be advised that you are leaving First National Bank's website. This link is provided as a courtesy.  First National Bank does not endorse or control the content of third party websites.";
var customFolder = "fnbhereford";
var slideSpeed = 500;
var tabEffect = "fade";	//slide, fade

$j(document).ready( function() {

	productTabs();

	$j(".confirm").click( function() {						   
			if (!confirmAlert($j(this).attr('href'))){
				return false;			
			}
		}); 	

// new page for INMO
	$j('a.newPage').each( function(){
		this.target = "_blank";
	});

// add id to body
$j(function(){
	if ($j('#primaryNav li a').hasClass("inPath")) {
		var primary = $j('#primaryNav li a.inPath').text().replace(/ /g,'');
		$j('body').attr("id",primary);
	}
});

// category page

if( $j('li.categoryListItem').length > 0 ){

	$j("li.categoryListItem a").bigTarget();
	$j("li.categoryListItem:last").css('borderBottom','1px solid #CDC4B2');

$j("li.categoryListItem")
	.mouseover(function() {	
		$j(this).stop().animate( {backgroundColor: '#ffffff'}, 'fast' )	
		$j("div.productContent h4 a", this).css('backgroundPosition','0 -23px')
	})
	.mouseout(function() {	
		$j(this).stop().animate( {backgroundColor: '#F2F0E3'}, 'slow' )
		$j("div.productContent h4 a", this).css('backgroundPosition','0 0')
	});
};

// left Nav

if( $j('#leftNav li').length > 0 ){
	$j("#leftNav li h2 a:not(.inPath)")
	.mouseover(function() {	
		$j(this).stop().animate( {backgroundColor: '#580000',color: '#fff'}, 'fast' )
	})
	.mouseout(function() {	
		$j(this).stop().animate( {backgroundColor: '#DDD5C0',color: '#362400'}, 'slow' )	
	});
};

// fancybox popup on apps
	$j("a#ssnWhy").fancybox({
		'frameWidth': 300,
		'frameHeight': 190
	});
	
	$j("#introText a.iframe").fancybox({
		'frameWidth': 570,
		'frameHeight': 520,
		'overlayOpacity': 0.8
	});
	
// Tell Me More - SAF - Calculators - OBL Popup provided by FancyBox 
	$j('#tellMeMoreButton a').addClass('iframe');
	
	$j("#tellMeMoreButton a").fancybox({
		'hideOnContentClick': false,
		'frameWidth': 570,
		'frameHeight': 520,
		'overlayOpacity': 0.8
	});
	
		
	$j('#financialCalculators li a').addClass('iframe');

	$j("#financialCalculators li a").fancybox({
		'hideOnContentClick': false,
		'frameWidth': 650,
		'frameHeight': 400,
		'overlayOpacity': 0.8
	}); 
	
// End of Fancybox jQuery



}); // END doc ready

function confirmAlert(url){
			jConfirm(alertText, "Confirm", function(r) {
				if( r ){
					window.open(url);
				} else {
					return false;
			}
		});
		return false;
}

function confirmAlert2(url){
	if (!confirmAlert(url)) 
		return false; 
}

function productTabs(){
	if( $j('#productTabs').length > 0 ){
		var offset = 40;
		$j('#productTabs dt').addClass('label');
		$j('#productTabs dt:eq(0)').addClass('selected');
		$j('#productTabs dd').addClass('pane');
		$j('#productTabs dd:eq(1), #productTabs dd:eq(2)').hide();
		$j('#productTabs').css('height', $j('#productTabs dd:eq(0)').height() + offset);
		
		$j('#productTabs dt').click( function(){
			var holdThis = $j(this);
			if( !holdThis.hasClass('selected') ){
				$j('#productTabs dt').removeClass('selected');
				holdThis.addClass('selected');
				if(tabEffect == "slide"){
					$j('#productTabs dd').slideUp(slideSpeed);
					$j('#productTabs').animate({ height : holdThis.next().height() + offset }, slideSpeed, function(){
						holdThis.next().slideDown(slideSpeed);									 
					});
				}
				else{
					$j('#productTabs dd').fadeOut(slideSpeed);
					$j('#productTabs').animate({ height : holdThis.next().height() + offset }, slideSpeed, function(){
						holdThis.next().fadeIn(slideSpeed);									 
					});
				}
			}
		});
	}
}
