window.onload = init;

var load = new Array();

function init() {
    var c;
    if ((c = load.length)) {
        while (c--) {
            load[c]();
        }
    }
    document.onclick = function (e) {
        e = e || window.event;
        var target = e.target || e.srcElement;
        if ('a' === target.nodeName.toLowerCase()) {
            if ('audio' === target.rel) {
                Pop.player('/media/player.php');
                return false;
            }
        }
        return true;
    };
    if (OVERLAY) {
        img.init();
        window.onresize = resize;
    }
}

var Pop = {
    winRef: null,
    player: function (href) {
        if (null == Pop.winRef || Pop.winRef.closed) {
            Pop.winRef = window.open(
                href,
                'audioPlayer',
                'resizable=yes, scrollbars=yes, top=0, left=0, width=600, height=300'
            );
            Pop.winRef.focus();
        } else {
            Pop.winRef.focus();
        }
    }
};

var Player = {
    insert: function (query) {
        UFO.create(
            {
                movie: "/media/swf/xspf_player.swf?playlist_url=/media/playlist.php?band="
                    + query + "&autoload=true",
                width: "320",
                height: "62",
                quality: "high",
                allowscriptaccess: "sameDomain",
                bgcolor: "#999999",
                majorversion: "7",
                build: "0",
                xi: "true"
            },
            "attachments-music"
        );
    }
};

var Splash = {
    init: function () {
        window.load[load.length] = Splash.toggle;
    },
    toggle: function () {
        Splash.footage = document.getElementById('footage').firstChild;
        Splash.list = document.getElementById('bandstand').getElementsByTagName('LI');
        Splash.link = document.getElementById('bandstand').getElementsByTagName('A');
        for (i = 0, c = Splash.link.length; i < c; i++) {
            //alert('/img/photos/splash-' + Splash.pics[i] + '.jpg');
            Splash.link[i].onmouseover = Splash.swap;
        }
    },
    swap: function () {
        var pc = this.href.split('/');
        Splash.footage.src = '/img/photos/splash-' + pc[(pc.length - 2)] + '.jpg';
        var c = Splash.list.length;
        while (c--) {
            Splash.list[c].className = '';
        }
        this.parentNode.className = 'highlight';
    }
};

var Slide = {
    h: 320,
    block: null,
    init: function () {
        try {
            Slide.block = document.getElementById('slide');
            Slide.s = document.getElementById('shrink');
            Slide.s1 = Slide.s.getElementsByTagName('DIV')[0];
            Slide.x = Slide.s1.offsetHeight;
            Slide.w = document.getElementById('wrap');
            Slide.w1 = Slide.w.getElementsByTagName('DIV')[0].firstChild
            Slide.s.style.height = Slide.h + 'px';
            Slide.s.style.backgroundImage = 'url(' + Slide.w1.src + ')';
            Slide.s1.style.display = 'none';
            Slide.w.style.height = Slide.x + 'px';
            //Slide.w1m = ((Slide.h / 2) - (Slide.x / 2));
            //Slide.w1.style.marginTop = '-' + Slide.w1m + 'px';
            //
            Slide.r = Slide.h;
            Slide.n = Slide.x;
            Slide.z = Slide.n;
            //
            window.load[load.length] = Slide.scroll;
        } finally {
            if (Slide.block) {
                Slide.block.style.visibility = 'visible';
            }
        }
    },
    scroll: function () {
        window.setTimeout(Slide.fade, 2000);
    },
    fade: function () {
        Slide.loop = window.setInterval(Slide.collapse, 10);
    },
    collapse: function () {
        Slide.r -= 5;
        Slide.n += 5;
        if (Slide.r > Slide.z) {
            Slide.s.style.height = Slide.r + 'px';
            Slide.w.style.height = Slide.n + 'px';
        } else {
            Slide.s.style.backgroundImage = '';
            Slide.s1.style.display = '';
            window.clearInterval(Slide.loop);
        }
    }
};


