// for Cool Menus
if(window.event + "" == "undefined") event = null;
function showMenu(){return false};
function mout(){return false};
function dummyObject() {this.mout=mout};
oM = new dummyObject();


window.onerror = function(){ return true; }

function target_blank(url){
    tmp = window.open(url);
    tmp = null;
}

document.write('<img src="'+dir+'/images/wcscreenrez.gif?width='+screen.width+'&height='+screen.height+'" width="1" height="1">'); 

function wcInternalPopup(url, height, width){
    var wide=width;
    var tall=height;
    var halfwide = (wide/2);
    var halftall = (tall/2);
    var pWidth = ( ((parseInt(screen.width) / 2)) - halfwide);
    var pHeight = (((parseInt(screen.height) / 2)) - halftall);
    var features = 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
    window.open(url,'internalpopup',features);
} 

function wcPopup(url, height, width, disclaimer){
    var wide=width;
    var tall=height;
    var halfwide = (wide/2);
    var halftall = (tall/2);
    var pWidth = ( ((parseInt(screen.width) / 2)) - halfwide);
    var pHeight = (((parseInt(screen.height) / 2)) - halftall);
    var features = 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
    window.open(url,'externalpopup',features);
}

function open_apps(nameofapp)
{
var pWidth = ( ((parseInt(screen.width) / 2)) - 350)
var pHeight = (((parseInt(screen.height) / 2)) - 300)
aWindow = window.open('https://www.usfed.org/Forms/OnlineForm.cgi?form=' + nameofapp,'application',"toolbar=0,location=0,directories=0,status=0,menubar=0,width=700,height=600,top=" + pHeight + ",left=" + pWidth + ",scrollbars=1,resizable=1,status=1");
}

function openPDF(page)
{
bWindow = window.open(fiDir + 'documents/'+page,'newWin');
	bWindow = null;
	return;
}

function openDisc(page)
{
var pWidth = ( ((parseInt(screen.width) / 2)) - 300)
var pHeight = (((parseInt(screen.height) / 2)) - 400)
bWindow = window.open(page,'discwin',"scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,width=600,height=600,top=" + pHeight + ",left=" + pWidth);
	bWindow = null;
	return;
}

/************************************************************************************************************
* This function is used in the onclick of the a tag to display the external site warning. 
* @param msg - Integer specifying the which message to display.
* @param lk - The a link object
* Usage: <a href="http://wwww.mysite.com" onclick="return displayThirdPartyAlert(1,this);">My Site</a>
**************************************************************************************************************/
function displayThirdPartyAlert(msg,lk){
	var description = lk.innerHTML;
	if(description.indexOf('alt="') != -1){
		var x = description.indexOf('alt="')+5;
		var temp = description.substring(x);
		description = temp.substring(0,temp.indexOf("\""));
	}
	showWarning(lk.href, description, lk.target, msg)
	return false;
}

/************************************************************************************************************
* This function is used in the href of the a tag to display the external site warning. 
* @param lk - The url of the site to be opened
* @param desc - The description of the site to be opened, i.e. the name of the site.
* @param target - Allows for the window to opened in a new window
* @param msg - Integer specifying the which message to display.
* Usage: <a href="javascript:('http://wwww.mysite.com');">My Site</a>
**************************************************************************************************************/

