var $j=jQuery.noConflict();
var alertText = "Please be advised that you are leaving NBRS Financial Bank's website. This link is provided as a courtesy.  NBRS Financial Bank does not endorse or control the content of third party websites.";
var customFolder = "nbrs";
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;			
			}
		}); 

// open pdfs in new window
/*$j("a[href*=.pdf]").click(function(){
	window.open(this.href);
	return false;
});*/

// write body id and class
$j(function(){
	var primary = $j('#primaryNav li a.inPath').text().replace(/ /g,'');
	$j('body').attr("class",primary);
});
	
// homepage equal height columns
var highestCol = Math.max($j('#leftColumn').height(),$j('#mainContent').height());
$j('.elements').height(highestCol);

// category page
	$j("#productCategory li.productLi a").bigTarget({
    	clickZone : '.productLi'
	});
	
	$j("#relatedProducts li a").bigTarget({
    	clickZone : '#relatedProducts li'
	});
	
	$j("#productCategory li.productLi")
	.css({'background-color': '#fff'})
	.mouseover(function(){
		$j("h3",this).stop().animate( { backgroundColor: '#D4E1E8' }, 'fast')
		$j("h3 a",this).stop().animate( { color: '#792154' }, 'fast')
		$j(this).stop().animate( { backgroundColor: '#E8F0F4' }, 'fast')
	})
	.mouseout(function(){
		$j("h3",this).stop().animate( { backgroundColor: '#EDF3F3' }, 'fast')
		$j("h3 a",this).stop().animate( { color: '#003366' }, 'fast')
		$j(this).stop().animate( { backgroundColor: '#fff' }, 'slow')
	});	

	
// 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': 520,
		'overlayOpacity': 0.8
	});
	
	$j('#shareButton a').addClass('iframe');
	
	$j("#shareButton 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


// confirm
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; 
}

// product tabs
function productTabs(){
	if( $j('#productTabs').length > 0 ){
		var offset = 80;
		$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);									 
					});
				}
			}
		});
	}
}
