(function(http) {
    // hb@geekworksunlimited.com
    if (!http) {
        return;
    }
    var i, slides, slide, json;
    function next(el, a, i) {
        if (!el || !a || !a.length) {
            return;
        }
        if (i > a.length) {
            i = 0;
        }
        var url = a[i], img = el.getElementsByTagName('img')[0] || document.createElement('img');
        setTimeout(function() {
            img.src = url;
            next(el, a, i + 1);
        }, 6000);
    }
    slides = [document.getElementById('slides-home')];
    for (i = 0; i < slides.length; i++) {
        slide = slides[i];
        if (!slide) {
            continue; // not on this page
        }
        http.open('GET', '/' + slide.id.replace(/\-/, '/') + '/', true);
        http.onreadystatechange = function() {
            if (http.readyState == 4) {
                if (http.status == 200) {
                    json = eval('(' + http.responseText + ')');
                    next(slide, json, 0);
                }
            }
        };
        http.send(null);
    }
})(function() {
    return ('XMLHttpRequest' in window) ? new XMLHttpRequest() : (('ActiveXObject' in window) ? new ActiveXObject("Msxml2.XMLHTTP") : null);
}());
