var domains_with_no_message= new Array("www.harboroneu.com","harboroneu.com","www.harborone.com","harborone.com","www.harboronecu.com","harboronecu.com","harboroneads.com","harborone.locatorsearch.com","members.cunamutual.com");

var domains_messages = new Array();
//SHORT WARNING MESSAGE
domains_messages["global1.onlinebank.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
domains_messages["command.onlinebank.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
domains_messages["demo1.onlinebank.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
//NEW DEMO SITE
domains_messages["demo2.onlinebank.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
domains_messages["commanduat1.onlinebank.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
//begin -- loans24.net
domains_messages["www.loans24.net"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
domains_messages["loans24.net"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
//begin -- h1businessonline.com
domains_messages["www.h1businessonline.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
domains_messages["h1businessonline.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
//begin -- cmdemo.com
domains_messages["www.cmdemo.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
domains_messages["cmdemo.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
//begin -- harboronecu.mortgagewebcenter.com
domains_messages["harboronecu.mortgagewebcenter.com"] = "Please note you are leaving the HarborOne website.  Each third party may have a privacy policy that differs from HarborOne.  Any linked site from this third party may provide less security than HarborOne's website.";
//END SHORT WARNING MESSAGE

//DEFAULT WARMING MESSAGE
var default_message = "Please note you are leaving the HarborOne website. HarborOne does not endorse or guarantee products, information, or recommendations provided by linked sites and HarborOne is not liable for any products or services advertised on these sites. Each third party may have a privacy policy that differs from HarborOne. Any linked site may provide less security than HarborOne's website.";
var default_mailto_message = "Please note: email messages are not secure. Please refrain from entering personal, confidential information in the message, such as your social security or account numbers. Thank you.";


function attach_external_check(internal_domains){
	
}

	
	window.addEvent('domready', function() {
	
	    $$("a").each(function(atag,index)
	    {
	    	if ((atag.href.match(/https?:\/\/(.[^\/]+)/))!=null){
		    	// get domain name, check http/https only.	    	
		    	var dm = atag.href.match(/https?:\/\/(.[^\/]+)/)[1];
		    	if(dm){
		    		dm = dm.toLowerCase();
			    	// check if atag is internal link
			    	var isInternal = false;
			    	var hasDefaultMessage = false;
			    	
			    	if(!isInternal){
			    		domains_with_no_message.each(function(item, index){
				    		if(item == dm){
				    			isInternal = true;
				    		}
				    	});
			    	}
			    	
			    	if(!isInternal){
			    		var msg = domains_messages[dm];
			    		if(msg==undefined){
			    			msg = default_message;
			    		}
			    	}
			    	
			    	// do attach check.
			    	if(!isInternal){
				        atag.addEvent("click", function(event) {
	
										var result = confirm(msg);
	
	
	
				            if (result == true)
				            {
				                return true;
				            }
				            else
				            {		        		
				                event = new Event(event).stop();
								//return false;
				            }
				        });
			    	}
		    	}
		    }
		  });
	});


	window.addEvent('domready', function() {
	
	    $$("a").each(function(atag,index)
	    {
	    	// get domain name, check mailto: only.	    	
	    	if ((atag.href.match(/mailto:(.[^\/]+)/))!=null){
		    	var dm = atag.href.match(/mailto:(.[^\/]+)/)[1];
		    	var msg = default_mailto_message;
		        atag.addEvent("click", function(event) {

							var result = confirm(msg);



	            if (result == true)
	            {
	                return true;
	            }
	            else
	            {		        		
	                event = new Event(event).stop();
					//return false;
	            }
	        });
	    	}
	    });
		});