contents = null

function startEngine(firstPage) {
    /* this will initialise head */

    loadScript('framework/stylesheets.js', function() {
        initStylesheets()
    })

    var loc = new String(window.location)
    loadScript('framework/pageLoader.js', function() {
        setLoadedPageContainer(document.getElementById('contents'))
        if (firstPage && ! loc.match('index.php')) {
            loadPage(firstPage)
        }
    })
    loadScript('effects/fader.js') // this will initialise head
    loadScript('effects/dayshift.js', function() { initClock() } )
}

function initXmlHttp() {
    try {
        return new ActiveXObject('Msxml2.XMLHTTP')
    } 
    catch (e) {
        try {
            return new ActiveXObject('Microsoft.XMLHTTP')
        } 
        catch (e2) {
            return new XMLHttpRequest()
        }
    }
}

pageFadeInAmount = 500
function changePage(page) {
    fadeChangePage(page, pageFadeInAmount)
}

////////////////////////////////////////////////////////////////////////////////
// convenience functions
////////////////////////////////////////////////////////////////////////////////
function linkFade(link) {
    var arr = rgbToArray(styles.rules.body.getItem('color'))
    startFadeOver(link, arr[0], 246, arr[1], 157, arr[2], 12, 1)
}

function loadGallery(name) {
    styles.deactivate('horizontal')
    styles.activate('wide')
    loadScript('toys/gallery/simpleImageDisplay.js')
    loadScript('toys/gallery/imageDisplayConfig.js')
    onPageLoad(function () { startImageEngine(name) } )
    loadScript('toys/gallery/images.js', function() { loadPage('images') })
}
