/*
* Function: isLeaving(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 isLeavingVP(this, strLanguage);">WebsiteName</a>
*	Example: <a href="http://www.yahoo.com/" onClick="return isLeavingVP(this, 'Eng');">Yahoo</a>
*/

function isLeaving(DestinationURL, Language) {
	/* Regular expression to allow the following websites:
		safeyouth.gov
	*/
	var allowedWebsites = /safeyouth\.org/;
	
	 // 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 now exiting the CDC NPIN Web site to link to an external Web site.\n CDC and NPIN are not responsible for the availability or content of external\n sites, nor do we endorse, warrant, or guarantee the services or information\n described or offered on external sites. Further, the site you are about to visit\n may contain information that may not be appropriate for all audiences. The\n views and information provided on external Web sites do not necessarily state\n or reflect those of the U.S. Department of Health and Human  Services, CDC,\n or NPIN.");
				break;
			case "Span":
				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.");
				break;
			// The default alert display language is English						
			default:
				return confirm("Notice\n\nYou are now exiting a Web site funded by the Federal government to link to an external Web site. The U.S. government, including the Centers for Disease Control and Prevention (CDC), the National Youth Violence Prevention Resource Center (NYVPRC), and its Federal Partner Agencies, are not responsible for the availability or content of external sites, nor are the services or information described or offered on the external sites endorsed, warranted or guaranteed by these agencies. The views and information provided on these external Web sites do not necessarily represent the official views of the U.S. government, the U.S. Department of Health and Human Services, CDC, or the NYVPRC.");	
				break;
		}
	 }
	 else return true;
}