﻿//This line is new
function handlerClickLeaveDIISR(e){
    var isNav = (navigator.appName.indexOf("Netscape") != -1);
    var myTarget = (isNav) ? e.currentTarget : event.srcElement;    
    var strTemp = "" + myTarget;
    
    while (strTemp.indexOf('http://') == -1 && 
           strTemp.indexOf('https://') == -1 &&
           strTemp.indexOf('mailto:') == -1 &&
           strTemp.indexOf('javascript:') == -1)
    {
        myTarget = myTarget.parentElement;
        strTemp = "" + myTarget;
    }
     
    myTarget = "" + myTarget;
							        
    if (myTarget.indexOf('http://') == 0 && 
        myTarget.indexOf('enterpriseconnect') == -1) 
    {
        // text for warning about leaving to a non-ret internet site goes here
        msg = 'You are now leaving the Enterprise Connect. \n';
        msg += 'Any information you exchange with this website\n';
        msg += 'is not connected to Enterprise Connect or \n';
        msg += 'the Department of Innovation, Industry, Science & Research.\n';
        msg += 'Do you wish to continue?';
        return confirm(msg);
    } 			 
}

function handlerClickLeaveEC(e){
    var isNav = (navigator.appName.indexOf("Netscape") != -1);
    var myTarget = (isNav) ? e.currentTarget : event.srcElement;    
    var strTemp = "" + myTarget;
    
    while (strTemp.indexOf('http://') == -1 && 
           strTemp.indexOf('https://') == -1 &&
           strTemp.indexOf('mailto:') == -1 &&
           strTemp.indexOf('javascript:') == -1)
    {
        myTarget = myTarget.parentElement;
        strTemp = "" + myTarget;
    }
     
    myTarget = "" + myTarget;
							        
    if (myTarget.indexOf('http://') == 0 && 
        myTarget.indexOf('enterpriseconnect') == -1) 
    {
        // text for warning about leaving to a non-ret internet site goes here
        msg = 'You are now leaving the Enterprise Connect website.\n';
        msg += 'Do you wish to continue?';
        return confirm(msg);
    } 			 
}

function addOnClick() {
    if (document.getElementById && document.createElement && document.appendChild) {
        var links = document.getElementsByTagName('a');
        for (var i=0; i<links.length; i++) {
            if (!links[i].onclick){
            	if (links[i].id.indexOf('tab') != -1) {
	        		links[i].onclick = handlerClickLeaveEC;
            	}
            	else {
	        		links[i].onclick = handlerClickLeaveDIISR;
	        	}
            }
	}
    }
}

