/**********************************************
*             Process External Links
*             Author: Tim Roerig - Purple Monkey Studios, Inc.
*            All DOM work
*   Modifed: Ray Schauer - Purple Monkey Studios, Inc.
*            Rebuilt as object
*	Modified: Tom Falk - Purple Monkey Studios, Inc.
*			 changed index to exclude mailto: and make site specific;
*	Modified: Andrew Boyce  - Purple Monkey Studios, Inc.
*			 Throws exceptions for Links to not display message
*
*             Example Call:
*   <script type="text/javascript" src="/externallinks.js"></script>
*             <script type="text/javascript">processPopups();</script>
***********************************************/
function alertExternalLinks() {
                // Define Configuration Attributes
                this.target = "ExternalWindow";
                this.prefix = "";
                this.postfix = "";
                this.msg =  "You are exiting Community Bank Oak Park River Forest. Thank you for visiting our site";
                //url exceptions go in this array to prevent the message, but still have it open in a new window
                this.exceptions = new Array("http://cboprf.mortgagewebcenter.com/Default.asp?bhcp=1","https://login.cboprf.com/pm_signin.asp");
				
				
                // Do Not Modify Below This Line
                this.ask = function() {
                    	var answer = confirm(this.getAttribute("msg"));
                    	if(answer) return true;
                    	else return false;
                };
                this.send = function() {
											return true;
                };

                // FIX: 7-10-07 - TF
                // Fixed global restrictions on href conditions to be more meaningful/site-specific

                // Create Processing Function
                this.process = function() {
					
                	for(i=0; (a = document.getElementsByTagName("a")[i]); i++) {
                    	if((a.getAttribute("href").indexOf(document.location.host) == -1 || document.location.host == '')
                        	&& a.getAttribute("href").indexOf("mailto:") < 0
                            && a.getAttribute("href").indexOf("http://") >= 0
                            && a.getAttribute("href").indexOf("cboprf.com") < 0) {
                                
                                if(processExceptions(this, a.getAttribute("href"))) {
																		a.onclick = this.send;
																} else {
                                    a.onclick = this.ask;
                                }
                                a.setAttribute("msg",this.msg);
																a.setAttribute("target",this.target);
                                a.innerHTML = this.prefix + a.innerHTML + this.postfix;
                          }
                      }
                };

}
function processPopups() {
                ael = new alertExternalLinks();
                ael.process();
}
function processExceptions(ael, anchors) {

	var exceptions = ael.exceptions;

	
	var ret = false;
	
   for(var i=0; i < exceptions.length; i++){
      var debug = exceptions[i];
			if(exceptions[i] == anchors){
         	ret = true;
         	break;
			}
    }
    return ret;
}