function showWarning(lk, desc, target, msg){
	desc = (desc) ? desc : "Third Party Site";
	target = (target) ? target : "_blank";
	msg = (msg) ? msg : 0;
	 
	var messages = new Array(6);
	messages[0] = '<h1 style="text-align:center">Third Party Site Disclaimer</h1><p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.  We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';
	
	messages[1] = '<h1 style="text-align:center">Third Party Site Disclaimer</h1><p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.  We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';
	
	messages[2] = '<h1 style="text-align:center">Third Party Site Disclaimer</h1><p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.  We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';
	
	messages[3] = '<h1 style="text-align:center">Third Party Site Disclaimer</h1><p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.  We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';
	
	messages[4] = '<h1 style="text-align:center">Third Party Site Disclaimer</h1><p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.  We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';
	
	messages[5] = '<h1 style="text-align:center">Third Party Site Disclaimer</h1><p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.  We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';

	var content = new Array();
	var index = 0;
	content[index++] = messages[msg];
	content[index++] = '<br /><br /><br />';
	content[index++] = '<div align="center"><a href="'+lk+'" target="'+target+'" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'">Continue</a>&#160;&#160;<a href="javascript:void(\'0\');" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'">Decline</a></div></div>';	
	document.getElementById("ex_dis").innerHTML = content.join("");
	document.getElementById("ex_dis").style.display = "block";
	scrollTo(0,0);
}

function showNCUA(){	
	
	document.getElementById("ex_dis3").style.display = "block";	
}

function hideNCUA(){	
	document.getElementById("ex_dis3").style.display = "none";	
}

function getUrl(){
	var url = document.location.href;
	var urlstart = url.indexOf("newUrl=") + 7;
	var urlToReturn = url.substring(urlstart);
	return urlToReturn;
}


/**
 *  @Name: _speedbump.js
 *  @Author: Paul McLanahan <paul.mclanahan at digitalinsight dot com>
 *  @Contrib: A lot of code from  Stuart Langridge's NiceTitles at http://kryogenix.org/
 *	@Updated: 6-15-2005
 *  @Usage: Simply add the following line to the <head> of your HTML page and this script
 *      will seek out all links that point to a 3rd party domain and add a 3rd party Speed Bump (SB)
 *      to them.  All that's really required of you is that you add elements to the 'allowedDomains'
 *      array to tell the script which links to ignore.
 *  @Code: <script language="JavaScript" type="text/javascript" src="/path/to/script/_speedbump.js"></script>
 *  @CSS: The class for the SB <div> will be 'speedbump', so you may style accordingly. The following style elements
 *      are set by the JS, so you don't need to worry about them.
 *          d.style.position = 'absolute';
 *          d.style.width = '<sbWidth>px'; // where <sbWidth> is the variable below
 *          d.style.top = <link_position - SB height + sbYOffset>; // where <link_position is the calclated y position of the link relative to the page, which is added to sbYOffset> which is a variable below.
 *          d.style.left = <link_position + sbXOffset>; // where <link_position is the same as above, and sbXOffset> is a variable below.
 *      The rest of the CSS should go in _styles.css and in a declaration that looks like:
 *          div.speedbump{
 *              border:2px solid #685539;
 *              background:#fff;
 *              padding:5px;
 *              etc...
 *          }
 *      But using your own values for the actual styles of course.
 *      You may then style any elements you add to the 'sbContent' variable below using the following example:
 *          div.speedbump h2{
 *              color: #685539;
 *              font-size: 2em;
 *              letter-spacing: 3px;
 *              etc...
 *          }
 */

/////// start configuration ////////////

var debug = false; // set to true to show an alert on page load with all links that will have the SB added.
var sbWidth = 350; // width of the SB div
var sbCentered = true; // whether or not to center the SB on the page. If false, the SB will be aligned relative to the link.
var openInNewWindow = true;  // whether or not to open the 3rd party links (TPLs) in new windows. This should always be false unless specifically asked for by the FI!
var sbXOffset = -(sbWidth/2); // x offset. This is only used if sbCentered is false.  Negative number means move left, positive means right. If 0 the left side of the SB will line up with the leftmost part of the link.
var sbYOffset = -30; // y offset. Negative number means move up, positive means down. If 0 the bottom of the SB will align with the top of the link. This also sets how far the top of the SB is from the top of the window.
var dhtmlTop = 100; // if the function showDHTMLSB() is called from coolmenus, this will set how far from the top of the page the SB is displayed.
var allowedDomains = [ // array containing strings which, if any one is found in a link, will cause the SB not to be added to said link.
	"javascript", // DO NOT REMOVE. This will find all links that use JavaScript in the href and ignore them.
	"centralwcu.org",  // add your FI's domain here.
	"3017",
	"10.101.5.10",
	"bankcardoffer.com"
];

var partnerDomains = [ // array containing strings which, if one matches a link that has had the sb added, will cause the sbPartnerContent string to be used indstead of sbContent.
    "paylinks.cunet.org",
    "secure5.arcot.com",
    "extraawards.com",
    "centralwcu-ihl.net"
];

// Edit the html in the 'sbContent' variable below to modify the contents of the SB div.
// Place the string ##SBLINK## inside an <a> tag (example below). ##SBLINK## will be replaced by the necessary 'href' and/or 'onclick' attributes.
var sbContent = '';
sbContent += '<div class="speedbumpIB"><div style="margin-bottom:10px;background: #FDFBF8"><img src="'+dir+'/images/logo_centralwcu.gif" width="203" height="86" alt="Central Willamette Community Credit Union" border="0" /></div>';
sbContent += '<h2 align="center">Third Party Site Disclaimer</h2>';
sbContent += '<p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.  We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';
sbContent += '<div align="center" class="sblinks"><a ##SBLINK##>Continue</a>&nbsp;&nbsp;<a href="#" onclick="hideSpeedBump();return false;">Cancel</a></div></div>';

var sbPartnerContent = '';
sbPartnerContent += '<div class="speedbumpIB"><div style="margin-bottom:10px;background: #FDFBF8"><img src="'+dir+'/images/logo_centralwcu.gif" width="203" height="86" alt="Central Willamette Community Credit Union" border="0" /></div>';
sbPartnerContent += '<h2 align="center">Third Party Site Disclaimer</h2>';
sbPartnerContent += '<p>By accessing the noted link you will be leaving Central Willamette Community Credit Union\'s website and entering a website hosted by another party.&nbsp;&nbsp;We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Central Willamette Community Credit Union\'s.</p><p>Do you wish to continue?</p>';
sbPartnerContent += '<div align="center" class="sblinks"><a ##SBLINK##>Continue</a>&nbsp;&nbsp;<a href="#" onclick="hideSpeedBump();return false;">Cancel</a></div></div>'; 

/////// end configuratin //////////////// 
/////// do not edit below this line /////

addEvent(window, "load", makeSpeedBumps);

var XHTMLNS = "http://www.w3.org/1999/xhtml";
var CURRENT_SPEEDBUMP;
var hiddenElements = new Array();

function makeSpeedBumps(){
	if (!document.createElement || !document.getElementsByTagName){if(debug)alert("No createElement or getElementsByTagName.");return;}
	// add namespace methods to HTML DOM; this makes the script work in both
	// HTML and XML contexts.
	if(!document.createElementNS){
	    document.createElementNS = function(ns,elt){
	        return document.createElement(elt);
	    }
	}
	// do our best to get the links[] array.
	if( !document.links){
	    document.links = document.getElementsByTagName("a");
	}
	if(document.links){
		if(debug)var out = "Links to which SBs will be attached:\n------------------------------------------\n";
		if(debug)var out2 = "\nLinks to which SBs will NOT be attached:\n------------------------------------------\n";
		// test every link
		for(i=0;i<document.links.length;i++){
//			var isTPL = true;
			var lnk = document.links[i];
			if(lnk.href){
				// test every allowedDomain against every link with an href attrib.
				/*for(j=0;j<allowedDomains.length;j++){
					// if we get a hit, call it not a TPL and stop the loop
					if(lnk.href.toLowerCase().indexOf("http") != 0 || lnk.href.indexOf(allowedDomains[j]) > -1){
						if(debug)out2 += "-> " + lnk.href + "\n";
						isTPL = false;
						break;
					}
				}*/
				// if it didn't match any allowedDomains, add the SB stuff
				if(isTPL(lnk.href,allowedDomains)){
					if(debug)out += "-> " + lnk.href + "\n";
					lnk.setAttribute("speedbump",lnk.href);
					lnk.setAttribute("href","javascript:void(0);");
		            addEvent(lnk,"click",showSpeedBump);
		            addEvent(lnk,"mouseover",fakeStatus);
		            addEvent(lnk,"mouseout",clearStatus);
				}
			}
		}
		if(debug)alert(out+out2);
	}
}

function showSpeedBump(e) {
	hideSpeedBump();
	if(lnk = getLnkObj(e)){
	    lnkPos = findPosition(lnk);
	    lnkPosX = lnkPos[0];
	    lnkPosY = lnkPos[1];
		
		// create the DIV via the DOM
		var d = document.createElementNS(XHTMLNS,"div");
	    
		// add styles
		d.className = "speedbump";
		d.style.width = sbWidth + 'px';
		d.style.position = 'absolute';
		
		// calculate the left position. Either centered or relative to the link
	    if (sbCentered && document.body && document.body.offsetWidth) {
	    	var dLeft = ((document.body.offsetWidth - sbWidth)/2);
		}
		else{
			var dLeft = (lnkPosX+sbXOffset);
			if(debug)alert(lnkPosX+' + '+sbXOffset);
		    if (document.body && document.body.offsetWidth && ((dLeft+sbWidth) > document.body.offsetWidth)) {
		        dLeft = (document.body.offsetWidth - sbWidth - sbXOffset);
				if(debug)alert(document.body.offsetWidth+' - '+sbWidth+' - '+sbXOffset);
		    }
			else if(dLeft < 1){
				dLeft = -sbXOffset;
			}
		}
		d.style.left = dLeft + 'px';
		
		// add the sbContent
		var reSBLink = /##SBLINK##/g;
		var sbHREF = lnk.getAttribute("speedbump");
		var sbATag = openInNewWindow ? 'href="#" onclick="window.open(\'' + sbHREF + '\');hideSpeedBump();return false;"' : 'href="' + sbHREF + '" onclick="document.location.href=this.href;hideSpeedBump();return false;"';
		d.innerHTML = (isPartner(sbHREF,partnerDomains)?sbPartnerContent:sbContent).replace(reSBLink,sbATag);
		
		// hide elements that will show over the speedbump
		hideTroubleElements(true);
		
		// append the DIV to the body of the document
	    document.getElementsByTagName("body")[0].appendChild(d);
				
		// calculate the top position of the div by getting its height after the sbContent is in
		if(d.offsetHeight){
			// if we can get the height of the div, then use it
			var sbHeight = d.offsetHeight;
		}
		else{
			// otherwise, we'll guess that they'll be 250px high on average
			var sbHeight = 250;
		}
		var dTop = lnkPosY - sbHeight + sbYOffset;
		if(dTop < 1){
			dTop = lnkPosY - sbYOffset;
		}
		d.style.top = dTop + 'px';
				    
		// scroll the window such that the top of the SB is sbYOffset from the top of the window
		window.scrollTo(0,dTop + sbYOffset);
		
		CURRENT_SPEEDBUMP = d;
	}
	return false;
}

function showDHTMLSB(uri){
	hideSpeedBump();
	
	// create the DIV via the DOM
	var d = document.createElementNS(XHTMLNS,"div");
    
	// add styles
	d.className = "speedbump";
	d.style.width = sbWidth + 'px';
	d.style.position = 'absolute';
	
	// calculate the left position. Either centered or relative to the link
   	var dLeft = ((document.body.offsetWidth - sbWidth)/2);
	d.style.left = dLeft + 'px';
	
	// add the sbContent
	var reSBLink = /##SBLINK##/g;
	var sbHREF = uri;
	var sbATag = openInNewWindow ? 'href="#" onclick="window.open(\'' + sbHREF + '\');hideSpeedBump();return false;"' : 'href="' + sbHREF + '" onclick="document.location.href=this.href;hideSpeedBump();return false;"';
	d.innerHTML = (isPartner(sbHREF,partnerDomains)?sbPartnerContent:sbContent).replace(reSBLink,sbATag);
	
	// hide elements that will show over the speedbump
	hideTroubleElements(true);
	
	// append the DIV to the body of the document
    document.getElementsByTagName("body")[0].appendChild(d);
			
	var dTop = dhtmlTop;
	d.style.top = dTop + 'px';
			    
	// scroll the window such that the top of the SB is sbYOffset from the top of the window
	window.scrollTo(0,dTop + sbYOffset);
	
	CURRENT_SPEEDBUMP = d;
}

function hideSpeedBump() {
    if (!document.getElementsByTagName) return;
    if (CURRENT_SPEEDBUMP) {
        document.getElementsByTagName("body")[0].removeChild(CURRENT_SPEEDBUMP);
        CURRENT_SPEEDBUMP = null;
    }
	hideTroubleElements(false);
}

function isTPL(needle,haystack){
    needle = needle.toLowerCase();
    for(n=0;n<haystack.length;n++){
        if(needle.indexOf("http") != 0 || needle.indexOf(haystack[n]) > -1){
            if(debug)out2 += "-> " + needle + "\n";
            return false;
        }
    }
    return true;
}

function isPartner(needle,haystack){
    needle = needle.toLowerCase();
    for(i=0;i<haystack.length;i++){
        if(needle.indexOf(haystack[i]) > -1)
            return true;
    }
    return false;
}

function hideTroubleElements(doHide){
	if(document.getElementById){
		if(obj = document.getElementById('cmdemo')){
			if(doHide){
				obj.style.visibility = 'hidden';
			}
			else{
				obj.style.visibility = 'visible';
			}
		}
	}
}

function fakeStatus(e){
	if(lnk = getLnkObj(e)){
	//	alert("Link to: "+lnk.getAttribute("speedbump"));
	    window.status = lnk.getAttribute("speedbump");
		return true;
	}
	else{
	    window.status = 'Third Party Website';
		return true;
	}
}

function clearStatus(e){
	window.status = '';
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}

function getLnkObj(e){
	if(!document.getElementsByTagName) return false;
	if(window.event && window.event.srcElement) {
		lnk = window.event.srcElement
	}
	else if(e && e.target){
		lnk = e.target;
	}
	if(!lnk) return false;
	if(lnk.nodeName.toUpperCase() != "A") {
		// lnk is a textnode -- ascend parents until we hit a link
		lnk = getParent(lnk,"A");
	}
	if(!lnk) return false;	
	return lnk;
}

function findPosition( oLink ) {
	if( oLink.offsetParent ) {
		for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
		}
		return [ posX, posY ];
	} else {
		return [ oLink.x, oLink.y ];
	}
}

