﻿// JavaScript Document
// pageutils.js
//
// * Page Utilities * 
// * - Insert page tools if appropriate * 
// * - Clean up breadcrumb trail, insert Home link * 

/* Add alternate stylesheets */
document.write('<l'+'ink rel="alternate stylesheet" href="/file-154709.css" type="text/css" media="screen,print" title="large" /'+'>');
document.write('<l'+'ink rel="alternate stylesheet" href="/file-154710.css" type="text/css" media="screen,print" title="largest" /'+'>');

/* Add onload events */
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}
if (typeof(CMS_onload)!="function" || navigator.userAgent.toLowerCase().indexOf("firefox")!=-1){
	addLoadEvent(function() {
		cleanCrumbs();
	})
	addLoadEvent(function() {
		setPageBanner();
	})
	addLoadEvent(function() {
		insertPageTools();
	})
	addLoadEvent(function() {
		preloadimgsrc();				  
	})
	addLoadEvent(function() {
		openCloseDiv();
	})
	addLoadEvent(function() {
		tabContent();
	})
	addLoadEvent(function() {
		P7_equalCols2(0,'cms-left-2-column','DIV','cms-center-2-column-left','DIV','cms-right-2-column','DIV','cms-center-2-column-right','DIV','cms-left-3-column','DIV','cms-center-3-column','DIV','cms-right-3-column','DIV','center-column','DIV','right-column','DIV');				
	})
}

function CMS_init(){
	cleanCrumbs();
	setPageBanner();
	insertPageTools();
	preloadimgsrc();
	openCloseDiv();
	tabContent();
	P7_equalCols2(0,'cms-left-2-column','DIV','cms-center-2-column-left','DIV','cms-right-2-column','DIV','cms-center-2-column-right','DIV','cms-left-3-column','DIV','cms-center-3-column','DIV','cms-right-3-column','DIV','center-column','DIV','right-column','DIV');				
}



/* Clean up breadcrumbs */
function cleanCrumbs() 
{
	if (findObj("cms-page-breadcrumb")!=null) {
		if (CMS_PageTitle=="Home") {
			setInnerHTML('cms-page-breadcrumb', '');
		} else {
			var origCrumb = getInnerHTML('cms-page-breadcrumb');
			if (origCrumb!=undefined) {
				if (origCrumb.indexOf("cid-292193")==-1) {
					var homeCrumb = '<a class="CMS_Breadcrumbs" href="//www.rbcbankusa.com/cid-292193.html">Home</a><span class="CMS_Breadcrumb_Delimiter"><span class="CMS_Breadcrumb_Delimiter_Txt"> &gt; </span></span>';
					setInnerHTML('cms-page-breadcrumb', homeCrumb+origCrumb);
				}
			}
		}
	}
}
/* Insert page tools */
function insertPageTools() 
{
	if (findObj("cms-content-pagetools")!=null) {
		var divPageTools = '<div class="page-tools"><div class="float-left"><a onclick="setActiveStyleSheet(\'normal\'); return false;" href="#"><img id="size-normal" height="16" alt="Set Text Size to Normal" src="/file-152181.gif" width="18" border="0" name="size-normal" /></a><a onclick="setActiveStyleSheet(\'large\'); return false;" href="#"><img id="size-large" height="16" alt="Set Text Size to Large" src="/file-152176.gif" width="21" border="0" name="size-large" /></a><a onclick="setActiveStyleSheet(\'largest\'); return false;" href="#"><img id="size-largest" height="16" alt="Set Text Size to Largest" src="/file-152178.gif" width="18" border="0" name="size-largest" /></a><br /><img height="10" alt="Change Text Size" src="/file-152174.gif" width="68" border="0" /></div><div class="float-left" id="page-tools-right"><a href="javascript:emailLink();"><img height="13" alt="Email a Friend" src="/file-152172.gif" width="81" border="0" /></a><br /><a href="javascript:printPreview();"><img height="13" alt="Print this Page" src="/file-152173.gif" width="81" border="0" /></a></div></div>';
		setInnerHTML('cms-content-pagetools', divPageTools);
	}
}

