//tabs
$$('.tabBody').each(function(el,ix) {
    el.style.display='none';
});
$$('.tab').each(function(el,ix) {
    el.writeAttribute('ix',ix);
    el.observe('click',function(ev) {
        changeTab($(ev.findElement('.tab')));
    });
});

var storedPageIndex=-1;
function tabCheck() {
    var pageIndex=window.location.hash.slice(1);
    if (pageIndex!='') {
        var useThisPageIndex='';
        $$('.tab').each(function(el,ix) {
            if (el.readAttribute('url')==pageIndex) {
                useThisPageIndex=ix;
            }
        });
        if (useThisPageIndex!=storedPageIndex) {
            doTab($$('.tab')[useThisPageIndex]);
            storedPageIndex=useThisPageIndex;
        }
    }
}

function changeTab(which) {
    window.location.hash=which.readAttribute('url');
}

function doTab(which) {
    if (which.select('.tabCenter img').length) {
        which.select('.tabCenter img').first().src=which.select('.tabCenter img').first().src.split('-off').join('-on');
    }
    which.addClassName('on');
    which.siblings().each(function(el,ix) {
        el.removeClassName('on');
        if (el.select('.tabCenter img').length) {
            el.select('.tabCenter img').first().src=el.select('.tabCenter img').first().src.split('-on').join('-off');
        }
    });
    $$('.tabBody').each(function(el1,ix1) {
        el1.style.display='none';
    });
    $$('.tabBody')[Number(which.readAttribute('ix'))].style.display='block';
}

//do initial display, start check
if ($$('.tab').length) {
    setInterval(tabCheck,50);
}
Event.observe(window,'load',function() {
    if ($$('.tab').length && window.location.hash=='') { changeTab($$('.tab').first()); }
});

//video player
$$('.videoLink').each(function(el,ix) {
    el.observe('click',function(ev) {
        var evEl=Event.extend(ev).findElement('a');
        window.open('/videoplayer.htm?'+evEl.href,'vidWin','width=655,height=380');
        ev.stop();
    });
});
//ppt and pdf links in new windows
$$('.pdfLink,.pptLink').each(function(el,ix) {
    el.writeAttribute('target','_blank');
});

//hp anim
Event.observe(window,'load',function() {
    if ($('flashTarget')) {
        var so = new SWFObject('/images/hp-anim.swf', 'hpAnim', 722, 379, '9', '#000000');
        so.addParam('menu', 'false');
        so.addParam('quality', 'autohigh');
        so.addParam('scale', 'noScale');
        so.addParam('align', 'TL');
        so.addParam('wmode', 'transparent');
        so.addParam('allowscriptaccess', 'always');
        so.addParam('allowfullscreen', 'true');
        so.write('flashTarget');
    }
});

//fix pngs in IE
if (BrowserDetect.browser=='Explorer' && BrowserDetect.version<=6) {
        DD_belatedPNG.fix('#mainMenu,#logo,.tabCenter img,.tab div,#mainCol,.pngFix');
}

