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


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

	productTabs();
	homeFeatured();
	quickLinks();
	categoryPage ();
	
	$j(".confirm").click( function() {						   
			if (!confirmAlert($j(this).attr('href'))){
				return false;			
			}
		}); 	
	
// new page for INMO
	$j('a.newPage').each( function(){
		this.target = "_blank";
	});

// fancybox popup on apps
	$j("a#ssnWhy").fancybox({
		'frameWidth': 300,
		'frameHeight': 190
	});
	
// Tell Me More - SAF - Calculators - OBL Popup provided by FancyBox 
	$j('#tellMeMoreButton a').addClass('iframe');
	
	$j("#tellMeMoreButton a").fancybox({
		'hideOnContentClick': false,
		'frameWidth': 570,
		'frameHeight': 480,
		'overlayOpacity': 0.8
	});
	
	$j('#shareButton a').addClass('iframe');
	
	$j("#shareButton a").fancybox({
		'hideOnContentClick': false,
		'frameWidth': 570,
		'frameHeight': 520,
		'overlayOpacity': 0.8
	});
	
// Calculators - OBL Popup provided by FancyBox 
	// online banking link in ultratopnav
	$j('#downstreamObl a').addClass('iframe');
	
	$j("#downstreamObl a.iframe").fancybox({
		'hideOnContentClick': false,
		'frameWidth': 550,
		'frameHeight': 300,
		'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

if ($j("#leftNav li ul.nthTier-2").length){
	  // animate sub menu
	  $j("#leftNav li ul.nthTier-2").hide().delay(300).slideDown(400);
	  // add arrows to leftnav
	   $j("#leftNav li a").not("#leftNav li li a").prepend('<span class="arrow"> > </span>');
	};
	
// remove flash image
if ($j("#flashBanner").length){
 	$j("#flashBanner a").css({display : "none"});
}   

}); // END doc ready


function categoryPage (){
if ( $j("#productCategory").length ){
	 $j("#productCategory li a").bigTarget();	
	 $j("#productCategory li").css('cursor','pointer')
	 $j("#productCategory li").not("#productCategory li li")
	   .mouseover(function() {
		  $j(this).stop().animate({backgroundColor: "#fff"}, 300);
		  $j("h3 a",this).stop().animate({color: "#1F92DD"}, 300);
		  $j(".learnMore a",this).stop().animate({backgroundPosition: "0 -65px"}, 220);
	   })
	   .mouseout(function() {
		  $j(this).stop().animate({backgroundColor: "#E9F1F9"}, 400);
		  $j("h3 a",this).stop().animate({color: "#003376"}, 400);
		  $j(".learnMore a",this).stop().animate({backgroundPosition: "0 0"}, 300);
	   });
	 
	};
};
// end categoryPage

function quickLinks() {
	$j('#quickLinksList li#qlFraud').addClass('active');
	$j('#quickLinksList li#qlFraud ul').delay(300).slideDown(300);
	$j('#quickLinksList li a').mouseover(
		function() {
			var checkElement = $j(this).next();
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			// slide down and remove active class
			$j('#quickLinksList ul:visible').slideUp(500);
			$j('#quickLinksList ul:visible').parent().removeClass('active');
			// slide up and add active class
			$j(this).parent().addClass('active')
			checkElement.slideDown(300);
			return false;
			}
		}
	);
}
// end quickLinks

function homeFeatured (){
if ( $j("#homeFeatured").length ){	
	 $j("#homeFeatured a").bigTarget();
	 
	 $j("#homeFeatured li")
		.mouseover(function() {	
			$j(".leftContent", this).stop().animate( {
				width: 102,
				backgroundPosition: '0 -171px'
				}, {queue:true, duration: 400});
			$j("a", this).stop().animate({color: "#ffffff"})
			$j(".arrow, p", this).stop().fadeTo(200,0);
		})
		.mouseout(function() {
			$j(".arrow, p", this).stop().fadeTo(580,1);
			$j("a", this).stop().animate({color: "#003399"})
			$j(".leftContent", this).stop().animate( {
					width: [229, 'easeOutBounce'],
					backgroundPosition: '0 0'
					}, 450);
		});
	
	};
};
// end homeFeatured

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').not("dd:eq(0)").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);									 
					});
				}
			}
		});
	}
}