/* Change stylesheet */
function setActiveStyleSheet(title)
{
	var i, a, p, main; 
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true; 
			if(a.getAttribute("title") == title) a.disabled = false;
			p = findObj("size-"+title);
			switch (title) {
				case "normal": 
					findObj("size-normal").src = "/file-152181.gif";
					findObj("size-large").src = "/file-152176.gif";
					findObj("size-largest").src = "/file-152178.gif";
					break;
				case "large": 
					findObj("size-normal").src = "/file-152180.gif";
					findObj("size-large").src = "/file-152177.gif";
					findObj("size-largest").src = "/file-152178.gif";
					break;
				case "largest": 
					findObj("size-normal").src = "/file-152180.gif";
					findObj("size-large").src = "/file-152176.gif";
					findObj("size-largest").src = "/file-152179.gif";
					break;
			}
		} 
	}
} 

/* Replace the innerHTML of an object */
function setInnerHTML(objName, newStr)
{
  obj = findObj(objName);
  if (obj.innerHTML)
  {
    obj.innerHTML = newStr;
  }
}

function getInnerHTML(objName)
{
  obj = findObj(objName);
  if (obj.innerHTML)
  {
    return obj.innerHTML;
  }
}

/* Content swap */

function tabContent(){
	if (findObj("tab-list")!=null) {
		var tabs=new ddtabcontent("tab-list")
		tabs.setpersist(false)
		tabs.setselectedClassTarget("linkparent") //"link" or "linkparent"
		tabs.init()
	}
}

//** Tab Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Updated Oct 7th, 07 to version 2.0. Contains numerous improvements:
//   -Added Auto Mode: Script auto rotates the tabs based on an interval, until a tab is explicitly selected
//   -Ability to expand/contract arbitrary DIVs on the page as the tabbed content is expanded/ contracted
//   -Ability to dynamically select a tab either based on its position within its peers, or its ID attribute (give the target tab one 1st)
//   -Ability to set where the CSS classname "selected" get assigned- either to the target tab's link ("A"), or its parent container

//** Updated Feb 18th, 08 to version 2.1: Adds a "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically

////NO NEED TO EDIT BELOW////////////////////////

function ddtabcontent(tabinterfaceid){
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
	this.enabletabpersistence=true
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
	this.subcontentids=[] //Array to store ids of the sub contents ("rel" attr values)
	this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
}

ddtabcontent.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 ""
}

ddtabcontent.setCookie=function(name, value){
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
}

ddtabcontent.prototype={

	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
		this.cancelautorun() //stop auto cycling of tabs (if running)
		var tabref=""
		try{
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=document.getElementById(tabid_or_position)
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
				tabref=this.tabs[tabid_or_position]
		}
		catch(err){alert("Invalid Tab ID or position entered!")}
		if (tabref!="") //if a valid tab is found based on function parameter
			this.expandtab(tabref) //expand this tab
	},

	cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
		if (dir=="next"){
			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
		}
		else if (dir=="prev"){
			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
		}
		if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
			this.cancelautorun() //stop auto cycling of tabs (if running)
		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
	},

	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
			this.enabletabpersistence=bool
	},

	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
		this.selectedClassTarget=objstr || "link"
	},

	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
	},

	expandtab:function(tabref){
		var subcontentid=tabref.getAttribute("rel") //Get id of subcontent to expand
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easily search through
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
		this.expandsubcontent(subcontentid)
		this.expandrevcontent(associatedrevids)
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : ""
		}
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
			ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition)
		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
	},

	expandsubcontent:function(subcontentid){
		for (var i=0; i<this.subcontentids.length; i++){
			var subcontent=document.getElementById(this.subcontentids[i]) //cache current subcontent obj (in for loop)
			subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none" //"show" or hide sub content based on matching id attr value
		}
		// 23Mar08 *FIX* - match column heights with variable tab content - JM
		if ((findObj("cms-right-2-column")!=null)&&(findObj("cms-center-2-column-right")!=null)) {
			document.getElementById("cms-right-2-column").style.height=document.getElementById("cms-center-2-column-right").clientHeight+"px";
		}
	},

	expandrevcontent:function(associatedrevids){
		var allrevids=this.revcontentids
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
		}
	},

	setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
		for (var i=0; i<this.hottabspositions.length; i++){
			if (tabposition==this.hottabspositions[i]){
				this.currentTabIndex=i
				break
			}
		}
	},

	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
		this.cycleit('next', true)
	},

	cancelautorun:function(){
		if (typeof this.autoruntimer!="undefined")
			clearInterval(this.autoruntimer)
	},

	init:function(automodeperiod){
		var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
		var persisterror=true //Bool variable to check whether persisted tab position is valid (can become invalid if user has modified tab structure)
		this.automodeperiod=automodeperiod || 0
		for (var i=0; i<this.tabs.length; i++){
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
			if (this.tabs[i].getAttribute("rel")){
				var tabinstance=this
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
				this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel") //store id of sub content ("rel" attr value)
				this.tabs[i].onclick=function(){
					tabinstance.expandtab(this)
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
					return false
				}
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
				}
				if (this.enabletabpersistence && parseInt(persistedtab)==i || !this.enabletabpersistence && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
					this.expandtab(this.tabs[i]) //expand current tab if it's the persisted tab, or if persist=off, carries the "selected" CSS class
					persisterror=false //Persisted tab (if applicable) was found, so set "persisterror" to false
				}
			}
		} //END for loop
		if (persisterror) //if an error has occured while trying to retrieve persisted tab (based on its position within its peers)
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
		}
	} //END int() function

} //END Prototype assignment

