


        function trim(stringToTrim) {
                return stringToTrim.replace(/^\s+|\s+$/g,"");
        }
        product = function( element ){
            if( !element) return;

            var descriptioncell = element.getElementsByTagName('td')[0];
            if( descriptioncell )
            {
                var descriptiontext = trim( descriptioncell.innerText || descriptioncell.textContent || "" );
                if( (!top.debug) && descriptiontext.length==0 )
                    return; // bailout; nothing to see here. top.debug only exists in edit mode.
            }

            var display = document.getElementById('products-showcase');
            var oldcontent = display.childNodes[0];
            var oldrow = document.getElementById('product-showtime');
            if( oldrow!=null )
            {
                oldrow.removeAttribute('id');
                while(oldcontent && (oldcontent.attributes==null || oldcontent.getAttribute("class")!="product")){
                    oldcontent = oldcontent.nextSibling;
                }
                if( oldcontent && oldrow.getElementsByTagName('td')[2] )
                {
                    oldrow.getElementsByTagName('td')[2].appendChild(oldcontent);
                }
            }
            var showtd = element.getElementsByTagName('td')[2];
            var showimg = showtd.getElementsByTagName('div')[0];

            element.id = "product-showtime";
            showtd.removeChild( showimg );
            while( display.firstChild )
                display.removeChild(display.firstChild);
            display.appendChild(showimg);
        }
        photo = function( id ){
            var showdiv = document.getElementById(id);
            if( !showdiv ) return;

            var showitem= showdiv.parentNode;
            if( !showitem ) return;
            if( !(showitem.nodeName=='LI' ) ) return;

            var display = document.getElementById('photos-showcase');
            var olditem = document.getElementById('photo-showtime');
            if( olditem!=null )
            {
                olditem.removeAttribute('id');
                var oldcontent = display.firstChild;
                while(oldcontent && (oldcontent.attributes==null || oldcontent.getAttribute("class")!="photo")){
                    oldcontent = oldcontent.nextSibling;
                }
                if( oldcontent )
                {
                    display.removeChild(oldcontent);
                    while( olditem.firstChild ) olditem.removeChild(olditem.firstChild);
                    olditem.appendChild(oldcontent);
                }
            }
            showitem.id = "photo-showtime";
            showitem.removeChild( showdiv );
            while( display.firstChild )
                display.removeChild(display.firstChild);
            display.appendChild(showdiv);
        }
        




