/**
 *
 * Home Script
 * Requires the Jax JavaScript Library
 *
 */

var fx = new JaxFx();
var curDiv = null;
var imgDivs = [['homeLocalImageArea', '0px'],
               ['homeVenuesImageArea', '-330px'],
               ['homeEventsImageArea', '-660px'],
               ['homePeopleImageArea', '-990px'],
               ['homeSupportersImageArea', '-1320px'],
               ['homeBlogImageArea', '-1650px'],
               ['homePollsImageArea', '-1980px'],
               ['homeInvolvedImageArea', '-2310px']];

function initFx() {
    fx.addStyles('homeLocalImageArea', [['top', '0px'],
                                        ['left', '960px'],
                                        ['zIndex', '11']]);
    fx.addStyles('homeVenuesImageArea', [['top', '-330px'],
                                         ['left', '960px'],
                                         ['zIndex', '12']]);
    fx.addStyles('homeEventsImageArea', [['top', '-660px'],
                                         ['left', '960px'],
                                         ['zIndex', '13']]);
    fx.addStyles('homePeopleImageArea', [['top', '-990px'],
                                         ['left', '960px'],
                                         ['zIndex', '14']]);
    fx.addStyles('homeSupportersImageArea', [['top', '-1320px'],
                                             ['left', '960px'],
                                             ['zIndex', '15']]);
    fx.addStyles('homeBlogImageArea', [['top', '-1650px'],
                                       ['left', '960px'],
                                       ['zIndex', '16']]);
    fx.addStyles('homePollsImageArea', [['top', '-1980px'],
                                        ['left', '960px'],
                                        ['zIndex', '17']]);
    fx.addStyles('homeInvolvedImageArea', [['top', '-2310px'],
                                           ['left', '960px'],
                                           ['zIndex', '18']]);
}

function slideHeader(dv) {
    curY = 0;
    newY = 0;
    for (var i = 0; i < imgDivs.length; i++) {
        if (imgDivs[i][0] == dv) {
            newY = parseInt(imgDivs[i][1]);
        }
        if (imgDivs[i][0] == curDiv) {
            curY = parseInt(imgDivs[i][1]);
        }
    }

    if (curDiv == null) {
        document.getElementById(dv).style.left = '960px';
        fx.move(dv, -175, newY, 25, 25);
        curDiv = dv;
    } else if (curDiv != dv) {
        document.getElementById(dv).style.left = '960px';
        animParams = [[curDiv, [['move', -1135, curY]]],
                      [dv, [['move', -175, newY]]]];
        fx.animate(animParams, 25, 25);
        curDiv = dv;
    }
}

// Track Mouse Function
trackMouse = function(event) {

    var brws = new JaxBrowser();
    var curY = (brws.browser == 'MSIE') ? window.event.clientY : event.clientY;

    if (curY > 500) {
        if (curDiv != null) {
            for (var i = 0; i < imgDivs.length; i++) {
                if (imgDivs[i][0] == curDiv) {
                    curY = parseInt(imgDivs[i][1]);
                }
            }
            fx.move(curDiv, 990, curY, 25, 25);
            curDiv = null;
        }
    }

};

addLoader(initFx);
addEvent('mousemove', trackMouse);

addLoader(initFx);