/* Find an object in the DOM by id */
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
} 

/* Jump pages open code */
var CMS_JumpPageUrl = "";
function navigateToJumpPage(jumpType, destURL) 
{
	var sCorpURL = "/jump/cid-101457.html";
	var sAffiliateURL = "/jump/cid-101461.html";
	var sNonAffiliateURL = "/jump/cid-101462.html";
	CMS_JumpPageUrl = destURL;
	var sArgs = "location=yes,toolbar=yes,menubar=yes,scrollbars=yes,status=yes,resizable=yes";
	switch (jumpType) {
		case "corporate": 
			openWindow(sCorpURL,"",sArgs);
			break;	
		case "affiliate": 
			openWindow(sAffiliateURL,"",sArgs);
			break;
		case "non-affiliate": 
			openWindow(sNonAffiliateURL,"",sArgs);
			break;
	}
}

var CMS_ContactCode = "general";
function openContactWindow(sCode)
{
	if (sCode!=null) {
		CMS_ContactCode = sCode;
	}
	openPopWindow("/misc/cid-101619.html");
}

function openPopWindow(sURL, iSize) 
{
	// default to most common size
	var sWidth = "624";
	switch (iSize) {
		case 1: 
			sWidth = "424";
			break;	
		case 3: 
			sWidth = "824";
			break;
	}
	var sArgs = "location=no,toolbar=no,menubar=no,scrollbars=yes,status=no,width="+sWidth+",height=720,resizable=no";
	openWindow(sURL,"",sArgs);
}

function openLocationWindow ()
{
 window.location.href = "http://maps.rbc.com/bankusa/form.asp";pageTracker._trackPageview("/locator"); 
}

function openSubscribeWindow ()
{
	openPopWindow("http://app.bronto.com/public/actionpage/execute_page/?fn=Mail_ActionPage_FormResponse&pid=1we61869878pdk2mq0pkbskydeq4h&page_type=addcontact&ssid=7952");
}

/* Common open window code */
function openWindow(sURL, sName, sArgs) 
{
	if (window)
	{
		if (sName=="") { sName="RBCBank"; };
		if (sArgs!="") 
		{
			if (sURL!="") {window.open(sURL,sName,sArgs)};
		} else {
			if (sURL!="") {window.open(sURL,sName)};
		}
	}
}

