var OverlaySwf = new Class({
    Implements: [Options, Events],
    options: {
        swf: '',
        id: 'launcher',
        background: '#333333',
        opacity: 0.7,
        speed: 500,
        size: {
            width: 100,
            height: 100
        }
    },
    initialize: function (options) {
        this.setOptions(options);
        this.options.id.each(function (item) {
            $(item).addEvent('click', this.launch.bind(this))
        }, this);
        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
            }
        })
    },
    create: function () {
        this.swfDiv = new Element('div', {
            'styles': {
                'display': 'block',
                'position': 'absolute',
                'width': this.options.size.width,
                'height': this.options.size.height,
                'top': this.getMidDivPosition().top,
                'left': this.getMidDivPosition().left,
                'opacity': 1
            }
        });
        this.swfDiv.adopt(new Swiff(this.options.swf, {
            id: this.options.id,
            width: this.options.size.width,
            height: this.options.size.height
        }))
    },
    getMidDivPosition: function () {
        var t = ((window.getSize().y - this.options.size.height) / 2 < 0) ? 0 : (window.getSize().y - this.options.size.height) / 2;
        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 + 25 : window.getSize().y + 25;
        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);
        window.addEvent('resize', this.resize.bind(this));
        myEffect = new Fx.Morph(this.fadeDiv, {
            duration: this.options.speed,
            transition: Fx.Transitions.Sine.easeOut,
            onComplete: function () {
                this.create();
                $(document.body).adopt(this.swfDiv);
                this.fadeDiv.addEvent('click', this.remove.bind(this))
            }.bind(this)
        });
        myEffect.start({
            'opacity': [this.options.opacity]
        });
        return false
    },
    remove: function () {
        this.swfDiv.destroy();
        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.bind(this))
    },
    resize: function () {
        this.fadeDiv.setStyles({
            'width': this.getgreyoutsize().width,
            'height': this.getgreyoutsize().height
        });
        this.swfDiv.setStyles({
            'top': this.getMidDivPosition().top,
            'left': this.getMidDivPosition().left
        })
    }
});
var FaqList = new Class({
    Implements: [Options, Events],
    options: {
        showall: true,
        titles: 'h3',
        showclass: 'selected'
    },
    initialize: function (container, options) {
        this.setOptions(options);
        this.container = $(container);
        this.show = new Element('p', {
            'html': 'Show all topics',
            'class': 'show_all'
        });
        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) {
            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);
                    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.fireEvent('clicked', true, 150);
                    return false
                } else {
                    item.toggleClass(this.options.showclass);
                    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.fireEvent('clicked', true, 250);
                    return false
                }
            }.bind(this))
        }, this)
    },
    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 topics') {
            this.show.set('text', 'Show all topics');
            this.container.getElements(this.options.titles).each(function (item, index) {
                if (item.hasClass(this.options.showclass)) {
                    item.removeClass(this.options.showclass)
                }
                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.fireEvent('clicked', true, 350)
            }, this);
            return false
        } else {
            this.show.set('text', 'Hide all topics');
            this.container.getElements(this.options.titles).each(function (item, index) {
                if (!item.hasClass(this.options.showclass)) {
                    item.addClass(this.options.showclass)
                }
                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.fireEvent('clicked', true, 350)
        }
        return false
    }
});
var confirm = new Class({
    initialize: function () {
        this.setup()
    },
    setup: function () {
        var links = $$('a[rel=external]');
        var msg = 'You are now leaving the MBNA website, which is hosted by MBNA Europe Bank Limited.<br /><br />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.  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.<br /><br />You can click the Close button now to return.<br /><br />';
        links.each(function (link) {
            new alertBox({
                id: link,
                msg: msg
            })
        })
    }
});
var alertBox = new Class({
    Implements: [Options, Events],
    options: {
        url: '',
        id: '',
        msg: '',
        background: '#333333',
        opacity: 0.7,
        speed: 500,
        size: {
            width: 500,
            height: 'auto'
        }
    },
    initialize: function (options) {
        this.setOptions(options);
        this.options.id.addEvent('click', this.launch.bind(this));
        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,
                zindex: 20
            }
        });
        this.alertBox = new Element('div', {
            'id': 'alertBox-Box',
            'styles': {
                'position': 'fixed',
                'width': this.options.size.width,
                'height': this.options.size.height,
                'display': 'block',
                'top': 0,
                'left': this.getMidDivPosition().left
            }
        }).adopt(new Element('div', {
            'id': 'alertBox-InBox'
        }).adopt(new Element('div', {
            'id': 'alertBox-BoxContent'
        }).adopt(new Element('div', {
            'id': 'alertBox-BoxWrapper',
            'html': this.options.msg
        }).adopt(new Element('div', {
            'id': 'alertBox-Buttons'
        }).adopt(new Element('input', {
            'id': 'BoxConfirmBtnOk',
            'value': 'Continue',
            'type': 'button',
            style: {
                'width': 70
            },
            events: {
                'click': this.goto.bind(this)
            }
        }), new Element('input', {
            'id': 'BoxConfirmBtnCancel',
            'value': 'Close',
            'type': 'button',
            style: {
                'width': 70
            },
            events: {
                'click': this.remove.bind(this)
            }
        }))))))
    },
    goto: function () {
        window.location = this.options.id.get('href')
    },
    getgreyoutsize: function () {
        var h = ($(document.body).getScrollSize().y > window.getSize().y) ? $(document.body).getScrollSize().y + 25 : window.getSize().y + 25;
        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.alertBox);
        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]
        });
        return false
    },
    getMidDivPosition: function () {
        if (this.alertBox) {
            var size = 0;
            this.alertBox.getChildren().each(function (item, index) {
                size += item.getSize().y
            });
            this.options.size.height = size
        }
        var t = ((window.getSize().y - this.options.size.height) / 2 < 0) ? 0 : (window.getSize().y - this.options.size.height) / 2;
        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
        }
    },
    remove: function () {
        this.alertBox.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))
    },
    resize_overlay: function () {
        this.fadeDiv.setStyles({
            'width': this.getgreyoutsize().width,
            'height': this.getgreyoutsize().height
        });
        this.alertBox.setStyles({
            'top': this.getMidDivPosition().top,
            'left': this.getMidDivPosition().left
        })
    }
});

