﻿//************************************************************************************* 
// File     :   synd_centerFeaturedImage.js
// Requires :   mf_domLibrary_0.1.js, prototype.js
// Author   :   Kyle Weems (ksw)
// Origin   :   mindfly.com
// Created  :   March 18, 2008
// Modified :   May 26, 2009
// Purpose  :   On a page where the featured products are located, center the thumbnails 
//              Of the products.
//*************************************************************************************

function centerFeaturedImages() {
    if ($$('.spnFeaturedProducts').length > 0) {
        for (i = 0; i < $$('.spnFeaturedProducts').length; i++) {
            $$('.spnFeaturedProducts')[i].select('.Thumbnail')[0].onload = function() {
            this.style.left = (Math.round(75 - (this.offsetWidth / 2)) - 10) + 'px';
            };
        }
    }
} // end of function centerFeaturedImages()


//Add Tabs to About Us Page
function aboutUsTabs() {
    if ($$('#liAbout div').length > 0) {
        $$('#liAbout div')[0].className = 'show';
        $$('#liAbout h2')[0].className = 'current';
        $$('#liAbout h2')[0].observe('click', function(event) { closeAllTabs(); $$('#liAbout div')[0].className = 'show'; $$('#liAbout h2')[0].className = 'current'; forceChange(); });
        $$('#liAquatic h2')[0].observe('click', function(event) { closeAllTabs(); $$('#liAquatic div')[0].className = 'show'; $$('#liAquatic h2')[0].className = 'current'; forceChange(); });
        $$('#liProductPurity h2')[0].observe('click', function(event) { closeAllTabs(); $$('#liProductPurity div')[0].className = 'show'; $$('#liProductPurity h2')[0].className = 'current'; forceChange(); });
        $$('#liEnvironment h2')[0].observe('click', function(event) { closeAllTabs(); $$('#liEnvironment div')[0].className = 'show'; $$('#liEnvironment h2')[0].className = 'current'; forceChange(); });
        $$('#liOurStaff h2')[0].observe('click', function(event) { closeAllTabs(); $$('#liOurStaff div')[0].className = 'show'; $$('#liOurStaff h2')[0].className = 'current'; forceChange(); });
    }
}

//Add "current" class name to tabs on About Page
function closeAllTabs() {
    $$('#liAbout div')[0].className = '';
    $$('#liAquatic div')[0].className = '';
    $$('#liProductPurity div')[0].className = '';
    $$('#liEnvironment div')[0].className = '';
    $$('#liOurStaff div')[0].className = '';
    $$('#liAbout h2')[0].className = '';
    $$('#liAquatic h2')[0].className = '';
    $$('#liProductPurity h2')[0].className = '';
    $$('#liEnvironment h2')[0].className = '';
    $$('#liOurStaff h2')[0].className = '';
}

function forceChange() {
}

addLoadEvent(centerFeaturedImages);

addLoadEvent(aboutUsTabs);




