// THREE ACROSS CORE

    var ThreeAcrossVIPage = Class.create();

    ThreeAcrossVIPage.prototype = {

        initialize: function() {

            this.bodyContainer = $('bodyContainer');
            this.brandID = brandConst.BRAND_ID;
            this.brandProductItem = {

                "GP": "brand1 productItem",
                "BR": "brand2 productItem",
                "ON": "brand3 productItem",
                "PL": "brand4 productItem",
                "AT": "brand10 productItem"
            };

            this.brandImgDiv = {

                "GP": "brand1 imgDiv",
                "BR": "brand2 imgDiv",
                "ON": "brand3 imgDiv",
                "PL": "brand4 imgDiv",
                "AT": "brand10 imgDiv"
            };

            if ((location.pathname == '/browse/categorySearch.do' ||
                location.pathname == '/browse/category.do' ||
                location.pathname == '/browse/search.do' ||
                location.pathname == '/browse/mpp.do')) {

                this.insertCSS();

                if (location.pathname == '/browse/categorySearch.do' ||
                location.pathname == '/browse/category.do' || 
                location.pathname == '/browse/mpp.do') {
                    
                    this.walkThroughProductGrid();
                }
                else if (location.pathname == '/browse/search.do') {

                    this.walkThroughSearchGrid();
                }
            }
            else {
                this.restoreCSS();
            }

        },

        insertCSS: function() {

            var headID = document.getElementsByTagName("head")[0];

            var cssNode = document.createElement('link');
            cssNode.type = 'text/css';
            cssNode.rel = 'stylesheet';
            cssNode.href = '/Asset_Archive/PLWeb/content/0001/588/891/assets/ThreeAcross.css';
            cssNode.media = 'screen';

            headID.appendChild(cssNode);

            this.restoreCSS();
        },


        restoreCSS: function() {

            //show tabTableOff now

            var headID = document.getElementsByTagName("head")[0];

            var cssNode = document.createElement('link');

            cssNode.type = 'text/css';
            cssNode.rel = 'stylesheet';
            cssNode.href = '/Asset_Archive/PLWeb/content/0001/588/891/assets/ThreeAcross_Restore.css';
            cssNode.media = 'screen';

            headID.appendChild(cssNode);

            if ($('tabTableOff') != null) {
                $('tabTableOff').style.visibility = "visible";
            }

        },

        /*
        *  walkThroughProductGrid()
        *  Grab every product image for every "brandX imgDiv".
        *  Then change it's src to the appropriate quickLook/p01 image path
        */

        walkThroughProductGrid: function() {

            var thisClass = this.brandProductItem[this.brandID];
            var allProducts = $$("div[class=" + thisClass + "]");
            var i = 0;
            var counter = 0;

            while (i < allProducts.length) {

                //check if previous sibling is a 'divider' (sub category)
                //if NOT then increment counter
                //else this is the beginning of a row and should set counter to 1

                prevNode = allProducts[i].previous();

                if (prevNode.className != 'divider1') {
                    counter++;
                    //allProducts[counter].style.border = "1px solid red";
                }
                else {
                    counter = 1;
                }

                //insert a 'clear' break after every third product (row)
                //OR for the last productItem
                //check the 'next' node to see if it is 'productToolsLine' (last product)
                //skip 'clear5' classes

                var nextNodeClassName = allProducts[i].next().className;

                if (nextNodeClassName == 'clear5') {
                    nextNodeClassName = allProducts[i].next().next().className;
                }

                if (counter == 3 || nextNodeClassName.indexOf('productToolsLine') >= 0) {

                    clearBreak = document.createElement('div');
                    clearBreak.setAttribute('class', 'threeAcrossClearFix');

                    if (clientBrowser.isIE6 == null) {

                        hiddenText = document.createTextNode(' ');
                        clearBreak.appendChild(hiddenText);

                    }
                    else {
                        clearBreak.innerHTML = "<div style='display:block;clear:both;color:#ffffff;width:450px;height:8px;'>.</div>";
                    }

                    allProducts[i].parentNode.insertBefore(clearBreak, allProducts[i].nextSibling);

                    counter = 0;

                }

                i++;

            }
        },

        /*
        *  walkThroughSearchGrid()
        *  Grab every product image for every "brandX imgDiv".
        *  Then change it's src to the appropriate quickLook/p01 image path
        */
        walkThroughSearchGrid: function() {

            var thisClass = this.brandProductItem[this.brandID];
            var allProducts = $$("div[class=" + thisClass + "]");
            var i = 0;
            var counter = 0;

            while (i < allProducts.length) {

                //check if previous sibling is a 'divider' (sub category)
                //if NOT then increment counter
                //else this is the beginning of a row and should set counter to 1

                prevNode = allProducts[i].previous();

                if (prevNode.className != 'divider1') {
                    counter++;
                    //allProducts[counter].style.border = "1px solid red";
                }
                else {
                    counter = 1;
                }

                //insert a 'clear' break after every third product (row)
                //OR for the last productItem
                //check the 'next' node to see if it is 'productToolsLine' (last product)
                //skip 'clear5' classes
                /*
                var nextNodeClassName = allProducts[i].next().className;

                if (nextNodeClassName == 'clear5') {
                nextNodeClassName = allProducts[i].next().next().className;
                }
                */
                var isThisTheLastProduct = false;

                if (allProducts[i].next().className == 'clear5') {

                    //hide built in clear5 elements
                    allProducts[i].next().setStyle({ display: 'none' });

                    //since next element is "clear5"
                    //check if this is last product in Search Grid
                    if (allProducts[i].next().next() == null) {
                        //alert('found last product');
                        isThisTheLastProduct = true;
                    }
                }

                if (counter == 3 || isThisTheLastProduct) {

                    clearBreak = document.createElement('div');
                    clearBreak.setAttribute('class', 'clear5');

                    if (clientBrowser.isIE6 == null) {

                        hiddenText = document.createTextNode(' ');
                        clearBreak.appendChild(hiddenText);

                    }
                    else {
                        clearBreak.innerHTML = "<div style='display:block;clear:both;color:#ffffff;width:450px;height:8px;'>.</div>";
                    }

                    allProducts[i].parentNode.insertBefore(clearBreak, allProducts[i].nextSibling);

                    counter = 0;

                }

                i++;

            }
        }
    }

    // THREE ACROSS CORE



    // THREE ACROSS DELAY LOADER

    if (location.pathname == '/browse/categorySearch.do' || location.pathname == '/browse/category.do'|| location.pathname == '/browse/search.do' || location.pathname == '/browse/mpp.do') {

        /**
         *  OVERRIDE
         *	replace asset path (2nd argument)
         *  with the quick look asset path
         *
         */

        imageLoader.delayLoad = (function(img, path) {

            ///Asset_Archive/GPWeb/Assets/Outfit/139/OUT13910/outfit/gp-otf-out13910oviv01.jpg
            ///Asset_Archive/GPWeb/Assets/Outfit/139/OUT13910/outfit/gp-otf-out13910odv01.jpg
            //check if this is an outfit or not
            if (path.indexOf('/outfit/') < 0){
                newPath = path.replace("category", "quick");
                newPath = newPath.replace("viv", "qlv");
            }
            else {
                newPath = path.replace("oviv", "odv");
            }
            //alert('loading : \n' + newPath);

            this.imgs[this.currentImg] = { img: img, src: newPath };
            this.currentImg = this.currentImg + 1;

            newPath = '';

        });
    }
        
    // THREE ACROSS DELAY LOADER





    // THREE ACROSS LOOK + LINK OVERRIDES

    var rePositionEverything = function () {

    if (location.pathname == '/browse/categorySearch.do' || location.pathname == '/browse/category.do' || location.pathname == '/browse/search.do' || location.pathname == '/browse/mpp.do') {

       /** 
        *  OVERRIDE
        *  need to adjust left positioning of the 
        *  crossLink module for larger VI images
        */
        
        crossLink.setPos = (function() {

            /// crossLink.mainContent isn't always readable using actual element instead
            //if(!(crossLink.mainContent && crossLink.moduleDim)) return;
            //crossLink.mainContentPos = Position.cumulativeOffset(crossLink.mainContent);

            crossLink.mainContentPos = Position.cumulativeOffset($('mainContentContainer'));

            var browserOffset = clientBrowser.isIE6 ? window.pageYOffset || document.documentElement.scrollTop : 0;

            //change crossLink.moduleDim to 95 since crossLink is not always readable
            //change crossLink.mainContentDim.width to 770 since this is not always available (IE6 only?)

            var crossLinkPos = crossLink.modulePos = crossLink.modulePos = [785 + crossLink.mainContentPos[0],

            (window.innerHeight || document.documentElement.clientHeight) + browserOffset - 95 - 10];

            //sometimes crossLink.module is undefined
            if (typeof crossLink.module != 'undefined') {
                if (!crossLink.isShown) {
                    crossLink.module.setStyle({ opacity: '0', left: crossLinkPos[0] + 'px', top: crossLinkPos[1] + 'px' });
                    crossLink.isShown = new Effect.Appear(crossLink.module.id, { duration: 1.0 });
                }
                else {
                    crossLink.module.setStyle({ left: crossLinkPos[0] + 'px', top: crossLinkPos[1] + 'px' });
                }
            }
        });

        if (clientBrowser.isIE6 && location.pathname == '/browse/category.do') {
            Event.observe(window, 'scroll', crossLink.setPos);
        }
        else if (top.location.href.indexOf('/browse/category') > 0) {
            Event.observe(window, 'resize', crossLink.setPos);
        }
    }

    /** 
     *  OVERRIDE
     *  need to adjust positioning of the 
     *  quickLook image for larger VI images
     */

    if (location.pathname == '/browse/categorySearch.do' || location.pathname == '/browse/category.do' || location.pathname == '/browse/search.do' || location.pathname == '/browse/mpp.do') {

        quickLook.openQuickLookLauncher = (function(strProductId, strDefaultStyleColor, strCategoryId, strVariantId, targetImg, isCrossSell, brandCode) {

            if (this.isLoaded) {

                var blnOpen = false;

                if (this.isQuickLookOpen) {
                    if (this.objP.strProductId != strProductId) blnOpen = true;
                } else {
                    blnOpen = true;
                }

                brandCode = brandCode || gidBrandSiteConstruct.currentBrandCode;

                if (blnOpen) {

                    var targetObj = $(targetImg);

                    if (!targetObj) return;

                    var cumulativeOffset = Position.cumulativeOffset(targetObj);
                    var realOffset = Position.realOffset(targetObj);
                    var scrollTop = (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
                    var scrollLeft = (document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);

                    // add 10 pixels to left value
                    // add 86 pixels to top value

                    var position = [cumulativeOffset[0] - (realOffset[0] - scrollLeft - 10), cumulativeOffset[1] - (realOffset[1] - scrollTop) + 36];
                    var target = this.objQuickLookTarget = {

                        strProductId: strProductId,
                        strDefaultStyleColor: strDefaultStyleColor,
                        strCategoryId: strCategoryId,
                        strVariantId: strVariantId,
                        position: position,
                        isCrossSell: isCrossSell,
                        obj: targetObj,
                        brandCode: brandCode
                    };

                    this.quickLookLauncherBoundBox = { top: target.position[1] + 4, left: target.position[0] + 4, right: target.position[0] + brandProperties.PRODUCTIMGWIDTH - 4, btm: target.position[1] + brandProperties.PRODUCTIMGHEIGHT - 4 };
                    this.objQuickLookLauncher.setStyle({ left: (target.position[0] + (brandProperties.QUICKLOOKTARGETXPOS)) + 'px',
                        top: (target.position[1] + this.QuickLookBtnAdj[brandCode] + (brandProperties.QUICKLOOKTARGETYPOS)) + 'px', visibility: 'visible'
                    });

                    if (!quickLook.initializeData) {
                        this.loadQuickLookModule(brandCode);
                    }
                }
            }
        });
    }
};


// THREE ACROSS LOOK + LINK OVERRIDES