
/* ************************************************************************
*   Global variables
* */

var basepath = '/apoteksgruppen/'

/**************************************************************************
*
*      Util to fire stored functions based on params and styles
*      see documentation http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/
*/

UTIL = {

    fire: function (func, funcname, args) {

        var namespace = PFO.initialize;  // indicate your obj literal namespace here

        funcname = (funcname === undefined) ? 'init' : funcname;
        if (func !== '' && namespace[func] && typeof namespace[func][funcname] == 'function') {
            namespace[func][funcname](args);
        }

    },

    loadEvents: function () {

        var bodyId = document.body.id;

        // hit up common first.
        UTIL.fire('common');
        UTIL.fire('fallback');


        // do all the classes too.
        $.each(document.body.className.split(/\s+/), function (i, classnm) {
            UTIL.fire(classnm);
            UTIL.fire(classnm, bodyId);
        });

        UTIL.fire('common', 'finalize');

    }

};




/*********************************************************
*
*       Conditional downloading of js files using yepnope
*
* */


yepnope([
    {
        load: basepath + 'upload/files/js/libs/h5f.js',
        callback: function () {
            /* to delay a callback set it up in a the PFO.complate object */
            jQuery(function ($) {
                H5F.setup($('form'));
            });
        }
    }]
);

