var $j=jQuery.noConflict(); 
var bankname = "Raritan Bay FCU"
var alertText = "Please be advised that you are leaving " + bankname + "'s website. This link is provided as a courtesy.  " + bankname + " does not endorse or control the content of third party websites.";

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

	$j("a.confirm").click( function() {						   
		if (!confirmAlert($j(this).attr('href'))){
			return false;			
		}
	});
	
	if( $j().fancybox )
	{	$j("#flashLink a").addClass("iframe");
		$j("#flashLink a").fancybox({
			'hideOnContentClick': false,
			'frameWidth': 530,
			'frameHeight': 500,
			'overlayOpacity': 0.8,
			'centerOnScroll': false
		});
	}
	
});


//controls speedbumps
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; 
}

//grabs the product ID from the hidden app links on the home page
function getProductID( productType ) {
	if( $j("#linkRC a").length > 0 || $j("#linkRS a").length > 0 )
	{	if( productType == "rc" )
			var tag = $j("#linkRC a");
		else if( productType == "rs" )
			var tag = $j("#linkRS a");
		
		var url = tag.attr("href");
		return url.split("=")[1].split("&")[0];
	}
	else
		return null;
}

//function called from flash to create popup link
//destination:String can only = "contactUs", "share", "application", "faq", "disclosure", "privacyPolicy"
//productType:String can only = "checking", "savings"  -  optional param
function showPopup(destination, url, productType){
	
	//performs the "click"
	if( destination == "application" )
	{	if( productType == "checking" )
		{	var url = $j("#linkRC a").attr("href");
			window.location = url;
		}
		else if( productType == "savings" )
		{	var url = $j("#linkRS a").attr("href");
			window.location = url;
		}
	}
	else
	{	$j("#flashLink a").removeAttr("id").attr("href", url).trigger("click");
	}
}