/* My Accounts scripts */
function navigateToAccount() 
{
	if (document.accountsform) 
	{
		switch (document.accountsform.accountlist.value) 
		{
			case "0":
				var sURL = "https://www1.rbcbankusa.com/cgi-bin/rbaccess/rbunxcgi?F6=1&F7=NS&F21=IB&F22=CN&REQUEST=CenturaClientSignin&LANGUAGE=ENGLISH";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/OLB");
				break;
			case "1":
				var sURL = "https://www.rbccentura.web-access.com/rbcc";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/webaccess");
				break;
			case "2":
				var sURL = "https://www.rbccentura.web-cashplus.com/Cashplus/";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/treasuryconnect");
				break;
			case "3":
				var sURL = "https://www.rbcbankusaredemption.com";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/rbcrewards");
				break;
			case "5":
				var sURL = "https://carenet.fnfismd.com/centura/ACCLogin.jsp";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/mortgage");
				break;
			case "6":
				var sURL = "https://www.rbcremotedeposit.blilk.com";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/remotedeposit");
				break;
			case "7":
				// currently not using this option
				var sURL = "https://rbccenturalockbox.vimagetech.com";
				document.location.href=sURL;
								break;
			case "8":
				var sURL = "https://rbcbank.symcor.com/wholesalelockbox/nq/admin/SSOIndex.asp";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/lockboxnetquery");
				break;
			case "9":
				var sURL = "https://www.rbcbankusalockbox.com";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/ARadvantage");
				break;
			case "10":
				var sURL = "http://dsclient.rbcds.com/fxdirect/index.cfm";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/FXDirect");
				break;
			case "11":
				var sURL = "https://webconnect.centura.com/cmwao/html/main.htm";
				document.location.href=sURL;
				break;
			case "12":
				var sURL = "https://webft.rbc.com";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/NetworkGateway");
				break;
			case "13":
				var sURL = "http://www.fabinvest.ficastdata.net";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/ALReporting");
				break;
			case "14":
				var sURL = "https://portal.sungardsn.com/i185";
				document.location.href=sURL;
				break;
			case "15":
				var sURL = "javascript:navigateToJumpPage('non-affiliate','https://www.renasantbank.com/welcome_RAM.htm')";
				document.location.href=sURL;
				pageTracker._trackPageview("/login/trustinquiry");
				break;
		}
	}
}

/* BEGIN - Print preview/Email link utils */
//
/* General */
	var _siteName = "RBC Bank";
	var _siteUrl = "www.rbcbankusa.com";

/* Buttons */

	var _labelPrint = "Print";
	var _labelClose = "Close";

/*  URLs */

	var _urlEmail = "cid-96667.preview";

/*  Email subjects */

	var _subjectContact = "RBC Bank - Contact Us";

/* Form validation */

	var _fieldReqTo = "The 'To' field is required.";
	var _fieldReqFrom = "The 'From' field is required.";
	var _fieldInvalidEmail = "Please enter a valid email address.";
	var _fieldInvalidComments = "Please enter a maximum of 200 characters.";
	var _formCommentsSent = "Your comments have been sent.";
//

var CMS_PageUrl =  document.location.href;

function printPreview(){
	/* Build up html doc to contain cms-page-body  */
	var doc = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
	doc += '<html xmlns="http://www.w3.org/1999/xhtml"><head>';
	doc += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
	doc += '<meta http-equiv="Content-Language" content="en-us" />';
	doc += '<link rel="stylesheet" href="/file-156198.css" name="default" type="text/css" media="all" charset="utf-8" />';
	doc += '<link rel="stylesheet" href="/file-156196.css" name="content" type="text/css" media="all" charset="utf-8" />';
	doc += '<link rel="stylesheet" href="/file-154910.css" name="preview" type="text/css" media="all" charset="utf-8" />';
	doc += '<link rel="stylesheet" href="/file-154909.css" name="print" type="text/css" media="print" charset="utf-8" />';
	doc += "<title>" + document.title + "</title>";
	doc += "</head><body><div id='cms-print-bar'><a href='javascript:window.print();'><b>" + 
		_labelPrint + "</b></a>&nbsp;|&nbsp;<a href='javascript:window.close();'>" + _labelClose + "</a></div>";
	doc += "<div id='cms-print-content'>";
	if (findObj("popup-content")==null) {
		if (findObj("cms-page-header")!=null) {
			doc += findObj("cms-page-header").innerHTML;
		}
		if (findObj("cms-page-body-content")!=null) {
			doc += findObj("cms-page-body-content").innerHTML;
		}
		if (findObj("cms-page-footer")!=null) {
			doc += findObj("cms-page-footer").innerHTML;
		}
	} else {
		if (findObj("cms-page-body")!=null) {
			doc += findObj("cms-page-body").innerHTML;
		}
	}
	doc += '</div></body></html>';
	var w = window.open("", "PrintWindow", "location=no,toolbar=no,menubar=no,scrollbars=yes,status=no,width=800,height=550,resizable=no");
	w.document.write(doc);
	w.document.close();
	w.focus();
}

function suggest()
{
	document.location = "mailto:" + _editorEmail + "?subject=" + _subjectSuggest;
}

function contact()
{
	document.location = "mailto:" + _editorEmail + "?subject=" + _subjectContact;
}

function emailLink()
{
	var qs = document.location.href;
	openPopWindow("/misc/cid-101556.html?CURL=" + qs);
}


/* Email Form */

