function openExternalWin(product, url) {
	if(! confirm("Thank you for visiting " + product + ".com.\nAstraZeneca does not review or control the content at the site to which this hyperlink connects;\ntherefore, this hyperlink does not constitute an endorsement by AstraZeneca of the content of any non-AstraZeneca site.\nDo you wish to continue?"))
    	return;

    var externalWin = window.open(url,null,"toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=500");
    if (externalWin.opener == null)
    	externalWin.opener=window;
        externalWin.opener.name="opener";
}

/***********************************************************************

Global variables for offRamp language

************************************************************************/
var iGlobalEng = 1;
var iThirdPartyEng = 2;
var iGlobalSpan = 3;
var iThirdPartySpan = 4;
var Abraxis = 5;
var Arimidex = 6;
var Faslodex = 7;

/***********************************************************************
function FollowURL(iLanguage, sURL, bReturn, sWndName, sOptions)

Description:
	Shows the off-ramp language to the user before navigating to a third-
	party or global site. 
	
Parameters:
	iLanguage: integer value defined above identifying the language to use
		Global AZ English = 1
		Third Party English = 2
		Global AZ Spanish = 3
		Third Party Spanish = 4
	sURL: string value identifying the URL the user is attempting to navigate to
	bReturn: optional boolean value identifying whether a return value is required by the caller
	sWndName: optional string identifying the name of the target window
	sOptions: optional string identifying window.open options
	
Example:
	FollowURL(iGlobalEng, "http://www.cnn.com", false, "CNN", "top=10,left=10")

************************************************************************/
function FollowURL(iLanguage, sURL, bReturn, sWndName, sOptions)
{
	var sPrompt;
	
	switch (iLanguage)
	{
		case 1: // iGlobalEng
			sPrompt = "This link will take you to a global section of this site maintained by AstraZeneca.\nIt may contain information that does not fall within the indications and guidelines of United States regulatory agencies.\n\nClick Cancel to return or OK to continue."
			break;
		case 2: // iThirdPartyEng
			sPrompt = "This link will take you to a site maintained by a third party who is solely responsible for its contents.\n\nAstraZeneca provides this link as a service to web site visitors. AstraZeneca is not responsible for the Privacy Policy of any third party web sites. We encourage you to read the privacy policy of every web site you visit.\n\nClick Cancel to return or OK to continue."
			break;
		case 3: // iGlobalSpan
			sPrompt = "Este enlace lo llevará a una sección mundial de este sitio mantenida por AstraZeneca.\nEste sitio puede contener información que no entra dentro de las indicaciones y guías de las agencias reglamentarias de Estados Unidos.\n\nHaga clic en Cancelar para regresar o en OK para continuar."
			break;
		case 4: //iThirdPartySpan
			sPrompt = "Este enlace lo llevará a un sitio que es mantenido por terceros, que son los únicos responsables de su contenido.\n\nAstraZeneca proporciona este enlace como un servicio a los visitantes a su sitio web. AstraZeneca no es responsable de la Política de Privacidad de sitios web de terceros. Por favor, lea la política de privacidad de cada sitio web que visite.\n\nHaga clic en Cancelar para regresar o en OK para continuar."
			break;
		case 5: //Abraxis
			sPrompt = 'This link will take you to a product Web site where you will find information about a chemotherapy option for metastatic breast cancer.\n\nThis site is maintained by Abraxis BioScience who is solely responsible for its contents. Abraxis and AstraZeneca are not responsible for the Privacy Policy of any third party web sites, should you choose to exit an Abraxis or AstraZeneca Web site. We encourage you to read the privacy policy of every web site you visit. Click "Cancel" to return or "OK" to continue.'
			break;	
		case 6: // ARIMIDEX
			sPrompt = "This link will take you to a product Web site where you will find information about a hormonal treatment for breast cancer.\n\nBreast cancer is a malignant tumor that grows in one or both of the breasts. Breast cancer usually develops in the ducts or lobules of the breast. Even after initial treatment for breast cancer, it's possible for breast cancer to come back--or recur--either at the same site as the original tumor or somewhere else in the body. The risk of recurrence is highest in the first 5 years following initial diagnosis, peaking within the first 3 years."
			break;
		case 7: // FASLODEX
			sPrompt = "This link will take you to a product Web site where you will find information about a hormonal treatment for hormone receptor-positive metastatic breast cancer in postmenopausal women whose disease has returned or progressed following antiestrogen therapy.\n\nDoctors use the term \"stage\" to refer to the extent of cancer within the body. Breast cancer staging takes into account the size and location of the primary breast tumor any regional lymph node involvement near the breast and underarm, and any metastatic disease. In stage IV, also known as metastatic cancer, the disease has spread from the breast to other parts of the body such as the bone, liver, lungs, or brain."
			break;
		case 8: // Pulmicort Spanish 
			sPrompt = "Las páginas que visites de aquí en adelante están en inglés." 
			break; 

		
	}
	
	if (sWndName == null) sWndName = "opener";
	if (sOptions == null) sOptions = "";

	if(! confirm(sPrompt))
		if (bReturn) return false;
		else return;

	var externalWin = window.open(sURL, null, sOptions);
	if (externalWin.opener == null)
		externalWin.opener = window;
	externalWin.opener.name = sWndName;
	if (bReturn) return true;
/*
	if (confirm(sPrompt))
  	{
		if (sURL != null) window.open(sURL, sWndName, sOptions);
		if (bReturn) return true;
	}
	else	
	{
		if (bReturn) return false;
	}
*/
}

