﻿    var strThisDomain = document.location.host;
    var easternsites = document.getElementsByTagName('easternsts').innertext.split(",");
    for(var x in easternsites)
    {
        strThisDomain=strThisDomain+","+easternsites[x]; 
    }
    var winevnt = window.Event ? true : false; 

    function processClicks(e) { 
    if (winevnt) 
        { 

            var srcElem = e.target 
            
        } 
        else 
        { 
            var srcElem = event.srcElement 
        } 
        
        while (srcElem != null && srcElem.tagName != "A") 
        {
		    srcElem = srcElem.parentNode;
		}

        if(srcElem != null && srcElem.tagName == "A" ) 
        { 
            var strURL = srcElem.href; 
            if(strURL.indexOf("http:") > -1 || strURL.indexOf("https:") > -1) 
            {
                  //if the Url contains a source from Url as a parameter, 
                  //we only want to verify the actual domain and not the query string parameter
                  //e.g. http://www.domainname.com/page.html?otherurl=http://www.effcu.com
                  //this should still be caught!
                  var startIndex = 7; //start index when there is no SSL
                  var endIndex = 0; 
                  
                  if(strURL.indexOf("https://") > -1 )
                  {
                      startIndex = 8; //start index when using SSL
                  }

                  //If Url has query string and other direct pages, ignore them, use only the www.domainname.com part of the Url                    
                  if(strURL.indexOf("/", startIndex) > -1)
                  {
                      endIndex = strURL.indexOf("/", startIndex);
                  }
                  
                  var verifyUrl = "";
                  
                  if(endIndex > 0)
                  {
                    verifyUrl = strURL.substring(startIndex, endIndex)
                  }else
                  {
                    verifyUrl = strURL.substring(startIndex, strURL.length)
                  }
                  
                  var strThisDomainArr = strThisDomain.split(",");
                  var cont = 0;
                  for(var z in strThisDomainArr)
                  {
                  
                     //if(strURL.indexOf(strThisDomainArr[z]) != -1 ) 
                     if(verifyUrl.indexOf(strThisDomainArr[z]) != -1 ) 
                     { 
                        cont = cont+1;
                     }
                  }
                  if(cont == 0 ) 
                  { 
                    window.location.replace("ld.aspx?r="+document.URL+"&e=\"" + strURL + "\"");
                    return false;
                  }
            }
            
            if(strURL.indexOf("showCalculator") > -1)
            {
                //Special case for calculators page
                return true;
            }
            
            if(strURL.indexOf("javascript://") > -1)
            {
                //Ektron Functionality uses this javascript pattern for it's functionality, therefore skip the validation
                return true;
            } 
            
            
            if(strURL.indexOf("javascript") > -1)
            {
                window.location.replace("ld.aspx?r="+document.URL+"&e=\"" + "\"");
                return true;
            } 
        }       
    } 
    if (winevnt) 
    document.captureEvents(Event.CLICK); 
    document.onclick = processClicks; 