function bookmarksite(title, url) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url, "")
    } else if (window.opera && window.print) {
        var elem = document.createElement('a');
        elem.setAttribute('href', url);
        elem.setAttribute('title', title);
        elem.setAttribute('rel', 'sidebar');
        elem.click()
    } else if (document.all) {
        window.external.AddFavorite(url, title)
    }
}
function getStringfromurl() {
    var url = location.href;
    var var_val = new Array();
    var url_vars = url.split('?')[1];
    if (url_vars != null) {
        var gets = url_vars.split('&');
        for (var g = 0; g < gets.length; g++) {
            var vars_arr = gets[g].split('=');
            var_val[vars_arr[0]] = vars_arr[1]
        }
    } else {
        var_val[0] = false
    }
    return var_val
}
var OverlayImage = new Class({
    Implements: [Options, Events],
    options: {
        url: '',
        id: 'launcher',
        background: '#333333',
        opacity: 0.7,
        speed: 500,
        size: {
            width: 100,
            height: 100
        }
    },
    initialize: function (options) {
        this.setOptions(options);
        this.options.id.each(function (item) {
            $(item).addEvent('click', this.launch.bind(this))
        }, this);
        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,
                zindex: 20
            }
        });
        this.imageDiv = new Element('div', {
            'styles': {
                'display': 'block',
                'position': 'absolute',
                'width': this.options.size.width,
                'height': this.options.size.height,
                'opacity': 1,
                'top': this.getMidDivPosition().top,
                'left': this.getMidDivPosition().left
            }
        });
        this.closeDiv = new Element('div', {
            'styles': {
                'width': '85px',
                'height': '70px',
                'display': 'block',
                'float': 'right',
                'background': '#0052C2',
                'position': 'absolute',
                'top': 0,
                'right': 0,
                'cursor': 'pointer'
            },
            events: {
                'click': this.remove.bind(this)
            }
        }).adopt(new Element('p', {
            html: 'close',
            styles: {
                'font-weight': 'bold',
                'color': '#ffffff',
                'margin': '20px 0 0 25px'
            }
        }));
        this.imageDiv.adopt(new Element('img', {
            'width': this.options.size.width,
            'height': this.options.size.height,
            'src': this.options.url
        }));
        this.imageDiv.adopt(this.closeDiv)
    },
    getMidDivPosition: function () {
        var t = ((window.getSize().y - this.options.size.height) / 2 < 0) ? 0 : (window.getSize().y - this.options.size.height) / 2;
        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 + 25 : window.getSize().y + 25;
        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.imageDiv);
        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]
        });
        return false
    },
    remove: function () {
        this.imageDiv.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))
    },
    resize_overlay: function () {
        this.fadeDiv.setStyles({
            'width': this.getgreyoutsize().width,
            'height': this.getgreyoutsize().height
        });
        this.imageDiv.setStyles({
            'top': this.getMidDivPosition().top,
            'left': this.getMidDivPosition().left
        })
    }
});
var confirm = new Class({
	initialize: function(){
		this.setup();
	},
	setup: function() {	
		var links = $$('a[rel=external]');
		var msg = 'You are now leaving the MBNA Ireland website, which is hosted by MBNA Europe Bank Limited.<br /><br />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.  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.<br /><br />You can click the Close button now to return.<br /><br />';
		links.each(function(link){
	new alertBox({id:link, msg:msg});
							});
	
	}
});

