/*
This function was created because there are several places in the NPIN Web site calling that should call
isLeavingNPIN but are calling isLeaving instead.  Rather than try to locate all of the instances of this function
we (re)created isLeaving and it makes a call to isLeavingNPIN.  See isLeavingNPIN for more details.

*/
function html_entity_decode(str) {
  var ta=document.createElement("textarea");
  ta.innerHTML=str.replace(/</g,"&lt;").replace(/>/g,"&gt;");
  return ta.value;
}


function isLeaving(strDestinationURL, strLanguage) {
	isLeavingNPIN(strDestinationURL, strLanguage)
	return false;
}


/*
* Function: isLeavingNPIN(DestinationURL)
* Description: A function to determine whether an HREF link should display
* an alert message when clicked. Alert message will display when HREF links
* to a non-approved website.
*
* Input: DestinationURL - the URL to be checked for approval
*		Language - the Language in which to display the alert message
			Options: Eng for English (default)
					Span for Spanish
* Returns: true or false indicating whether or not the link should be shown
*
* Usage: <a href="WebsiteURL" onClick="return isLeavingNPIN(this, strLanguage);">WebsiteName</a>
*	Example: <a href="http://www.yahoo.com/" onClick="return isLeavingNPIN(this, 'Eng');">Yahoo</a>
*/

function isLeavingNPIN(DestinationURL, Language) {
	/* Regular expression to allow the following websites:
		cdc.gov
		cdcnpin.org
	*/
	var allowedWebsites = /cdc\.gov|cdcnpin\.org|nineandahalfminutes/;
	var VisitSite
	
	// 	Test the DestinationURL to check if the alert message should be shown.
	if (allowedWebsites.test(DestinationURL) == false) {
		// Determine which language to display the alert
		switch(Language) {
			case "Eng":
				//return confirm("Notice\n\n You are temporarily leaving the CDC NPIN web site to open an external web site. CDC and NPIN are not responsible for the availability or content of external sites, nor do we endorse, warrant, or guarantee the services or information described or offered on external sites. Further, the site you are about to visit may contain information that may not be appropriate for all audiences. The views and information offered on extermal web sites do not necessarily state or reflect those of the U.S. Department of Health and Human Services, CDC or NPIN. ");
				VisitSite = confirm("Notice\n\nYou are temporarily leaving the CDC NPIN web site to open an external web site. CDC and NPIN are not responsible for the availability or content of external sites, nor do we endorse, warrant, or guarantee the services or information described or offered on external sites. Further, the site you are about to visit may contain information that may not be appropriate for all audiences. The views and information offered on extermal web sites do not necessarily state or reflect those of the U.S. Department of Health and Human Services, CDC or NPIN. ");
				//alert(VisitSite);
				if (VisitSite == true)
				{
					window.open(DestinationURL);
				}
				return false;
				break;
			case "Span":
				//return confirm("Aviso\n\n Usted está temporalmente saliendo del sitio en la Web de NPIN de los CDC para vincular un sitio en la Web externo. Los CDC y NPIN no se encargan de la disponibilidad o el contenido de los sitios externos, ni nosotros apoyamos, merecemos, o garantizamos los servicios o la información descrita u ofrecida en los sitios externos. Aún más, el sitio que usted está por visitar puede contener información que quizá no sea apropiada para todas las audencias. Las criteros y la información proporcionada en los sitios en la Web externos no necesariamente declaran o reflejan los del Departamento de la Salud y Servicio Sociales de los Estados Unidos, los CDC o NPIN.");
				VisitSite = confirm(html_entity_decode("Aviso\n\n Usted est&aacute; temporalmente saliendo del sitio en la Web de NPIN de los CDC para vincular un sitio en la Web externo. Los CDC y NPIN no se encargan de la disponibilidad o el contenido de los sitios externos, ni nosotros apoyamos, merecemos, o garantizamos los servicios o la informaci&oacute;n descrita u ofrecida en los sitios externos. A&uacute;n m&aacute;s, el sitio que usted est&aacute; por visitar puede contener informaci&oacute;n que quiz&aacute; no sea apropiada para todas las audencias. Las criteros y la informaci&oacute;n proporcionada en los sitios en la Web externos no necesariamente declaran o reflejan los del Departamento de la Salud y Servicio Sociales de los Estados Unidos, los CDC o NPIN."));
				if (VisitSite == true)
				{
					window.open(DestinationURL);
				}
				return false;				
				break;
			// The default alert display language is English						
			default:
				//return confirm("Notice\n\n You are temporarily leaving the CDC NPIN web site to open an external web site. CDC and NPIN are not responsible for the availability or content of external sites, nor do we endorse, warrant, or guarantee the services or information described or offered on external sites. Further, the site you are about to visit may contain information that may not be appropriate for all audiences. The views and information offered on extermal web sites do not necessarily state or reflect those of the U.S. Department of Health and Human Services, CDC or NPIN.");	
				VisitSite = confirm("Notice\n\nYou are temporarily leaving the CDC NPIN web site to open an external web site. CDC and NPIN are not responsible for the availability or content of external sites, nor do we endorse, warrant, or guarantee the services or information described or offered on external sites. Further, the site you are about to visit may contain information that may not be appropriate for all audiences. The views and information offered on extermal web sites do not necessarily state or reflect those of the U.S. Department of Health and Human Services, CDC or NPIN. ");
				//alert(VisitSite);
				if (VisitSite == true)
				{
					window.open(DestinationURL);
				}
				return false;
				break;
		}
	}
	else return true;
}

/*
** Function is obsolete. Should use isLeavingNPIN(DestinationURL, Language) function **
function leaving(){
     return confirm("Notice\n\n You are now exiting the CDC NPIN website to link(s) to external website(s).\n CDC and NPIN are not responsible for the availability or content of these\n external sites, nor do we endorse, warrant or guarantee the services or\n information described or offered on the sites. Further, the site you are about\n to visit may contain information that may not be appropriate for all audiences.\n The views and information provided on these external websites do not\n necessarily state or reflect those of the U.S. Department of Health and\n Human Services, CDC, or NPIN.");
}
*/

/*
** Function is obsolete. Should use isLeavingNPIN(DestinationURL, Language) function **
function s_leaving(){
     return confirm("Aviso\n\n Usted está ahora saliendo del sitio en la Web de NPIN de los CDC para\n vincular a un sitio en la Web externo. Los CDC y NPIN no se encargan\n de la disponibilidad o el contenido de los sitios externos, ni nosotros\n apoyamos, merecemos, o garantizamos los servicios o la información\n descrita u ofrecida en los sitios externos. Aún más, el sitio que usted\n está por visitar puede contener información que quizá no sea apropiada\n para todas las audiencias. Los criterios y la información proporcionada en\n los sitios en la Web externos no necesariamente declaran o reflejan los\n del Departamento de Salud y Servicios Sociales de los Estados Unidos, \n los CDC o NPIN.");
}
*/
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

