﻿function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

// Notify function
function notify(url)
{
	agree=confirm("You have requested a link to the website of a third-party and, if you elect to continue, will be leaving the Cannon Federal Credit Union website. PLEASE NOTE that while visiting and using the third-party website, you will be subject to the third-party's own separate disclosures, privacy policy, security policy, website, and other terms and conditions. Said website is controlled and administered solely by the third-party. \n\nIf you click \"OK\", an external website that is owned and operated by a third-party will be opened \nin a new browser window. \n\nIf you click \"CANCEL\" you will be returned to our website.");
	if (agree){x=window.open(url);}
}

// Clear text function

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 
//Document Text Resizer script (May 14th, 08'): By JavaScript Kit: http://www.javascriptkit.com

var documenttextsizer={

prevcontrol: '', //remember last control clicked on/ selected
existingclasses: '',

setpageclass:function(control, newclass){
	if (this.prevcontrol!='')
			this.css(this.prevcontrol, 'selectedtoggler', 'remove') //de-select previous control, by removing 'selectedtoggler' from it
	document.documentElement.className=this.existingclasses+' '+newclass //apply new class to document
	this.css(control, 'selectedtoggler', 'add') //select current control
	this.setCookie('pagesetting', newclass, 5) //remember new class added to document for 5 days
	this.prevcontrol=control
},

css:function(el, targetclass, action){
	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
	if (action=="check")
		return needle.test(el.className)
	else if (action=="remove")
		el.className=el.className.replace(needle, "")
	else if (action=="add")
		el.className+=" "+targetclass
},

getCookie:function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return null
},

setCookie:function(name, value, days){
	if (typeof days!="undefined"){ //if set persistent cookie
		var expireDate = new Date()
		var expstring=expireDate.setDate(expireDate.getDate()+days)
		document.cookie = name+"="+value+"; path=/; expires="+expireDate.toGMTString()
	}
	else //else if this is a session only cookie
		document.cookie = name+"="+value
},

setup:function(targetclass){
	this.existingclasses=document.documentElement.className //store existing CSS classes on HTML element, if any
	var persistedsetting=this.getCookie('pagesetting')
	var alllinks=document.getElementsByTagName("a")
	for (var i=0; i<alllinks.length; i++){
		if (this.css(alllinks[i], targetclass, "check")){
			if (alllinks[i].getAttribute("rel")==persistedsetting) //if this control's rel attribute matches persisted doc CSS class name
				this.setpageclass(alllinks[i], alllinks[i].getAttribute("rel")) //apply persisted class to document
			alllinks[i].onclick=function(){
				documenttextsizer.setpageclass(this, this.getAttribute("rel"))
				return false
			}
		}
	}
}

}