// Add an eventListener to browsers that can do it somehow.
// Originally by the amazing Scott Andrew.
function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, true);
//		if(debug)alert("obj.addEventListener worked");
		return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
//		if(debug)alert("obj.attachEvent worked");
		return r;
	}
	else if (document.getElementById){
		// feeble attempt to get this to work in IE for Mac
//		if(debug)alert("obj.on"+evType+"=fn worked");
		eval("obj.on"+evType+"=fn");
	}
	else{
		if(debug)alert("addEvent won't work");
		return false;
	}
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}

function navIframe(){
    if(!document.getElementById)return;
    url = document.location.href;
    formName = url.match(/form=([^&]+)/);
    if(!formName || !formName[1]){
        alert("You must use a link on the\nsite to get to this page");
        document.location.replace("/home/home");
        return;
    }
    else
        fName = formName[1];
    fHeight = url.match(/h=([^&]+)/);
    fHeight = (fHeight && fHeight[1] ? fHeight[1] : 2300) + "px";
    
    objFrame = document.createElement('iframe');
	objFrame.frameBorder = 0;
	objFrame.style.border = 'none';
	objFrame.style.width = "100%";
    objFrame.style.height = fHeight;
    objFrame.src = "https://www.centralwcu.org/Forms/OnlineForm.cgi?form="+fName;
//    objFrame.src = "https://skynet.diginsite.com/staging/centralwcu/centralwcudocs/Forms/OnlineForm.cgi?form="+formName;
	document.getElementById('iframeContainer').appendChild(objFrame);
}

function navContactIFrame(){
    if(!document.getElementById)return;
    url = document.location.href;
    formName = url.match(/type=([^#&]+)/);
    if(!formName || !formName[1]){
        fName = 'email';
    }
    else
        fName = formName[1];
    
    objFrame = document.getElementById("formFrame");
    objFrame.src = "https://www.centralwcu.org/Forms/OnlineForm.cgi?form=contact&type="+fName;
//    objFrame.src = "https://skynet.diginsite.com/staging/centralwcu/centralwcudocs/Forms/OnlineForm.cgi?form=contact&type="+fName;
}

function addTableColors(){
    if(!document.getElementsByTagName)return;
    oRows = document.getElementsByTagName('tr');
    for(i=0;i<oRows.length;i++){
        oRows[i].className = "row"+(i%2);
    }
}
//end of file