function parseEmail() {
	var email = document.forms[0].Recipient1.value;
	if(email.length < 6 || email.match(/(\.\.|\.@|@\.)/))
		return false;
	var index = email.indexOf('@');
	if(index == -1 || !email.substring(0, index).match(/^[\w\.-]+$/))
		return false;
	email = email.substring(index + 1, email.length);
	index = email.lastIndexOf('.');
	if(email.length < 4 || index == -1 || !email.substring(0, index).match(/^[\w\.-]+$/))
		return false;
	email = email.substring(index + 1, email.length);
	if(!email.substring(0, email.length).match(/^[a-zA-Z]{2,6}$/))
		return false;
	return true;
}

function validateEmail() {
	if(document.forms[0].Recipient1.value == "")
	{
		alert(_fieldReqTo);
		document.forms[0].Recipient1.focus();
		return false;
	}
	else if(!parseEmail())
	{
		alert(_fieldInvalidEmail);
		document.forms[0].Recipient1.focus();
		return false;
	}
	else if(document.forms[0].Sender.value == "")
	{
		alert(_fieldReqFrom);
		document.forms[0].Sender.focus();
		return false;
	}
	
	return true;
}

function validateComments()
{
	if(document.forms[0].Comments.value.length > 200)
	{
		alert(_fieldInvalidComments);
		document.forms[0].Recipient1.focus();
		return false;		
	}
	return true;
}

function submitForm()
{
	if(validateComments() && validateEmail())
	{
		document.forms[0].submit();
		alert(_formCommentsSent);
		window.close();
	}
}

/* END - Print preview/Email link utils */

/*Image rollover */
function imageholderclass(){
	this.over=new Array();
	this.down=new Array();
	this.src=new Array();
	this.store=store;
	
	function store(src, down, over){
		var AL=this.src.length;
		this.src[AL]=new Image(); this.src[AL].src=src;
		this.over[AL]=new Image(); this.over[AL].src=over;
		this.down[AL]=new Image(); this.down[AL].src=down;
	}
}

var ih = new imageholderclass();
var mouseisdown=0;

function preloader(t){
	for(i=0;i<t.length;i++){
		if(t[i].getAttribute('srcover')||t[i].getAttribute('srcdown')){
			
			storeimages(t[i]);
			var checker='';
			checker=(t[i].getAttribute('srcover'))?checker+'A':checker+'';
			checker=(t[i].getAttribute('srcdown'))?checker+'B':checker+'';
			
			switch(checker){
			case 'A' : mouseover(t[i]);mouseout(t[i]); break;
			case 'B' : mousedown(t[i]); mouseup2(t[i]); break;
			case 'AB' : mouseover(t[i]);mouseout(t[i]); mousedown(t[i]); mouseup(t[i]); break;
			default : return;			
			}
			
			if(t[i].src){t[i].setAttribute("oldsrc",t[i].src);}
		}
	}
}
function mouseup(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");this.oldmouseup();}
	}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");}}
	t.onmouseup=newmouseup;
}

function mouseup2(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");this.oldmouseup();}
		}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");}}
	t.onmouseup = newmouseup;
}

function mousedown(t){
	var newmousedown;
	if(t.onmousedown){
		t.oldmousedown=t.onmousedown;
		newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");this.oldmousedown();}}
	}
	else{newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");}}}
	t.onmousedown=newmousedown;
}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover){
		t.oldmouseover=t.onmouseover;
		newmouseover=function(){this.src=this.getAttribute("srcover");this.oldmouseover();}
	}
	else{newmouseover=function(){this.src=this.getAttribute("srcover");}}
	t.onmouseover=newmouseover;
}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout=function(){this.src=this.getAttribute("oldsrc");this.oldmouseout();}
	}
	else{newmouseout=function(){this.src=this.getAttribute("oldsrc");}}
	t.onmouseout=newmouseout;
}

function storeimages(t){
	var s=(t.getAttribute('src'))?t.getAttribute('src'):'';
	var d=(t.getAttribute('srcdown'))?t.getAttribute('srcdown'):'';
	var o=(t.getAttribute('srcover'))?t.getAttribute('srcover'):'';
	ih.store(s,d,o);
}
function preloadimgsrc(){
	if(!document.getElementById) return;
	var it=document.getElementsByTagName('IMG');
	var it2=document.getElementsByTagName('INPUT');
	preloader(it);
	preloader(it2);
}
/* END - Image rollover */

/* Open/Close div */

