(function() { // Start closure

    //
    // General page load dynamics
    // and custom behaviours
    //

    // Import Library
    //
    eval(JELLY.unpack());
    






    // MODAL POPUP




    
    // Dialogs 
    //
    

    Q('a.track-order-link').each(function (el) {
        Dialog.init();
        addEvent(el, 'click', function (e) {
            stopEvent(e);
            var data = parseQuery(el),
			toolbar = confirmToolbar(data.goto),
			message = createElement('p html:"' +
				"You will be taken away from Lipsy's website and to the couriers website to track your order \
				<br /><br /> \
				Continue?" + '"'),
			branch = createBranch('div', [message, toolbar]).root;
            Dialog.setContent(branch).open(350);
        });
    });

    Q('div[id^=order-history-][id$=-info]').each(function (el) {
        Dialog.init();
        removeElement(el);
        removeClass(el, 'js-hide');
        addClass(el, 'content flow-area');
        var target = el.id.replace(/-info$/, '-th'),
		branch = createBranch('p', 'a @:trigger, href:, text:"More info"');
        branch.trigger.onclick = function (e) {
            stopEvent(e);
            Dialog.setContent(el).open(350);
        };
        insertElement(branch.root, target);
    });



    





    // TOOLTIPS





    // Fix IE < 8 using alt text as tooltips
    //
    if (browser.ie && browser.ie < 8) {
        Q('img[alt]:not([title])').each(function(el) {
            el.title = '';
        });
    }






    

})();     // End Closure
