var engine;
var tools;
var tooltip;
function init() {
var event = argItems('event');
var task = argItems('task');
var category = argItems('category');
var product = argItems('product');
var tool = argItems('tool');
if (checkOS() == false) {
showMessage('<div id="getFlash">We apologize for any inconvenience, but we do not support your operating system.</div>');
}
else if (checkBrowser() == false) {
showMessage('<div id="getFlash">You must upgrade your browser to view this site. Download the latest version <a href="#" onclick="openInParent(\'http://www.firefox.com/\');">here</a>.</div>');
}
else if (DetectFlashVer(7, 0, 0) == false) {
showMessage('<div id="getFlash">This site requires Adobe Flash Player.  Download the latest version <a href="#" onclick="openInParent(\'http://www.adobe.com/products/flashplayer/\');">here</a>.</div>');
}
else {
tooltip = new Tooltip('ctnr_main');
var options = ({ 'tooltip': tooltip, 'event': event, 'task': task, 'category': category, 'product': product, 'tool': tool });
engine = new SiteEngine( '.', options );
engine.start();
tools = new ToolsEngine( '.');
tools.start(tool);
preloadImages();
}
}
function loadTool(toolID) {
var toolCodes = ['home02', 'auto05', 'budget03', 'budget05', 'creditline01', 'creditline02', 'savings01', 'savings03'];
var toolCode = toolCodes[toolID-1];
tools.loadTemplate(toolCode);
}
function checkBrowser() {
var pass = true;
if ((BrowserDetect.browser == 'Explorer') && (BrowserDetect.version < 5.5)) {
pass = false;
}
else if ((BrowserDetect.browser == 'Firefox') && (BrowserDetect.version < 1.5)) {
pass = false;
}
else if ((BrowserDetect.browser == 'Netscape') && (BrowserDetect.version < 7.2)) {
pass = false;
}
return pass;
}
function checkOS() {
var pass = true;
if (navigator.userAgent.indexOf('Windows 95') != -1) {
pass = false;
}
else if (navigator.userAgent.indexOf('Windows NT 4') != -1) {
pass = false;
}
return pass;
}
function showMessage(msg) {
$('flash').innerHTML = msg;
$('tabs').innerHTML = '';
$('status').innerHTML = '';
$('status').style.display = 'none';
}
function preloadImages() {
var imgList = [ 'images/btn_viewDetails.gif',
'images/tt_arrow_tl.png',
'images/tt_arrow_tr.png',
'images/tt_arrow_bl.png',
'images/tt_arrow_br.png',
'images/tt_shadow_top.png',
'images/tt_shadow_left.png',
'images/tt_shadow_bottom.png',
'images/detail_lft.png',
'images/detail_rt.png',
'images/detail_bg.png',
'images/lrnRsc_lft.gif',
'images/lrnRsc_rt.gif',
'images/hd_learningResources.gif',
'images/lrnRsc_icn.gif',
'images/bg_productBox.gif',
'images/icn_article.gif',
'images/icn_calc.gif',
'images/icn_checking.gif',
'images/icn_creditCards.gif',
'images/icn_equalHousing.gif',
'images/icn_faq.gif',
'images/icn_insurance.gif',
'images/icn_investment.gif',
'images/icn_learnResource.png',
'images/icn_loans.gif',
'images/icn_online.gif',
'images/icn_savings.gif',
'images/tab_all.gif',
'images/tab_all-down.gif',
'images/tab_all-over.gif',
'images/tab_goal.gif',
'images/tab_all-down.gif',
'images/tab_all-over.gif',
'images/btn_previous.gif',
'images/btn_previous-off.gif',
'images/btn_next.gif',
'images/btn_next-off.gif'
];
for (var i=0; i<imgList.length; i++) {
var img = new Image();
img.src = imgList[i];
}
}
function swapImage(img, path) {
img.src = path;
}
function argItems (theArgName) {
var sArgs = location.search.slice(1).split('&');
var r = '';
for (var i = 0; i < sArgs.length; i++) {
if (sArgs[i].slice(0,sArgs[i].indexOf('=')) == theArgName) {
r = sArgs[i].slice(sArgs[i].indexOf('=')+1);
break;
}
}
return (r.length > 0 ? unescape(r).split(',') : '')
}
function scrollDesc(footerNum) {
engine.scrollDesc(footerNum);
}
function slideTaskNav() {
engine.highlightTaskNav();
}
function slideCatNav() {
engine.highlightCatNav();
}
function fadeInProducts() {
engine.showProducts({ page: 1, fadeIn: true });
}
function openInParent(url, pageID) {
cmCreateManualLinkClickTag(url, null, pageID);
if (window.opener && !window.opener.closed) {
window.opener.location.href = url;
window.opener.focus();
}
else {
window.open(url, 'ria_bofa');
}
}
function buildCMLink(url, promoCode) {
var finalLink = '';
var anchorLink = '';
var pos = url.indexOf('#');
if (pos > 0) {
anchorLink = url.substr(pos, url.length);
finalLink = url.substr(0, pos);
}
else {
finalLink = url;
}
finalLink = (finalLink.indexOf('?') >= 0) ? (finalLink +'&'+ promoCode) : (finalLink +'?'+ promoCode);
if (anchorLink != '') {
finalLink += anchorLink;
}
return finalLink;
}
function CM_createPageID(nameStr) {
nameStr = 'RIA ' + nameStr.unescapeHTML();
var re1 = /[^A-Za-z0-9 ]/g;
var re2 = /\s+/g;
nameStr = nameStr.replace(re1, '');
nameStr = nameStr.replace(re2, ' ');
return nameStr;
}
function CM_createCatID(nameArray) {
var catID = 'RIA:';
var re1 = /[^A-Za-z0-9 ]/g;
var re2 = /\s+/g;
for (var i=0; i<nameArray.length; i++) {
nameArray[i] = nameArray[i].unescapeHTML();
nameArray[i] = nameArray[i].replace(re1, '');
nameArray[i] = nameArray[i].replace(re2, '_');
}
catID += nameArray.join(':');
return catID;
}
function CM_createPromoCode(nameArray) {
var promoCode = 'cm_sp=RIA-';
var reg = new RegExp("<sup>.*</sup>");
var re1 = /[^A-Za-z0-9 ]/g;
var re2 = /\s+/g;
for (var i=0; i<nameArray.length; i++) {
nameArray[i] = nameArray[i].unescapeHTML();
nameArray[i] = nameArray[i].replace(reg, '');
nameArray[i] = nameArray[i].replace(re1, '');
nameArray[i] = nameArray[i].replace(re2, '_');
}
promoCode += nameArray.join('-_-');
return promoCode;
}
function CM_createPageString(nameStr) {
nameStr = nameStr.unescapeHTML();
var re1 = /[^A-Za-z0-9 ]/g;
var re2 = /\s+/g;
nameStr = nameStr.replace(re1, '');
nameStr = nameStr.replace(re2, '_');
return nameStr;
}
function CM_logPageView(lastID, pageID, catID) {
lastID = CM_createPageID(lastID);
pageString = window.location + CM_createPageString(pageID);
pageID = CM_createPageID(pageID);
catID = CM_createCatID(catID);
cmCreateManualLinkClickTag(pageString, null, lastID);
cmCreatePageviewTag(pageID, null, null, catID);
}
function tooltipData(name) {
return engine.data.tipHash[name];
}
function showProductDetail(pid) {
engine.showDetail(pid);
}
function printDetail() {
var container = printContainer.document.getElementById('printContent');
printContainer.focus();
printContainer.print();
}
function checkIE55() {
if (Prototype.Browser.IE == true) {
var dataString = navigator.appVersion;
var versionString = 'MSIE';
var index = dataString.indexOf(versionString);
var version = parseFloat(dataString.substring(index+versionString.length+1));
if (version == '5.5') {
return true;
}
}
return false;
}
Effect.Collapse = function(element) {
element = $(element);
return new Effect.Scale(element, 1, Object.extend({
duration: 0.3, scaleFromCenter: true,
scaleX: false, scaleContent: false, restoreAfterFinish: true,
beforeSetup: function(effect) { effect.element.makePositioned().makeClipping(); },
afterFinishInternal: function(effect) { effect.element.hide().undoClipping(); }
}, arguments[1] || {}));
}
Effect.Expand = function(element) {
element = $(element);
var elementDimensions = element.getDimensions();
var oldStyle = {
top: element.style.top,
left: element.style.left,
width: element.style.width,
height: element.style.height };
return new Effect.Scale(element, 100, Object.extend({
duration: 0.3, scaleFromCenter: true,
scaleX: false,
scaleContent: false,
scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
scaleFrom: 1,
afterSetup: function(effect) {
effect.element.makePositioned();
effect.element.down().makePositioned();
effect.element.makeClipping().setStyle({height: '0px'}).show();
},
afterUpdateInternal: function(effect) {
effect.element.down().setStyle({top: (effect.dims[0] - effect.element.clientHeight) + 'px' });
},
afterFinishInternal: function(effect) {
effect.element.undoClipping().undoPositioned();
}
}, arguments[1] || {}));
}
var AjaxRequest = Class.create();
AjaxRequest.prototype = {
initialize: function(options) {
this.handlers = new Array();
this.baseURL = (options.baseURL != null) ? options.baseURL : '';
this.action = (options.action != null) ? options.action : 'action';
this.handler = (options.handler != null) ? options.handler : 'default';
this.onComplete = options.onComplete;
this.onFailure = (options.onError != null) ? options.onError : this._onRequestError.bind(this);
},
registerHandler: function(handlerId, handlerObject) {
handlerObject.parent = this;
this.handlers[handlerId] = handlerObject;
},
sendRequest: function(requestPath, options) {
var requestURL = this.baseURL + requestPath;
if ( arguments.length >= 3 ) {
options = { parameters: this._createQueryString(arguments, 2) };
}
new Ajax.Request(requestURL, this._requestOptions(options));
},
sendUpdateRequest: function(requestPath, container, options) {
var requestURL = this.baseURL + requestPath;
if ( arguments.length >= 4 ) {
options = { parameters: this._createQueryString(arguments, 3) };
}
new Ajax.Updater(container, requestURL, options);
},
dispatch: function(object, action, options) {
try {
this.handlers[object][action](options);
} catch(e) { alert('Dispatch Error ' + e); }
},
_requestOptions: function(options_in) {
var options = (options_in != null) ? options_in : {};
options.onSuccess = this._onRequestSuccess.bind(this);
options.onFailure = (options.onError != null) ? options.onError : this.onFailure;
this.options = {
parameters: options.parameters,
method: 'get',
onSuccess: options.onSuccess,
onFailure: options.onFailure
};
Object.extend(this.options, options);
return this.options;
},
_createQueryString: function( theArgs, offset ) {
var queryString = "";
for ( var i = offset ; i < theArgs.length ; i++ ) {
if ( i != offset )
queryString += "&";
var anArg = theArgs[i];
if ( anArg.name != undefined && anArg.value != undefined ) {
queryString += anArg.name + "=" + escape(anArg.value);
}
else {
var ePos = anArg.indexOf('=');
var argName = anArg.substring( 0, ePos );
var argValue = anArg.substring( ePos + 1 );
queryString += argName + "=" + escape(argValue);
}
}
return queryString;
},
_onRequestSuccess: function(req) {
var resp = req.responseXML.getElementsByTagName("ajax-response")[0];
if (resp == null)
return;
this._processAjaxResponse(resp.getElementsByTagName("response"));
},
_processAjaxResponse: function(xmlElements) {
for ( var i = 0; i < xmlElements.length; i++ ) {
var responseElement = xmlElements[i];
if ( responseElement.nodeType != 1 )
continue;
if ( this.onComplete ) {
this.onComplete( responseElement );
}
var responseId = responseElement.getAttribute("id");
var responseType = responseElement.getAttribute("type");
if ( responseType == "object" ) {
this._processAjaxObjectUpdate( this.handlers[responseId], responseElement );
}
else if ( responseType == "element" ) {
this._processAjaxElementUpdate( responseId, responseElement );
}
else {
alert('unrecognized AjaxResponse type : ' + responseType );
}
}
},
_processAjaxObjectUpdate: function( handler, resp ) {
var action = (resp.getAttribute(this.action) != null) ? (resp.getAttribute(this.action)) : this.handler;
try {
handler[action](resp);
} catch(e) { alert('Invalid action: ' + e + '|' + handler.toString() + '|'); }
},
_processAjaxElementUpdate: function( responseId, responseElement ) {
$(responseId).innerHTML = RicoUtil.getContentAsString( responseElement );
},
_onRequestError: function(req) {
alert('FAILURE ' + req);
}
}
var RicoUtil = {
getContentAsString: function( parentNode ) {
return parentNode.xml != undefined ?
this._getContentAsStringIE(parentNode) :
this._getContentAsStringMozilla(parentNode);
},
_getContentAsStringIE: function(parentNode) {
var contentStr = "";
for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) {
var n = parentNode.childNodes[i];
if (n.nodeType == 4) {
contentStr += n.nodeValue;
}
else {
contentStr += n.xml;
}
}
return contentStr;
},
_getContentAsStringMozilla: function(parentNode) {
var xmlSerializer = new XMLSerializer();
var contentStr = "";
for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) {
var n = parentNode.childNodes[i];
if (n.nodeType == 4) {
contentStr += n.nodeValue;
}
else {
contentStr += xmlSerializer.serializeToString(n);
}
}
return contentStr;
}
}
var SiteEngine = Class.create();
SiteEngine.prototype = {
initialize: function(url, options) {
var request = new AjaxRequest({ baseURL: url });
request.registerHandler('content', this);
var isIE55 = checkIE55();
var data = new SiteData();
var view = new ViewMain(isIE55);
var browse = new ViewBrowse(isIE55);
var detail = new ViewDetail(isIE55);
this.request = request;
this.data = data;
this.view = view;
this.browse = browse;
this.detail = detail;
this.options = options;
this.tooltip = options.tooltip;
this.base = url;
this.activeEvent = ((options.event != null) && (options.event != '')) ? options.event : 0;
this.activeTask = ((options.task != null) && (options.task != '')) ? options.task : 0;
this.activeCategory = ((options.category != null) && (options.category != '')) ? options.category : 1;
this.showProduct = ((options.product != null) && (options.product != '')) ? options.product : 0;
this.showTool = ((options.tool != null) && (options.tool != '')) ? options.tool : 0;
this.nextTask = '';
this.taskSlideUp = false;
this.browsing = (options.category != '') ? true : false;
this.isFirstView = true;
this.isFree = true;
this.fromBrowseAll = false;
this.categoryFile = '/xml/categories.xml';
this.eventFile = '/xml/events.xml';
this.taskFile = '/xml/tasks.xml';
this.TPMapFile = '/xml/task_product_map.xml';
this.productFile = '/xml/products.xml';
this.resourceFile = '/xml/resources.xml';
this.TRMapFile = '/xml/task_resource_map.xml';
this.TooltipFile = '/xml/tooltips.xml';
this.toolsFile = '/xml/tools.xml';
this.currentPage = 1;
this.browsePage = 1;
this.lastPageID = 'Splash';
},
start: function() {
this.view.setStatus('Loading Categories...');
this.request.sendRequest( this.categoryFile, { onError: this.categoryError.bind(this) } );
},
categories: function(resp) {
this.view.setStatus('Processing Categories...');
this.data.processCategories( resp );
this.view.setStatus('Loading Events...');
this.request.sendRequest( this.eventFile, { onError: this.eventError.bind(this) } );
},
events: function(resp) {
this.view.setStatus('Processing Events...');
this.data.processEvents( resp );
this.view.setStatus('Loading Tasks...');
this.request.sendRequest( this.taskFile, { onError: this.taskError.bind(this) } );
},
tasks: function(resp) {
this.view.setStatus('Processing Events...');
this.data.processTasks( resp );
this.view.setStatus('Loading Products...');
this.request.sendRequest( this.productFile, { onError: this.productError.bind(this) } );
},
products: function(resp) {
this.view.setStatus('Processing Products...');
this.data.processProducts( resp );
this.view.setStatus('Loading Task Product Map...');
this.request.sendRequest( this.TPMapFile, { onError: this.TPMapError.bind(this) } );
},
task_product_map: function(resp) {
this.view.setStatus('Processing Task Product Map...');
this.data.processTPMap( resp );
this.view.setStatus('Loading Resources...');
this.request.sendRequest( this.resourceFile, { onError: this.resourceError.bind(this) } );
},
resources: function(resp) {
this.view.setStatus('Processing Resources...');
this.data.processResources( resp );
this.view.setStatus('Loading Task Resource Map...');
this.request.sendRequest( this.TRMapFile, { onError: this.TRMapError.bind(this) } );
},
task_resource_map: function(resp) {
this.view.setStatus('Processing Task Resource Map...');
this.data.processTRMap( resp );
this.view.setStatus('Loading Tooltips...');
this.request.sendRequest( this.TooltipFile, { onError: this.tooltipError.bind(this) });
},
tooltips: function(resp) {
this.view.setStatus('Processing Tooltips...');
this.data.processTooltips( resp );
this.view.setStatus('Loading Tools Data...');
this.request.sendRequest( this.toolsFile, { onError: this.toolsError.bind(this) });
},
tools: function(resp) {
this.view.setStatus('Processing Tools Data...');
this.data.processTools( resp );
this.done();
},
done: function() {
if (this.options.category != '') {
if (this.activeEvent == 0) {
this.activeEvent = this.data.eventArray[0].id;
}
if (this.activeTask == 0) {
this.activeTask = this.data.dataTree[this.activeEvent].tasks[0].id;
}
}
else if ((this.activeEvent == 0) && (this.activeTask > 0)) {
if (this.data.taskHash[this.activeTask] != null) {
this.activeEvent = this.data.taskHash[this.activeTask].eventId;
}
else {
this.activeTask = 0;
}
}
else if ((this.showProduct > 0) && (this.options.event == '') && (this.options.task == '')) {
var product = this.data.productHash[this.showProduct];
if (product != null) {
this.activeCategory = product.categoryId;
this.browsing = true;
}
else {
this.showProduct = 0;
}
}
else if (this.showTool > 0) {
this.activeEvent = this.data.eventArray[0].id;
loadTool(this.showTool);
}
this.detail.showProduct = this.showProduct;
this.view.hideStatus();
this.view.setTabs(this.browsing);
this.view.setHelp();
this.view.setFlash(this.activeEvent, this.activeTask);
if (this.browsing) {
this.showBrowseAll();
}
},
details: function(resp) {
var pid = this.data.processDetail( resp );
this.setDetail(pid);
this.view.hideStatus();
},
changeEvent: function(eventId, taskId) {
if (!this.fromBrowseAll) {
this.activeEvent = eventId;
if (taskId != null) {
this.activeTask = taskId;
}
this.showTasks();
}
this.fromBrowseAll = false;
},
changeTask: function(taskId) {
if ((taskId != this.activeTask) && this.view.canMove) {
this.nextTask = taskId;
this.highlightTaskNav();
this.detail.hide();
}
},
changeCategory: function(catId) {
if ((catId != this.activeCategory) && this.browse.canMove) {
this.isLocked = false;
this.nextCategory = catId;
this.highlightCatNav();
this.detail.hide();
}
},
highlightTaskNav: function() {
if (this.data.taskHash[this.activeTask] == null) {
this.activeTask = this.data.eventArray[0].id;
}
var startPos = this.data.getTaskPos(this.activeEvent, this.activeTask);
var endPos = this.data.getTaskPos(this.activeEvent, this.nextTask);
var promoCode;
if (startPos > endPos) {
this.activeTask = this.data.getPrevTask(this.activeEvent, this.activeTask);
setTimeout('slideTaskNav()',20);
this.taskSlideUp = true;
}
else if (startPos < endPos) {
this.activeTask = this.data.getNextTask(this.activeEvent, this.activeTask);
setTimeout('slideTaskNav()',20);
this.taskSlideUp = false;
}
else {
this.activeTask = this.nextTask;
this.showProducts({ page: 1, slide: 1 });
pageID = CM_createPageID(this.data.dataTree[this.activeEvent].name +' '+ this.data.taskHash[this.activeTask].name +' '+ this.currentPage);
this.view.changeResources(this.data.taskHash[this.activeTask].resources, pageID);
}
this.view.setActiveTask(this.activeTask);
},
highlightCatNav: function() {
var startPos = this.data.getCategoryPos(this.activeCategory);
var endPos = this.data.getCategoryPos(this.nextCategory);
if (startPos > endPos) {
this.activeCategory = this.data.getPrevCategory(this.activeCategory);
setTimeout('slideCatNav()',20);
this.catSlideUp = true;
}
else if (startPos < endPos) {
this.activeCategory = this.data.getNextCategory(this.activeCategory);
setTimeout('slideCatNav()',20);
this.catSlideUp = false;
}
else {
this.activeCategory = this.nextCategory;
this.showProducts({ page: 1, slide: 1 });
}
this.browse.setActiveCategory(this.activeCategory);
},
setFlash: function(eventID, taskId) {
this.isFree = false;
this.view.setStatus('Loading Navigation...');
this.view.setFlash(eventID, taskId);
},
showTasks: function(taskId) {
var pageID;
var changeActive = true;
if (taskId != null) {
this.activeTask = taskId;
}
if ((this.activeTask == 0) || (this.activeTask == null)) {
this.activeTask = this.data.dataTree[this.activeEvent].tasks[0].id;
}
else {
for (var i=0; i < this.data.dataTree[this.activeEvent].tasks.length; i++) {
if (this.data.dataTree[this.activeEvent].tasks[i].id == this.activeTask) {
changeActive = false;
}
}
if (changeActive) {
this.activeTask = this.data.dataTree[this.activeEvent].tasks[0].id;
}
}
pageID = CM_createPageID(this.data.dataTree[this.activeEvent].name +' '+ this.data.taskHash[this.activeTask].name +' '+ this.currentPage);
this.view.setTasks(this.data.dataTree[this.activeEvent].name, this.data.dataTree[this.activeEvent].tasks, this.activeTask);
this.view.slideInTasks();
this.view.setResources(this.data.taskHash[this.activeTask].resources, pageID);
},
showProducts: function(options) {
if (options == null) { options = {}; }
var page = (options.page != null) ? options.page : 1;
var slide = options.slide;
var fade = (options.fadeIn != null) ? options.fadeIn : false;
var moveRight;
var pageID;
var catID;
this.tooltip.hide();
if (this.browsing && this.browse.canMove) {
moveRight = (page < this.browsePage) ? false : true;
this.browse.setProducts(this.data.categoryHash[this.activeCategory].products, page, slide, this.showProduct);
this.browse.setHeading(this.data.categoryHash[this.activeCategory].title);
if (slide != null) {
if (slide == 'horz') {
this.browse.slideProductsX(moveRight);
}
else {
this.browse.slideProductsY(this.catSlideUp);
}
}
this.browsePage = page;
pageID = 'Category ' + this.data.categoryHash[this.activeCategory].title + ' ' + page;
catID = ['Category', this.data.categoryHash[this.activeCategory].title];
CM_logPageView(this.lastPageID, pageID, catID);
this.lastPageID = pageID;
}
else if (this.view.canMove) {
moveRight = (page < this.currentPage) ? false : true;
this.view.setProducts(this.data.taskHash[this.activeTask].products, page, slide, this.showProduct);
this.view.setHeading(this.data.taskHash[this.activeTask].name);
if (slide != null) {
if (slide == 'horz') {
this.view.slideProductsX(moveRight);
}
else {
this.view.slideProductsY(this.taskSlideUp);
}
}
this.currentPage = page;
pageID = this.data.dataTree[this.activeEvent].name + ' ' + this.data.taskHash[this.activeTask].name + ' ' + page;
catID = [this.data.dataTree[this.activeEvent].name, this.data.taskHash[this.activeTask].name];
CM_logPageView(this.lastPageID, pageID, catID);
this.lastPageID = pageID;
}
this.isFree = true;
this.showProduct = 0;
},
showDetail: function(pid) {
var pageID;
var catID;
var promoCode;
if (this.browsing) {
pageID = 'Category ' + this.data.categoryHash[this.activeCategory].title + ' ' + this.data.productHash[pid].title;
catID = ['Category', this.data.categoryHash[this.activeCategory].title];
promoCode = CM_createPromoCode([this.data.categoryHash[this.activeCategory].title, this.data.productHash[pid].title]);
}
else {
pageID = this.data.dataTree[this.activeEvent].name + ' ' + this.data.taskHash[this.activeTask].name + ' ' + this.data.productHash[pid].title;
catID = [this.data.dataTree[this.activeEvent].name, this.data.taskHash[this.activeTask].name];
promoCode = CM_createPromoCode([this.data.dataTree[this.activeEvent].name, this.data.taskHash[this.activeTask].name, this.data.productHash[pid].title]);
}
this.detail.promoCode = promoCode;
this.detail.pageID = CM_createPageID(pageID);
if (this.data.productHash[pid].isLoaded == true) {
this.setDetail(pid);
}
else {
this.view.setStatus('Loading Product Information...');
this.request.sendRequest('/xml/details/product_' + pid + '.xml', { onError: this.loadError.bind(this) });
}
CM_logPageView(this.lastPageID, pageID, catID);
},
setDetail: function(pid) {
var top = (this.browsing) ? 134 : 184;
if (this.browsing) {
this.detail.show(this.data.productHash[pid], top);
}
else {
this.detail.show(this.data.productHash[pid], top, this.data.dataTree[this.activeEvent], this.data.taskHash[this.activeTask]);
}
},
hideDetail: function() {
this.detail.hide();
},
showBrowseAll: function() {
if (this.view.canMove && this.isFree) {
var category = (this.data.categoryHash[this.activeCategory] != null) ? this.activeCategory : 1;
this.browsing = true;
this.view.hide();
this.detail.hide();
this.browse.show();
tooltip.hide();
if (this.isFirstView) {
this.browse.setProducts(this.data.categoryHash[category].products, null, null, this.showProduct);
this.browse.setHeading(this.data.categoryHash[category].title);
this.browse.setActiveCategory(category);
this.browse.canMove = true;
this.isFirstView = false;
}
var pageID = 'Category ' + this.data.categoryHash[category].title + ' ' + this.browsePage;
var catID = ['Category', this.data.categoryHash[category].title];
CM_logPageView(this.lastPageID, pageID, catID);
this.lastPageID = pageID;
tools.hide();
}
},
hideBrowseAll: function() {
if (this.view.canMove && this.isFree) {
this.browsing = false;
this.fromBrowseAll = true;
this.browse.hide();
this.detail.hide();
this.view.show();
this.view.setFlash(this.activeEvent, this.activeTask);
tooltip.hide();
if (this.activeEvent > 0) {
var pageID = this.data.dataTree[this.activeEvent].name + ' ' + this.data.taskHash[this.activeTask].name + ' ' + this.currentPage;
var catID = [this.data.dataTree[this.activeEvent].name, this.data.taskHash[this.activeTask].name];
CM_logPageView(this.lastPageID, pageID, catID);
this.lastPageID = pageID;
}
else {
CM_logPageView(this.lastPageID, 'RIA Splash', ['RIA']);
this.lastPageID = pageID;
this.fromBrowseAll = false;
}
tools.hide();
}
},
fadeTasks: function() {
this.isFree = false;
this.detail.hide();
this.view.hideHeading();
this.view.fadeTasks();
this.view.fadeProducts();
this.view.fadeResources(this.data.taskHash[this.activeTask].resources);
},
scrollDesc: function(footerNum) {
this.detail.scrollTo(footerNum);
},
toggleHelp: function() {
var state = this.tooltip.toggle();
this.view.setHelp(state);
},
getToolData: function(toolCode) {
return this.data.toolHash[toolCode];
},
categoryError: function() {
this.view.setStatus('Error Loading Categories');
},
eventError: function() {
this.view.setStatus('Error Loading Events');
},
taskError: function() {
this.view.setStatus('Error Loading Tasks');
},
productError: function() {
this.view.setStatus('Error Loading Products');
},
resourceError: function() {
this.view.setStatus('Error Loading Resources');
},
TPMapError: function() {
this.view.setStatus('Error Loading Task Product Map');
},
TRMapError: function() {
this.view.setStatus('Error Loading Task Resource Map');
},
tooltipError: function() {
this.view.setStatus('Error Loading Tooltips');
},
toolsError: function() {
this.view.setStatus('Error Loading Tool Data');
},
loadError: function(e) {
this.view.setStatus('There was an error loading<br/> the requested document.<br/>Status Code: ' + e.status);
}
};
var SiteData = Class.create();
SiteData.prototype = {
initialize: function() {
this.eventArray = new Array();
this.taskArray = new Array();
this.categoryList = new Array();
this.dataTree = new Object();
this.taskHash = new Object();
this.productHash = new Object();
this.categoryHash = new Object();
this.resourceHash = new Object();
this.tipHash = new Object();
this.toolHash = new Object();
this.toolList = new Object();
},
processEvents: function(data) {
var events = data.getElementsByTagName('event');
for (var i=0; i<events.length; i++) {
var thisEvent = new Object();
thisEvent.id = events[i].getAttribute('id');
thisEvent.name = events[i].getElementsByTagName('name')[0].firstChild.nodeValue;
thisEvent.image = events[i].getElementsByTagName('image')[0].firstChild.nodeValue;
thisEvent.tasks = new Array();
this.eventArray[i] = thisEvent;
this.dataTree[thisEvent.id] = thisEvent;
}
},
processTasks: function(data) {
var tasks = data.getElementsByTagName('task');
for (var i=0; i<tasks.length; i++) {
var thisTask = new Object();
thisTask.id = tasks[i].getAttribute('id');
thisTask.eventId = tasks[i].getAttribute('event_id');
thisTask.name = tasks[i].getElementsByTagName('name')[0].firstChild.nodeValue;
thisTask.products = new Array();
thisTask.resources = new Array();
this.taskArray[i] = thisTask;
this.taskHash[thisTask.id] = thisTask;
this.dataTree[thisTask.eventId].tasks.push(thisTask);
}
},
processProducts: function(data) {
var products = data.getElementsByTagName('product');
for (var i=0; i<products.length; i++) {
var thisProduct = new Object();
var rec = products[i];
thisProduct.id = rec.getAttribute('id');
thisProduct.title = (rec.getElementsByTagName('title')[0].firstChild != null) ? rec.getElementsByTagName('title')[0].firstChild.nodeValue : '';
thisProduct.summary = (rec.getElementsByTagName('summary')[0].firstChild != null) ? rec.getElementsByTagName('summary')[0].firstChild.nodeValue : '';
thisProduct.availability = (rec.getElementsByTagName('availability')[0].firstChild != null) ? rec.getElementsByTagName('availability')[0].firstChild.nodeValue : '';
thisProduct.categoryId = rec.getAttribute('category_id');
thisProduct.category = this.categoryHash[thisProduct.categoryId];
thisProduct.position = rec.getAttribute('position');
thisProduct.bullets = new Array();
thisProduct.descriptions = new Array();
thisProduct.footers = new Array();
thisProduct.links = new Array();
thisProduct.learn = '';
thisProduct.cta = '';
thisProduct.isLoaded = false;
this.productHash[thisProduct.id] = thisProduct;
if (thisProduct.categoryId > 0) {
this.categoryHash[thisProduct.categoryId].products.push(thisProduct);
}
}
},
processDetail: function(data) {
var node = data.getElementsByTagName('product')[0];
var bullets = data.getElementsByTagName('bullet');
var descriptions = data.getElementsByTagName('description');
var footers = data.getElementsByTagName('footer');
var cta = data.getElementsByTagName('cta');
var learn = data.getElementsByTagName('learn_link');
var links = data.getElementsByTagName('links');
var productId = node.getAttribute('id');
var product = this.productHash[productId];
product.isLoaded = true;
for (var i=0; i<bullets.length; i++) {
var rec = bullets[i];
var content = (rec.firstChild != null) ? rec.firstChild.nodeValue : '';
product.bullets.push(content);
}
for (var i=0; i<descriptions.length; i++) {
var rec = descriptions[i];
var content = (rec.firstChild != null) ? rec.firstChild.nodeValue : '';
product.descriptions.push(content);
}
for (var i=0; i<footers.length; i++) {
var rec = footers[i];
var content = (rec.firstChild != null) ? rec.firstChild.nodeValue : '';
product.footers.push(content);
}
for (var i=0; i<links.length; i++) {
var rec = links[i];
var link = new Object();
link.type = (rec.getElementsByTagName('link_type')[0].firstChild != null) ? rec.getElementsByTagName('link_type')[0].firstChild.nodeValue : '';
link.text = (rec.getElementsByTagName('link_text')[0].firstChild != null) ? rec.getElementsByTagName('link_text')[0].firstChild.nodeValue : '';
link.url = (rec.getElementsByTagName('link_url')[0].firstChild != null) ? rec.getElementsByTagName('link_url')[0].firstChild.nodeValue : '';
product.links.push(link);
}
if (cta.length > 0) {
var rec = cta[0];
var cta = new Object();
cta.text = (rec.getElementsByTagName('cta_text')[0].firstChild != null) ? rec.getElementsByTagName('cta_text')[0].firstChild.nodeValue : '';
cta.url = (rec.getElementsByTagName('cta_url')[0].firstChild != null) ? rec.getElementsByTagName('cta_url')[0].firstChild.nodeValue : '';
product.cta = cta;
}
if (learn.length > 0) {
var rec = learn[0];
var content = (rec.firstChild != null) ? rec.firstChild.nodeValue : '';
product.learn = content;
}
return productId;
},
processTPMap: function(data) {
var map = data.getElementsByTagName('map-item');
for (var i=0; i<map.length; i++) {
var taskId = map[i].getAttribute('task_id');
var productId = map[i].getAttribute('product_id');
if ((this.productHash[productId] != null) && (this.taskHash[taskId] != null)) {
this.taskHash[taskId].products.push(this.productHash[productId]);
}
}
},
processCategories: function(data) {
var categories = data.getElementsByTagName('category');
for (var i=0; i<categories.length; i++) {
var thisCategory = new Object();
var rec = categories[i];
thisCategory.id = rec.getAttribute('id');
thisCategory.title = (rec.getElementsByTagName('title')[0].firstChild != null) ? rec.getElementsByTagName('title')[0].firstChild.nodeValue : '';
thisCategory.image = (rec.getElementsByTagName('image')[0].firstChild != null) ? rec.getElementsByTagName('image')[0].firstChild.nodeValue : '';
thisCategory.navImage = (rec.getElementsByTagName('lnav_image')[0].firstChild != null) ? rec.getElementsByTagName('lnav_image')[0].firstChild.nodeValue : '';
thisCategory.products = new Array();
this.categoryHash[thisCategory.id] = thisCategory;
this.categoryList.push(thisCategory);
}
},
processResources: function(data) {
var resources = data.getElementsByTagName('resource');
for (var i=0; i<resources.length; i++) {
var thisResource = new Object();
var rec = resources[i];
thisResource.id = rec.getAttribute('id');
thisResource.title = (rec.getElementsByTagName('title')[0].firstChild != null) ? rec.getElementsByTagName('title')[0].firstChild.nodeValue : '';
thisResource.summary = (rec.getElementsByTagName('summary')[0].firstChild != null) ? rec.getElementsByTagName('summary')[0].firstChild.nodeValue : '';
thisResource.type = (rec.getElementsByTagName('type')[0].firstChild != null) ? rec.getElementsByTagName('type')[0].firstChild.nodeValue : '';
thisResource.mainText = (rec.getElementsByTagName('text')[0].firstChild != null) ? rec.getElementsByTagName('text')[0].firstChild.nodeValue : '';
thisResource.mainURL = (rec.getElementsByTagName('url')[0].firstChild != null) ? rec.getElementsByTagName('url')[0].firstChild.nodeValue : '';
thisResource.linkText = (rec.getElementsByTagName('link_text')[0].firstChild != null) ? rec.getElementsByTagName('link_text')[0].firstChild.nodeValue : '';
thisResource.linkURL = (rec.getElementsByTagName('link_url')[0].firstChild != null) ? rec.getElementsByTagName('link_url')[0].firstChild.nodeValue : '';
this.resourceHash[thisResource.id] = thisResource;
}
},
processTRMap: function(data) {
var map = data.getElementsByTagName('map-item');
for (var i=0; i<map.length; i++) {
var taskId = map[i].getAttribute('task_id');
var resourceId = map[i].getAttribute('resource_id');
if (this.taskHash[taskId] != null) {
this.taskHash[taskId].resources.push(this.resourceHash[resourceId]);
}
}
},
processTooltips: function(data) {
var tips = data.getElementsByTagName('tooltip');
for (var i=0; i<tips.length; i++) {
var rec = tips[i];
var tipTag = rec.getAttribute('tag_name');
var content = (rec.getElementsByTagName('content')[0].firstChild != null) ? rec.getElementsByTagName('content')[0].firstChild.nodeValue : '';
this.tipHash[tipTag] = content;
}
},
processTools: function(data) {
var tools = tips = data.getElementsByTagName('tool');
for (var i=0; i<tools.length; i++) {
var rec = tools[i];
var tObj = new Object();
tObj.id = tools[i].getAttribute('id');
tObj.toolCode = tools[i].getAttribute('tool_code');
tObj.products = new Array();
tObj.resources = new Array();
var products = rec.getElementsByTagName('product');
var resources = rec.getElementsByTagName('resource');
for (var j=0; j<products.length; j++) {
var pObj = new Object();
pObj.id = products[j].getAttribute('id');
pObj.title = products[j].getAttribute('title');
pObj.category = products[j].getAttribute('category');
pObj.code = tObj.toolCode;
tObj.products.push(pObj);
}
for (var j=0; j<resources.length; j++) {
var rObj = new Object();
rObj.title = resources[j].getAttribute('title');
rObj.type = resources[j].getAttribute('type');
rObj.url = resources[j].getAttribute('url');
rObj.text = resources[j].getAttribute('text');
tObj.resources.push(rObj);
}
this.toolList[tObj.id] = tObj.toolCode;
this.toolHash[tObj.toolCode] = tObj;
}
},
getTaskPos: function(eventId, taskId) {
var taskList = this.dataTree[eventId].tasks;
var pos = 0;
for (var i=0; i < taskList.length; i++) {
if (taskList[i].id == taskId) {
pos = i;
continue;
}
}
return pos;
},
getNextTask: function(eventId, taskId) {
var taskList = this.dataTree[eventId].tasks;
var id = 0;
for (var i=0; i < taskList.length; i++) {
if (taskList[i].id == taskId) {
id = taskList[(i+1)].id;
continue;
}
}
return id;
},
getPrevTask: function(eventId, taskId) {
var taskList = this.dataTree[eventId].tasks;
var id = 0;
for (var i=0; i < taskList.length; i++) {
if (taskList[i].id == taskId) {
id = taskList[(i-1)].id;
continue;
}
}
return id;
},
getCategoryPos: function(catId) {
var catList = this.categoryList;
var pos = 0;
for (var i=0; i < catList.length; i++) {
if (catList[i].id == catId) {
pos = i;
continue;
}
}
return pos;
},
getNextCategory: function(catId) {
var catList = this.categoryList;
var id = 0;
for (var i=0; i < catList.length; i++) {
if (catList[i].id == catId) {
id = catList[(i+1)].id;
continue;
}
}
return id;
},
getPrevCategory: function(catId) {
var catList = this.categoryList;
var id = 0;
for (var i=0; i < catList.length; i++) {
if (catList[i].id == catId) {
id = catList[(i-1)].id;
continue;
}
}
return id;
}
}
var ViewMain = Class.create();
ViewMain.prototype = {
initialize: function(IE55) {
this.container = $('ctnr_main');
this.leftNavContainer = $('lnav_container');
this.productsContainer = $('goalProducts');
this.resourceContainer = $('lrnRsc_container');
this.detailContainer = $('detail_container');
this.resourceWrap = $('learnResource');
this.flash = $('flash');
this.lnav = $('goalNav');
this.tabs = $('tabs');
this.help = $('help');
this.pagebar = $('pageBar');
this.heading = $('pageHd');
this.paging = $('goalsView');
this.status = $('status');
this.resourceOne = $('resource1');
this.resourceTwo = $('resource2');
this.activeSlider = 0;
this.emptySlider = 1;
this.sliders = new Array();
this.sliders.push( $('goalGroup1') );
this.sliders.push( $('goalGroup2') );
this.slideY = 365;
this.slideX = 700;
this.perPage = 4;
this.boxName = '';
this.promoCode = '';
this.isIE55 = IE55;
this.showingProducts = false;
this.loading = true;
this.canMove = true;
this.showProduct = 0;
},
show: function() {
this.leftNavContainer.show();
this.productsContainer.show();
this.resourceContainer.show();
this.flash.show();
this.pagebar.show();
this.setTabs();
},
hide: function() {
this.leftNavContainer.hide();
this.productsContainer.hide();
this.resourceContainer.hide();
this.flash.hide();
this.pagebar.hide();
this.setTabs(true);
},
setHelp: function(state) {
var content;
if (state == true) {
content = '<a href="#" onclick="engine.toggleHelp(); return false">Turn Help Off</a>';
}
else {
content = '<a href="#" onclick="engine.toggleHelp(); return false">Turn Help On</a>';
}
this.help.update(content);
},
setFlash: function(eventId, taskId) {
var content;
if (eventId > 0) {
content = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="756" height="115" id="money_puzzle" align="middle" onmouseover="tooltip.show(event, tooltipData(\'flash\'))" onmouseout="tooltip.hide()" onmousemove="tooltip.move(event)">' +
'<param name="allowScriptAccess" value="sameDomain" />' +
'<param name="movie" value="topnav.swf?eventID='+ eventId +'&taskID='+ taskId +'" />' +
'<param name="quality" value="high" />' +
'<param name="bgcolor" value="#ffffff" />' +
'<param name="wmode" value="opaque" />' +
'<param name="menu" value="false" />' +
'<embed src="topnav.swf?eventID='+ eventId +'&taskID='+ taskId +'" quality="high" bgcolor="#ffffff" width="756" height="115" name="money_puzzle" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" menu="false"/>' +
'</object>';
this.flash.setStyle({ height: 115, zIndex: 10 });
}
else {
content = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="756" height="530" id="boa_splash" align="middle">' +
'<param name="allowScriptAccess" value="sameDomain" />' +
'<param name="movie" value="boa_splash.swf" />' +
'<param name="quality" value="high" />' +
'<param name="bgcolor" value="#ffffff" />' +
'<param name="wmode" value="opaque" />' +
'<param name="menu" value="false" />' +
'<embed src="boa_splash.swf" quality="high" bgcolor="#ffffff" width="756" height="530" name="boa_splash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" menu="false"/>' +
'</object>';
this.flash.setStyle({ height: 530, zIndex: 500 });
}
this.flash.update(content);
},
setTasks: function(eventTitle, taskList, activeTask) {
var content = '<h1>' + eventTitle + '</h1><ul id="lnavList" onmouseover="tooltip.show(event, tooltipData(\'task_nav\'))" onmouseout="tooltip.hide()" onmousemove="tooltip.move(event)">';
for (var i=0; i<taskList.length; i++) {
if (taskList[i].id == activeTask) {
content += '<li id="lnav_item_' + taskList[i].id + '" class="selected down"';
}
else {
content += '<li id="lnav_item_' + taskList[i].id + '"';
}
content += '  onclick="engine.changeTask(\''+ taskList[i].id +'\'); return false">' + taskList[i].name + '</li>';
}
content += '</ul><img src="images/lnav_btm.gif" alt="" width="90" height="13" hspace="0" vspace="0" border="0">';
this.leftNavContainer.hide();
this.lnav.update(content);
},
setProducts: function(productList, pageNum, slide, productId) {
this.canMove = false;
pageNum = (pageNum == null) ? 1 : pageNum;
if (productId > 0) {
var isMatch = false;
for (var i=0; i<productList.length; i++) {
if (productList[i].id == productId) {
isMatch = true;
pageNum = Math.ceil((i+1)/this.perPage);
this.showProduct = productId;
break;
}
}
}
var count = productList.length;
var perPage = this.perPage;
var start = ((pageNum-1) * perPage);
var end = (count < (pageNum*perPage)) ? count : (pageNum*perPage);
var content = '';
var viewing = '';
var paging = '';
var cellNum = 1;
if ((pageNum == null) || (pageNum < 1) || ( pageNum > (Math.ceil(productList.length/perPage)))) {
pageNum = 1;
}
if (slide == null) {
sliderNum = this.activeSlider;
}
else {
sliderNum = this.emptySlider;
}
for (var i=start; i<end; i++) {
var img = './' + (productList[i].category != null) ? productList[i].category.image : '';
content += '<div class="productBox" id="p'+ cellNum + this.boxName +'">';
content += '<img onclick="engine.showDetail('+ productList[i].id +'); return false" class="icon" width="30" height="46" alt="" src="'+ img +'"/>';
content += '<h3>' + productList[i].title + '</h3>';
content += '<p>' + productList[i].summary + '</p>';
content += '<p class="limited">' + productList[i].availability + '</p>';
content += '<div class="cta"><img src="./images/btn_viewDetails.gif" alt="View Details" width="84" height="18" hspace="0" vspace="0" border="0" onclick="engine.showDetail('+ productList[i].id +'); return false" onmouseover="tooltip.show(event, tooltipData(\'product\'))" onmouseout="tooltip.hide()" onmousemove="tooltip.move(event)"></div></div>';
cellNum++;
}
this.sliders[sliderNum].update(content);
paging = '<p>viewing ' + (((pageNum-1)*perPage)+1) + '-';
paging += (count > (pageNum*perPage)) ? (pageNum*perPage) : (count);
paging += ' of ' + count + '</p>';
if (slide == null) {
this.appearProducts();
}
if ((pageNum == 1) && (count <= perPage)) {
viewing = paging + '<img src="./images/btn_previous-off.gif" alt="Previous" width="75" height="18" hspace="0" vspace="0" border="0" class="btnOff"/><p>' +
'</p><img src="./images/btn_next-off.gif" alt="Next" width="75" height="18" hspace="0" vspace="0" border="0" class="btnOff"/>';
}
else if ((pageNum == 1) && (count > perPage)) {
viewing = paging + '<img src="./images/btn_previous-off.gif" alt="Previous" width="75" height="18" hspace="0" vspace="0" border="0" class="btnOff"/><p>' +
'</p><img src="./images/btn_next.gif" alt="Forward" width="75" height="18" hspace="0" vspace="0" border="0" onclick="engine.showProducts({ page: 2, slide: \'horz\' }); return false" onmouseover="tooltip.show(event, tooltipData(\'product_arrow\'))" onmouseout="tooltip.hide()"/>';
}
else if ((pageNum > 1) && (count > (pageNum*perPage))) {
viewing = paging + '<img src="./images/btn_previous.gif" alt="Previous" width="75" height="18" hspace="0" vspace="0" border="0" onclick="engine.showProducts( { page: ' + (pageNum-1) + ', slide: \'horz\' }); return false" onmouseover="tooltip.show(event, tooltipData(\'product_arrow\'))" onmouseout="tooltip.hide()"/><p>' +
'</p><img src="./images/btn_next.gif" alt="Forward" width="75" height="18" hspace="0" vspace="0" border="0" onclick="engine.showProducts( { page: ' + (pageNum+1) + ', slide: \'horz\' }); return false" onmouseover="tooltip.show(event, tooltipData(\'product_arrow\'))" onmouseout="tooltip.hide()"/>';
}
else {
viewing = paging + '<img src="./images/btn_previous.gif" alt="Previous" width="75" height="18" hspace="0" vspace="0" border="0" onclick="engine.showProducts( { page: ' + (pageNum-1) + ', slide: \'horz\' }); return false" onmouseover="tooltip.show(event, tooltipData(\'product_arrow\'))" onmouseout="tooltip.hide()"/><p>' +
'</p><img src="./images/btn_next-off.gif" alt="Forward" width="75" height="18" hspace="0" vspace="0" border="0" class="btnOff"/>';
}
this.paging.update(viewing);
},
setResources: function(list, pageID) {
if (list.length != null) {
this.currentResources = list;
}
if (pageID != null) {
this.pageID = pageID;
}
var wrappers = [ this.resourceOne, this.resourceTwo ];
var resourceList = this.currentResources;
for (var i=0; i<wrappers.length; i++) {
var content = '';
if ((resourceList[i] != null) && (resourceList[i].type != null)) {
var mainURL = resourceList[i].mainURL;
var linkURL = resourceList[i].linkURL;
if (resourceList[i].type == 'lf_calc') {
content = '<img id="recImg" onclick="tools.loadTemplate(\'' + resourceList[i].mainURL + '\'); return false" width="30" height="45" alt="" src="images/icn_calc.gif"/>';
content += '<h3 onclick="tools.loadTemplate(\'' + resourceList[i].mainURL + '\'); return false">'+ resourceList[i].title +'</h3>';
content += '<p>' + resourceList[i].summary +'</p>';
content += '<a href="#" onclick="tools.loadTemplate(\'' + resourceList[i].mainURL + '\'); return false">'+ resourceList[i].mainText +'</a>';
}
else {
content = '<img id="recImg" onclick="openInParent(\'' + mainURL + '\',\'' + this.pageID + '\'); return false" width="30" height="45" alt="" src="images/icn_' + resourceList[i].type + '.gif"/>';
content += '<h3 onclick="openInParent(\'' + mainURL + '\',\'' + this.pageID + '\'); return false">'+ resourceList[i].title +'</h3>';
content += '<p>' + resourceList[i].summary +'</p>';
content += '<a href="#" onclick="openInParent(\'' + mainURL + '\',\'' + this.pageID + '\'); return false" target="_parent">'+ resourceList[i].mainText +'</a>';
}
if ((resourceList[i].linkText != '') && (resourceList[i].linkURL != '')) {
content += '<a href="#" class="relatedRsc" onclick="openInParent(\'' + linkURL + '\',\'' + this.pageID + '\'); return false" target="_parent">'+ resourceList[i].linkText +'</a>';
}
}
wrappers[i].update(content);
}
this.appearResources();
},
setHeading: function(title) {
var content = '<h2>'+ title +'</h2>';
this.heading.update(content);
this.appearHeading();
},
setActiveTask: function(taskId) {
var navList = $('lnavList');
var nodes = navList.getElementsByTagName('li');
for (var i=0; i < nodes.length; i++) {
if (nodes[i].id == 'lnav_item_'+taskId) {
nodes[i].className = 'selected down';
}
else {
nodes[i].className = '';
}
}
},
slideProductsY: function(up) {
var dist = (up) ? -(this.slideY) : this.slideY;
this.sliders[this.emptySlider].setStyle({ top: -(dist), left: 0 });
new Effect.Move(this.sliders[this.activeSlider], { x: 0, y: dist, duration: 0.6 });
new Effect.Move(this.sliders[this.emptySlider], { x: 0, y: dist, duration: 0.6, afterFinish: this.enableMove.bind(this) });
var temp = this.emptySlider;
this.emptySlider = this.activeSlider;
this.activeSlider = temp;
},
slideProductsX: function(right) {
var dist = (right) ? -(this.slideX) : this.slideX;
this.sliders[this.emptySlider].setStyle({ left: -(dist), top: 0 });
new Effect.Move(this.sliders[this.activeSlider], { x: dist, y: 0, duration: 0.5 });
new Effect.Move(this.sliders[this.emptySlider], { x: dist, y: 0, duration: 0.5, afterFinish: this.enableMove.bind(this) });
var temp = this.emptySlider;
this.emptySlider = this.activeSlider;
this.activeSlider = temp;
},
hideTasks: function() {
this.leftNavContainer.hide();
},
fadeTasks: function() {
new Effect.Fade(this.leftNavContainer, { queue: { position: 'end', scope: 'tasks' }, duration: 0.3 });
},
slideInTasks: function() {
this.hideStatus();
if (this.isIE55 == true) {
new Effect.Appear(this.leftNavContainer, { queue: { position: 'end', scope: 'tasks' }, afterFinish: fadeInProducts });
}
else {
new Effect.SlideDown(this.leftNavContainer, { queue: { position: 'end', scope: 'tasks' }, afterFinish: fadeInProducts });
}
if (this.loading) {
new Effect.Appear( this.resourceContainer, { queue: { position: 'end', scope: 'tasks' }, duration: 0.4} );
this.loading = false;
}
},
fadeProducts: function() {
this.sliders[this.emptySlider].update('');
if (this.showingProducts) {
for (var i=1; i<(this.perPage+1); i++) {
var prodBox = 'p' + i + this.boxName;
if ($(prodBox)) {
new Effect.Fade(prodBox, { duration: 0.2 });
}
}
this.showingProducts = false;
}
},
appearProducts: function() {
for (var i=1; i<(this.perPage+1); i++) {
var prodBox = 'p' + i + this.boxName;
if ($(prodBox)) {
if (this.showProduct > 0) {
$(prodBox).show();
}
else {
$(prodBox).hide();
if (i == this.perPage) {
new Effect.Appear(prodBox, { queue: { position: 'end', scope: 'products' }, duration: 0.2, afterFinish: this.enableMove.bind(this) });
}
else {
new Effect.Appear(prodBox, { queue: { position: 'end', scope: 'products' }, duration: 0.2 });
}
}
}
}
if (this.showProduct > 0) {
showProductDetail(this.showProduct);
this.enableMove();
this.showProduct = 0;
}
this.showingProducts = true;
},
fadeResources: function(list) {
if (this.isIE55 == true) {
this.resourceOne.hide();
this.resourceTwo.hide();
}
else {
new Effect.Fade(this.resourceOne, { queue: { position: 'end', scope: 'resources' }, duration: 0.5 });
new Effect.Fade(this.resourceTwo, { queue: { position: 'end', scope: 'resources' }, duration: 0.5 });
}
},
appearResources: function() {
if (this.isIE55 == true) {
this.resourceOne.show();
this.resourceTwo.show();
}
else {
new Effect.Appear(this.resourceOne, { queue: { position: 'end', scope: 'resources' }, duration: 0.5 });
new Effect.Appear(this.resourceTwo, { queue: { position: 'end', scope: 'resources' }, duration: 0.5 });
}
},
changeResources: function(list, pageID) {
this.pageID = pageID;
this.currentResources = list;
new Effect.Fade(this.resourceOne, { queue: { position: 'end', scope: 'resources' }, duration: 0.5 });
new Effect.Fade(this.resourceTwo, { queue: { position: 'end', scope: 'resources' }, duration: 0.5, afterFinish: this.setResources.bind(this) });
},
hideHeading: function() {
$(this.pagebar).hide();
},
appearHeading: function() {
new Effect.Appear(this.pagebar, { queue: { position: 'end', scope: 'heading' }, duration: 0.3 });
},
hidePaging: function() {
},
appearPaging: function() {
new Effect.Appear(this.paging, { queue: { position: 'end', scope: 'heading' }, duration: 0.3 });
},
setTabs: function(browsing) {
var content = '';
if (browsing) {
content = '<img src="images/tab_goal.gif" alt="Browse by Goal" name="nav_goal" width="100" height="25" border="0" hspace="0" vspace="0" onclick="engine.hideBrowseAll(); return false" onmouseover="swapImage(this, \'images/tab_goal-over.gif\'); tooltip.show(event, tooltipData(\'goal_tab\'))" onmouseout="swapImage(this, \'images/tab_goal.gif\'); tooltip.hide()" onmousemove="tooltip.move(event)">' +
'<img src="images/tab_all-down.gif" alt="Browse All" name="nav_all" width="100" height="25" border="0" hspace="0" vspace="0" class="btnOff">';
}
else {
content = '<img src="images/tab_goal-down.gif" alt="Browse by Goal" name="nav_goal" width="100" height="25" border="0" hspace="0" vspace="0" class="btnOff">' +
'<img src="images/tab_all.gif" alt="Browse All" name="nav_all" width="100" height="25" border="0" hspace="0" vspace="0" onclick="engine.showBrowseAll(); return false" onmouseover="swapImage(this, \'images/tab_all-over.gif\'); tooltip.show(event, tooltipData(\'category_tab\'))" onmouseout="swapImage(this, \'images/tab_all.gif\'); tooltip.hide()" onmousemove="tooltip.move(event)">';
}
this.tabs.update(content);
},
setStatus: function(msg) {
this.status.update(msg);
this.status.show();
},
hideStatus: function() {
this.status.hide();
this.status.update('');
},
enableMove: function() {
this.canMove = true;
}
}
var ViewBrowse = Class.create();
Object.extend(Object.extend(ViewBrowse.prototype, ViewMain.prototype), {
initialize: function(IE55) {
this.catContainer = $('category_container');
this.leftNavContainer = $('lnav_container');
this.productsContainer = $('catProducts');
this.lnav = $('catNav');
this.heading = $('catPageHd');
this.paging = $('catView');
this.pagebar = $('catPageBar');
this.activeSlider = 0;
this.emptySlider = 1;
this.sliders = new Array();
this.sliders.push( $('catGroup1') );
this.sliders.push( $('catGroup2') );
this.slideY = 445;
this.slideX = 700;
this.perPage = 6;
this.boxName = 'cat';
this.isIE55 = IE55;
this.canMove = true;
this.showProduct = 0;
},
show: function() {
this.catContainer.show();
},
hide: function() {
this.catContainer.hide();
},
setActiveCategory: function(catId) {
var nodes = this.lnav.getElementsByTagName('li');
var last = nodes.length-1;
var active = 'lnav_cat_' + catId;
for (var i=0; i < nodes.length; i++) {
if ((nodes[i].id == active) && (last == i)) {
nodes[i].className = 'selected down last';
}
else if (nodes[i].id == active) {
nodes[i].className = 'selected down';
}
else if (last == i) {
nodes[i].className = 'last';
}
else {
nodes[i].className = '';
}
}
}
});
var ViewDetail = Class.create();
ViewDetail.prototype = {
initialize: function(IE55) {
this.detailWrapper = $('detail_wrapper');
this.detailContainer = $('detail_container');
this.title = $('product_name');
this.summary = $('summary');
this.cta = $('cta');
this.text = $('text');
this.slidetrack = $('scrollbar');
this.slider = $('scrollbox');
this.path = $('path');
this.resourceContainer = $('lrnRscSm_container');
this.resources = $('resources');
this.promoCode = '';
this.pageID = '';
this.isIE55 = IE55;
this.showProduct = 0;
},
show: function(product, top, event, task) {
var printTitle = '';
var printSummary = '';
var printCTA = '';
var printText = '';
var printResc = '';
var reg = new RegExp("<sup>(.*)</sup>");
var title = product.title.replace(reg, "<sup><a href=\"javascript:scrollDesc(\'$1\')\">$1<\/a><\/sup>");
this.title.update('<h1>' + title + '</h1>');
printTitle = '<h1>' + product.title + '</h1>';
if (task != null) {
this.path.update('<p>You selected the catagories <b>' + event.name + '</b> and <b>' + task.name + '</b> to get here.</p>');
}
else {
this.path.update('');
}
var summaryText = product.summary.replace(reg, "<sup><a href=\"javascript:scrollDesc(\'$1\')\">$1<\/a></sup>");
var summary = '<p>' + summaryText + '</p><ul id="bullets">';
printSummary = '<p>' + product.summary + '</p><ul id="bullets">';
for (var i=0; i<product.bullets.length; i++) {
var reg = new RegExp("<sup>(.*)</sup>");
var bullet = product.bullets[i].replace(reg, "<sup><a href=\"javascript:scrollDesc(\'$1\')\">$1<\/a></sup>");
summary += '<li>' + bullet + '</li>';
printSummary += '<li>' + product.bullets[i] + '</li>';
}
this.summary.update(summary + '</ul>');
printSummary += '</ul>';
var text = '';
for (var i=0; i<product.descriptions.length; i++) {
text += '<p>' + product.descriptions[i]+ '</p>';
printText += '<p>' + product.descriptions[i]+ '</p>';
}
for (var i=0; i<product.footers.length; i++) {
text += '<p class="legal" id="footer'+ (i+1) +'">' + product.footers[i] + '</p>';
printText += '<p class="legal">' + product.footers[i] + '</p>';
}
if (product.footers.length == 0) {
text += '<p class="legal">&#160;</p>';
}
this.text.update(text);
if (product.links.length > 0) {
var learning = '<ul id="lrnRsc_sm">';
var end = product.links.length-1;
for (var i=0; i<product.links.length; i++) {
var rec = product.links[i];
var thisClass = (i==end) ? 'last ' : '';
var recURL = rec.url;
thisClass += rec.type;
if (rec.type == 'lf_calc') {
learning += '<li class="calc"><a href="#" onclick="tools.loadTemplate(\'' + rec.url + '\'); engine.hideDetail(); return false">' + rec.text + '</a></li>';
}
else {
learning += '<li class="'+ thisClass +'"><a href="#" onclick="openInParent(\'' + recURL + '\', \''+ this.pageID + '\'); return false">'+ rec.text +'</a></li>';
}
}
learning += '</ul>';
this.resources.update(learning);
this.resourceContainer.show();
}
else {
this.resourceContainer.hide();
}
var cta = '';
if (product.learn != '') {
var learnURL = buildCMLink(product.learn, this.promoCode);
cta += '<div class="ctaBtn" onclick="openInParent(\''+ learnURL +'\', \''+ this.pageID + '\'); return false"><img src="images/ctaBtn_lft.gif" alt="" class="ctaBtn_lft" width="26" height="20"><img src="images/ctaBtn_rt.gif" alt="" class="ctaBtn_rt" width="28" height="20"><a href="#" onclick="return false">Learn More</a></div>';
}
if ((product.cta != '') && (product.cta.text != '')) {
var ctaURL = buildCMLink(product.cta.url, this.promoCode);
cta += '<div class="ctaBtn" onclick="openInParent(\''+ ctaURL + '_Apply' + '\', \''+ this.pageID + '\'); return false"><img src="images/ctaBtn_lft.gif" alt="" class="ctaBtn_lft" width="26" height="20"><img src="images/ctaBtn_rt.gif" alt="" class="ctaBtn_rt" width="28" height="20"><a href="#" onclick="return false">'+ product.cta.text +'</a></div>';
}
this.cta.update(cta);
this.slidetrack.hide();
this.detailWrapper.setStyle({ 'top': top + 'px' });
if (this.showProduct > 0) {
this.detailContainer.hide();
this.detailContainer.show();
this.showProduct = 0;
}
else if (this.isIE55 == true) {
this.detailContainer.show();
new ViewDetailScroller(this.isIE55);
}
else {
new Effect.Expand(this.detailContainer, {afterFinish: function() { new ViewDetailScroller(this.isIE55); }});
}
var printDoc = printContainer.document;
printDoc.getElementById('product_name').innerHTML = printTitle;
printDoc.getElementById('summary').innerHTML = printSummary;
printDoc.getElementById('cta').innerHTML = printCTA;
printDoc.getElementById('text').innerHTML = printText;
printDoc.getElementById('resources').innerHTML = printResc;
},
hide: function() {
if (this.showProduct == 0) {
if (this.isIE55 == true) {
this.detailContainer.hide();
}
else {
new Effect.Collapse(this.detailContainer);
}
}
},
scrollTo: function(footerNum) {
var footer = $('footer' + footerNum);
if (this.slidetrack.visible()) {
var topY = (footer.offsetTop - $('textArea').offsetHeight + 15);
var barMult = 140 / (this.text.offsetHeight - $('textArea').offsetHeight);
var barTopY = topY * barMult;
if (topY > 0) {
new Effect.Move (this.text, { x: 0, y: -topY, mode: 'absolute' });
new Effect.Move (this.slider, { x: 2, y: barTopY, mode: 'absolute' });
}
}
},
setScrollBar: function() {
var curTop = parseInt(this.text.style.top || '0');
var barMult = 140 / (this.text.offsetHeight - $('textArea').offsetHeight);
this.slider.setStyle({ 'top': -(curTop * barMult) + 'px' });
}
}
var ViewDetailScroller = Class.create();
ViewDetailScroller.prototype = {
initialize: function(IE55) {
this.wrapper = $('detail_container');
this.text = $('text');
this.sliderbox = $('scrollbox');
this.slidetrack = $('scrollbar');
this.upArrow = $('scrollup');
this.dnArrow = $('scrolldwn');
this.moveStep = 5;
this.isIE55 = IE55;
this.scrollDir;
this.offsetY;
this.timer;
this.Slider;
this.offsetY = this.text.offsetHeight;
this.textOffsetY = $('textArea').offsetHeight;
this.text.style.top = '0px';
this.scrollMult = (this.offsetY - this.textOffsetY) / 140;
this.barMult = 140 / (this.offsetY - this.textOffsetY);
if (this.offsetY < 160) {
this.slidetrack.hide();
}
else {
this.slidetrack.show();
this._buildScroller();
}
},
scrollUp: function() {
this.scrollDir = 'up';
this.timer = setInterval(this._doScroll.bind(this), 50);
},
scrollDn: function() {
this.scrollDir = 'down';
this.timer = setInterval(this._doScroll.bind(this), 50);
},
stopScroll: function() {
window.clearInterval(this.timer);
},
_buildScroller: function() {
this.upArrow.onmousedown = this.scrollUp.bind(this);
this.upArrow.onmouseup = this.stopScroll.bind(this);
this.dnArrow.onmousedown = this.scrollDn.bind(this);
this.dnArrow.onmouseup = this.stopScroll.bind(this);
if (this.isIE55 != true) {
new Control.Slider(this.sliderbox, this.slidetrack, { minimum:0, maximum:160, axis: 'vertical', increment: 4, onSlide: this._doDrag.bind(this), onChange: this._doDrag.bind(this) });
}
},
_doDrag: function(v) {
this.text.setStyle({ 'top': (($('textArea').offsetHeight - this.offsetY) * v) + 'px' });
},
_doScroll: function() {
if (this.scrollDir == 'up') {
this._scrollUp();
}
else if (this.scrollDir == 'down') {
this._scrollDn();
}
},
_scrollUp: function() {
var curTop = (this.text.style.top == null) ? 0 : parseInt(this.text.style.top);
if (curTop < 0) {
curTop = curTop + this.moveStep;
this.text.setStyle({ 'top': curTop + 'px' });
if ((curTop * this.barMult) > 0) {
this.sliderbox.setStyle({ 'top': '0px' });
}
else {
this.sliderbox.setStyle({ 'top': -(curTop * this.barMult) + 'px' });
}
}
},
_scrollDn: function() {
var curTop = (this.text.style.top == null) ? 0 : parseInt(this.text.style.top);
var newTop;
if (curTop > ($('textArea').offsetHeight - this.offsetY)) {
curTop = curTop - this.moveStep;
newTop = ((curTop * this.barMult) < -140) ? '140' : (-(curTop * this.barMult));
this.text.setStyle({ 'top': curTop + 'px' });
this.sliderbox.setStyle({ 'top': newTop + 'px' });
}
}
}
var Tooltip = Class.create();
Tooltip.prototype = {
initialize: function(element) {
this.tool;
this.arrow;
this.shadow;
this.content;
this.container = $(element);
this.dims = this.container.getDimensions();
this.arrows = new Array();
this.activeArrow = '';
this.tipsOn = false;
this.isOn = false;
this.timer;
this.ttHeight;
this.ttWidth;
this.toolX;
this.toolY;
this.midX = this.container.offsetWidth/2 + (this.container.style.left ? parseInt(this.container.style.left) : 0);
this.midY = this.container.offsetHeight/2 + (this.container.style.top ? parseInt(this.container.style.top) : 0);
this._initTool();
this.hide();
},
show: function(e, text, now) {
this.toolX = Event.pointerX(e);
this.toolY = Event.pointerY(e);
this.content.innerHTML = text;
this.tool.style.display = 'block';
if ((this.toolX < this.midX) && (this.toolY < this.midY)) {
this.activeArrow = 0;
this.offsetX = -4;
this.offsetY = 24;
}
else if ((this.toolX >= this.midX) && (this.toolY < this.midY)) {
this.activeArrow = 1;
this.offsetX = -this.tool.offsetWidth;
this.offsetY = 24;
}
else if ((this.toolX < this.midX) && (this.toolY >= this.midY)) {
this.activeArrow = 2;
this.offsetX = -4;
this.offsetY = -this.tool.offsetHeight - 21;
}
else {
this.activeArrow = 3;
this.offsetX = -this.tool.offsetWidth;
this.offsetY = -this.tool.offsetHeight - 21;
}
this.arrow.innerHTML = this.arrows[this.activeArrow];
this.tool.style.display = 'none';
if (now) {
this._appear(now);
}
else {
this.timer = setInterval(this._appear.bind(this), 750);
}
},
hide: function() {
window.clearInterval(this.timer);
this.tool.style.display = 'none';
this.tool.style.top = -1000 + 'px';
this.tool.style.left = -1000 + 'px';
this.isOn = false;
},
move: function(e) {
this.toolX = Event.pointerX(e);
this.toolY = Event.pointerY(e);
},
toggle: function() {
this.tipsOn = (this.tipsOn == true) ? false : true;
return this.tipsOn;
},
_appear: function(now) {
window.clearInterval(this.timer);
if ((this.tipsOn == true) || (now == true)) {
this.tool.style.display = 'block';
this.isOn = true;
this._position();
}
},
_position: function() {
this.tool.style.left = (this.toolX + this.offsetX) + 'px';
this.tool.style.top = (this.toolY + this.offsetY) + 'px';
},
_initTool: function() {
var node = document.createElement('div');
node.id = 'tooltipDialog';
node.innerHTML =
'<div id="ttCornersTop"><img class="png" src="./images/tt_shadow_top.png" width="215" height="10"/></div>' +
'<div id="ttShadowMiddle">' +
'<div id="ttContentArea"> </div>' +
'</div>' +
'<div id="ttShadowBtm"><img class="png" src="./images/tt_shadow_bottom.png" width="215" height="11"/></div>' +
'<div id="arrowWrapper"> </div>';
this.container.appendChild(node);
this.tool = $('tooltipDialog');
this.arrow = $('arrowWrapper');
this.content = $('ttContentArea');
this.arrows.push('<img id="ttArrowTL" class="ttArrow" src="./images/tt_arrow_tl.png" width="40" height="25"/>');
this.arrows.push('<img id="ttArrowTR" class="ttArrow" src="./images/tt_arrow_tr.png" width="40" height="25"/>');
this.arrows.push('<img id="ttArrowBL" class="ttArrow" src="./images/tt_arrow_bl.png" width="40" height="28"/>');
this.arrows.push('<img id="ttArrowBR" class="ttArrow" src="./images/tt_arrow_br.png" width="40" height="28"/>');
}
}
var StandardSlider = Class.create();
StandardSlider.prototype = {
initialize: function(handle, track, display, mult, start, showDecimal) {
this.display = $(display);
this.mult = (mult != null) ? mult : 100;
this.start = (start != null) ? start : 0;
this.showDecimal = (showDecimal == true) ? true : false;
this.slider = new Control.Slider(handle, track, {axis:'horizontal', sliderValue: this.start, range: $R(0, this.mult), onSlide: this.updateDisplay.bind(this), onChange: this.updateDisplay.bind(this) });
this.display.onchange = this.updateSlider.bind(this);
this.isFree = true;
if (this.showDecimal) {
this.display.value = Math.round(this.start * 100)/100;
}
else {
this.display.value = this.start;
}
},
get: function() {
return this.display.value;
},
set: function(val) {
this.slider.setValue(val);
},
reset: function() {
this.slider.setValue(this.start);
},
updateDisplay: function(val) {
if (this.isFree) {
if (this.showDecimal) {
this.display.value = Math.round(val * 100)/100;
}
else {
this.display.value = Math.round(val);
}
}
this.isFree = true;
},
updateSlider: function(e) {
var val = this.display.value;
this.isFree = false;
this.slider.setValue(val);
}
}
var DynamicSlider = Class.create();
DynamicSlider.prototype = {
initialize: function(handle, track, display, start, mult, step) {
this.display = $(display);
this.mult = (mult != null) ? mult : 100;
this.step = (step != null) ? step : 5;
this.start = (start != null) ? start : 0;
this.slider = new Control.Slider(handle, track, {axis:'horizontal', onSlide: this.updateDisplay.bind(this), onChange: this.snapSlider.bind(this) });
this.set(this.start/this.mult);
this.display.value = this.start;
this.display.onchange = this.updateSlider.bind(this);
this.timer;
this.isFree = true;
},
get: function() {
return this.display.value;
},
set: function(val) {
this.slider.setValue(val);
},
reset: function() {
this.slider.setValue(this.start);
},
updateDisplay: function(val) {
if (val >= .90) {
clearTimeout(this.timer);
this.timer = setTimeout(this.incrementMult.bind(this), 20);
}
else if (val < .90) {
clearTimeout(this.timer);
val *= 10/9;
this.display.value = Math.round(val*this.mult);
}
},
snapSlider: function(val) {
if (this.isFree) {
if (val > .90) {
val = .90;
this.set(val);
this.isFree = false;
}
val *= 10/9;
this.display.value = Math.round(val*this.mult);
}
this.isFree = true;
},
incrementMult: function() {
if (this.slider.active) {
this.mult += this.step;
this.display.value = Math.round(this.slider.value*this.mult);
this.slider.setValue(1);
this.timer = setTimeout(this.incrementMult.bind(this), 100);
}
else {
this.slider.setValue(.90);
}
},
updateSlider: function(e) {
var val = this.display.value / this.mult;
val = (val > .90) ? .90 : val;
this.isFree = false;
this.slider.setValue(val);
}
}
var DoubleSlider = Class.create();
DoubleSlider.prototype = {
initialize: function(handle1, handle2, track, display1, display2, mult1, mult2, start1, start2) {
this.display1 = $(display1);
this.display2 = $(display2);
this.mult1 = (mult1 != null) ? mult1 : 100;
this.mult2 = (mult2 != null) ? mult2 : 100;
this.start1 = (start1 != null) ? start1 : 0;
this.start2 = (start2 != null) ? start2 : 0;
this.slider1 = new Control.Slider(handle1, track, {axis:'horizontal', sliderValue: this.start1, onSlide: this.updateDisplay1.bind(this) });
this.slider2 = new Control.Slider(handle2, track, {axis:'horizontal', sliderValue: this.start2, onSlide: this.updateDisplay2.bind(this) });
this.display1.onchange = this.updateSlider1.bind(this);
this.display1.onchange = this.updateSlider2.bind(this);
this.display1.value = this.mult1 * this.start1;
this.display2.value = this.mult2 * this.start2;
},
get1: function() {
return this.display1.value;
},
get2: function() {
return this.display2.value;
},
set1: function(val) {
this.slider1.setValue(val1);
},
set2: function(val) {
this.slider2.setValue(val);
},
reset: function() {
this.slider1.setValue(this.start1);
this.slider2.setValue(this.start2);
},
updateDisplay1: function(val) {
this.display1.value = Math.round(val*this.mult1);
},
updateDisplay2: function(val) {
this.display2.value = Math.round(val*this.mult2);
},
updateSlider1: function(e) {
var val = this.display1.value / this.mult1;
this.slider1.setValue(val);
},
updateSlider2: function(e) {
var val = this.display2.value / this.mult2;
this.slider2.setValue(val);
}
}
var DoubleDynamicSlider = Class.create();
DoubleDynamicSlider.prototype = {
initialize: function(handle1, handle2, track, display1, display2, start1, start2, mult, step) {
this.display1 = $(display1);
this.display2 = $(display2);
this.step = (step != null) ? step : 10;
this.mult = (mult != null) ? mult : 100;
this.start1 = (start1 != null) ? start1 : 0;
this.start2 = (start2 != null) ? start2 : 0;
this.slider1 = new Control.Slider(handle1, track, {axis:'horizontal', sliderValue: this.start1, onSlide: this.updateDisplay1.bind(this), onChange: this.snapSlider1.bind(this) });
this.slider2 = new Control.Slider(handle2, track, {axis:'horizontal', sliderValue: this.start2, onSlide: this.updateDisplay2.bind(this), onChange: this.snapSlider2.bind(this) });
this.set1(this.start1/this.mult);
this.set2(this.start2/this.mult);
this.display1.value = this.start1;
this.display2.value = this.start2;
this.display1.onchange = this.updateSlider1.bind(this);
this.display2.onchange = this.updateSlider2.bind(this);
this.isFree = true;
this.timer1;
this.timer2;
},
get1: function() {
return this.display1.value;
},
get2: function() {
return this.display2.value;
},
set1: function(val) {
this.slider1.setValue(val);
},
set2: function(val) {
this.slider2.setValue(val);
},
reset: function() {
this.slider1.setValue(this.start1);
this.slider2.setValue(this.start2);
},
updateDisplay1: function(val) {
if (val >= .90) {
clearTimeout(this.timer1);
this.timer1 = setTimeout(this.incrementMult1.bind(this), 20);
}
else if (val < .90) {
clearTimeout(this.timer1);
val *= 10/9;
this.display1.value = Math.round(val*this.mult);
}
},
updateDisplay2: function(val) {
if (val >= .90) {
clearTimeout(this.timer2);
this.timer = setTimeout(this.incrementMult2.bind(this), 20);
}
else if (val < .90) {
clearTimeout(this.timer2);
val *= 10/9;
this.display2.value = Math.round(val*this.mult);
}
},
snapSlider1: function(val) {
if (this.isFree) {
if (val > .90) {
val = .90;
this.set1(val);
this.isFree = false;
}
val *= 10/9;
this.display1.value = Math.round(val*this.mult);
}
this.isFree = true;
},
snapSlider2: function(val) {
if (this.isFree) {
if (val > .90) {
val = .90;
this.set2(val);
this.isFree = false;
}
val *= 10/9;
this.display2.value = Math.round(val*this.mult);
}
this.isFree = true;
},
incrementMult1: function() {
if (this.slider1.active) {
this.mult += this.step;
this.display1.value = Math.round(this.slider1.value*this.mult);
this.slider1.setValue(1);
this.timer = setTimeout(this.incrementMult1.bind(this), 100);
}
else {
this.slider1.setValue(.90);
}
},
incrementMult2: function() {
if (this.slider2.active) {
this.mult += this.step;
this.display2.value = Math.round(this.slider2.value*this.mult);
this.slider2.setValue(1);
this.timer = setTimeout(this.incrementMult2.bind(this), 100);
}
else {
this.slider2.setValue(.90);
}
},
updateSlider1: function(e) {
var val = this.display1.value / this.mult;
val = (val > .90) ? .90 : val;
this.isFree = false;
this.slider1.setValue(val);
},
updateSlider2: function(e) {
var val = this.display2.value / this.mult;
val = (val > .90) ? .90 : val;
this.isFree = false;
this.slider2.setValue(val);
}
}
var IncSlider = Class.create();
IncSlider.prototype = {
initialize: function(handle, track, display, start, inputVals) {
this.handle = $(handle);
this.display = $(display);
this.values = inputVals;
this.start = (start != null) ? start : values[0];
this.slider = new Control.Slider(handle, track, {axis:'horizontal', range: $R(this.values[0],this.values[this.values.length-1]), alignx: 0, sliderValue: this.start, values: inputVals, onSlide: this.updateDisplay.bind(this), onChange: this.updateDisplay.bind(this) });
this.display.onchange = this.updateSlider.bind(this);
this.display.value = this.start;
},
get: function() {
return this.display.value;
},
set: function(val) {
this.slider.setValue(val);
},
reset: function() {
this.slider.setValue(this.start);
},
updateDisplay: function(val) {
this.display.value = val;
},
updateSlider: function(e) {
var val = this.display.value;
this.slider.setValue(val);
}
}
var ContentBox = Class.create();
ContentBox.prototype = {
initialize: function(topbar, display, content, options ) {
this.topbar = $(topbar);
this.display = $(display);
this.content = $(content);
this.options = options || {};
this.topbarOpenClass = this.options.topbarOpenClass || 'open';
this.topbarClosedClass = this.options.topbarOpenClass || 'closed';
this.displayOpenClass = this.options.displayOpenClass || 'open';
this.displayClosedClass = this.options.displayClosedClass || 'closed';
this.callback = this.options.callback || null;
this.state = this.options.state || 'open';
this.next = this.state;
this.topbarClass = this.topbar.className;
this.displayClass = this.display.className;
this.topbar.onclick = this.toggle.bind(this);
this._setState();
this.isDone = true;
},
toggle: function() {
if (this.state == 'closed') {
this.state = 'locked';
this.next = 'open';
this.display.className = this.displayClass + ' ' + this.displayOpenClass;
Effect.BlindDown(this.display, {duration: .3, afterFinish: this._moveDone.bind(this)});
}
else if (this.state == 'open') {
this.state = 'locked';
this.next = 'closed';
Effect.BlindUp(this.display, {duration: .3, afterFinish: this._moveDone.bind(this)});
}
},
setTitle: function(data) {
this.topbar.innerHTML = '<h2>' + data + '</h2>';
},
setContent: function(data) {
this.content.innerHTML = data;
},
getContent: function() {
return this.content.innerHTML;
},
_moveDone: function() {
this.state = this.next;
this._setState();
},
_setState: function() {
if (this.state == 'open') {
this.topbar.className = this.topbarClass + ' ' + this.topbarOpenClass;
this.display.className = this.displayClass + ' ' + this.displayOpenClass;
}
else if (this.state == 'closed') {
this.topbar.className = this.topbarClass + ' ' + this.topbarClosedClass;
this.display.className = this.displayClass + ' ' + this.displayClosedClass;
}
if (this.isDone) {
tools.initScroll();
}
this.isDone = true;
}
}
var ToolsEngine = Class.create();
ToolsEngine.prototype = {
initialize: function(url) {
var baseRequest = new AjaxRequest({ baseURL: url, onError: this.requestError.bind(this) });
var toolRequest = new AjaxRequest({ baseURL: '', handler: 'dispatch', onError: this.requestError.bind(this) });
baseRequest.registerHandler('content', this);
toolRequest.registerHandler('lf_calc', this);
toolRequest.registerHandler('lf_glossary', this);
this.baseRequest = baseRequest;
this.toolRequest = toolRequest;
this.data = '';
this.view = '';
this.toolID = '';
this.leftColBoxes = new Array();
this.rightColBox;
this.sessionID = '';
this.proxyBaseURL = '/tools';
this.mainTemplate = '/templates/tools_main.xml';
this.toolsURL = this.proxyBaseURL + '/bofa-ria/';
this.savedPageID = '';
this.activeRequest = false;
this.showTool = 0;
},
requestError: function() {
this.view.setStatus('ERROR: Server Timeout');
},
start: function(tool) {
this.showTool = tool;
this.baseRequest.sendRequest( this.mainTemplate );
},
loadTemplate: function(toolID) {
if (this.view.isShowing) {
this.view.fadeColumns();
}
else {
this.savedPageID = engine.lastPageID;
}
this.toolID = toolID;
this.view.setStatus('Loading template...');
var url = '/templates/tool_' + this.toolID + '.xml';
this.baseRequest.sendRequest( url );
var pageID = 'Calculator ' + toolID + ' initial';
var catID = ['Calculator', toolID];
CM_logPageView(engine.lastPageID, pageID, catID);
engine.lastPageID = pageID;
},
loadGlossary: function() {
var url;
this.view.setStatus('Loading glossary...');
if (this.data.sessionID == '') {
url = this.toolsURL + this.toolID + '/tool.fcs?glossaryxml';
}
else {
url = this.toolsURL + this.toolID + '/tool.fcs;jsessionid=' + this.data.sessionID + '?glossaryxml';
}
this.toolRequest.sendRequest( url );
},
loadHelp: function() {
var url;
this.view.setStatus('Loading help...');
if (this.data.sessionID == '') {
url = this.toolsURL + this.toolID + '/tool.fcs?xmlonly&toolpage=help';
}
else {
url = this.toolsURL + this.toolID + '/tool.fcs;jsessionid=' + this.data.sessionID + '?xmlonly&toolpage=help';
}
this.toolRequest.sendRequest( url );
},
loadTool: function() {
var url;
this.view.setStatus('Loading calculator...');
if (this.data.sessionID == '') {
url = this.toolsURL + this.toolID + '/tool.fcs?xmlonly&toolpage=initial';
}
else {
url = this.toolsURL + this.toolID + '/tool.fcs;jsessionid=' + this.data.sessionID + '?xmlonly&toolpage=initial';
}
this.toolRequest.sendRequest( url );
},
dispatch: function(resp) {
var objectID = resp.getAttribute('id');
if (objectID == 'lf_glossary') {
this.data.parseGlossary(resp);
this.loadHelp();
}
else if (objectID == 'lf_calc') {
var state = resp.getElementsByTagName('page')[0].getAttribute('name');
if (state == 'help') {
this.data.parseHelp(resp);
this.loadTool();
}
else if (state == 'initial') {
this.data.parseInit(resp);
this.view.initTool(this.data);
this.view.hideStatus();
}
else if (state == 'results') {
this.data.parseResult(resp);
this.view.showResult(this.data);
}
else {
this.data.parseError(resp);
}
}
else {
alert('ERROR: Invalid Object ID');
}
this.activeRequest = false;
},
container: function(resp) {
$('tools_container').innerHTML = RicoUtil.getContentAsString( resp );
if ((this.data == '') || (this.view == '')) {
var data = new ToolsData();
var view = new ToolsView(this.proxyBaseURL);
this.data = data;
this.view = view;
}
},
toolTemplate: function(resp) {
this.data.storeToolTemplate( RicoUtil.getContentAsString( resp ) );
this.loadGlossary();
},
resultTemplate: function(resp) {
this.data.storeResultTemplate( RicoUtil.getContentAsString( resp ) );
},
tipContent: function(resp) {
this.data.parseTip( RicoUtil.getContentAsString( resp ) );
},
legalContent: function(resp) {
this.data.parseLegal( RicoUtil.getContentAsString( resp ) );
},
extraGlossary: function(resp) {
this.data.parseExtraGlossary( resp );
},
getResults: function() {
if (this.activeRequest == false) {
var url = this.toolsURL + this.toolID + '/tool.fcs;jsessionid=' + this.data.sessionID + '?xmlonly&toolpage=results&submittingPage=initial';
var formStr;
this.activeRequest = true;
if (this.data.toolID == 'budget03') {
formStr = this.getBudget03();
}
else if (this.data.toolID == 'creditline01') {
formStr = this.getCreditline01();
}
else if (this.data.toolID == 'creditline02') {
formStr = this.getCreditline02();
}
else {
formStr = $('calcForm').serialize();
}
url += '&' + formStr;
this.toolRequest.sendRequest( url );
this.view.showLoading();
var pageID = 'Calculator ' + this.toolID + ' results';
var catID = ['Calculator', this.toolID];
CM_logPageView(engine.lastPageID, pageID, catID);
engine.lastPageID = pageID;
}
},
getBudget03: function() {
var currentTotal = 0;
var desiredTotal = 0;
for (var i=0; i<this.data.special; i++) {
currentTotal += $F('Miscellaneous_current' + i);
desiredTotal += $F('Miscellaneous_desired' + i);
}
formStr = $('calcForm').serialize(true);
formStr['Miscellaneous_current'] = parseInt(formStr['Miscellaneous_current']) + parseInt(currentTotal);
formStr['Miscellaneous_desired'] = parseInt(formStr['Miscellaneous_desired']) + parseInt(desiredTotal);
formStr = $H(formStr).toQueryString();
return formStr;
},
getCreditline01: function() {
var ltv = parseInt($F('LTV1'));
if (ltv > 95) {
$('LTV2').value = ltv-5;
$('LTV3').value = ltv-10;
$('LTVUsr').value = ltv-15;
}
else if (ltv > 90) {
$('LTV2').value = ltv+5;
$('LTV3').value = ltv-5;
$('LTVUsr').value = ltv-10;
}
else if (ltv < 5) {
$('LTV2').value = ltv+5;
$('LTV3').value = ltv+10;
$('LTVUsr').value = ltv+15;
}
else {
$('LTV2').value = ltv+5;
$('LTV3').value = ltv+10;
$('LTVUsr').value = ltv-5;
}
formStr = $('calcForm').serialize();
return formStr;
},
getCreditline02: function() {
formStr = $('calcForm').serialize(true);
for (var i=0; i<this.data.maxLoans; i++) {
if (this.data.loans['loan'+i] == null) {
formStr['ODebts'+i] = 0;
formStr['OMonPmt'+i] = 0;
formStr['OMonLeft'+i] = 0;
}
}
for (var i=0; i<this.data.maxCredit; i++) {
if (this.data.credit['credit'+i] == null) {
formStr['CDebt'+i] = 0;
formStr['CRate'+i] = 0;
}
}
formStr = $H(formStr).toQueryString();
return formStr;
},
showGraphs: function(num) {
this.view.showGraphs(this.data, num);
},
showTables: function(num, page) {
this.view.showTables(this.data, num, page);
},
showRows: function() {
this.view.toggleRowDisplay(this.data);
},
hide: function() {
engine.lastPageID = this.savedPageID;
this.view.hide();
},
initScroll: function() {
this.view.scroller.configure();
},
addDebtItem: function() {
var loanType = $F('loanType');
var loanName = $F('loanName');
if (this.data.checkDebtCount(loanType) == false) {
$('loanType').parentNode.className = 'fieldWrapper error';
}
else if ((loanType == '') || (loanName == '')) {
$('loanType').parentNode.className = (loanType == '') ? 'fieldWrapper error' : 'fieldWrapper';
$('loanName').parentNode.parentNode.className = (loanName == '') ? 'fieldWrapper error' : 'fieldWrapper';
this.data.removeDebtItem(loanType);
}
else {
var pos = this.data.addDebtItem(loanType);
$('loanType').parentNode.className = 'fieldWrapper';
$('loanName').parentNode.parentNode.className = 'fieldWrapper';
this.view.buildDebtItem(loanType, loanName, pos);
if ((this.data.loans.keys().length + this.data.credit.keys().length) > 1) {
this.view.showDebtDetail();
}
else {
this.view.hideDebtDetail();
}
$('loanName').value = '';
$('loanTypeNone').selected = true;
if (this.data.loans.keys().length >= this.data.maxLoans) {
$('loanTypeLoan').disabled = true;
}
else {
$('loanTypeLoan').disabled = false;
}
if (this.data.credit.keys().length >= this.data.maxCredit) {
$('loanTypeCredit').disabled = true;
$('loanTypeOther').disabled = true;
}
else {
$('loanTypeCredit').disabled = false;
$('loanTypeOther').disabled = false;
}
}
},
showAddDebt: function() {
this.view.appearAddDebt();
},
removeDebtItem: function(node, loanType, pos) {
this.view.removeDebtBox(node);
this.data.removeDebtItem(loanType, pos);
if ((this.data.loans.keys().length + this.data.credit.keys().length) > 1) {
this.view.showDebtDetail();
}
else {
this.view.hideDebtDetail();
}
},
glossary: function(key) {
return this.data.glossary[key];
},
print: function() {
var container = printCalc.document.getElementById('printContent');
this.view.print(this.data, container);
printCalc.focus();
printCalc.print();
}
}
var ToolsData = Class.create();
ToolsData.prototype = {
initialize: function(url) {
this.toolID;
this.sessionID = '';
this.mainTitle = '';
this.subTitle = '';
this.template = '';
this.label = '';
this.fieldHash = {};
this.fields = new Array();
this.results = new Array();
this.textResults = new Array();
this.graphs = new Array();
this.tables = new Array();
this.errors = new Array();
this.help = new Array();
this.extras = new Array();
this.special = 0;
this.meta = {};
this.tip = '';
this.legal = '';
this.errorHeader = '';
this.tableTitle = '';
this.graphTitle = '';
this.glossary = {};
this.maxLoans = 5;
this.maxCredit = 5;
this.loans = $H({});
this.credit = $H({});
},
parseInit: function(resp) {
this.toolID = resp.getAttribute('name');
this.sessionID = resp.getAttribute('jsessionid');
this.mainTitle = resp.getElementsByTagName('tool')[0].getAttribute('title');
this.subTitle = resp.getElementsByTagName('page')[0].getAttribute('title');
this.fieldHash = {};
this.fields = [];
this.errors = [];
this.errorHeader = '';
this.isInit = (resp.getElementsByTagName('page')[0].getAttribute('name') == 'initial') ? true : false;
var meta = resp.getElementsByTagName('dataDictionaryItem');
if (this.isInit) {
this.meta = {};
this.loanCount = 0;
this.creditCount = 0;
for (var i=0; i<meta.length; i++) {
var obj = new Object();
obj.name = meta[i].getAttribute('name');
obj.defaultValue = meta[i].getAttribute('defaultValue');
obj.minValue = meta[i].getAttribute('minValue');
obj.maxValue = meta[i].getAttribute('maxValue');
obj.format = meta[i].getAttribute('dataFormat');
this.meta[obj.name] = obj;
}
}
var rows = resp.getElementsByTagName('item');
for (var i=0; i<rows.length; i++) {
if (rows[i].getAttribute('itemType') == 'field') {
var item = rows[i];
var field = new Object();
field.dataName = (item.getAttribute('toolDataName') != null) ? item.getAttribute('toolDataName') : '';
field.dataType = (item.getAttribute('type') != null) ? item.getAttribute('type') : '';
field.postfix = (item.getAttribute('postFieldDisplay') != null) ? item.getAttribute('postFieldDisplay') : '';
field.prefix = (item.getAttribute('preFieldDisplay') != null) ? item.getAttribute('preFieldDisplay') : '';
if (item.getAttribute('filteredLabel') != null) {
field.fieldLabel = item.getAttribute('filteredLabel');
}
else {
field.fieldLabel = (item.getAttribute('rawLabel') != null) ? item.getAttribute('rawLabel') : '';
}
field.glossaryKey = (item.getAttribute('glossaryKey') != null) ? rows[i].getAttribute('glossaryKey') : '';
field.postDisplay = (item.getAttribute('postFieldDisplay') != null) ? item.getAttribute('postFieldDisplay') : '';
field.value = item.getAttribute('value');
field.error = (item.parentNode.getAttribute('invalid') != null) ? true : false;
field.doInit = true;
if (this.meta[field.dataName] != null) {
var obj = this.meta[field.dataName];
field.defaultValue = obj.defaultValue;
field.minValue = obj.minValue;
field.maxValue = obj.maxValue;
field.format = obj.format;
}
this.fields.push(field);
this.fieldHash[field.dataName] = field;
}
}
var errors = resp.getElementsByTagName('errorMessage');
if (errors.length > 0) {
this.errorHeader = resp.getElementsByTagName('errorMessages')[0].getAttribute('label');
for (var i=0; i<errors.length; i++) {
this.errors.push(errors[i].getAttribute('label'));
}
}
this[this.toolID](resp);
},
parseHelp: function(resp) {
var items = resp.getElementsByTagName('item');
this.help = [];
for (var i=0; i<items.length; i++) {
if (items[i].getAttribute('itemType') == 'textLabel') {
if (items[i].getAttribute('fullLabel') != null) {
this.help.push(items[i].getAttribute('fullLabel'));
}
}
}
},
parseResult: function(resp) {
this.errorHeader = '';
this.errors = '';
this.parseCommon(resp);
if (this.toolID == 'creditline01') {
this.resultsCreditline01(resp);
}
},
parseCommon: function(resp) {
this.graphs = [];
this.tables = [];
this.label = resp.getElementsByTagName('fieldLayout')[1].getAttribute('label');
this._parseResultsBase(resp);
var graphXML = resp.getElementsByTagName('graph')[0];
var graphObj = new Object();
graphObj.name = graphXML.getAttribute('name');
graphObj.title = resp.getElementsByTagName('title')[0].firstChild.nodeValue;
this.graphTitle = resp.getElementsByTagName('title')[0].firstChild.nodeValue;
graphObj.text = this._getGraphText(resp, graphObj.name + '.Text1');
graphObj.graphSessionID = graphXML.getAttribute('graphUuid');
graphObj.param = graphXML.getElementsByTagName('param')[0].firstChild.nodeValue;
this.graphs.push(graphObj);
var tableList = resp.getElementsByTagName('table');
for (var k=0; k<tableList.length; k++) {
var tableXML = tableList[k];
var scrollClass = (tableXML.getAttribute('scrollableClass') != null) ? tableXML.getAttribute('scrollableClass') : '';
var type = (tableXML.getAttribute('type') != null) ? tableXML.getAttribute('type') : '';
if ((type == 'formatted') && (scrollClass == 'scrollable')) {
var tableObj = new Object();
tableObj.rowDisplay = tableXML.getAttribute('rowDisplay');
tableObj.rowCount = tableXML.getAttribute('rowCount');
tableObj.title = tableXML.getElementsByTagName('title')[0].firstChild.nodeValue;
tableObj.data = new Array();
var columns = tableXML.getElementsByTagName('columnNames')[0].getElementsByTagName('name');
var colList = new Array();
for (var i=0; i<columns.length; i++) {
var name = columns[i].firstChild.nodeValue;
colList.push(name);
}
tableObj.columns = colList;
var rows = tableXML.getElementsByTagName('row');
for (var i=0; i<rows.length; i++) {
var data = rows[i].getElementsByTagName('data');
var row = new Array();
for (var j=0; j<data.length; j++) {
row.push(data[j].firstChild.nodeValue);
}
tableObj.data.push(row);
}
this.tables.push(tableObj);
}
}
},
home02: function(resp) {
},
auto05: function(resp) {
var fields = this.fields;
for (var i=0; i<fields.length; i++) {
if (fields[i].dataName == 'LoanTerm') {
fields[i].range = [0, 12, 24, 36, 48, 60, 72];
}
}
},
budget03: function(resp) {
},
budget05: function(resp) {
},
creditline01: function(resp) {
var fields = this.fields;
for (var i=0; i<fields.length; i++) {
if (fields[i].dataName == 'LTV1') {
fields[i].range = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100];
}
}
},
creditline02: function(resp) {
var optionList = resp.getElementsByTagName('option');
var options = new Array();
for (var i=0; i<optionList.length; i++) {
var context = (optionList[i].getAttribute('parentName') != null) ? optionList[i].getAttribute('parentName') : '';
if (context == 'LoanTyp') {
var obj = new Object();
obj.dataName = optionList[i].getAttribute('name');
obj.fieldLabel = optionList[i].getAttribute('fullLabel');
obj.glossaryKey = optionList[i].getAttribute('glossaryKey');
obj.selected = optionList[i].getAttribute('selected');
}
}
},
savings01: function(resp) {
},
savings03: function(resp) {
var fields = this.fields;
for (var i=0; i<fields.length; i++) {
if (fields[i].dataName == 'TermSavings') {
fields[i].range = [6, 12, 18, 24, 30, 36, 42, 48, 64, 60, 66, 72, 78, 84, 90];
}
}
},
resultsCreditline01: function(resp) {
var items = resp.getElementsByTagName('item');
var rows = new Array();
var totals = new Array();
var count = 0;
for (var i=0; i<items.length; i++) {
var type = (items[i].getAttribute('itemType') != null) ? items[i].getAttribute('itemType') : '';
var rowClass = (items[i].getAttribute('rowClass') != null) ? items[i].getAttribute('rowClass') : '';
var obj = new Object();
if (type == 'columnTextLabel') {
obj.percent = parseFloat(items[i].getAttribute('label'));
rows.push(obj);
}
else if (rowClass == 'grandTotal') {
if (count == 0) {
rows[count].selected = true;
}
rows[count++].total = items[i].getAttribute('value');
}
}
this.extras = rows.sort( function(a,b) { return a.percent - b.percent; });
},
parseGlossary: function(resp) {
this.sessionID = resp.getAttribute('jsessionid');
var items = resp.getElementsByTagName('glossary');
for (var i=0; i<items.length; i++) {
var key = items[i].getAttribute('key');
var title = items[i].getElementsByTagName('title')[0].firstChild.nodeValue;
var def = items[i].getElementsByTagName('definition')[0].firstChild.nodeValue;
this.glossary[key] = '<b>' + title + '</b><br/>' + def;
}
},
parseTip: function(resp) {
this.tip = resp;
},
parseLegal: function(resp) {
this.legal = resp;
},
parseExtraGlossary: function(resp) {
this.glossary = {};
var items = resp.getElementsByTagName('item');
for (var i=0; i<items.length; i++) {
var key = items[i].getAttribute('key');
var title = items[i].getAttribute('title');
var def = items[i].firstChild.nodeValue;
this.glossary[key] = '<b>' + title + '</b><br/>' + def;
}
},
parseError: function(resp) {
},
_parseResultsBase: function(resp) {
this.results = [];
this.textResults = [];
var rows = resp.getElementsByTagName('item');
for (var i=0; i<rows.length; i++) {
if (rows[i].getAttribute('itemType') == 'field') {
var item = rows[i];
var field = new Object();
field.dataName = item.getAttribute('toolDataName');
field.dataType = item.getAttribute('type');
field.fieldLabel = item.getAttribute('rawLabel');
field.glossaryKey = (item.getAttribute('glossaryKey') != null) ? rows[i].getAttribute('glossaryKey') : '';
field.postfix = (item.getAttribute('postFieldDisplay') != null) ? item.getAttribute('postFieldDisplay') : '';
field.prefix = (item.getAttribute('preFieldDisplay') != null) ? item.getAttribute('preFieldDisplay') : '';
field.value = item.getAttribute('value');
this.results.push(field);
}
else if (rows[i].getAttribute('itemType') == 'textLabel') {
var item = rows[i];
var field = new Object();
field.dataName = (item.getAttribute('name') != null) ? item.getAttribute('name') : '';
field.fullLabel = (item.getAttribute('fullLabel') != null) ? item.getAttribute('fullLabel') : '';
field.rawLabel = (item.getAttribute('rawLabel') != null) ? item.getAttribute('rawLabel') : '';
this.textResults.push(field);
}
}
},
storeToolTemplate: function(tmpl) {
this.toolTemplate = tmpl;
},
storeResultTemplate: function(tmpl) {
this.resultTemplate = tmpl;
},
_getGraphText: function(node, name) {
var items = node.getElementsByTagName('item');
var result;
for (var i=0; i<items.length; i++) {
if (items[i].getAttribute('name') == name) {
result = items[i].getAttribute('fullLabel');
break;
}
}
return result;
},
checkDebtCount: function(loanType) {
if (loanType == 'loan') {
return (this.loans.keys().length < this.maxLoans) ? true : false;
}
else {
return (this.credit.keys().length < this.maxCredit) ? true : false;
}
},
addDebtItem: function(loanType) {
var pos;
if (loanType == 'loan') {
for (var i=0; i<this.maxLoans; i++) {
if (this.loans['loan'+i] == null) {
this.loans['loan'+i] = true;
pos = i
break;
}
}
}
else {
for (var i=0; i<this.maxCredit; i++) {
if (this.credit['credit'+i] == null) {
this.credit['credit'+i] = true;
pos = i
break;
}
}
}
return pos;
},
removeDebtItem: function(loanType, pos) {
var pos;
if (loanType == 'loan') {
this.loans.remove('loan'+pos);
}
else {
this.credit.remove('credit'+pos);
}
return pos;
}
}
var ToolsView = Class.create();
ToolsView.prototype = {
initialize: function(url) {
this.imageURL = url + '/ImageServlet;jsessionid=';
this.sessionID;
this.toolID;
this.fields;
this.container = $('tools_container');
this.inner = $('tools_inner');
this.title = $('tool_title');
this.lcol = $('tool_left');
this.rcol = $('tool_right');
this.status = $('status');
this.sliders = new Array();
this.leftBoxes = new Array();
this.rightBox;
this.legalBox;
this.errorBox;
this.tabState = '';
this.isInit = true;
this.isShowing = false;
this.startPos;
this.endPos;
this.currentTable = 0;
this.currentGraph = 0;
this.currentPage = 1;
this.scroller = new ToolScroller(this.inner, this.lcol, this.rcol);
},
show: function () {
$('tools_wrapper').style.display = 'block';
$('printCalc').style.display = 'none';
if (this.isShowing) {
new Effect.Appear(this.lcol, { duration: 0.3, afterFinish: this.initControls.bind(this) });
new Effect.Appear(this.rcol, { duration: 0.3 });
}
else {
if (checkIE55()) {
new Effect.Appear(this.container, { afterFinish: this.initControls.bind(this) });
}
else {
new Effect.Expand(this.container, { afterFinish: this.initControls.bind(this) });
}
}
this.isShowing = true;
},
hide: function() {
if (this.isShowing) {
if (checkIE55()) {
new Effect.Fade(this.container, { afterFinish: this._hideDone.bind(this) });
}
else {
new Effect.Collapse(this.container, { afterFinish: this._hideDone.bind(this) });
}
}
},
_hideDone: function() {
$('tools_wrapper').style.display = 'none';
this.isShowing = false;
},
setStatus: function(msg) {
this.status.innerHTML = msg;
this.status.style.display = 'block';
},
hideStatus: function() {
this.status.style.display = 'none';
this.status.innerHTML = '';
},
initTool: function(dataObj) {
var toolData = engine.getToolData(dataObj.toolID);
var content = '';
this.isInit = true;
this.lcol.style.top = '0px';
this.rcol.style.top = '0px';
$('scrollboxLg').style.top = '0px';
this.sessionID = dataObj.sessionID;
this.toolID = dataObj.toolID;
this.fields = dataObj.fields;
if (dataObj.errorHeader == '') {
this.setTitle(dataObj.mainTitle);
content += this._boxTemplate('left', 0);
if (toolData.resources.length > 0) {
content += this._boxTemplate('left', 1);
}
if (toolData.products.length > 0) {
content += this._boxTemplate('left', 2);
}
content += this._boxTemplate('left', 3);
this.lcol.innerHTML = content;
this._addToolBox(dataObj.subTitle, dataObj.toolTemplate);
this._setLabels(dataObj.fields);
this.errorBox = $('toolError');
if (toolData.resources.length > 0) {
var box1 = new ContentBox('leftHead1', 'leftBox1', 'leftContent1');
box1.setTitle('Learning Resources');
box1.setContent(this.setResources(toolData));
}
if (toolData.products.length > 0) {
var box2 = new ContentBox('leftHead2', 'leftBox2', 'leftContent2');
box2.setTitle('Related Products');
box2.setContent(this.setProducts(toolData));
}
var box3 = new ContentBox('leftHead3', 'leftBox3', 'leftContent3', { displayOpenClass: 'last' });
box3.setTitle('Learn more about this calculator');
box3.setContent(this.setHelp(dataObj));
this.rcol.innerHTML = this._boxTemplate('right', 0) + this._boxTemplate('right', 1);
var box0 = new ContentBox('rightHead0', 'rightBox0', 'rightContent0' );
var box1 = new ContentBox('rightHead1', 'rightBox1', 'rightContent1', { displayOpenClass: 'last' });
box0.setTitle('Results');
box1.setTitle('Important note about this calculator');
this.rightBox = box0;
this.legalBox = box1;
this.setTip(dataObj);
this.setLegal(dataObj);
}
else {
this.setTip(dataObj);
this.setLegal(dataObj);
}
if (dataObj.errorHeader != '') {
var errorStr = '<b>' + dataObj.errorHeader + '</b>';
for (var i=0; i<dataObj.errors.length; i++) {
errorStr += '<br/>' + dataObj.errors[i];
}
this.setToolError(errorStr);
}
else {
this.hideToolError();
this.show();
}
},
initControls: function() {
var rowList = this.fields;
$('printCalc').style.display = 'none'
this.sliders = [];
for (var i=0; i<rowList.length; i++) {
var name = rowList[i].dataName;
if ($(name + '_track') && rowList[i].doInit) {
var curVal = (parseFloat(rowList[i].value.replace(/,/g,"")) > 0) ? parseFloat(rowList[i].value.replace(/,/g,"")) : 0;
if ($(name + '_track').className == 'slider nomax') {
var defVal = rowList[i].defaultValue;
var maxVal = (defVal >= curVal) ? ((defVal > 0) ? (defVal * 4) :(rowList[i].maxValue/10)): (curVal * 4);
var stepVal = (defVal > 0) ? (Math.round(defVal / 10)) : (Math.round(maxVal/10));
var slider = new DynamicSlider(name + '_slider', name + '_track', name, curVal, maxVal, stepVal);
this.sliders.push(slider);
}
if ($(name + '_track').className == 'slider nomax dual') {
var name2 = rowList[i+1].dataName;
var curVal2 = parseFloat(rowList[i+1].value.replace(/,/g,""));
var defVal = rowList[i].defaultValue;
var highVal = (curVal > curVal2) ? curVal : curVal2;
var maxVal = (defVal > highVal) ? (defVal * 4) : (highVal * 4);
var stepVal = Math.round(defVal / 10);
if (defVal <= 0) {
maxVal = rowList[i].maxValue/4
stepVal = maxVal/10;
}
var slider = new DoubleDynamicSlider(name + '_slider', name2 + '_slider', name + '_track', name, name2, curVal, curVal2, maxVal, stepVal);
this.sliders.push(slider);
}
else if ($(name + '_track').className == 'slider') {
var defVal = rowList[i].defaultValue;
var maxVal = rowList[i].maxValue;
var showDecimal = (rowList[i].postDisplay == '%') ? true : false;
var slider = new StandardSlider(name + '_slider', name + '_track', name, maxVal, curVal, showDecimal);
this.sliders.push(slider);
}
else if ($(name + '_track').className == 'slider inc5') {
var values = rowList[i].range;
var slider = new IncSlider(name + '_slider', name + '_track', name, curVal, values);
this.sliders.push(slider);
}
rowList[i].doInit = false;
}
}
if (this.isInit) {
if (this.toolID == 'home02') {
this._home02Init(rowList);
}
else if (this.toolID == 'creditline02') {
this._creditline02Init(rowList);
}
this.isInit = false;
}
this.scroller.configure();
},
setTitle: function(content) {
this.title.innerHTML = '<h1>' + content + '</h1>';
},
setHelp: function(dataObj) {
var help = dataObj.help;
var content = '';
for (var i=0; i<help.length; i++) {
content += '<p>' + help[i] + '</p>';
}
return content;
},
setTip: function(dataObj) {
this.rightBox.setContent('<p class="info">' + dataObj.tip + '</p>');
},
setLegal: function(dataObj) {
this.legalBox.setContent(dataObj.legal);
},
setResources: function(toolData) {
var content = '';
for (var i=0; i<toolData.resources.length; i++) {
if (toolData.resources[i].type == 'lf_calc') {
content += '<li class="calc"><a href="#" onclick="tools.loadTemplate(\'' + toolData.resources[i].url + '\'); return false">' + toolData.resources[i].title + '</a></li>';
}
else {
content += '<li class="' + toolData.resources[i].type + '"><a href="#" onclick="openInParent(\'' + toolData.resources[i].url + '\', \'RIA Managing Credit Debt Understand credit and debt basics MyAccess Checking\'); return false">' + toolData.resources[i].title + '</a></li>';
}
}
return '<ul id="lrnRsc_sm">' + content + '<ul>';
},
setProducts: function(toolData) {
var content = '';
for (var i=0; i<toolData.products.length; i++) {
content += '<li class="' + toolData.products[i].category + '"><a href="#" onclick="engine.showDetail(\'' + toolData.products[i].id + '\'); return false">' + toolData.products[i].title + '</a></li>';
}
return '<ul class="products">' + content + '<ul>';
},
setToolError: function(content) {
this.errorBox.innerHTML = content;
this.errorBox.style.display = 'block';
},
hideToolError: function() {
this.errorBox.style.display = 'none';
},
showLoading: function() {
this.rightBox.setContent('<div class="results"><img class="loading" src="./images/loading.gif" height="128" width="128"/><br/><div class="loading">Loading...</div></div>');
},
showResult: function(dataObj) {
this.lcol.style.top = '0px';
this.rcol.style.top = '0px';
$('scrollboxLg').style.top = '0px';
$('printCalc').style.display = 'block';
var errors = document.getElementsByClassName('fieldWrapper', $('leftContent0'));
this.currentTable = 0;
this.currentGraph = 0;
this.currentPage = 1;
this.tabState = '';
this.startPos = 1;
this.endPos = (dataObj.tables.length > 0) ? dataObj.tables[this.currentTable].rowDisplay : 0;
this.rightBox.setContent(dataObj.resultTemplate);
for (var i=0; i<errors.length; i++) {
errors[i].className = 'fieldWrapper';
}
this.hideToolError();
this[this.toolID+'Results'](dataObj);
if (this.rightBox.state == 'closed') {
this.rightBox.toggle();
}
},
fadeColumns: function() {
this.setTitle('');
new Effect.Fade(this.lcol, { duration: 0.3 });
new Effect.Fade(this.rcol, { duration: 0.3 });
},
_addToolBox: function(title, content) {
var box = new ContentBox('leftHead0', 'leftBox0', 'leftContent0')
box.setTitle(title);
box.setContent(content);
this.leftBoxes.push(box);
},
_setLabels: function(rowList) {
for (var i=0; i<rowList.length; i++) {
var name = rowList[i].dataName;
if ($(name + '_title') != null) {
$(name + '_title').innerHTML = this._titleTemplate(name, rowList[i].fieldLabel, rowList[i].glossaryKey);
if (rowList[i].error) {
$(name + '_title').parentNode.className = 'fieldWrapper error';
}
else {
$(name + '_title').parentNode.className = 'fieldWrapper';
}
}
}
},
_home02Init: function(rowList) {
for (var i=0; i<rowList.length; i++) {
if (rowList[i].dataName == 'TermYrs') {
$(rowList[i].value + 'yr').checked = true;
}
}
},
_creditline02Init: function(rowList) {
this.hideDebtDetail();
for (var i=0; i<rowList.length; i++) {
if (rowList[i].dataName == 'LoanTyp') {
$('loanType' + rowList[i].value).checked = true;
}
}
},
home02Results: function(dataObj, isPrint) {
var summary = '';
var results = dataObj.results;
for (var i=0; i<results.length; i++) {
summary += '<tr><td>' + this._resultLabel(results[i], dataObj.glossary) + '</td><td>';
summary += results[i].prefix + results[i].value + results[i].postfix;
summary += '</td></tr>';
}
if (isPrint) {
return '<h3>' + dataObj.label + '</h3><table class="resultOverview"><tbody>' + summary + '</tbody></table>';
}
else {
$('sumTable').innerHTML = '<table class="resultOverview"><tbody>' + summary + '</tbody></table>';
this.showGraphs(dataObj, 0);
}
},
auto05Results: function(dataObj, isPrint) {
var summary = '';
var results = dataObj.results;
for (var i=0; i<results.length; i++) {
summary += '<tr><td>' + this._resultLabel(results[i], dataObj.glossary) + '</td><td>';
summary += results[i].prefix + results[i].value + results[i].postfix;
summary += '</td></tr>';
}
if (isPrint) {
return '<h3>' + dataObj.label + '</h3><table class="resultOverview"><tbody>' + summary + '</tbody></table>';
}
else {
$('sumTable').innerHTML = '<table class="resultOverview"><tbody>' + summary + '</tbody></table>';
this.showGraphs(dataObj, 0);
}
},
budget03Results: function(dataObj, isPrint) {
var summary = '<tr><td>&#160</td><td>Your current spending</td><td>Your desired spending</td></tr>';
var results = dataObj.results.splice(1, dataObj.results.length);
for (var i=0; i<results.length; i++) {
if (i % 2 == 0) {
summary += '<tr><td>' + this._resultLabel(results[i], dataObj.glossary) + '</td><td>' + results[i].prefix + results[i].value + results[i].postfix;
}
else {
summary += '<td>' + results[i].prefix + results[i].value + results[i].postfix + '</td></tr>';
}
}
if (isPrint) {
return '<h3>' + dataObj.label + '</h3><table class="resultOverview"><tbody>' + summary + '</tbody></table>';
}
else {
$('sumTable').innerHTML = '<table class="resultOverview"><tbody>' + summary + '</tbody></table>';
this.showGraphs(dataObj, 0);
}
},
budget05Results: function(dataObj, isPrint) {
var summary = '';
var results = dataObj.textResults;
this.currentTable = 0;
for (var i=0; i<results.length-1; i++) {
summary += '<p>' + results[i].fullLabel + '</p>';
}
if (isPrint) {
return summary;
}
else {
$('sumTable').innerHTML = summary;
this.showGraphs(dataObj, 0);
}
},
creditline01Results: function(dataObj, isPrint) {
var summary = '';
var extras = dataObj.extras;
summary += '<tr><td><a onmousemove="tooltip.move(event)" onmouseout="tooltip.hide()" onmouseover="tooltip.show(event, tools.glossary(\'ltv\'))" onclick="tooltip.show(event, tools.glossary(\'ltv\'), true); return false" href="#">Loan-to-value ratio</a><br/>(percent of your home\'s value)</td><td>Maximum amount of loans possible, minus your <a onmousemove="tooltip.move(event)" onmouseout="tooltip.hide()" onmouseover="tooltip.show(event, tools.glossary(\'mortgagebalance\'))" onclick="tooltip.show(event, tools.glossary(\'mortgagebalance\'), true); return false" href="#">existing loan(s)</a></td></tr>';
for (var i=0; i<extras.length; i++) {
if (extras[i].selected) {
summary += '<tr><td><b>' + extras[i].percent + '.00%</b></td><td><b>$' + extras[i].total + '</b></td></tr>';
}
else {
summary += '<tr><td>' + extras[i].percent + '.00%</td><td>$' + extras[i].total + '</td></tr>';
}
}
if (isPrint) {
return '<table class="resultOverview"><tbody>' + summary + '</tbody></table>';
}
else {
$('sumTable').innerHTML = '<table class="resultOverview"><tbody>' + summary + '</tbody></table>';
this.showGraphs(dataObj, 0);
}
},
creditline02Results: function(dataObj, isPrint) {
var heading = '<p>' + dataObj.textResults[0].fullLabel + '</p>'
var summary = '';
var results = dataObj.results.splice(1, dataObj.results.length);
summary += '<tr><td>&#160</td><td>Current loans</td><td>Single loan</td></tr>';
for (var i=0; i<results.length; i++) {
if (i % 2 == 0) {
summary += '<tr><td>' + this._resultLabel(results[i], dataObj.glossary) + '</td><td>' + results[i].prefix + results[i].value + results[i].postfix;
}
else {
summary += '<td>' + results[i].prefix + results[i].value + results[i].postfix + '</td></tr>';
}
}
if (isPrint) {
return heading + '<table class="resultOverview"><tbody>' + summary + '</tbody></table>';
}
else {
$('sumTable').innerHTML = heading + '<table class="resultOverview"><tbody>' + summary + '</tbody></table>';
this.showGraphs(dataObj, 0);
}
},
savings01Results: function(dataObj, isPrint) {
var summary = '';
var results = dataObj.textResults;
this.currentTable = 0;
for (var i=0; i<(results.length-1); i++) {
if (results[i].fullLabel.substr(0, 8) != 'Decrease') {
summary += '<p>' + results[i].rawLabel + '</p>';
}
}
if (isPrint) {
return summary;
}
else {
$('sumTable').innerHTML = summary;
this.showGraphs(dataObj, 0);
}
},
savings03Results: function(dataObj, isPrint) {
var summary = '';
var results = dataObj.textResults;
this.currentTable = 0;
for (var i=0; i<(results.length-1); i++) {
summary += '<p>' + results[i].fullLabel + '</p>';
}
if (isPrint) {
return summary;
}
else {
$('sumTable').innerHTML = summary;
this.showGraphs(dataObj, 0);
}
},
_boxTemplate: function(side, boxNum) {
var tmpl = new Template('<div id="#{align}Head#{num}" class="toolboxHd"></div><div id="#{align}Box#{num}" class="toolbox"><div id="#{align}Content#{num}" class="boxContent"></div></div>');
var show = { align: side, num: boxNum };
return tmpl.evaluate(show);
},
_titleTemplate: function(name, title, glossaryKey) {
var tmpl;
var show;
if (glossaryKey == '') {
tmpl = new Template('<label for="#{display}">#{label}</label>');
show = { display: name, label: title };
}
else {
tmpl = new Template('<label for="#{display}"><a href="#" onclick="tooltip.show(event, tools.glossary(\'#{key}\'), true); return false" onmouseover="tooltip.show(event, tools.glossary(\'#{key}\'))" onmouseout="tooltip.hide()" onmousemove="tooltip.move(event)">#{label}</a></label>');
show = { display: name, label: title, key: glossaryKey.toLowerCase() };
}
return tmpl.evaluate(show);
},
_resultLabel: function(dataObj, glossary) {
var tmpl;
if ((dataObj.glossaryKey == '') || (glossary[dataObj.glossaryKey.toLowerCase()] == null)) {
tmpl = new Template('#{label}');
show = { label: dataObj.fieldLabel };
}
else {
tmpl = new Template('<a href="#" onclick="tooltip.show(event, tools.glossary(\'#{key}\'), true); return false" onmouseover="tooltip.show(event, tools.glossary(\'#{key}\'))" onmouseout="tooltip.hide()" onmousemove="tooltip.move(event)">#{label}</a>');
show = { label: dataObj.fieldLabel, key: dataObj.glossaryKey.toLowerCase() };
}
return tmpl.evaluate(show);
},
_pagingTemplate: function(show) {
var tmpl;
if (this.currentPage == 'all') {
tmpl = new Template('Rows: #{firstRow} thru #{lastRow} of #{rowCount}');
}
else {
tmpl = new Template('<img onclick="tools.showTables(#{firstPage}); return false" class="first" width="11" height="10" alt="First Row" src="./images/btn_results-first.gif"/>&#160' +
'<img onclick="tools.showTables(#{prevPage}); return false" class="prev" width="11" height="10" alt="Previous Row" src="./images/btn_results-prev.gif"/>&#160;' +
'Rows: #{firstRow} thru #{lastRow} of #{rowCount}&#160;' +
'<img onclick="tools.showTables(#{nextPage}); return false" class="next" width="11" height="10" alt="Next Row" src="./images/btn_results-next.gif"/>&#160;' +
'<img onclick="tools.showTables(#{lastPage}); return false" class="last" width="11" height="10" alt="Last Row" src="./images/btn_results-last.gif"/>');
}
return tmpl.evaluate(show);
},
_loanTemplate: function(show) {
var tmpl = new Template('<div id="hd#{pos}"><h3>#{loanName}</h3><img src="./images/btn_sm_close.gif" alt="Close Item" width="10" height="10" class="close" onclick="tools.removeDebtItem(this, \'loan\', #{pos}); return false"/></div>' +
'<div id="bd#{pos}"><div class="fieldWrapper"><label for="ODebts#{pos}">Amount I still owe</label>' +
'<span class="currency">$</span>' +
'<div id="ODebts#{pos}_track" class="slider nomax"><img id="ODebts#{pos}_slider" src="./images/slider_btn.png" alt="" width="18" height="18" class="sliderBtn png"/><span class="min">&#8212;</span><span class="max">+</span></div>' +
'<span><input name="ODebts#{pos}" id="ODebts#{pos}" type="text" value="0"></input></span></div>' +
'<div class="fieldWrapper"><label for="OMonPmt#{pos}">Monthly payments</label>' +
'<span class="currency">$</span>' +
'<div id="OMonPmt#{pos}_track" class="slider nomax"><img id="OMonPmt#{pos}_slider" src="./images/slider_btn.png" alt="" width="18" height="18" class="sliderBtn png"/><span class="min">&#8212;</span><span class="max">+</span></div>' +
'<span><input name="OMonPmt#{pos}" id="OMonPmt#{pos}" type="text" value="0"></input></span></div>' +
'<div class="fieldWrapper"><label for="OMonLeft#{pos}">Months left</label>' +
'<div id="OMonLeft#{pos}_track" class="slider nomax"><img id="OMonLeft#{pos}_slider" src="./images/slider_btn.png" alt="" width="18" height="18" class="sliderBtn png"/><span class="min">&#8212;</span><span class="max">+</span></div>' +
'<span><input name="OMonLeft#{pos}" id="OMonLeft#{pos}" type="text" value="0"></input></span></div></div>');
return tmpl.evaluate(show);
},
_creditTemplate: function(show) {
var tmpl = new Template('<div id="hd#{pos}"><h3>#{loanName}</h3><img src="./images/btn_sm_close.gif" alt="Close Item" width="10" height="10" class="close" onclick="tools.removeDebtItem(this, \'credit\', #{pos}); return false"/></div>' +
'<div id="bd#{pos}"><div class="fieldWrapper"><label for="CDebt#{pos}">Amount I still owe</label>' +
'<span class="currency">$</span>' +
'<div id="CDebt#{pos}_track" class="slider nomax"><img id="CDebt#{pos}_slider" src="./images/slider_btn.png" alt="" width="18" height="18" class="sliderBtn png"/><span class="min">&#8212;</span><span class="max">+</span></div>' +
'<span><input name="CDebt#{pos}" id="CDebt#{pos}" type="text" value="0"></input></span></div>' +
'<div class="fieldWrapper"><label for="CRate#{pos}">Interest rate</label>' +
'<span class="percent">%</span>' +
'<div id="CRate#{pos}_track" class="slider"><img id="CRate#{pos}_slider" src="./images/slider_btn.png" alt="" width="18" height="18" class="sliderBtn png"/><span class="min">&#8212;</span><span class="max">+</span></div>' +
'<span><input name="CRate#{pos}" id="CRate#{pos}" type="text" value="0"></input></span></div></div>');
return tmpl.evaluate(show);
},
buildDebtItem: function(type, name, position) {
var parent = $('loanContainer');
var node = document.createElement('div');
var owed = (type == 'loan') ? 'ODebts' : 'CDebt';
node.className = 'customItem';
node.id = 'loan' + type + position;
if (type == 'loan') {
node.innerHTML = this._loanTemplate({ loanName: name, pos: position });
}
else {
node.innerHTML = this._creditTemplate({ loanName: name, pos: position });
}
this.lastNode = position;
parent.appendChild(node);
node.style.display = 'none';
new Effect.Appear(node.id, { duration: 0.3, afterFinish: this.initDebtBox.bind(this) });
},
initDebtBox: function() {
new ContentBox('hd'+this.lastNode, 'bd'+this.lastNode, 'bd'+this.lastNode);
this.initControls();
},
appearAddDebt: function() {
$('addDebt').style.display = 'none';
new Effect.Appear('addLoan', { duration: 0.3, afterFinish: this.scroller.configure.bind(this) });
},
showDebtDetail: function() {
$('loanDetail').style.display = 'block';
$('addLoan').style.display = 'none';
$('addDebt').style.display = 'block';
$('getResults').style.display = 'block';
this.scroller.configure();
},
hideDebtDetail: function() {
$('loanDetail').style.display = 'none';
$('addLoan').style.display = 'block';
$('addDebt').style.display = 'none';
$('getResults').style.display = 'none';
this.scroller.configure();
},
removeDebtBox: function(node) {
var container = node.parentNode.parentNode;
var parent = container.parentNode;
parent.removeChild(container);
this.scroller.configure();
},
showGraphs: function(dataObj, num) {
var graphNum = (num != null) ? num : 0;
$('dataTitle').innerHTML = '<h3>' + dataObj.graphTitle + '</h3>';
$('dataDisplay').innerHTML = this._buildGraphs(dataObj.graphs, graphNum);
$('tablePaging').style.display = 'none';
$('showRows').style.display = 'none';
this._setTabs('graphs');
},
showTables: function(dataObj, num, page) {
this.currentTable = (num != null) ? num : this.currentTable;
this.currentPage = (page != null) ? page : this.currentPage;
if (this.currentPage == 'all') {
this.startPos = 1;
this.endPos = dataObj.tables[this.currentTable].rowCount;
}
else {
var display = dataObj.tables[this.currentTable].rowDisplay;
this.startPos = (display * (this.currentPage-1)) + 1;
this.endPos = (dataObj.tables[this.currentTable].rowCount < (display * this.currentPage)) ? dataObj.tables[this.currentTable].rowCount : (display * this.currentPage);
}
$('dataTitle').innerHTML = '<h3>' + dataObj.tableTitle + '</h3>';
$('dataDisplay').innerHTML = this._buildTables(dataObj.tables);
$('showRows').style.display = 'block';
this._setPaging(dataObj);
this._setTabs('tables');
},
_setTabs: function(active) {
this.tabState = active;
if ((active == 'tables') && ($('tablesTab') != null)) {
$('graphsTab').className = 'resultTab';
$('tablesTab').className = 'resultTab on';
}
else if ((active == 'graphs') && ($('graphsTab') != null)) {
$('graphsTab').className = 'resultTab on';
$('tablesTab').className = 'resultTab';
}
this.scroller.configure();
},
_setPaging: function(dataObj) {
var perPage = dataObj.tables[this.currentTable].rowDisplay;
var rowCount = dataObj.tables[this.currentTable].rowCount;
var prevPage = ((this.currentPage-1) < 1) ? 1 : this.currentPage-1;
var lastPage = ((rowCount % perPage) == 0) ? (rowCount / perPage) : (Math.floor(rowCount / perPage) + 1);
var nextPage = ((this.currentPage+1) > lastPage) ? lastPage : this.currentPage+1;
var show = {
firstPage: this.currentTable +', 1',
prevPage: this.currentTable +', '+ prevPage,
nextPage: this.currentTable +', '+ nextPage,
lastPage: this.currentTable +', '+ lastPage,
firstRow: this.startPos,
lastRow: this.endPos,
rowCount: rowCount
};
$('tablePaging').style.display = 'block';
$('tablePaging').innerHTML = this._pagingTemplate(show);
},
toggleRowDisplay: function(dataObj) {
if (this.currentPage == 'all') {
$('showRows').innerHTML = 'Show All Table Rows';
this.currentPage = 1;
}
else {
$('showRows').innerHTML = 'Show ' + dataObj.tables[this.currentTable].rowDisplay + ' Table Rows';
this.currentPage = 'all';
}
this.showTables(dataObj);
},
_buildGraphs: function(graphs, active) {
var imageLink = this.imageURL + this.sessionID + '?param=' + graphs[active].param;
var content = '<img src="' + imageLink + '" width="338" height="267"/>';
if (graphs[active].text != null) {
content += '<br/><p>' + graphs[active].text + '</p>';
}
return content;
},
_buildTables: function(tables) {
var active = this.currentTable;
var content = '<table class="resultData"><tbody id="resultData">';
content += this._buildRows(tables[active], this.startPos, this.endPos);
content += '</tbody></table>';
return content;
},
_buildRows: function(tableObj, start, end) {
var firstCol = (start != null) ? start-1 : 0;
var lastCol = (end != null) ? end : tableObj.columns.length;
var cols = tableObj.columns;
var rows = tableObj.data;
var content = '<tr>';
for (var i=0; i<cols.length; i++) {
content += '<th>' + cols[i] + '</th>';
}
content += '</tr>';
for (var i=firstCol; i<lastCol; i++) {
var data = rows[i];
content += '<tr>';
for (var j=0; j<data.length; j++) {
content += '<td>' + data[j] +'</td>';
}
content += '</tr>';
}
return content;
},
print: function(dataObj, container) {
var content = '<h3>Your Information</h3><table>';
for (var i=0; i<dataObj.fields.length; i++) {
if ($(dataObj.fields[i].dataName) != null ) {
content += '<tr><td>' + dataObj.fields[i].fieldLabel + '</td><td>' + dataObj.fields[i].prefix + $F(dataObj.fields[i].dataName) + dataObj.fields[i].postfix + '</td></tr>';
}
}
content += '</table>';
content += '<h3>Results</h3>';
content += this[this.toolID + 'Results'](dataObj, true);
if (dataObj.graphs.length > 0) {
content += this._buildGraphs(dataObj.graphs, this.currentGraph);
}
if (dataObj.tables.length > 0) {
this.startPos = 1;
this.endPos = dataObj.tables[this.currentTable].rowCount;
content += this._buildTables(dataObj.tables);
}
container.innerHTML = content;
}
}
var ToolScroller = Class.create();
ToolScroller.prototype = {
initialize: function(wrapper, lcol, rcol) {
this.container = wrapper;
this.lcol = lcol;
this.rcol = rcol;
this.slider = $('scrollboxLg');
this.track = $('scrollbarLg');
this.upArrow = $('scrollUpLg');
this.dnArrow = $('scrollDnLg');
this.timer;
this.Slider;
this.moveStep = 5;
this.scrollRange;
this.scrollDir;
this.cy;
this.my;
this.sm;
this.bm;
this.max;
this.leftScroll = false;
this.rightScroll = false;
this.canScroll = false;
this.isInit = true;
this.container.style.top = '0px';
this.lcol.style.top = '0px';
this.rcol.style.top = '0px';
this._buildScroller();
},
configure: function() {
var leftY = this.lcol.getHeight();
var rightY = this.rcol.getHeight();
window.clearInterval(this.timer);
this.scrollRange = this.track.getHeight() - this.slider.getHeight();
this.cy = (leftY > rightY) ? leftY : rightY;
this.my = this.container.getHeight();
this.sm = (this.cy - this.my) / this.scrollRange;
this.bm = this.scrollRange / (this.cy - this.my);
this.max = (leftY > rightY) ? this.lcol : this.rcol;
this.leftScroll = (leftY <= this.my) ? false : true;
this.rightScroll = (rightY <= this.my) ? false : true;
this.canScroll = (this.leftScroll || this.rightScroll) ? true : false;
if (this.isInit) {
this.Slider = new Control.Slider(this.slider, this.track, { axis: 'vertical', minimum: 0, maximum: 430, onSlide: this._doDrag.bind(this), onChange: this._doDrag.bind(this) });
this.isInit = false;
}
if (parseInt(this.slider.style.top) != 0) {
var curTop = parseInt(this.max.style.top);
if (this.leftScroll && (-(leftY - this.my) >= curTop)) {
this.lcol.style.top = -(leftY - this.my) + 'px';
}
if (this.rightScroll && (-(rightY - this.my) >= curTop)) {
this.rcol.style.top = -(rightY - this.my) + 'px';
}
curTop = parseInt(this.max.style.top);
this.slider.style.top = -(curTop * this.bm) + 'px';
}
if (this.canScroll) {
this.Slider.setEnabled();
}
else {
this.Slider.setDisabled();
this.lcol.style.top = '0px';
this.rcol.style.top = '0px';
this.slider.style.top = '0px';
}
},
scrollUp: function() {
this.scrollDir = 'up';
this.timer = setInterval(this._doScroll.bind(this), 50);
},
scrollDn: function() {
this.scrollDir = 'down';
this.timer = setInterval(this._doScroll.bind(this), 50);
},
stopScroll: function() {
window.clearInterval(this.timer);
},
_buildScroller: function() {
this.upArrow.onmousedown = this.scrollUp.bind(this);
this.upArrow.onmouseup = this.stopScroll.bind(this);
this.dnArrow.onmousedown = this.scrollDn.bind(this);
this.dnArrow.onmouseup = this.stopScroll.bind(this);
},
_doDrag: function(v) {
var topVal = (this.my - this.cy) * v;
window.clearInterval(this.timer);
if (this.leftScroll) {
this.lcol.style.top = topVal + 'px';
}
if (this.rightScroll) {
this.rcol.style.top = topVal + 'px';
}
},
_doScroll: function() {
if (this.scrollDir == 'up') {
this._scrollUp();
}
else if (this.scrollDir == 'down') {
this._scrollDn();
}
},
_scrollUp: function() {
var curTop = (this.max.style.top == null) ? 0 : parseInt(this.max.style.top);
if (curTop < 0) {
curTop = ((curTop + this.moveStep) > 0) ? 0 : (curTop + this.moveStep);
if (this.leftScroll) {
this.lcol.style.top = curTop + 'px';
}
if (this.rightScroll) {
this.rcol.style.top = curTop + 'px';
}
if ((curTop * this.bm) > 0) {
this.slider.style.top = '0px';
window.clearInterval(this.timer);
}
else {
this.slider.style.top = -(curTop * this.bm) + 'px';
}
}
},
_scrollDn: function() {
var curTop = (this.max.style.top == null) ? 0 : parseInt(this.max.style.top);
if (curTop > (this.my - this.cy)) {
curTop -= this.moveStep;
if (this.leftScroll) {
this.lcol.style.top = curTop + 'px';
}
if (this.rightScroll) {
this.rcol.style.top = curTop + 'px';
}
if ((curTop * this.bm) < -this.scrollRange) {
this.slider.style.top = this.scrollRange + 'px';
window.clearInterval(this.timer);
}
else {
this.slider.style.top = -(curTop * this.bm) + 'px';
}
}
}
}
document.getElementsByClassName = function(className) {
var children = document.getElementsByTagName('*') || document.all;
var elements = new Array();
for (var i = 0; i < children.length; i++) {
var child = children[i];
var classNames = child.className.split(' ');
for (var j = 0; j < classNames.length; j++) {
if (classNames[j] == className) {
elements.push(child);
break;
}
}
}
return elements;
}
var Reflection = {
defaultHeight : 0.5,
defaultOpacity: 0.5,
add: function(image, options) {
Reflection.remove(image);
doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
if (options) {
for (var i in doptions) {
if (!options[i]) {
options[i] = doptions[i];
}
}
} else {
options = doptions;
}
try {
var d = document.createElement('div');
var p = image;
var classes = p.className.split(' ');
var newClasses = '';
for (j=0;j<classes.length;j++) {
if (classes[j] != "reflect") {
if (newClasses) {
newClasses += ' '
}
newClasses += classes[j];
}
}
var reflectionHeight = Math.floor(p.height*options['height']);
var divHeight = Math.floor(p.height*(1+options['height']));
var reflectionWidth = p.width;
if (document.all && !window.opera) {
d.className = newClasses;
p.className = 'reflected';
d.style.cssText = p.style.cssText;
p.style.cssText = 'vertical-align: bottom';
var reflection = document.createElement('img');
reflection.src = p.src;
reflection.style.width = reflectionWidth+'px';
reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px';
reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';
d.style.width = reflectionWidth+'px';
d.style.height = divHeight+'px';
p.parentNode.replaceChild(d, p);
d.appendChild(p);
d.appendChild(reflection);
} else {
var canvas = document.createElement('canvas');
if (canvas.getContext) {
d.className = newClasses;
p.className = 'reflected';
d.style.cssText = p.style.cssText;
p.style.cssText = 'vertical-align: bottom';
var context = canvas.getContext("2d");
canvas.style.height = reflectionHeight+'px';
canvas.style.width = reflectionWidth+'px';
canvas.height = reflectionHeight;
canvas.width = reflectionWidth;
d.style.width = reflectionWidth+'px';
d.style.height = divHeight+'px';
p.parentNode.replaceChild(d, p);
d.appendChild(p);
d.appendChild(canvas);
context.save();
context.translate(0,image.height-1);
context.scale(1,-1);
context.drawImage(image, 0, 0, reflectionWidth, image.height);
context.restore();
context.globalCompositeOperation = "destination-out";
var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);
gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");
context.fillStyle = gradient;
if (navigator.appVersion.indexOf('WebKit') != -1) {
context.fill();
} else {
context.fillRect(0, 0, reflectionWidth, reflectionHeight*2);
}
}
}
} catch (e) {
}
},
remove : function(image) {
if (image.className == "reflected") {
image.className = image.parentNode.className;
image.parentNode.parentNode.replaceChild(image, image.parentNode);
}
}
}
function addReflections() {
var rimages = document.getElementsByClassName('reflect');
for (i=0;i<rimages.length;i++) {
var rheight = null;
var ropacity = null;
var classes = rimages[i].className.split(' ');
for (j=0;j<classes.length;j++) {
if (classes[j].indexOf("rheight") == 0) {
var rheight = classes[j].substring(7)/100;
} else if (classes[j].indexOf("ropacity") == 0) {
var ropacity = classes[j].substring(8)/100;
}
}
Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
}
}
var previousOnload = window.onload;
window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari"
},
{
prop: window.opera,
identity: "Opera"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.init();