/************************************************************************
function ValidateWebForm(reqFields, reqLabels, theForm)

Description:
	Validates the required fields of a form, including the format of
	an email address (named either email or *_email). Ensures that a 
	checkbox, radio, or select box has a value if required.

Parameters:
	reqFields: string containing names of required form fields
	reqLabels: string containing user-readable description of fields
	theForm: object representing the web form to be validated

Example: 
	ValidateWebForm('fname', 'First Name', document.form1);
	
*************************************************************************/
function ValidateWebForm(reqFields, reqLabels, theForm){
   var fieldname, required, i, j;
   
   for(i = 0; i < theForm.elements.length; i++) {
      required = false;
      for(j = 0; j < reqFields.length; j++)  {
         if(theForm.elements[i].name == reqFields[j]) {
            required = true;
            fieldname = reqLabels[j];
            break;
         }
      }
      if(required == true) {
         if((theForm.elements[i].type == "text" || theForm.elements[i].type == "password") && theForm.elements[i].value == "")  {
            alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + fieldname + "\n\nPlease fill in this field and submit again.");
            theForm.elements[i].focus();
            return false;
         }
         if(theForm.elements[i].name == "email" || theForm.elements[i].name.indexOf("_email") != -1) {
			var e1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
			var e2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
			var reg1 = new RegExp(e1str);
			var reg2 = new RegExp(e2str);
			if (reg1.test(theForm.elements[i].value) || !reg2.test(theForm.elements[i].value)) {
				alert("Please enter a valid email address, i.e. user@domain.com!")
				theForm.elements[i].focus();
				return false;
			}
         }
         if(theForm.elements[i].type == "radio")   {
            var rdoName = theForm.elements[i].name;
            var rdoChecked = 0;
            for(var j = 0; j < theForm.elements[rdoName].length; j++)   {
               if(theForm.elements[rdoName][j].checked == true)   {
                  rdoChecked += 1;
               }
            }
            if(rdoChecked == 0)  {
               alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + fieldname + "\n\nPlease fill in this field and submit again.");
               theForm.elements[i].focus();
               return false;
            }
         }
         if(theForm.elements[i].type == "checkbox")   {
            var cbxName = theForm.elements[i].name;
            var cbxChecked = 0;
            for(var j = 0; j < theForm.elements[cbxName].length; j++)   {
               if(theForm.elements[cbxName][j].checked == true)   {
                  cbxChecked += 1;
               }
            }
            if(cbxChecked == 0)  {
               alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + fieldname + "\n\nPlease fill in this field and submit again.");
               theForm.elements[i].focus();
               return false;
            }
         }
         if(theForm.elements[i].type == "select-one" && theForm.elements[i].selectedIndex == 0)   {
            alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + fieldname + "\n\nPlease fill in this field and submit again.");
            theForm.elements[i].focus();
            return false;
         }
      }
   }
      
	return true;
}