function switchcontent(className, filtertag){
	this.className=className
	this.collapsePrev=false //Default: Collapse previous content each time
	this.persistType="none" //Default: Disable persistence
	//Limit type of element to scan for on page for switch contents if 2nd function parameter is defined, for efficiency sake (ie: "div")
	this.filter_content_tag=(typeof filtertag!="undefined")? filtertag.toLowerCase() : ""
}

switchcontent.prototype.setStatus=function(openHTML, closeHTML){ //PUBLIC: Set open/ closing HTML indicator. Optional
	this.statusOpen=openHTML
	this.statusClosed=closeHTML
}

switchcontent.prototype.setColor=function(openColor, closeColor){ //PUBLIC: Set open/ closing color of switch header. Optional
	this.colorOpen=openColor
	this.colorClosed=closeColor
}

switchcontent.prototype.setPersist=function(bool, days){ //PUBLIC: Enable/ disable persistence. Default is false.
	if (bool==true){ //if enable persistence
		if (typeof days=="undefined") //if session only
			this.persistType="session"
		else{ //else if non session persistent
			this.persistType="days"
			this.persistDays=parseInt(days)
		}
	}
	else
		this.persistType="none"
}

switchcontent.prototype.collapsePrevious=function(bool){ //PUBLIC: Enable/ disable collapse previous content. Default is false.
	this.collapsePrev=bool
}


switchcontent.prototype.sweepToggle=function(setting){ //PUBLIC: Expand/ contract all contents method. (Values: "contract"|"expand")
	if (typeof this.headers!="undefined" && this.headers.length>0){ //if there are switch contents defined on the page
		for (var i=0; i<this.headers.length; i++){
			if (setting=="expand")
				this.expandcontent(this.headers[i]) //expand each content
			else if (setting=="contract")
				this.contractcontent(this.headers[i]) //contract each content
		}
	}
}


// -------------------------------------------------------------------
// PUBLIC: defaultExpanded(indices_of_contents)- Set contents that should be expanded by default when the page loads.
// Note that the persistence feature (if enabled) overrides this setting.
// Pass in the position of the contents relative to the rest of the contents ie: defaultExpanded(0,2,3) would expand the 1st, 3rd, and 4th contents by default
// -------------------------------------------------------------------

switchcontent.prototype.defaultExpanded=function(){
	var expandedindices=[] //Array to hold indices (position) of content to be expanded by default
	//Loop through function arguments, and store each one within array
	//Two test conditions: 1) End of Arguments array, or 2) If "collapsePrev" is enabled, only the first entered index (as only 1 content can be expanded at any time)
	for (var i=0; (!this.collapsePrev && i<arguments.length) || (this.collapsePrev && i==0); i++)
		expandedindices[expandedindices.length]=arguments[i]
	this.expandedindices=expandedindices.join(",") //convert array into a string of the format: "0,2,3" for later parsing by script
}


//PRIVATE: Sets color of switch header.

switchcontent.prototype.togglecolor=function(header, status){
	if (typeof this.colorOpen!="undefined")
		header.style.color=status
}


//PRIVATE: Sets status indicator HTML of switch header.

switchcontent.prototype.togglestatus=function(header, status){
	if (typeof this.statusOpen!="undefined")
		header.firstChild.innerHTML=status
}


//PRIVATE: Contracts a content based on its corresponding header entered

switchcontent.prototype.contractcontent=function(header){
	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content for this header
	innercontent.style.display="none"
	this.togglestatus(header, this.statusClosed)
	this.togglecolor(header, this.colorClosed)
}


//PRIVATE: Expands a content based on its corresponding header entered

switchcontent.prototype.expandcontent=function(header){
	var innercontent=document.getElementById(header.id.replace("-title", ""))
	innercontent.style.display="block"
	this.togglestatus(header, this.statusOpen)
	this.togglecolor(header, this.colorOpen)
}

// -------------------------------------------------------------------
// PRIVATE: toggledisplay(header)- Toggles between a content being expanded or contracted
// If "Collapse Previous" is enabled, contracts previous open content before expanding current
// -------------------------------------------------------------------

switchcontent.prototype.toggledisplay=function(header){
	var innercontent=document.getElementById(header.id.replace("-title", "")) //Reference content for this header
	if (innercontent.style.display=="block")
		this.contractcontent(header)
	else{
		this.expandcontent(header)
		if (this.collapsePrev && typeof this.prevHeader!="undefined" && this.prevHeader.id!=header.id) // If "Collapse Previous" is enabled and there's a previous open content
			this.contractcontent(this.prevHeader) //Contract that content first
	}
	if (this.collapsePrev)
		this.prevHeader=header //Set current expanded content as the next "Previous Content"
}


