var adTrigger = {
    adConfig: {'timeout':20000,'topAdContainer':'ad0','topAdFrame':'ad0frame','rightAdContainer':'ad1','rightAdFrame':'ad1frame','bottomAdContainer':'ad2','bottomAdFrame':'ad2frame'},
    adUnits: {
		'generic': {'top':'/ads/msn/top/','right':'/ads/msn/right','bottom':'/ads/msn/top'},
		'hair':{'top':'/ads/msn/top/hair','right':'/ads/msn/right/hair','bottom':'/ads/msn/top/hair'},
		'facial':{'top':'/ads/msn/top/facial','right':'/ads/msn/right/facial','bottom':'/ads/msn/top/facial'},
		'lipstick':{'top':'/ads/msn/top/lipstick','right':'/ads/msn/right/lipstick','bottom':'/ads/msn/top/lipstick'},
		'lipliner':{'top':'/ads/msn/top/lipliner','right':'/ads/msn/right/lipliner','bottom':'/ads/msn/top/lipliner'},
		'gloss':{'top':'/ads/msn/top/gloss','right':'/ads/msn/right/gloss','bottom':'/ads/msn/top/gloss'},
		'eyeshadow':{'top':'/ads/msn/top/eyeshadow','right':'/ads/msn/right/eyeshadow','bottom':'/ads/msn/top/eyeshadow'},
		'eyeliner':{'top':'/ads/msn/top/eyeliner','right':'/ads/msn/right/eyeliner','bottom':'/ads/msn/top/eyeliner'},
		'mascara':{'top':'/ads/msn/top/mascara','right':'/ads/msn/right/mascara','bottom':'/ads/msn/top/mascara'},
		'blush':{'top':'/ads/msn/top/blush','right':'/ads/msn/right/blush','bottom':'/ads/msn/top/blush'},
		'polish':{'top':'/ads/msn/top/nails','right':'/ads/msn/right/nails','bottom':'/ads/msn/top/nails'},
		'acrylic':{'top':'/ads/msn/top/acrylic','right':'/ads/msn/right/acrylic','bottom':'/ads/msn/top/acrylic'},
		'teeth':{'top':'/ads/msn/top/teeth','right':'/ads/msn/right/teeth','bottom':'/ads/msn/top/teeth'},
		'eyewear':{'top':'/ads/msn/top/eyewear','right':'/ads/msn/right/eyewear','bottom':'/ads/msn/top/eyewear'},
		'sunglasses':{'top':'/ads/msn/top/sunglasses','right':'/ads/msn/right/sunglasses','bottom':'/ads/msn/top/sunglasses'},
		'necklace':{'top':'/ads/msn/top/necklace','right':'/ads/msn/right/necklace','bottom':'/ads/msn/top/necklace'},
		'earrings':{'top':'/ads/msn/top/earrings','right':'/ads/msn/right/earrings','bottom':'/ads/msn/top/earrings'},
		'cover':{'top':'/ads/msn/top/cover','right':'/ads/msn/right/cover','bottom':'/ads/msn/top/cover'},
		'cLooks':{'top':'/ads/msn/top/cLooks','right':'/ads/msn/right/cLooks','bottom':'/ads/msn/top/cLooks'},
		'cosmetics':{'top':'/ads/msn/top/facial','right':'/ads/msn/right/facial','bottom':'/ads/msn/top/facial'},
		'concealer':{'top':'/ads/msn/top/facial','right':'/ads/msn/right/facial','bottom':'/ads/msn/top/facial'},
		'foundation':{'top':'/ads/msn/top/facial','right':'/ads/msn/right/facial','bottom':'/ads/msn/top/facial'},
		'accessories':{'top':'/ads/msn/top/accessories','right':'/ads/msn/right/accessories','bottom':'/ads/msn/top/accessories'}
    },
    sections: {
		'site-home':{'section':'generic','top':true,'right':false,'bottom':false},
		'site-feature':{'section':'generic','top':true,'right':true,'bottom':false},
		'site-contact':{'section':'generic','top':true,'right':true,'bottom':false},
		'site-contact-submitted':{'section':'generic','top':true,'right':true,'bottom':false},


		'home': {'section':'generic','top':true,'right':false,'bottom':false},
		'signInForm': {'section':'generic','top':true,'right':false,'bottom':false},
		'registrationForm': {'section':'generic','top':true,'right':false,'bottom':false},
		'registrationError': {'section':'generic','top':true,'right':false,'bottom':false},
		'registrationComplete': {'section':'generic','top':true,'right':false,'bottom':false},
		'registrationPrompt': {'section':'generic','top':true,'right':false,'bottom':false},
		'welcomeScreen': {'section':'generic','top':true,'right':false,'bottom':false},
		'beginMakeoverOverlay': {'section':'generic','top':true,'right':false,'bottom':false},
		'uploadPhoto': {'section':'generic','top':true,'right':false,'bottom':false},
		'uploadPhotoEnhance': {'section':'generic','top':true,'right':false,'bottom':false},
		'uploadPhotoTrace': {'section':'generic','top':true,'right':false,'bottom':false},
		'hairCelebrity': {'section':'hair','top':true,'right':true,'bottom':false},
		'hairStyleLibrary': {'section':'hair','top':true,'right':true,'bottom':false},
		'hairStyleLibraryAdjustHairColor': {'section':'hair','top':true,'right':true,'bottom':false},
		'hairStyleLibraryAdjustHairStyle': {'section':'hair','top':true,'right':true,'bottom':false},
		'hairStyleLibraryAdjustHighlights': {'section':'hair','top':true,'right':true,'bottom':false},
		'hairStyleLibraryAdjustLowlights': {'section':'hair','top':true,'right':true,'bottom':false},
		'cosmetics': {'section':'cosmetics','top':true,'right':true,'bottom':false},
		'cosmeticsEyes': {'section':'cosmetics','top':true,'right':true,'bottom':false},
		'cosmeticsEyesShadow': {'section':'eyeshadow','top':true,'right':true,'bottom':false},
		'cosmeticsEyesLiner': {'section':'eyeliner','top':true,'right':true,'bottom':false},
		'cosmeticsEyesMascara': {'section':'mascara','top':true,'right':true,'bottom':false},
		'cosmeticsEyesBrows': {'section':'cosmetics','top':true,'right':true,'bottom':false},
		'cosmeticsLips': {'section':'lipstick','top':true,'right':true,'bottom':false},
		'cosmeticsLipsLipstick': {'section':'lipstick','top':true,'right':true,'bottom':false},
		'cosmeticsLipsLipliner': {'section':'lipliner','top':true,'right':true,'bottom':false},
		'cosmeticsLipsGloss': {'section':'cosmetics','top':true,'right':true,'bottom':false},
		'cosmeticsLipsTeeth': {'section':'teeth','top':true,'right':true,'bottom':false},
		'cosmeticsHandNails': {'section':'polish','top':true,'right':true,'bottom':false},
		'cosmeticsFace': {'section':'cosmetics','top':true,'right':true,'bottom':false},
		'cosmeticsFaceConcealer': {'section':'concealer','top':true,'right':true,'bottom':false},
		'cosmeticsFaceFoundation': {'section':'foundation','top':true,'right':true,'bottom':false},
		'cosmeticsFaceBlush': {'section':'blush','top':true,'right':true,'bottom':false},
		'accessories': {'section':'accessories','top':true,'right':true,'bottom':false},
		'accessoriesJewelry': {'section':'accessories','top':true,'right':true,'bottom':false},
		'accessoriesJewelryEarrings': {'section':'earrings','top':true,'right':true,'bottom':false},
		'accessoriesJewelryNecklaces': {'section':'necklace','top':true,'right':true,'bottom':false},
		'accessoriesEyewear': {'section':'eyewear','top':true,'right':true,'bottom':false},
		'accessoriesEyewearSunglasses': {'section':'sunglasses','top':true,'right':true,'bottom':false},
		'accessoriesEyewearGlasses': {'section':'eyewear','top':true,'right':true,'bottom':false},
		'accessoriesEyewearContacts': {'section':'eyewear','top':true,'right':true,'bottom':false},
		'accessoriesHeadHair': {'section':'cover','top':true,'right':true,'bottom':false},
		'accessoriesHeadHairHats': {'section':'cover','top':true,'right':true,'bottom':false},
		'accessoriesHeadHairClips': {'section':'cover','top':true,'right':true,'bottom':false},
		'oneClickLooks': {'section':'cLooks','top':true,'right':true,'bottom':false},
		'savedLooks': {'section':'generic','top':true,'right':true,'bottom':false},  // PJHL: 08/18/2009 No ad for saved looks
		'shoppingBag': {'section':null,'top':true,'right':true,'bottom':false},
		'zzz':''
    },
    initialize: function() {
		adTrigger.refreshRandomNumber();
        if (adTrigger.section) {
            this.section = adTrigger.section;
        }
        if (!this.section) {this.section = '';}
    },
    startTimer: function() {
		this.timer = setInterval("adTrigger.rotate()", this.adConfig.timeout);
    },
    rotate: function() {
        if (typeof($) == "undefined") {
            DomReady.ready(function() {
                adTrigger.showAd();
            });
        } else {
            $(document).ready(function() {
                adTrigger.showAd();
            });
        }
    },
    refreshRandomNumber : function() {
		// PJHL - 2009/09/24: Check for random number... needed for iVillage ads
		if (window.refreshRandomNumber) {
			window.refreshRandomNumber();
		}
    },
    showAd: function() {
		adTrigger.refreshRandomNumber();
        if (this.sectionObj.top == true) {
            document.getElementById(this.adConfig.topAdContainer).style.display = 'block';
            document.getElementById(adTrigger.adConfig.topAdFrame).src = adTrigger.adUnits[adTrigger.section].top;
        } else {
            adTrigger.hideAd('top');
        }
        
        if (this.sectionObj.right == true) {
            document.getElementById(this.adConfig.rightAdContainer).style.display = 'block';
            document.getElementById(adTrigger.adConfig.rightAdFrame).src = adTrigger.adUnits[adTrigger.section].right;
        } else {
            adTrigger.hideAd('right');
        }
        
		/*
        if (this.sectionObj.bottom == true) {
            document.getElementById(this.adConfig.bottomAdContainer).style.display = 'block';
            document.getElementById(adTrigger.adConfig.bottomAdFrame).src = adTrigger.adUnits[adTrigger.section].bottom;
        } else {
            adTrigger.hideAd('bottom');
        } */
    },
    newSection: function(section) {
        if (this.timer) {
            clearInterval(this.timer);
        }
        this.section = section;
		if (this.adConfig.timeout == null || this.adConfig.timeout == 0) {
		} else {
        	this.startTimer();
		}
        if (typeof($) == "undefined") {
            DomReady.ready(function() {
                adTrigger.showAd();
            });
        } else {
            $(document).ready(function() {
                adTrigger.showAd();
            });
        }
    },
    trigger: function(adminSection) {
        // see which ads to fire
        this.sectionObj = this.sections[adminSection];
        if (this.sectionObj.section == this.section) {
        } else {
            this.newSection(this.sectionObj.section);
        }
    },
    hideAd: function(location) {
        switch(location) {
            case 'top':
				document.getElementById(this.adConfig.topAdContainer).style.display = 'none';
				document.getElementById(this.adConfig.topAdFrame).src = '';
				break;
            case 'right':
				document.getElementById(this.adConfig.rightAdContainer).style.display = 'none';
				document.getElementById(this.adConfig.rightAdFrame).src = '';
				break;
            case 'bottom':
				document.getElementById(this.adConfig.bottomAdContainer).style.display = 'none';
				document.getElementById(this.adConfig.bottomAdFrame).src = '';
				break;
            default:
            break;
        }
    },
    zzz: function() {}
};
