

//window.onerror = function(){ return true; }

function target_blank(url){
    tmp = window.open(url);
    tmp = null;
}

function makeNavImage(name,width,height){
this.name_on="nav-" + name +"-on.gif";
this.name_off="nav-" + name +"-off.gif";
this.width=width;
this.height=height;
this.newimage_on = new Image(width,height);
this.newimage_on.src = dir + '//Cobrander/CapeCodFive/Custom/' + this.name_on;
this.newimage_off = new Image(width,height);
this.newimage_off.src = dir + '//Cobrander/CapeCodFive/Custom/' + this.name_off;
}

function img_act(imgName){
document[imgName].src =  navitems[imgName].newimage_on.src;
}

function img_inact(imgName){
window.status = "";
document[imgName].src =  navitems[imgName].newimage_off.src;
}


document.write('<img src="'+dir+'//Cobrander/CapeCodFive/Custom/wcscreenrez.gif?width='+screen.width+'&height='+screen.height+'" width="1" height="1">'); 

// for backpage snippet SD rotate on refresh
function FeaturePromo(url,img,words){
	this.url = url;
	this.img = img;
	this.text = words;
	this.html = [];
	this.getHTML = function(isFirst){
		this.isFirst = isFirst || false;
		this.html[this.html.length] = '<div onclick="'+ (this.url.indexOf('http')!=0?'document.location.href=\'?pageLabel=':'showWarning(\'') + this.url +'\''+ (this.url.indexOf('http')!=0?'':')')+'" class="feature" style="'+(isFirst?'margin-left:0;':'')+'cursor:pointer;">';
		this.html[this.html.length]='<div><img src="//Cobrander/CapeCodFive/Custom/ftr_top_'+ this.img +'.gif" width="169" height="43" border="0" alt="" /></div>';
		this.html[this.html.length]='<div class="featureText"><p><img src="/Cobrander/CapeCodFive/Custom/ftr_img_'+ this.img +'.gif" width="141" height="66" border="0" alt="" /><br />'+ this.text +'</p></div>';
		this.html[this.html.length]='<div><img src="/Cobrander/CapeCodFive/Custom/ftr_bottom.gif" width="169" height="23" border="0" alt="Learn more" /></div></div>';
		return this.html.join('');
	}
}


function BackHistory(url,img,alt){
	this.url = url;
	this.img = img;
	this.alt = alt;
	this.getHTML = function(){
		return '<a href="javascript:wcInternalPopup(\'fiFiles/static/documents/'+this.url+'\',550,700)" onmouseover="showElement(\'back_history_info\')" onmouseout="hideElement(\'back_history_info\')"><img src="/Cobrander/CapeCodFive/Custom/'+this.img+'" /></a>';
	}
}

function hideElement(eId){
	document.getElementById(eId).style.visibility='hidden';
}

function showElement(eId){
	document.getElementById(eId).style.visibility='visible';
}

function getHomeFeaturesHTML(numToGet,homeFeatures){
    var featNums = [];
    while(numToGet > featNums.length){
        testNum = Math.floor(Math.random()*homeFeatures.length);
        if(!featNums.contains(testNum))
            featNums[featNums.length]=testNum;
    }
    var allFeatures=[];
    for(i=0;featNums.length > i; i++){
        allFeatures[allFeatures.length]=homeFeatures[featNums[i]].getHTML(i==0?true:false)
    }
	return allFeatures.join('');
}

function getHomeFeaturesHTML2(numToGet,homeFeatures){
    var featNums = [];
    var cnt=0;
    while(numToGet > featNums.length){
        testNum = cnt;
        cnt++;
        if(!featNums.contains(testNum))
            featNums[featNums.length]=testNum;
    }
    var allFeatures=[];
    for(i=0;featNums.length > i; i++){
        allFeatures[allFeatures.length]=homeFeatures[featNums[i]].getHTML(i==0?true:false)
    }
	return allFeatures.join('');
}

Array.prototype.contains = function(value){
	for(var i=0;i<this.length;i++){
		if(this[i] === value)return true;
	}
	return false;
}


//##################################




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('fiFiles/static/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 msgHead = '<div class="logoWarn" align="center"><img src="/Cobrander/CapeCodFive/Custom/logo_capecod5.gif" width="112" height="61" alt="Cape Cod 5" border="0" /></div>';
	var messages = new Array(6);
	messages[0] = '<h2 style="text-align:center">Third Party Site Disclaimer</h1><p>The Cape Cod Five Cents Savings Bank provides links to other Web sites for convenience and informational purposes only. Users should be aware that when they select this link to an external Web site, they are leaving the Bank\'s Web site. Cape Cod Five is not responsible for the contents of any linked site or the contents of any link contained in a linked site. The inclusion of a link does not imply endorsement by the Bank or the site, its content, advertisers or sponsors.</p>';
	
	messages[1] = messages[0];
	
	messages[2] = messages[0];
	
	messages[3] = messages[0];
	
	messages[4] = messages[0];
	
	messages[5] = '<h2 style="text-align:center">Email Security Disclaimer</h2><p><strong>IMPORTANT:</strong> Please do not use this e-mail for communicating sensitive personal information like account numbers or social security numbers.</p>';

	var content = new Array();
	var index = 0;
	content[index++] = msgHead;
	content[index++] = messages[msg];
	content[index++] = '<p align="center"><a href="'+lk+'" target="'+target+'" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'">Yes, please continue &gt;&gt;</a>&#160;&#160;<a href="javascript:void(\'0\');" onclick="document.getElementById(\'ex_dis\').style.display = \'none\'">Cancel</a></p></div>';	
	document.getElementById("ex_dis").innerHTML = content.join("");
	document.getElementById("ex_dis").style.display = "block";
	scrollTo(0,0);
}

/*
function showWarning(URL)
{
	document.location.href = "?pageLabel=thirdparty&amp;newUrl="+URL;
}	
*/
function getUrl(){
	var url = document.location.href;
	var urlstart = url.indexOf("newUrl=") + 7;
	var urlToReturn = url.substring(urlstart);
	return urlToReturn;
}

function goToLocation(fieldId){
	if(!document.getElementById)return;
	var obj=document.getElementById(fieldId);
	var formValue=obj.options[obj.selectedIndex].value;
		
	if (formValue.length > 0){
		if(/^http/.test(formValue)){
			window.open(formValue);
		}
		else{
			document.location.href = formValue;
		}
	} else {
		alert("Please select your destination.");
	}
}

//end of file