mbnaurl = new URI();
/*if (mbnaurl.get('host') != 'localhost' && mbnaurl.get('host').indexOf('165') != -1) {
    if (mbnaurl.get('host').indexOf('www') == -1) {
        mbnaurl.set('host', 'www.' + mbnaurl.get('host'));
        mbnaurl.go()
    }
}*/
Enviro = 0;
if (mbnaurl.get('scheme') != 'file') {
    if (mbnaurl.get('host') != 'localhost' && mbnaurl.get('host').indexOf('206') == -1) {
   
    } else {
      
		Enviro = 1
    }
}

function init() {
    document.body.className = "loading";
    window.addEvent('domready', function () {
        $$('body').adopt(new Element('div', {
            'id': 'bgl'
        }), new Element('div', {
            'id': 'bgr'
        }));
        Cufon.replace('h1, h2, .h2, .tel', {
            onAfterReplace: function () {
                if (Browser.Engine.trident && Browser.Engine.version <= 4) {} else {
                    $$('div.btm').setStyles({
                        'position': 'absolute',
                        'bottom': '0'
                    })
                }
            }
        });
        $$('div.plinth').each(function (plinth) {
            plinth.adopt(new Element('div', {
                'class': 'top'
            }), new Element('div', {
                'class': 'btm'
            }))
        });
        if ($$('div.leftNav')) {
            $$('div.leftNav').each(function (nav) {
                nav.adopt(new Element('div', {
                    'class': 'top'
                }), new Element('div', {
                    'class': 'btm'
                }))
            })
        }
        $$('div.tabs').each(function (item) {
            new TabPane(item)
        });
        $$('span.backLinks').each(function (item) {
            new Element('p', {
                'class': 'top-link-right'
            }).adopt(new Element('a', {
                'text': 'Back',
                'href': '#',
                'class': 'cta',
                'events': {
                    'click': function () {
                        history.back();
                        return false
                    }
                }
            })).replaces(item)
        });
        //$$('div.bookmarks').each(function(item){new Bookmarks(item);if(Browser.Engine.trident&&Browser.Engine.version<=4){}else{$$('div.btm').setStyles({'position':'absolute','bottom':'0'})}});
        $$('a.logon').each(function (item, i) {
            item.addEvent('click', function (e) {
                e.preventDefault();
                var mcookl = Cookie.write('mbna_csm_v', '1', {
                    'duration': '60'
                });
                lab = document.title + '_' + i;
                gafire({
                    'cat': 'ocs-login',
                    'eventType': 'click',
                    'label': lab
                });
                var locStr = (top.location != location ? "top.location" : "window.location");
                setTimeout(locStr + "='" + item.href + "'", 750)
            })
        });
        $$('a.register').each(function (item, i) {
            item.addEvent('click', function (e) {
                e.preventDefault();
                var mcookr = Cookie.write('mbna_csm_v', '2', {
                    'duration': '60'
                });
                lab = document.title + '_' + i;
                gafire({
                    'cat': 'ocs-register',
                    'eventType': 'click',
                    'label': lab
                });
                var locStr = (top.location != location ? "top.location" : "window.location");
                setTimeout(locStr + "='" + item.href + "'", 750)
            })
        });
        $$('a.ocsdemo').each(function (item, i) {
            item.addEvent('click', function (e) {
                e.preventDefault();
                lab = document.title + '_' + i;
                gafire({
                    'cat': 'ocs-demo',
                    'eventType': 'click',
                    'label': lab
                })
            })
        });
        $$('a.logActivate').each(function (item, i) {
            item.addEvent('click', function (e) {
                e.preventDefault();
                lab = 'Login-and-activate_' + i;
                gafire({
                    'cat': 'ocs-activate',
                    'eventType': 'click',
                    'label': lab
                });
                var locStr = (top.location != location ? "top.location" : "window.location");
                setTimeout(locStr + "='" + item.href + "'", 750)
            })
        });
        $$('a.regActivate').each(function (item, i) {
            item.addEvent('click', function (e) {
                e.preventDefault();
                lab = 'Register-and-activate_' + i;
                gafire({
                    'cat': 'ocs-activate',
                    'eventType': 'click',
                    'label': lab
                });
                var locStr = (top.location != location ? "top.location" : "window.location");
                setTimeout(locStr + "='" + item.href + "'", 750)
            })
        });
        $$('a.apps').each(function (item, i) {
            item.addEvent('click', function (e) {
                e.preventDefault();
                t = new URI(item.href);
                lab = t.getData('CV_sourceCode') + '_' + document.title + '_' + i;
                gafire({
                    'cat': 'Apps',
                    'eventType': 'click',
                    'label': lab
                })
            })
        });
        $$('a.ads').each(function (item, i) {
            item.addEvent('click', function (e) {
                e.preventDefault();
                lab = item.get('id');
                gafire({
                    'cat': 'RealEstate',
                    'eventType': 'click',
                    'label': lab
                });
                if (item.get('rel') != 'blank') {
                    var locStr = (top.location != location ? "top.location" : "window.location");
                    setTimeout(locStr + "='" + item.href + "'", 750)
                }
            })
        });
        if (mbnaurl.getData('bme')) {
            lab = mbnaurl.getData('bme') + "_" + document.title;
            gafire({
                'cat': 'bookmark',
                'eventType': 'enterFrom',
                'label': lab
            })
        }
        document.body.className = "domReady";
        new compare();
        new external();
        var blankLinks = $$('a[rel=blank]');
        blankLinks.each(function (item) {
            item.addEvent('click', function () {
                newwindow = window.open(item.href, 'mbna');
                if (window.focus) {
                    newwindow.focus()
                }
                return false
            }.bind(this));
            item.addEvent('keypress', function (e) {
                if (e.key == 'enter' || e.key == 'space') {
                    newwindow = window.open(item.href, 'mbna');
                    if (window.focus) {
                        newwindow.focus()
                    }
                    return false
                }
            }.bind(this));
            if (item.hasClass('button') || item.hasClass('button-large')) {
                item.appendText(", opens a new window")
            } else {
                item.appendText(" ");
                if (Enviro == 1) {
                    src = '/ireland/lib-ui/img/modules/global/new_window.png'
                } else {
                    src = '/lib-ui/img/modules/global/new_window.png'
                }
                item.adopt(new Element('img', {
                    'src': src,
                    'alt': 'opens a new window'
                }))
            }
        }, this);
        if (Browser.Engine.trident && Browser.Engine.version <= 4) {} else {
            $$('div.btm').setStyles({
                'position': 'absolute',
                'bottom': '0'
            })
        }
    })
}
var UnderstandSlide = new Class({
    Implements: [Options, Events],
    options: {
        placeholder: 'slideshow'
    },
    initialize: function (options) {
        this.setOptions(options);
        this.current = 0;
        this.enabled = true;
        this.placement = $(this.options.placeholder);
        this.p1 = new Element('div', {
            'class': 'inlineSlide'
        });
        this.p2 = new Element('div', {
            'class': 'inlineSlide'
        });
        this.p3 = new Element('div', {
            'class': 'inlineSlide'
        });
        this.slider = new Element('div', {
            'class': 'slider'
        }).adopt(this.p1, this.p2, this.p3);
        this.mask = new Element('div', {
            'class': 'mask'
        }).adopt(this.slider);
        this.slides = new Array();
        this.placement.getElements('div.slide').each(function (item, i) {
            this.slides[i] = item.clone(true);
            item.destroy()
        }, this);
        this.length = this.slides.length;
        $$('div.plinth').each(function (plinth) {
            plinth.getFirst('div.btm').setStyles({
                'bottom': '0px',
                'position:': 'absolute'
            })
        });
        this.prev = new Element('a', {
            'class': 'ctrlPre',
            'href': '#',
            'events': {
                'click': function () {
                    n = this.current - 1;
                    this.setSlide(n);
                    return false
                }.bind(this)
            }
        });
        this.next = new Element('a', {
            'class': 'ctrlNxt',
            'href': '#',
            'events': {
                'click': function () {
                    n = this.current + 1;
                    this.setSlide(n);
                    return false
                }.bind(this)
            }
        });
        this.placement.empty();
        this.container = new Element('div', {
            'class': 'understand-slide'
        }).adopt(new Element('span', {
            'class': 'top'
        }), new Element('span', {
            'class': 'btm'
        }), this.mask, this.prev, this.next);
        this.placement.adopt(this.container);
        this.p1.adopt(this.slides[2].clone(true));
        this.p2.adopt(this.slides[0].clone(true));
        this.p3.adopt(this.slides[1].clone(true));
        this.timer = this.setSlide.delay(5000, this, 1)
    },
    setSlide: function (slide) {
        if (this.enabled) {
            this.enabled = false;
            if (slide > this.current) {
                goto = -1214
            } else {
                goto = 0
            }
            if (slide > this.length - 1) {
                slide = 0
            }
            if (slide < 0) {
                slide = this.length - 1
            }
            var myEffect = new Fx.Morph(this.slider, {
                duration: '500',
                transition: Fx.Transitions.Sine.easeOut,
                onComplete: function () {
                    this.p1.empty();
                    this.p2.empty();
                    this.p3.empty();
                    p = slide - 1;
                    if (p < 0) {
                        p = this.length - 1
                    }
                    n = slide + 1;
                    if (n > this.length - 1) {
                        n = 0
                    }
                    this.p1.adopt(this.slides[p].clone(true));
                    this.p2.adopt(this.slides[slide].clone(true));
                    this.p3.adopt(this.slides[n].clone(true));
                    Cufon.replace('h2');
                    this.slider.setStyle('left', '-607px');
                    this.current = slide;
                    this.timer = $clear(this.timer);
                    this.timer = this.setSlide.delay(7000, this, slide + 1);
                    new external();
                    this.enabled = true
                }.bind(this)
            });
            myEffect.start({
                'left': goto
            })
        }
    }
});
/*Bookmarks = new Class({
    Implements: [Options, Events],
    options: {
        bookmarks: ['facebook', 'twitter', 'digg'],
        data: {
            facebook: {
                image: '/lib-ui/img/modules/bookmarks/facebook.png',
                url: ''
            },
            twitter: {
                image: '/lib-ui/img/modules/bookmarks/twitter.png',
                url: ''
            },
            digg: {
                image: '/lib-ui/img/modules/bookmarks/digg.png',
                url: ''
            }
        }
    },
    initialize: function (container, options) {
        if (Enviro == 1) {
            f = "/ireland"
        } else {
            f = ""
        }
        this.setOptions(options);
        this.title = encodeURIComponent(document.title);
        this.url = encodeURIComponent(mbnaurl);
        this.container = container;
        new Element('span', {
            'text': 'Share this: '
        }).inject(this.container);
        this.options.bookmarks.each(function (i) {
            entry = "";
            if (this.url.indexOf("%3F") == -1) {
                entry = this.url + encodeURIComponent("?bme=" + i)
            } else {
                if (!mbnaurl.getData('bme')) {
                    entry = this.url + encodeURIComponent("&bme=" + i)
                } else {
                    entry = this.url
                }
            }
            switch (i) {
            case 'facebook':
                this.container.adopt(new Element('span').adopt(new Element('a', {
                    'href': 'http://www.facebook.com/sharer.php?u=' + entry + '&t=' + this.title,
                    'events': {
                        'click': function (e) {
                            e.preventDefault();
                            lab = i + "_" + document.title;
                            gafire({
                                'cat': 'bookmark',
                                'eventType': 'click',
                                'label': lab
                            });
                            newwindow = window.open('http://www.facebook.com/sharer.php?u=' + entry + '&t=' + this.title, 'mbna');
                            if (window.focus) {
                                newwindow.focus()
                            }
                        }
                    }
                }).adopt(new Element('img', {
                    'src': f + this.options.data.facebook.image,
                    'alt': 'Click to share on Facebook. Opens a new window'
                }))));
                break;
            case 'twitter':
                this.container.adopt(new Element('span').adopt(new Element('a', {
                    'href': 'http://twitter.com/home?status=' + entry,
                    'events': {
                        'click': function (e) {
                            e.preventDefault();
                            lab = i + "_" + document.title;
                            gafire({
                                'cat': 'bookmark',
                                'eventType': 'click',
                                'label': lab
                            });
                            newwindow = window.open('http://twitter.com/home?status=' + entry, 'mbna');
                            if (window.focus) {
                                newwindow.focus()
                            }
                        }
                    }
                }).adopt(new Element('img', {
                    'src': f + this.options.data.twitter.image,
                    'alt': 'Click to share on Twitter. Opens a new window'
                }))));
                break;
            case 'digg':
                this.container.adopt(new Element('span').adopt(new Element('a', {
                    'href': 'http://digg.com/submit?url=' + entry + '&title=' + this.title,
                    'events': {
                        'click': function (e) {
                            e.preventDefault();
                            lab = i + "_" + document.title;
                            gafire({
                                'cat': 'bookmark',
                                'eventType': 'click',
                                'label': lab
                            });
                            newwindow = window.open('http://digg.com/submit?url=' + entry + '&title=' + this.title, 'mbna');
                            if (window.focus) {
                                newwindow.focus()
                            }
                        }
                    }
                }).adopt(new Element('img', {
                    'src': f + this.options.data.digg.image,
                    'alt': 'Click to share on Digg. Opens a new window'
                }))));
                break
            }
        }, this);
        new Element('p', {
            'text': 'By using this social bookmarking function you are subscribing to each website\'s own privacy terms.',
            'class': 'small'
        }).inject(this.container, 'after')
    }
});*/
compare = new Class({
    Implements: [Events],
    initialize: function () {
        this.cards = new Array();
        this.selectedcards = new Array();
        this.comparecount = 0;
        this.overlay = new greyout();
        this.rows = $$("div.card-row");
        this.small = $$('p.small');
        this.rows.each(function (item, i) {
            this.cards[i] = new Array();
            item.getChildren("div").each(function (t, n) {
                switch (t.get('class')) {
                case "col-cardName":
                    this.cards[i]['cardName'] = t.get('html');
                    this.cards[i]['cardName-text'] = t.get('text');
                    break;
                case "col-BT":
                    this.cards[i]['BT'] = t.get('html');
                    break;
                case "col-APR":
                    this.cards[i]['APR'] = t.get('html');
                    break;
                case "col-features":
                    this.cards[i]['features'] = t.get('html');
                    break;
                case "col-example":
                    this.cards[i]['example'] = t.get('html');
                    break;
                case "col-compare":
                    this.cards[i]['link'] = t.getFirst("p").getFirst("a").clone();
                    this.cards[i]['ch'] = new checkbox({
                        'id': 'comp' + i
                    });
                    this.cards[i]['ch'].addEvent('changed', this.check.bind(this, i));
                    new Element('p', {
                        'class': 'compare'
                    }).adopt(this.cards[i]['ch'].box, new Element('label', {
                        'html': '<span class="hide"> Add the ' + this.cards[i]['cardName-text'] + 'to </span>Compare',
                        'for': 'comp' + i
                    })).inject(t, 'top');
                    break
                }
            }, this)
        }, this);
        this.button = new Element("span").adopt(new Element("a", {
            'href': '#',
            'class': 'button compare',
            'text': 'Compare now'
        }));
        $$('li.col-compare').adopt(this.button.appendText("(up to four choices)"));
        this.button.addEvent('click', this.gocompare.bind(this));
        if (Browser.Engine.trident && Browser.Engine.version <= 4) {} else {
            $$('div.btm').setStyles({
                'position': 'absolute',
                'bottom': '0'
            })
        }
    },
    remove: function () {
        this.button.dispose()
    },
    gocompare: function () {
        if (this.comparecount >= 2) {
            this.buildTable();
            this.overlay.launch();
            var myFx = new Fx.Scroll($(document.body)).start(0, 160);
            return false
        } else {
            alert("Please select 2 or more cards to compare")
        }
        return false
    },
    buildTable: function () {
        this.closeDiv = new Element('div', {
            'class': 'tblClose'
        }).adopt(new Element('a', {
            'text': 'close',
            'href': '#',
            'events': {
                'click': function () {
                    this.overlay.remove()
                }.bind(this)
            }
        }));
        this.table = new Element('table', {
            'id': 'comparetable'
        });
        this.nameRow = new Element("tr").adopt(new Element("th", {
            "text": "Card name"
        }));
        this.selectedcards.each(function (i, n) {
            this.nameRow.adopt(new Element("td", {
                'html': this.cards[i]["cardName"],
                'styles': {
                    'font-weight': 'bold'
                }
            }).adopt(this.cards[i]["link"].clone().setStyles({
                'margin': '0 auto 0 auto'
            }).addEvent('click', function (e) {
                newwindow = window.open(e.target.href, 'mbna');
                if (window.focus) {
                    newwindow.focus()
                }
                return false
            }).appendText(', opens a new window')))
        }, this);
        this.btRow = new Element("tr").adopt(new Element("th", {
            "text": "Balance Transfers"
        }));
        this.selectedcards.each(function (i, n) {
            this.btRow.adopt(new Element("td", {
                'html': this.cards[i]["BT"]
            }))
        }, this);
        this.aprRow = new Element("tr").adopt(new Element("th", {
            "text": "Interest Rates"
        }));
        this.selectedcards.each(function (i, n) {
            this.aprRow.adopt(new Element("td", {
                'html': this.cards[i]["APR"]
            }))
        }, this);
        this.feaRow = new Element("tr").adopt(new Element("th", {
            "text": "Features"
        }));
        this.selectedcards.each(function (i, n) {
            this.feaRow.adopt(new Element("td", {
                'html': this.cards[i]["features"]
            }))
        }, this);
        this.exRow = new Element("tr").adopt(new Element("th", {
            "text": "Representative Example"
        }));
        this.selectedcards.each(function (i, n) {
            this.exRow.adopt(new Element("td", {
                'html': this.cards[i]["example"]
            }))
        }, this);
        this.applyRow = new Element("tr").adopt(new Element("th", {
            "text": "Apply"
        }));
        this.selectedcards.each(function (i, n) {
            this.applyRow.adopt(new Element("td").adopt(this.cards[i]["link"].clone().setStyles({
                'margin': '0 auto 0 auto'
            }).addEvent('click', function (e) {
                newwindow = window.open(e.target.href, 'mbna');
                if (window.focus) {
                    newwindow.focus()
                }
                return false
            }).appendText(', opens a new window')))
        }, this);
        this.table.adopt(new Element('tbody').adopt(this.nameRow, this.btRow, this.aprRow, this.rewRow, this.feaRow, this.exRow, this.applyRow));
        this.sp = new Element('div', {
            'styles': {
                'padding': '0 20px 0 20px'
            }
        });
        this.small.each(function (item) {
            this.sp.adopt(item)
        }, this);
        this.overlay.setContent(new Element('div', {
            'role': 'alert'
        }).adopt(new Element('div', {
            'class': 'top'
        }).adopt(this.closeDiv), this.table, this.sp, new Element('div', {
            'class': 'btm'
        })))
    },
    check: function (n) {
        box = this.cards[n]['ch'];
        if (this.selectedcards.contains(n + "")) {
            this.comparecount--;
            this.selectedcards.erase(n + "")
        } else {
            if (this.comparecount == 4) {
                alert("You can only select up to 4 cards to compare.");
                box.unselect()
            } else {
                this.comparecount++;
                this.selectedcards.include(n + "")
            }
        }
    }
});
checkbox = new Class({
    Implements: [Options, Events],
    options: {
        id: 'check'
    },
    initialize: function (options) {
        this.setOptions(options);
        this.skip = false;
        this.cb = new Element('input', {
            'type': 'checkbox',
            "id": this.options.id
        });
        this.box = new Element("span", {
            "class": "checkbox",
            "tabindex": 0,
            "id": this.options.id + "_styled"
        }).adopt(this.cb);
        this.box.addEvent("mouseover", function () {
            this.box.addClass('over')
        }.bind(this));
        this.box.addEvent("mouseout", function () {
            this.box.removeClass('over')
        }.bind(this));
        this.box.addEvent("mousedown", function () {
            this.box.addClass('pushed')
        }.bind(this));
        this.box.addEvent("mouseout", function () {
            this.box.removeClass('pushed')
        }.bind(this));
        this.box.addEvent("click", function () {
            if (!this.skip) {
                this.box.removeClass('pushed');
                if (this.box.hasClass("selected")) {
                    this.box.removeClass('selected');
                    this.cb.erase('checked')
                } else {
                    this.box.addClass('selected');
                    this.cb.set('checked', 'checked')
                }
                this.changed()
            } else {
                this.skip = false
            }
        }.bind(this));
        this.box.addEvent("focus", function () {
            this.box.addClass('over')
        }.bind(this));
        this.box.addEvent("blur", function () {
            this.box.removeClass('over')
        }.bind(this));
        this.box.addEvent("keydown", function (e) {
            if (e.key == 'enter' || e.key == 'space') {
                this.box.addClass('pushed')
            }
        }.bind(this));
        this.box.addEvent("keyup", function (e) {
            if (e.key == 'enter' || e.key == 'space') {
                if (!this.skip) {
                    this.box.removeClass('pushed');
                    if (this.box.hasClass("selected")) {
                        this.box.removeClass('selected');
                        this.cb.erase('checked')
                    } else {
                        this.box.addClass('selected');
                        this.cb.set('checked', 'checked')
                    }
                    this.changed()
                } else {
                    this.skip = false
                }
            }
        }.bind(this));
        return this
    },
    changed: function () {
        this.fireEvent('changed')
    },
    unselect: function () {
        if (this.box.hasClass("selected")) {
            this.box.removeClass('selected');
            this.cb.erase('checked')
        }
    }
});
greyout = new Class({
    Implements: [Options, Events],
    options: {
        'background': '#002D56',
        'opacity': 0.8,
        'speed': 500,
        'size': {
            'width': 922,
            'height': "auto"
        },
        'top': 200,
        'position': 'absolute',
        'innerclass': 'overlayTable'
    },
    initialize: function (options) {
        this.setOptions(options);
        this.fadeDiv = new Element('div', {
            'styles': {
                'display': 'block',
                'position': 'absolute',
                'top': 0,
                'left': 0,
                'width': this.getgreyoutsize().width,
                'height': this.getgreyoutsize().height,
                'background': this.options.background,
                'opacity': 0,
                'z-index': 220
            },
            'class': 'greyout'
        });
        this.inner = new Element('div', {
            'class': this.options.innerclass,
            'tabindex': '0',
            'role': 'alert',
            'styles': {
                'display': 'block',
                'position': this.options.position,
                'width': this.options.size.width,
                'opacity': 1,
                'top': this.getMidDivPosition().top,
                'left': this.getMidDivPosition().left,
                'z-index': 220
            }
        })
    },
    setContent: function (el) {
        this.inner.empty();
        this.inner.adopt(el)
    },
    getMidDivPosition: function () {
        var t = this.options.top;
        var l = ((window.getSize().x - this.options.size.width) / 2 < 0) ? 0 : (window.getSize().x - this.options.size.width) / 2;
        return {
            'left': l,
            'top': t
        }
    },
    getgreyoutsize: function () {
        var h = ($(document.body).getScrollSize().y > window.getSize().y) ? $(document.body).getScrollSize().y : window.getSize().y;
        var w = ($(document.body).getScrollSize().x > window.getSize().x) ? $(document.body).getScrollSize().x : window.getSize().x;
        return {
            'width': w,
            'height': h
        }
    },
    launch: function () {
        $(document.body).adopt(this.fadeDiv);
        $(document.body).adopt(this.inner);
        this.resize_overlay();
        window.addEvent('resize', this.resize_overlay.bind(this));
        myEffect = new Fx.Morph(this.fadeDiv, {
            duration: this.options.speed,
            transition: Fx.Transitions.Sine.easeOut,
            onComplete: function () {
                this.fadeDiv.addEvent('click', this.remove.bind(this))
            }.bind(this)
        });
        myEffect.start({
            'opacity': [this.options.opacity]
        });
        this.inner.focus();
        return false
    },
    remove: function () {
        this.inner.dispose();
        myEffect = new Fx.Morph(this.fadeDiv, {
            duration: this.options.speed,
            transition: Fx.Transitions.Sine.easeIn,
            onComplete: function () {
                this.fadeDiv.dispose()
            }.bind(this)
        });
        myEffect.start({
            'opacity': [0]
        });
        window.removeEvent('resize', this.resize_overlay.bind(this));
        return false
    },
    resize_overlay: function () {
        this.fadeDiv.setStyles({
            'width': this.getgreyoutsize().width,
            'height': this.getgreyoutsize().height
        });
        this.inner.setStyles({
            'top': this.getMidDivPosition().top,
            'left': this.getMidDivPosition().left
        })
    }
});
masthead = new Class({
    Implements: [Options, Events],
    options: {
        elId: "masthead",
        width: 535,
        height: 262,
        existStart: 3,
        banners: {}
    },
    initialize: function (options) {
        this.slides = new Array();
        this.setOptions(options);
        this.box = $(this.options.elId);
        this.list = this.box.getFirst("ul").getChildren("li");
        this.currentSlide = 0;
        this.list.each(function (item, i) {
            item.addEvent('click', this.selectSlide.bind(this, i))
        }, this);
        s = 0;
        if (Cookie.read('mbna_csm_v') > 0) {
            s = this.options.existStart - 1
        }
        this.selectSlide(s)
    },
    pause: function () {
        this.timer = $clear(this.timer)
    },
    start: function () {
        next = this.currentSlide + 1;
        if (next > this.options.banners.length - 1) {
            next = 0
        }
        this.timer = this.selectSlide.delay(this.options.banners[this.currentSlide].displayTime, this, next)
    },
    selectSlide: function (i) {
        this.currentSlide = i;
        if ($(document.body).hasClass('domReady')) {
            this.list.each(function (item, index) {
                if (index == i) {
                    item.getFirst("a").addClass("selected")
                } else {
                    item.getFirst("a").removeClass("selected")
                }
            }, this);
            d = new Element("div", {
                "class": "banner",
                "tabindex": 0,
                "role": "alert"
            });
            if (this.options.banners[i].type == "img") {
                this.an = new Element("a", {
                    "href": this.options.banners[i].url,
                    "target": this.options.banners[i].target
                });
                this.an.addEvent('click', function (e) {
                    e.preventDefault();
                    lab = this.options.banners[i].id;
                    gafire({
                        'cat': 'RealEstate',
                        'eventType': 'click',
                        'label': lab
                    });
                    if (this.options.banners[i].target == "_blank") {
                        newwindow = window.open(this.options.banners[i].url, 'mbna');
                        if (window.focus) {
                            newwindow.focus()
                        }
                    } else {
                        var locStr = (top.location != location ? "top.location" : "window.location");
                        setTimeout(locStr + "='" + this.options.banners[i].url + "'", 750)
                    }
                }.bind(this));
                d.adopt(this.an.adopt(new Element("img", {
                    "src": this.options.banners[i].file,
                    "alt": this.options.banners[i].alt,
                    "width": this.options.width,
                    "height": this.options.height
                })))
            }
            if (this.options.banners[i].type == "swf") {
                d.adopt(new Swiff(this.options.banners[i].file, {
                    width: this.options.width,
                    height: this.options.height
                }), new Element("div", {
                    "class": "hide"
                }).adopt(new Element("p", {
                    "text": "Transcript of Flash file: " + this.options.banners[i].alt
                })))
            }
            this.box.getFirst("div.banner").destroy();
            this.box.adopt(d);
            next = i + 1;
            if (next > this.options.banners.length - 1) {
                next = 0
            }
            this.timer = $clear(this.timer);
            this.timer = this.selectSlide.delay(this.options.banners[i].displayTime, this, next);
            return false
        } else {
            this.selectSlide.delay(50, this, this.currentSlide)
        }
    }
});
var TabPane = new Class({
    Implements: [Options, Events],
    options: {
        selected: 0
    },
    initialize: function (container, options) {
        this.container = container;
        this.selectedtab = 0;
        this.selectedtabID = "";
        this.tabs = new Hash();
        this.setup();
        this.urlchange = false
    },
    setup: function () {
        n = 0;
        tab = "";
        this.container.getElement('ul').getElements('li').each(function (item, index) {
            t = {
                'li': item,
                'div': $(item.getElement('a').get('href').substr(1)),
                'a': item.getElement('a')
            };
            item.getElement('a').adopt(new Element('span'));
            if (mbnaurl.get('fragment').contains(t.div.id)) {
                n = index;
                tab = t.div.id
            }
            if (index == this.options.selected) {
                t.li.addClass('selected');
                this.selectedtabID = t.div.id
            } else {
                t.div.addClass('hidden')
            }
            t.a.set('rel', index);
            t.a.addEvent('click', this.toggle.bind(this, index));
            t.a.addEvent('keypress', function (e) {
                if (e.key != 'tab') {
                    this.toggle.bind(this, index).run()
                }
            }.bind(this));
            this.tabs.include(index, t)
        }, this);
        this.options.selected = n;
        this.selectedtabID = tab;
        this.toggle(n);
        if (n > 0) {
            var winScroller = new Fx.Scroll(window);
            winScroller.start(0, $(this.selectedtabID).getPosition().y)
        }
    },
    btm: function () {
        if (Browser.Engine.trident && Browser.Engine.version <= 4) {
            $$('div.tabs').each(function (plinth) {
                plinth.getFirst('div.btm').destroy();
                plinth.adopt(new Element('div', {
                    'class': 'btm'
                }))
            });
            $$('div.btm').setStyle('bottom', '-15px')
        } else {
            $$('div.tabs').each(function (plinth) {
                plinth.getFirst('div.btm').destroy();
                plinth.adopt(new Element('div', {
                    'class': 'btm'
                }))
            });
            $$('div.btm').setStyle('bottom', '0px')
        }
    },
    toggle: function (n) {
        old = this.selectedtabID;
        this.options.selected = n;
        this.tabs.each(function (item, index) {
            if (index == this.options.selected) {
                item.li.addClass('selected');
                item.div.removeClass('hidden');
                this.selectedtabID = item.div.id
            } else {
                item.div.addClass('hidden');
                item.li.removeClass('selected')
            }
        }, this);
        mbnaurl.set('fragment', this.selectedtabID);
        freeze = $(window).getScroll().y;
        mbnaurl.go();
        window.scroll(0, freeze);
        this.btm.delay(300);
        return false
    }
});
var FaqList = new Class({
    Implements: [Options, Events],
    options: {
        showall: true,
        titles: 'h3',
        showclass: 'selected'
    },
    initialize: function (container, options) {
        this.setOptions(options);
        this.lnk = new Array();
        this.container = $(container);
        this.show = new Element('p', {
            'html': 'Show all',
            'class': 'show_all link'
        });
        this.show.addEvent('click', this.toggleall.bind(this));
        if (this.options.showall) {
            this.show.inject(this.container, 'top')
        }
        this.container.getElements(this.options.titles).each(function (item, index) {
            this.lnk[index] = new Element('a', {
                'text': ' More [+]',
                'class': 'expandable',
                'href': '#',
                'events': {
                    'click': function () {
                        item.fireEvent('click');
                        return false
                    }.bind(this)
                }
            }).inject(item, 'before');
            item.getNext().setStyles({
                display: 'none',
                overflow: 'hidden',
                height: 0
            });
            item.getNext().set('opacity', 0);
            item.addEvent('click', function (e) {
                if (item.getNext().getStyle('display') == 'block') {
                    item.toggleClass(this.options.showclass);
                    this.lnk[index].set('text', ' More [+]');
                    var myEffect = new Fx.Morph(item.getNext(), {
                        duration: 150,
                        transition: Fx.Transitions.Sine.easeOut,
                        onComplete: function () {
                            item.getNext().setStyle('display', 'none')
                        }
                    });
                    myEffect.start({
                        'height': [0],
                        'opacity': 0
                    });
                    this.btm.delay(300);
                    this.fireEvent('clicked', true, 150);
                    return false
                } else {
                    item.toggleClass(this.options.showclass);
                    this.lnk[index].set('text', ' Less [-]');
                    item.getNext().setStyle('display', 'block');
                    var myEffect = new Fx.Morph(item.getNext(), {
                        duration: 250,
                        transition: Fx.Transitions.Sine.easeOut
                    });
                    var size = 0;
                    item.getNext().getChildren().each(function (item, index) {
                        size += item.getSize().y;
                        item.getChildren().each(function (item, index) {
                            if (item.get('tag') == 'li') {
                                size += 5
                            }
                        })
                    });
                    myEffect.start({
                        'height': [size],
                        'opacity': 1
                    });
                    this.btm.delay(300);
                    this.fireEvent('clicked', true, 250);
                    return false
                }
            }.bind(this))
        }, this)
    },
    btm: function () {
        $$('div.plinth').each(function (plinth) {
            plinth.getFirst('div.btm').destroy();
            plinth.adopt(new Element('div', {
                'class': 'btm'
            }))
        });
        $$('div.btm').setStyle('bottom', '0px')
    },
    resize: function () {
        this.container.getElements(this.options.titles).each(function (item, index) {
            if (item.hasClass(this.options.showclass)) {
                var myEffect = new Fx.Morph(item.getNext(), {
                    duration: 250,
                    transition: Fx.Transitions.Sine.easeOut
                });
                var size = 0;
                item.getNext().getChildren().each(function (item, index) {
                    size += item.getSize().y
                });
                myEffect.start({
                    'height': [size],
                    'opacity': 1
                })
            }
        }, this)
    },
    toggleall: function () {
        if (this.show.get('text') == 'Hide all') {
            this.show.set('text', 'Show all');
            this.container.getElements(this.options.titles).each(function (item, index) {
                if (item.hasClass(this.options.showclass)) {
                    item.removeClass(this.options.showclass)
                }
                this.lnk[index].set('text', ' More [+]');
                var myEffect = new Fx.Morph(item.getNext(), {
                    duration: 350,
                    transition: Fx.Transitions.Sine.easeOut,
                    onComplete: function () {
                        item.getNext().setStyle('display', 'none')
                    }
                });
                myEffect.start({
                    'height': [0],
                    'opacity': 0
                });
                this.btm.delay(350);
                this.fireEvent('clicked', true, 350)
            }, this);
            return false
        } else {
            this.show.set('text', 'Hide all');
            this.container.getElements(this.options.titles).each(function (item, index) {
                if (!item.hasClass(this.options.showclass)) {
                    item.addClass(this.options.showclass)
                }
                this.lnk[index].set('text', ' Less [-]');
                item.getNext().setStyle('display', 'block');
                var myEffect = new Fx.Morph(item.getNext(), {
                    duration: 350,
                    transition: Fx.Transitions.Sine.easeOut
                });
                var size = 0;
                item.getNext().getChildren().each(function (item, index) {
                    size += item.getSize().y;
                    item.getChildren().each(function (item, index) {
                        if (item.get('tag') == 'li') {
                            size += 5
                        }
                    })
                });
                myEffect.start({
                    'height': [size],
                    'opacity': 1
                })
            }, this);
            this.btm.delay(350);
            this.fireEvent('clicked', true, 350)
        }
        return false
    }
});
/*var NewsFeedList = new Class({
    Implements: [Options, Events],
    options: {
        xmlPath: 'lib-ui/newsroom/xml/',
        imgPath: 'lib-ui/newsroom/img/thumb/',
        urlPath: 'about-us/news-room/',
        Dataxml: 'feed.xml',
        placeholder: 'newsroom'
    },
    initialize: function (id, options) {
        this.setOptions(options);
        var myRequest = new Request({
            url: this.options.xmlPath + this.options.Dataxml,
            onSuccess: function (txt, xml) {
                this.data = xml2json.parser(txt).newslist.newsitem;
                this.text = new Element('div');
                this.image = new Element('img', {
                    'src': this.options.imgPath + 'default.png',
                    'alt': ''
                });
                this.c1 = new Element('a', {
                    'href': '#',
                    'class': 'selected',
                    'text': 'select news story 1',
                    'styles': {
                        'overflow': 'hidden',
                        'text-indent': '-999px'
                    },
                    'events': {
                        'click': function () {
                            this.setslide(0);
                            return false
                        }.bind(this)
                    }
                });
                this.c2 = new Element('a', {
                    'href': '#',
                    'text': 'select news story 2',
                    'styles': {
                        'overflow': 'hidden',
                        'text-indent': '-999px'
                    },
                    'events': {
                        'click': function () {
                            this.setslide(1);
                            return false
                        }.bind(this)
                    }
                });
                this.c3 = new Element('a', {
                    'href': '#',
                    'text': 'select news story 3',
                    'styles': {
                        'overflow': 'hidden',
                        'text-indent': '-999px'
                    },
                    'events': {
                        'click': function () {
                            this.setslide(2);
                            return false
                        }.bind(this)
                    }
                });
                this.controls = new Element('ul').adopt(new Element('li', {
                    'class': 'c1'
                }).adopt(this.c1), new Element('li', {
                    'class': 'c2'
                }).adopt(this.c2), new Element('li', {
                    'class': 'c3'
                }).adopt(this.c3), new Element('li', {
                    'class': 'all'
                }).adopt(new Element('a', {
                    'href': this.options.urlPath,
                    'text': 'Go to the news room',
                    'styles': {
                        'overflow': 'hidden',
                        'text-indent': '-999px'
                    }
                })));
                this.current = 0;
                $(this.options.placeholder).empty();
                $(this.options.placeholder).adopt(new Element('div', {
                    'class': 'lft'
                }).adopt(this.image, this.controls), new Element('div', {
                    'class': 'rgt'
                }).adopt(this.text), new Element('div', {
                    'class': 'clearBoth'
                }), new Element('div', {
                    'class': 'top'
                }), new Element('div', {
                    'class': 'btm'
                }));
                this.setslide(0)
            }.bind(this),
            onFailure: function (xml) {}.bind(this)
        }).send()
    },
    setslide: function (slide) {
        this.current = slide;
        this.text.empty();
        d = this.options.urlPath + this.data[slide].url;
        img = this.options.imgPath + this.data[slide].image;
        if (this.data[slide].image == 'none') {
            img = this.options.imgPath + 'default.png'
        }
        this.image.set('src', img);
        this.text.adopt(new Element('p', {
            'text': this.data[slide].title
        }).adopt(new Element('br'), new Element('a', {
            'href': d,
            'html': 'more<span class="hide"> about ' + this.data[slide].title + '</span>...'
        })));
        this.c1.removeClass('selected');
        this.c2.removeClass('selected');
        this.c3.removeClass('selected');
        switch (slide) {
        case 0:
            this.c1.addClass('selected');
            break;
        case 1:
            this.c2.addClass('selected');
            break;
        case 2:
            this.c3.addClass('selected');
            break
        }
        next = this.current + 1;
        if (next > 2) {
            next = 0
        }
        this.timer = $clear(this.timer);
        this.timer = this.setslide.delay(5000, this, next)
    }
});*/
limitRows = new Class({
    Implements: [Events],
    initialize: function (n) {
        this.show = n;
        this.rows = $$("div.card-row");
        this.rows.each(function (item, i) {
            if (i >= this.show) {
                item.setStyle('display', 'none')
            }
        }, this);
        this.disp = $$("div.cardDisplay");
        this.btn = new Element('a', {
            'href': '#',
            'text': 'View more card choices',
            'class': 'showall',
            'events': {
                'click': this.showall.bind(this)
            }
        });
        this.disp.adopt(this.btn)
    },
    showall: function () {
        this.rows.each(function (item, i) {
            if (i >= this.show) {
                item.setStyle('display', 'block')
            }
        }, this);
        this.btn.dispose();
        return false
    }
});
var external = new Class({
    initialize: function () {
        this.top = (window.getSize().y - 300) / 3;
        this.overlay = new greyout({
            'innerclass': 'alertbox',
            'position': 'fixed',
            'top': this.top,
            'size': {
                'width': 400
            }
        });
        this.Links = $$('a[rel=external]');
        this.Links.each(function (item) {
            item.addEvent('click', function () {
                this.launch(item);
                return false
            }.bind(this))
        }, this)
    },
    launch: function (i) {
        if (i.hasClass('trusted')) {
            t = "By choosing this link you will be taken to another web site where the privacy and security policies may differ from our site. <br /> MBNA is not responsible for the content of external websites."
        } else {
            t = "By clicking Continue, you will be taken to a website that is not affiliated with MBNA Europe Bank and may offer a different privacy policy and level of security. <br /> MBNA Europe Bank is not responsible for and does not endorse, guarantee or monitor content, availability, viewpoints, products or services that are offered or expressed on other websites."
        }
        cont = new Element('div').adopt(new Element('h3', {
            'text': 'You are now leaving MBNA Europe Bank'
        }), new Element('p', {
            'html': t
        }), new Element('div').adopt(new Element('p').adopt(new Element('a', {
            'text': 'back to mbna.ie',
            'class': 'button-large backtosite',
            'href': '#',
            'events': {
                'click': function () {
                    if (i.hasClass('a2o')) {
                        lab = document.title + '_' + i.text;
                        gafire({
                            'cat': 'external-a2o',
                            'eventType': 'click-backtosite',
                            'label': lab
                        })
                    } else if (i.hasClass('insurance')) {
                        lab = document.title + '_' + i.text;
                        gafire({
                            'cat': 'external-insurance',
                            'eventType': 'click-backtosite',
                            'label': lab
                        })
                    } else {
                        lab = document.title + '_' + i.text;
                        gafire({
                            'cat': 'external-other',
                            'eventType': 'click-backtosite',
                            'label': lab
                        })
                    }
                    this.overlay.remove();
                    return false
                }.bind(this)
            }
        }), new Element('a', {
            'text': 'continue to external site, opens a new window',
            'class': 'button-large continue',
            'href': '#',
            'events': {
                'click': function () {
                    if (i.hasClass('a2o')) {
                        lab = document.title + '_' + i.text;
                        gafire({
                            'cat': 'external-a2o',
                            'eventType': 'click',
                            'label': lab
                        })
                    } else if (i.hasClass('insurance')) {
                        lab = document.title + '_' + i.text;
                        gafire({
                            'cat': 'external-insurance',
                            'eventType': 'click',
                            'label': lab
                        })
                    } else {
                        lab = document.title + '_' + i.text;
                        gafire({
                            'cat': 'external-other',
                            'eventType': 'click',
                            'label': lab
                        })
                    }
                    newwindow = window.open(i.href, 'mbna');
                    if (window.focus) {
                        newwindow.focus()
                    }
                    this.overlay.remove();
                    return false
                }.bind(this)
            }
        }))));
        this.overlay.setContent(cont);
        this.overlay.launch()
    }
});
Tooltip = new Class({
    Implements: [Options, Events],
    options: {
        x: 0,
        y: 0,
        duration: 0,
        tip: '',
        passelement: false,
        element: null,
        offsety: 23,
        offsetx: 15
    },
    initialize: function (options) {
        this.setOptions(options);
        this.t = null;
        if (this.options.passelement) {
            this.content = this.options.element
        } else {
            this.content = new Element('p', {
                'html': this.options.tip
            })
        }
        this.tipBox = new Element('div', {
            'styles': {
                'opacity': 0,
                'top': this.options.y - this.options.offsety,
                'left': this.options.x + this.options.offsetx
            },
            'class': 'ToolTip'
        }).adopt(new Element('div', {
            'class': 'top'
        }).adopt(new Element('p', {
            styles: {
                'text-align': 'right'
            }
        }).adopt(new Element('a', {
            'text': 'close',
            'styles': {
                'cursor': 'pointer'
            },
            events: {
                click: function () {
                    this.hide()
                }.bind(this)
            }
        }))), new Element('div', {
            'class': 'lft'
        }), new Element('div', {
            'class': 'midle'
        }).adopt(this.content), new Element('div', {
            'class': 'btm'
        }));
        $(document.body).adopt(this.tipBox)
    },
    show: function () {
        var myEffect = new Fx.Morph(this.tipBox, {
            duration: 200,
            transition: Fx.Transitions.Sine.easeIn
        });
        myEffect.start({
            'opacity': 1
        });
        this.t = $clear(this.t);
        if (this.options.duration > 0) {
            this.t = this.hide.delay(this.options.duration, this)
        }
    },
    hide: function () {
        var myEffect = new Fx.Morph(this.tipBox, {
            duration: 200,
            transition: Fx.Transitions.Sine.easeIn
        });
        myEffect.start({
            'opacity': 0
        })
    },
    setCoord: function (x, y) {
        this.tipBox.setStyles({
            'top': y - this.options.offsety,
            'left': x + this.options.offsetx
        })
    }
});
Video = new Class({
    Implements: [Options, Events],
    options: {
        width: 649,
        height: 276,
        player: 'mbnaplayer.swf',
        folderDepth: '',
        xml: '',
        placement: 'player'
    },
    initialize: function (options) {
        this.setOptions(options);
        this.p = this.options.folderDepth + 'lib-ui/video/player/' + this.options.player;
        this.x = this.options.folderDepth + 'lib-ui/video/xml/' + this.options.xml;
        try {
            var myRequest = new Request({
                url: this.x,
                onSuccess: function (txt) {
                    this.data = xml2json.parser(txt);
                    this.build()
                }.bind(this),
                onFailure: function () {}.bind(this)
            }).send()
        } catch (e) {
            this.data = {
                vidset: {
                    title: 'Contactless',
                    flvlocation: 'contactless-480x270.flv',
                    sidelinks: {
                        sidelink: [{
                            podtype: 'image',
                            values: 'paypass.png'
                        }, {
                            podtype: 'text',
                            values: 'Introducing new contacless technology'
                        }]
                    },
                    transcript: 'contactless-480x270.txt'
                }
            };
            this.build()
        }
    },
    build: function () {
        if (Enviro == 1) {
            f = "/ireland"
        } else {
            f = ""
        }
        this.translink = new Element('p', {
            'class': 'transcript'
        }).adopt(new Element('a', {
            'href': this.options.folderDepth + 'lib-ui/video/transcripts/' + this.data.vidset.transcript,
            'class': 'cta',
            'rel': 'blank',
            'text': 'View transcript of ' + this.data.vidset.title + ' video',
            'events': {
                'click': function () {
                    newwindow = window.open(this.options.folderDepth + 'lib-ui/video/transcripts/' + this.data.vidset.transcript, 'mbna');
                    if (window.focus) {
                        newwindow.focus()
                    }
                    return false
                }.bind(this),
                'keypress': function (e) {
                    if (e.key == 'enter' || e.key == 'space') {
                        newwindow = window.open(this.options.folderDepth + 'lib-ui/video/transcripts/' + this.data.vidset.transcript, 'mbna');
                        if (window.focus) {
                            newwindow.focus()
                        }
                        return false
                    }
                }.bind(this)
            }
        }).adopt(new Element('img', {
            'src': f + '/lib-ui/img/modules/global/new_window.png',
            'alt': 'opens a new window'
        })));
        $(this.options.placement).adopt(new Swiff(this.p, {
            width: this.options.width,
            height: this.options.height,
            properties: {
                'tabindex': 0
            },
            vars: {
                'mbnaxml': this.x,
                'base': this.options.folderDepth
            }
        }), this.translink)
    }
});
var msgCheck = new Class({
    Implements: [Options, Events],
    options: {
        target: 'alert',
        folderDepth: '',
        xml: 'lib-ui/mbnauto/xml/alert.xml'
    },
    initialize: function (options) {
        this.setOptions(options);
        try {
            var myRequest = new Request({
                url: this.options.folderDepth + this.options.xml,
                onSuccess: function (txt) {
                    this.data = xml2json.parser(txt);
                    this.build()
                }.bind(this)
            }).send()
        } catch (e) {}
    },
    build: function () {
        if (this.data.message.image != 'none') {
            m = new Element('img', {
                'src': this.options.folderDepth + this.data.message.image,
                'alt': this.data.message.alt
            });
            $(this.options.target).adopt(m);
            if (this.data.message.href != 'none') {
                new Element('a', {
                    'href': this.data.message.href
                }).wraps(m)
            }
            $(this.options.target).setStyle('margin', '0 0 5px 0')
        }
    }
});
function playtrack(options) {
    options = JSON.decode(options);
    _gaq.push(['_trackEvent', 'videos', options.eventType, options.title])
}
function gafire(options) {
    _gaq.push(['_trackEvent', options.cat, options.eventType, options.label])
}
