﻿function open_window(url,w,h)
{
	mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=80,top=50,width=' + w + ', height=' + h )
}


//Add External Popup
$(document).ready(function(){
						   
	var aTags= document.getElementsByTagName("a"); 
	for(var i = 0; i < aTags.length; i++)
	{
		theLink = aTags[i].href;
		if(theLink != "")
		{
			if(theLink.match("http://"))
			{
				// The following is a list of domains/IPs considered as "Internal", so it won't popup the confirmation
			    if (!theLink.match("172.16.22.5") 
			    	&& !theLink.match("enfamil.ca") 
			    	&& !theLink.match("meadjohnson.ca") 
			    	&& !theLink.match("enfalac.ca") 
			    	&& !theLink.match("enfalac.com") 
			    	&& !theLink.match("localhost") 
			    	&& !theLink.match("addthis.com") 
			    	&& !theLink.match("nonlinear.ca")) 
				//if (false) 
				{
					aTags[i].onclick = function() {
						
						if(window.location.pathname.match(/fr/))
						{
							mywin = window.open("/fr/badges/leaving.html","win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=80,top=50,width=350, height=300');
						}else{
							mywin = window.open("/en/badges/leaving.html","win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left=80,top=50,width=350, height=300');
						}
						
						if(!document.getElementById("theLink"))
						{
							$("body").append('<div id="theLink" style="display:none;"></div>');
						}
						$("#theLink").html(this.href);
						return false;
						
						//if(confirm('!!Temporary Alert!! \n You are about to leave Enfamil.ca. Are you sure?'))
//						{
//							window.location = this.href;
//						}
//						else
//						{
//							return false; 
//						}
//						alert("Outgoing Link");
						
						//theLink = this.href;
						//theLink = theLink.replace("http://","");
						//theLink = theLink.replace("www.","");
						//pageTracker._trackPageview('/outgoing/' + theLink); // was urchinTracker
					}
				}
			}
		}
	}
});