// -------------------------------------------------------------------
// PRIVATE: collectElementbyClass()- Searches and stores all switch contents (based on shared class name) and their headers in two arrays
// Each content should carry an unique ID, and for its header, an ID equal to "CONTENTID-TITLE"
// -------------------------------------------------------------------

switchcontent.prototype.collectElementbyClass=function(classname){ //Returns an array containing DIVs with specified classname
	var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element
	this.headers=[], this.innercontents=[]
	if (this.filter_content_tag!="") //If user defined limit type of element to scan for to a certain element (ie: "div" only)
		var allelements=document.getElementsByTagName(this.filter_content_tag)
	else //else, scan all elements on the page!
		var allelements=document.all? document.all : document.getElementsByTagName("*")
	for (var i=0; i<allelements.length; i++){
		if (typeof allelements[i].className=="string" && allelements[i].className.search(classnameRE)!=-1){
			if (document.getElementById(allelements[i].id+"-title")!=null){ //if header exists for this inner content
				this.headers[this.headers.length]=document.getElementById(allelements[i].id+"-title") //store reference to header intended for this inner content
				this.innercontents[this.innercontents.length]=allelements[i] //store reference to this inner content
			}
		}
	}
}


//PRIVATE: init()- Initializes Switch Content function (collapse contents by default unless exception is found)

switchcontent.prototype.init=function(){
	var instanceOf=this
	this.collectElementbyClass(this.className) //Get all headers and its corresponding content based on shared class name of contents
	if (this.headers.length==0) //If no headers are present (no contents to switch), just exit
		return
	//If admin has changed number of days to persist from current cookie records, reset persistence by deleting cookie
	if (this.persistType=="days" && (parseInt(switchcontent.getCookie(this.className+"_dtrack"))!=this.persistDays))
		switchcontent.setCookie(this.className+"_d", "", -1) //delete cookie
	// Get ids of open contents below. Four possible scenerios:
	// 1) Session only persistence is enabled AND corresponding cookie contains a non blank ("") string
	// 2) Regular (in days) persistence is enabled AND corresponding cookie contains a non blank ("") string
	// 3) If there are contents that should be enabled by default (even if persistence is enabled and this IS the first page load)
	// 4) Default to no contents should be expanded on page load ("" value)
	var opencontents_ids=(this.persistType=="session" && switchcontent.getCookie(this.className)!="")? ','+switchcontent.getCookie(this.className)+',' : (this.persistType=="days" && switchcontent.getCookie(this.className+"_d")!="")? ','+switchcontent.getCookie(this.className+"_d")+',' : (this.expandedindices)? ','+this.expandedindices+',' : ""
	for (var i=0; i<this.headers.length; i++){ //BEGIN FOR LOOP
		if (typeof this.statusOpen!="undefined") //If open/ closing HTML indicator is enabled/ set
			this.headers[i].innerHTML='<span class="status"></span>'+this.headers[i].innerHTML //Add a span element to original HTML to store indicator
		if (opencontents_ids.indexOf(','+i+',')!=-1){ //if index "i" exists within cookie string or default-enabled string (i=position of the content to expand)
			this.expandcontent(this.headers[i]) //Expand each content per stored indices (if ""Collapse Previous" is set, only one content)
			if (this.collapsePrev) //If "Collapse Previous" set
			this.prevHeader=this.headers[i]  //Indicate the expanded content's corresponding header as the last clicked on header (for logic purpose)
		}
		else //else if no indices found in stored string
			this.contractcontent(this.headers[i]) //Contract each content by default
		this.headers[i].onclick=function(){instanceOf.toggledisplay(this)}
	} //END FOR LOOP
	switchcontent.dotask(window, function(){instanceOf.rememberpluscleanup()}, "unload") //Call persistence method onunload
}


// -------------------------------------------------------------------
// PRIVATE: rememberpluscleanup()- Stores the indices of content that are expanded inside session only cookie
// If "Collapse Previous" is enabled, only 1st expanded content index is stored
// -------------------------------------------------------------------

