﻿// JScript File

var urlBmsSite = 'http://www.bms.com/medicalgrants';
var urlJointSite = 'AZ/Content/index.html';

// function: Type2DiabetesAction
// this function is called from EducationalInterest.aspx.vb when
// the user selects "Adult Type 2 Diabetes Mellitus" as the 
// sub area of educational interest, and then clicks the Continue button
function Type2DiabetesAction() {
    GotoJointSite();
}

// function: GotoJointSite
// this function will redirect the user to the joint website
// it will either redirect window.open to the website, or
// open a new browser window to the website 
function GotoJointSite() {
    // show a javascript alert before redirecting
    ShowLeavingMEGOAlert();
    if (opener == null) {
        // the browser window was not opened with javascript
        window.location = urlJointSite;
    } else if (opener != null && !opener.closed) {        
        // the browser window was opened with javascript, and the
        // user has not closed the opener
        opener.location = urlJointSite;
        self.close();
    } else {
        // if the user has already closed the opener, then we won't be
        // able to redirect it's location, so instead open a new window
        window.open(urlJointSite);
        self.close();
    }    
}

// function: GotoBmsSite
// Called from a link on \AZ\Content\index.html
// this function redirects the browser to the BMS website
function GotoBmsSite() {
    // show a javascript alert before redirecting
    ShowLeavingJointAlert();
    // redirect the browser
    window.location = urlBmsSite;
}

// function: ShowLeavingMEGOAlert
// this function displays a javascript alert to tell the user that he is
// browsing away from the MEGO website
function ShowLeavingMEGOAlert() {
    var message = '';
    message += 'You are now leaving the MEGO web page and entering the AstraZeneca';
    message += ' and Bristol-Myers Squibb joint web page. Please note, all diabetes';
    message += ' grants must be submitted through the BMS portal to be considered for funding.';
    alert (message);
}

// function: ShowLeavingJointAlert
// this function displays a javascript alert to tell the user that he is
// browsing away from the joint AZ/BMS website
function ShowLeavingJointAlert() {
    var message = '';
    message += 'You are now leaving the AstraZeneca and Bristol-Myers Squibb joint';
    message += ' web page and entering the Bristol-Myers Squibb Medical Education Grants';
    message += ' and Charitable Contributions web page.';
    alert(message);
}


