function newleavingSite(url)
{
	if (window.confirm("NOTICE\n\n  The appearance of external hyperlinks ("+url+") does not constitute endorsement by the United States Department of Defense of the linked web sites, or the information, products or services contained therein. For other than authorized activities such as military exchanges and Morale, Welfare and Recreation (MWR) sites, the United States Department of Defense does not exercise any editorial control over the information you may find at these locations.  Such links are provided consistent with the stated purpose of this DoD Web site."))
    {     
    	openNewWin(url);
    }
}//leavingSite

function openNewWin(url)
{
	var x=0;
	var y=0;
	var w=600;
	var h=300;	
	var denominator=2;	
	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);
	if (((navigator.appName == "Netscape") && (parseInt (navigator.appVersion) >= 3)))
		version = "n3";
    	else
		version = "n2";
	if (version == "n3")
	{
		if (navigator.javaEnabled())
	    	{
		        var toolkit = new java.awt.Toolkit.getDefaultToolkit();
		        var screen_size = toolkit.getScreenSize();
			w = (screen_size.width)/denominator;
			h = (screen_size.height)/denominator;
		        x = ((1-(1/denominator))*(screen_size.width))/2; 
		        y = 10;
	        }
	}
	var attributes = ("location,width="+w+",height="+h+",directories,menubar,resizable,scrollbars,status,toolbar,left="+x+",top="+y+",screenX="+x+",screenY="+y);	
	window.open(url,"exitWindow",attributes);
}//openNewWin


function newfixLinks()
{	
	var i = 0;
	var url = new String('');
	var hostName = new String('');
	var realUrl;
	var noticeexemptions = new Array('.osd.mil','mhswebdev','mhswebstaging','tricare.mil','www.mytricare.com','corp-ws.wpsic.com','triwest.com','dtic.mil','gsa.gov','tricare15.army.mil','express-scripts.com','secure.ucci.com','trdp.org','pdhealth.mil', 'usembassy.state.gov','patientsafety.satx.disa.mil/','infocenter.humana-military.com', 'tricareformularysearch.org','health.mil', '199.211.83.134', '199.211.83.135', '199.211.83.117','.mil');
	var popupexemptions = new Array('.osd.mil','mhswebdev','mhswebstaging','tricare.mil', 'patientsafety.satx.disa.mil/','health.mil', '199.211.83.134', '199.211.83.135', '199.211.83.117','.mil');

	for (i=0;i<document.links.length;i++)
	{
		url=((document.links[i].href).toLowerCase()); // change link to lower case so that comparisons can be made in all lower case (psuedo case insensitivity)
		realUrl=document.links[i].href;		// save the real link (not converted to lower case) to put back into the document
		hostName=((document.links[i].hostname).toLowerCase()); //get the hostname

		var trusted = false;
		var trustedpopup = true;
		if((hostName.length==0) || (url.indexOf("mailto:")>-1) || (url.indexOf("javascript:")>-1)){
			trusted = true;
			trustedpopup = false;
		}
		else{
			var j=0;
			for(j=0; j < noticeexemptions.length;j++)
			{
				if(hostName.indexOf(noticeexemptions[j])>-1)
					trusted = true;
			}

			if(trusted)
			{
				var k=0;
				for(k=0; k < popupexemptions.length; k++)
				{
					if(hostName.indexOf(popupexemptions[k])>-1)
						trustedpopup = false;
				}
			}
		}

		if(!trusted) //EXIT NOTICE AND POPUP
		{
			if( document.links[i].target!="noexit" )
				document.links[i].href = "/include/exitwarning.aspx?link=" + realUrl;
			document.links[i].target = "_blank";

			//if( document.links[i].target.length>0)
			//	document.links[i].target = "";
			//document.links[i].href = "javascript:newleavingSite('"+realUrl+"');";

		}
		else //NO EXIT NOTICE
		{
			if(trustedpopup) //POPUP ONLY
			{
				document.links[i].target = "_blank";
				//if( document.links[i].target.length == 0)
				//	document.links[i].href = "javascript:openNewWin('"+realUrl+"');";
			}

		}
		
	}
}

newfixLinks();