//Function to store index of opened ULs relative to other ULs in Tree into cookie:
switchcontent.prototype.rememberpluscleanup=function(){
	//Define array to hold ids of open content that should be persisted
	//Default to just "none" to account for the case where no contents are open when user leaves the page (and persist that):
	var opencontents=new Array("none")
	for (var i=0; i<this.innercontents.length; i++){
		//If persistence enabled, content in question is expanded, and either "Collapse Previous" is disabled, or if enabled, this is the first expanded content
		if (this.persistType!="none" && this.innercontents[i].style.display=="block" && (!this.collapsePrev || (this.collapsePrev && opencontents.length<2)))
			opencontents[opencontents.length]=i //save the index of the opened UL (relative to the entire list of ULs) as an array element
		this.headers[i].onclick=null //Cleanup code
	}
	if (opencontents.length>1) //If there exists open content to be persisted
		opencontents.shift() //Boot the "none" value from the array, so all it contains are the ids of the open contents
	if (typeof this.statusOpen!="undefined")
		this.statusOpen=this.statusClosed=null //Cleanup code
	if (this.persistType=="session") //if session only cookie set
		switchcontent.setCookie(this.className, opencontents.join(",")) //populate cookie with indices of open contents: classname=1,2,3,etc
	else if (this.persistType=="days" && typeof this.persistDays=="number"){ //if persistent cookie set instead
		switchcontent.setCookie(this.className+"_d", opencontents.join(","), this.persistDays) //populate cookie with indices of open contents
		switchcontent.setCookie(this.className+"_dtrack", this.persistDays, this.persistDays) //also remember number of days to persist (int)
	}
}


// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------


switchcontent.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

switchcontent.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 ""
}

switchcontent.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+"; expires="+expireDate.toGMTString()
	}
	else //else if this is a session only cookie
		document.cookie = name+"="+value
}

//   MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
//1) Instance.setStatus(openHTML, closedHTML)- Sets optional HTML to prefix the headers to indicate open/closed states
//2) Instance.setColor(openheaderColor, closedheaderColor)- Sets optional color of header when it's open/closed
//3) Instance.setPersist(true/false)- Enables or disabled session only persistence (recall contents' expand/contract states)
//4) Instance.collapsePrevious(true/false)- Sets whether previous content should be contracted when current one is expanded
//5) Instance.defaultExpanded(indices)- Sets contents that should be expanded by default (ie: 0, 1). Persistence feature overrides this setting!
//6) Instance.init() REQUIRED

var togglediv;

function openCloseDiv(){
	togglediv=new switchcontent("answers", "div") //Limit scanning of switch contents to just "div" elements

	//togglediv.setStatus('<img src="../images/arrow-open.gif" /> ', '<img src="../images/arrow-closed.gif" /> ')
	togglediv.setStatus('<img src="/file-156195.gif" /> ', '<img src="/file-156194.gif" /> ')
	//togglediv.setColor('#ffffff', '#ffffff')
	togglediv.setPersist(false)
	togglediv.collapsePrevious(false) //Only one content open at any given time
	togglediv.init()
}

/* END - Open/Close div */

/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

function setPageBanner()
{
	if (document.getElementById('banner_list') != null && document.getElementById('banner_link') != null)
	{
		function createCookie(name, value, days)
		{
			if(days)
			{
				var date = new Date();
				date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
				var expires = '; expires=' + date.toGMTString();
			}
			else
			{
				var expires = '';
			}
			document.cookie = name + '=' + value + expires + '; path=/';
		}

		function readCookie(name)
		{
			var nameEQ = name + '=';
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++)
			{
				var c = ca[i];
				while(c.charAt(0) == ' ')
					c = c.substring(1,c.length);
				if(c.indexOf(nameEQ) == 0)
					return c.substring(nameEQ.length,c.length);
			}
			return null;
		}

		var banners = document.getElementById('banner_list').innerHTML.split('||');
		if(banners[0].length > 0) // make sure banner_list is not empty and has no space at the beginning -- neither will work properly, so exit gracefully
		{
			var currentCookie = readCookie('Banner_');
			var currentBanner = (currentCookie < banners.length && currentCookie != null && banners[currentCookie] != 'undefined' ? currentCookie : 0);
			document.getElementById('banner_link').innerHTML = '<img src="' + banners[currentBanner] + '" />';
			currentBanner++;
			if(currentBanner >= banners.length)
			{
				currentBanner = 0;
			}
			createCookie('Banner_', currentBanner, 30);
		}
	}
}