/**
 * @copyright (c) 2009 Eduardo D. Sada (www.coders.me)
 * @license MIT - http://es.wikipedia.org/wiki/Licencia_MIT
*/
var alertBox=new Class({
					   Implements:[Options, Events],
					   options:{url:'',id:'', msg:'', background:'#333333',opacity:0.7,speed:500,size:{width:500,height:'auto'}},
					   initialize: function(options){
						   this.setOptions(options);
						   this.options.id.addEvent('click',this.launch.bind(this));
						   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,zindex:20}});
						   //set up message
						   
			
						   
this.alertBox = new Element('div',{'id':'alertBox-Box', 'styles':{'position':'fixed', 'width': this.options.size.width, 'height': this.options.size.height, 'display':'block','top':0, 'left':this.getMidDivPosition().left}}).adopt( new Element('div',{'id':'alertBox-InBox'}).adopt(new Element('div',{'id':'alertBox-BoxContent'}).adopt(new Element('div',{'id':'alertBox-BoxWrapper', 'html':this.options.msg}).adopt(new Element('div',{'id':'alertBox-Buttons'}).adopt(new Element('input',{'id':'BoxConfirmBtnOk', 'value':'Continue', 'type':'button',style:{'width':70}, events:{'click':this.goto.bind(this)}}),new Element('input',{'id':'BoxConfirmBtnCancel','value':'Close', 'type':'button',style:{'width':70}, events:{'click':this.remove.bind(this)}}))))));
						   
						   
					   },
					   goto:function(){
						  window.location=this.options.id.get('href');
					   },
					   getgreyoutsize:function(){
								
														  var h=($(document.body).getScrollSize().y>window.getSize().y)?$(document.body).getScrollSize().y+25:window.getSize().y+25;
														  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.alertBox);
									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]});
									return false;
									},
									getMidDivPosition:function(){
								                          if(this.alertBox){
														  
														 var size=0;
														 this.alertBox.getChildren().each(function(item, index){size+=item.getSize().y;});
														 this.options.size.height=size;
														  }
														   var t=((window.getSize().y-this.options.size.height)/2<0)?0:(window.getSize().y-this.options.size.height)/2;
														   
														   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}
								}
								,
									remove:function(){
									this.alertBox.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));},
										resize_overlay:function(){
										this.fadeDiv.setStyles({'width':this.getgreyoutsize().width,'height':this.getgreyoutsize().height});
											this.alertBox.setStyles({'top':this.getMidDivPosition().top, 'left':this.getMidDivPosition().left});

 }
								
					   
					   });