/************************************************************************
function ValidateText(oText, sFieldName)

Description:
	Validates the text object specified by the first argument. The second
	argument contains the user-readable description of the text field.

Parameters:
	oText: object representing the field to be validated
	sFieldName: string containing the user-readable description of the 
				field

Example: 
	ValidateText(document.myForm.firstname, 'First Name');
	
*************************************************************************/
function ValidateText(oText, sFieldName)
{
	if(oText.value == "")  {
	   alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + sFieldName + "\n\nPlease fill in this field and submit again.");
	   oText.focus();
	   return false;
	}
	return true;
}

/************************************************************************
function ValidateEmailAddress(oEmail, sFieldName)

Description:
	Validates the text object specified by the first argument. The second
	argument contains the user-readable description of the email field.

Parameters:
	oText: object representing the email field to be validated
	sFieldName: string containing the user-readable description of the 
				email field

Example: 
	ValidateEmailAddress(document.myForm.friendemail, 'Friend's EMail Address');
	
*************************************************************************/
function ValidateEmailAddress(oEmail, sFieldName)
{
	if (oEmail.value == "")
	{
		alert("Please enter a valid email address, i.e. user@domain.com, for " + sFieldName + "!");
		oEmail.focus();
		return false;
	}
	
	var e1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	var e2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
	var reg1 = new RegExp(e1str);
	var reg2 = new RegExp(e2str);
	if (reg1.test(oEmail.value) || !reg2.test(oEmail.value))
	{
		alert("Please enter a valid email address, i.e. user@domain.com, for " + sFieldName + "!");
		oEmail.focus();
		return false;
	}
	return true;
}

/************************************************************************
function ValidateRadio(oRadio, sFieldName)

Description:
	Validates the set of radio buttons specified by the first argument.
	The second argument contains the user-readable description of the 
	radio button group.

Parameters:
	oRadio: object representing the group of radio buttons to be 
			validated
	sFieldName: string containing the user-readable description of the 
				radio button group

Example: 
	ValidateRadio(document.myForm.gender, 'Gender');
	
*************************************************************************/
function ValidateRadio(oRadio, sFieldName)
{
	var rdoName = oRadio.name;
	var rdoChecked = 0;
	for(var j = 0; j < oRadio.length; j++)   {
	   if(oRadio[j].checked == true)   {
	      rdoChecked += 1;
	   }
	}
	if(rdoChecked == 0)  {
	   alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + sFieldName + "\n\nPlease fill in this field and submit again.");
	   return false;
	}
	return true;
}

/************************************************************************
function ValidateCheckbox(oCheck, sFieldName)

Description:
	Validates the checkbox object specified by the first argument. The 
	second argument contains the user-readable description of the 
	checkbox.

Parameters:
	oCheck: object representing the checkbox field to be validated
	sFieldName: string containing the user-readable description of the 
				checkbox

Example: 
	ValidateCheckbox(document.myForm.agreement, 'Compliance Agreement');
	
*************************************************************************/
function ValidateCheckbox(oCheck, sFieldName)
{
	var cbxChecked = 0;
	for(var j = 0; j < oCheck.length; j++)   {
	   if(oCheck[j].checked == true)   {
	      cbxChecked += 1;
	   }
	}

	if(cbxChecked == 0)  {
	   alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + sFieldName + "\n\nPlease fill in this field and submit again.");
	   oCheck[0].focus();
	   return false;
	}
	return true;
}

