jQuery(function(){

	// exclude all links in your domain
	var myDomain = "e-pfg.com";

	// will exclude any link containing the string from having a disclaimer
	var exceptions = new Array("e-pfg.com");
	
	// will force any link containing the string to open in a new window
	var forceNewWindow = new Array(".pdf");
	
	var myClicked; // stores attributes for 'a' element
	
	$("a").click(function(event){
		var disclamerPass = false;
		myClicked = this;
		
		for(var f=0;f<forceNewWindow.length;f++) {
			if(myClicked.href.indexOf(forceNewWindow[f]) != -1) {
				myClicked.target = "_blank";
			}
		}
		for(var i=0;i<exceptions.length;i++) {
			if((myClicked.href.indexOf(exceptions[i]) != -1) || (myClicked.href.indexOf(myDomain) != -1)) {
				disclamerPass = true;
			} else {
				myClicked.target = "_blank"; // added for Pinnacle
			}
		}
		if (disclamerPass==true) {
			window.location = a.href;
		} else {
			$('#dialog').dialog('open');
			event.preventDefault();
		}
	});
	
	$('#dialog').dialog({
		autoOpen: false,
		width: 500,
		resizable: false,
		buttons: {
			"Continue": function() {
				if(myClicked.target == "_blank") {
					window.open(myClicked.href);
					$(this).dialog("close"); 
				} else {
					window.location = myClicked.href;
				}
			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
});