/************************************************************************
function ValidateSelect(oSelect, sFieldName)

Description:
	Validates the select object specified by the first argument. The 
	second argument contains the user-readable description of the 
	select field. This function only works if the select box is a 
	select-one select box (no multiple responses) and the first option in
	the	select box is an invalid response (e.g. "Select a state").

Parameters:
	oSelect: object representing the select field to be validated
	sFieldName: string containing the user-readable description of the 
				select field

Example: 
	ValidateSelect(document.myForm.state, 'State');
	
*************************************************************************/
function ValidateSelect(oSelect, sFieldName)
{
	if(oSelect.type == "select-one" && oSelect.selectedIndex == 0)   {
	   alert("You must fill in all required form fields. You have not filled in the following required field:\n\n" + sFieldName + "\n\nPlease fill in this field and submit again.");
	   oSelect.focus();
	   return false;
	}
	return true;
}

/* CURRENT FUNCTIONS */
	function offRampStandard1(langIncluded,siteName,windowName,URL,otherOptions,returnEnabled) 
	{	
				
		var aLanguage = new Array(2);

		langIncluded = langIncluded - 1	
		aLanguage[0] = "This link will take you to a global section of this site maintained by AstraZeneca.\n It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click Cancel to return or OK to continue.";
		aLanguage[1] = "This link will take you to a site maintained by a third party who is solely responsible for its contents.\n\n AstraZeneca provides this link as a service to web site visitors. AstraZeneca is not responsible for the Privacy Policy of any third party web sites. We encourage you to read the privacy policy of every web site you visit.\n\n Click Cancel to return or OK to continue.";	  

		if (windowName == null) windowName = '';
		if (otherOptions == null) otherOptions = '';
		
  		if (confirm(aLanguage[langIncluded]))
  		{
			if (URL != null) window.open(URL,windowName ,otherOptions);
			if (returnEnabled) return true;
		}
		else	
			if (returnEnabled) return false;
	}
		
		/* function that prompts the user to let them know that they are leaving the site.
		This function should be used....blah blah add pra stuff for why.
	*/
	function offRampStandard(langIncluded,siteName,windowName,URL,otherOptions) 
	{
		var sStatementDefault = "if no language was given";
		var sStatement1 = "This link will take you to a global section of this site maintained by AstraZeneca.\n It may contain information that does not fall within the indications and guidelines of United States regulatory agencies. Click Cancel to return or OK to continue.";
		var sStatement2 = "This link will take you to a site maintained by a third party who is solely responsible for its contents.\n\n AstraZeneca provides this link as a service to web site visitors. AstraZeneca is not responsible for the Privacy Policy of any third party web sites. We encourage you to read the privacy policy of every web site you visit.\n\n Click Cancel to return or OK to continue.";
		//hold for future statements	
		//used for dialog prompt.
		//check sitename and otheroptions
		if (windowName == null)
		{
			windowName = '';
		}
		if (otherOptions == null)
		{
			otherOptions = '';
		}
		//checks for what kind of lang is required,depending on the type of site.1 - AZ global , 2- 3rd party
  		switch (langIncluded)
  		{
  			case 1:
  				sPrompt = sStatement1
  				break;
  			case 2:
  				sPrompt = sStatement2
  				break;
  			//case 3:
  				//sPrompt = sStatement3
  			//	break;
  			default:
  				sPrompt = sStatement1Default
  		}
		 	//now we have the "language to use, lets prompt the user.	
  		if (confirm(sPrompt))
  		{
			if (URL == null)
				{
					//no url just return true;
					return true;
				}
			else
				{
					window.open(URL,windowName ,otherOptions);
					return true;
				}
		}
		else	
		{
			return false;
		}
	}