/**
 * @author Clinton
 */
var Grove = {};
Grove.WWW = (function(){ //private members
    function HTMLBuilder(){
    
        var that = this;
        
        this.appendScript = function(url){ //void
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = url;
            document.getElementsByTagName('head')[0].appendChild(script);
        };
        
        this.getURLParameter = function(url, name){ //String
            var regexS;
            var regex;
            var results;
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            regexS = "[\\?&]" + name + "=([^&#]*)";
            regex = new RegExp(regexS);
            results = regex.exec(url);
            return results ? results[1] : "";
        };
        
        this.getLeftNavigationPageId = function(categoryid){
            var _level3_cat, _level2_cat, _level1_cat;
            _level3_cat = this.getSiteCategoryDetails(categoryid);
            if (_level3_cat) {
                _level2_cat = this.getSiteCategoryDetails(_level3_cat.parent_category_id);
            }
            if (_level2_cat) {
                _level1_cat = this.getSiteCategoryDetails(_level2_cat.parent_category_id);
            }
            if (_level1_cat) {
                if (_level1_cat.id == 4171) {
                    return "str_vp";
                }
                else 
                    if (_level1_cat.id == 4229) {
                        return "str_tp";
                    }
                    else 
                        if (_level1_cat.id == 4234) {
                            return "str_mfs";
                        }
            }
            return "";
        };
        
        this.getSiteCategoryDetails = function(categoryid){
            for (var i = 0; i < _data_Categories._categories.length; i++) {
                if (parseInt(_data_Categories._categories[i].id, 10) == parseInt(categoryid, 10)) {
                    return _data_Categories._categories[i];
                }
            }
        };
        
        this.writeProductNavigation = function(categoryid){
        
            var _level3_cat, _level2_cat, _level1_cat;
            _level3_cat = this.getSiteCategoryDetails(categoryid);
            if (_level3_cat) {
                _level2_cat = this.getSiteCategoryDetails(_level3_cat.parent_category_id);
            }
            if (_level2_cat) {
                _level1_cat = this.getSiteCategoryDetails(_level2_cat.parent_category_id);
            }
            
            if (_level1_cat) {
                document.write('<a href="' + _level1_cat.page + '" title="' + _level1_cat.name.toLowerCase() + '">' + _level1_cat.name.toLowerCase() + '</a><span class="sepBreadcrumb">&rsaquo;</span>');
            }
            if (_level2_cat) {
                document.write('<span>' + _level2_cat.name.toLowerCase() + '</span><span class="sepBreadcrumb">&rsaquo;</span>');
            }
            if (_level3_cat) {
                // dont show level 3 category in bredcrumbs for career compass & personal compass
                if (parseInt(_level3_cat.id, 10) != 4225 && parseInt(_level3_cat.id, 10) != 4226) {
                    document.write('<a href="' + (_level3_cat.page ? _level3_cat.page : "category.html?categoryid=" + _level3_cat.id) + '" title="' + _level3_cat.name.toLowerCase() + '">' + _level3_cat.name.toLowerCase() + '</a><span class="sepBreadcrumb">&rsaquo;</span>');
                }
            }
        };
        
        this.getTemplateType = function(){
            if (data.parent.detailImages.length > 1) {
                return "IMAGE_GALLERY";
            }
            else 
                if (data.parent.imgURL_zoom_book1 || data.parent.imgURL_zoom_book2 || data.parent.imgURL_zoom_book3) {
                    return "LOOK_INSIDE";
                }
                else {
                    return "IMAGE_ZOOM";
                }
        };
        
        this.writeImageGallery = function(){
            for (var i = 0; i < data.parent.detailImages.length; i++) {
                document.write('<div><img ' + (i == 0 ? 'class="shown"' : '') + ' src="' + data.parent.detailImages[i].imgURL + '" alt="Complete Set ' + (i + 1) + '" /></div>');
            }
        };
        
        this.writeLookInsideImages = function(){
            var _isFirst = true;
            var count = 1;
            if (data.parent.imgURL_zoom_book1) {
                document.write('<div><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center"><img class="shown" src="' + data.parent.imgURL_zoom_book1 + '" alt="' + data.parent.name + (count++) + '" /></td></tr></table></div>');
                _isFirst = false;
            }
            
            if (data.parent.imgURL_zoom_book2) {
                document.write('<div><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center"><img ' + (_isFirst ? 'class="shown"' : '') + ' src="' + data.parent.imgURL_zoom_book2 + '" alt="' + data.parent.name + (count++) + '" /></td></tr></table></div>');
                _isFirst = false;
            }
            
            if (data.parent.imgURL_zoom_book3) {
                document.write('<div><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center"><img ' + (_isFirst ? 'class="shown"' : '') + ' src="' + data.parent.imgURL_zoom_book3 + '" alt="' + data.parent.name + (count++) + '" /></td></tr></table></div>');
                _isFirst = false;
            }
        };
        
        this.writeVideos = function(){
            for (var i = 0; data.relatedResources && i < data.relatedResources.length; i++) {
                if (data.relatedResources[i].type == 'Video') {
                    document.write('<div id="viewVid' + data.relatedResources[i].id + '" class="overlayContentVid">');
                    
                    document.write('<object style="visibility: hidden;" id="vid' + data.relatedResources[i].id + '" data="' + data.relatedResources[i].url + '&amp;hl=en&amp;fs=1&amp;autoplay=1&amp;showsearch=0&amp;enablejsapi=1&amp;playerapiid=vid' + data.relatedResources[i].id + '" ');
                    document.write('name="vid' + data.relatedResources[i].id + '" type="application/x-shockwave-flash" width="481" height="389">');
                    document.write('<param name="movie" value="' + data.relatedResources[i].url + '&amp;hl=en&amp;fs=1&amp;autoplay=1&amp;showsearch=0&amp;enablejsapi=1&amp;playerapiid=vid' + data.relatedResources[i].id + '">');
                    document.write('<param value="always" name="allowscriptaccess">');
                    document.write('<param value="true" name="allowfullscreen">');
                    document.write('</object>');
                    document.write('    <p>');
                    document.write('    <strong>' + data.relatedResources[i].name + '</strong><br />');
                    document.write(data.relatedResources[i].description);
                    document.write('    </p>');
                    document.write('</div>');
                    
                }
            }
        };
        
        this.writeNonDownloadAssociatedLeagerGuides = function(){
           
                document.write('          <table class="multiAddToCart">');
                document.write('          <!-- BEGIN leader\'s guide display (optional) -->');
                document.write('            <tr>');
                document.write('              <!-- Header should vary based on the type of product. -->');
                document.write('              <th class="item">Associated Leader&#8217;s Guide</th>');
                document.write('              <th class="qty" colspan="2">Quantity</th>');
                document.write('            </tr>');
                
                var cssStyleIfOnlyOneAssocLeadersGuide = (data.nonDownloadableProducts.leadersGuide.length > 1 ? "" : "background:none;");
                
                document.write('            <tr class="template">');
                document.write('              <td style="' + cssStyleIfOnlyOneAssocLeadersGuide + '">');
                
                document.write('                <select id="leaderItem1" class="item" name="leaderItem1" style="display:' + ((data.nonDownloadableProducts.leadersGuide && data.nonDownloadableProducts.leadersGuide.length > 1) ? "block" : "none") + '">');
                
                for (var i = 0; data.nonDownloadableProducts.leadersGuide && i < data.nonDownloadableProducts.leadersGuide.length; i++) {
                    document.write('                  <option value="' + data.nonDownloadableProducts.leadersGuide[i].id + '">' + data.nonDownloadableProducts.leadersGuide[i].shortDescription + ': $' + data.nonDownloadableProducts.leadersGuide[i].price + '</option>');
                }
                
                document.write('                </select>');
                
                
                if (data.nonDownloadableProducts.leadersGuide && data.nonDownloadableProducts.leadersGuide.length == 1) {
                    document.write('<label for="leader">'+data.nonDownloadableProducts.leadersGuide[0].shortDescription + ': $' + data.nonDownloadableProducts.leadersGuide[0].price+'</label>');
                }
                document.write('              </td>');
                
                document.write('              <!-- multiAddToCart quantity fields should have id and name that follow the pattern "identifier#" and class name qty -->');
                document.write('              <td style="' + cssStyleIfOnlyOneAssocLeadersGuide + '"><input id="qty1" class="qty" type="text" name="qty1" maxlength="3" value="0" /></td>');
                document.write('              <!-- multiAddToCart delete buttons should have id and name that follow the pattern "identifier#" and class name del -->');
                document.write('              <!-- Class name disabled hides the delete button -->');
                document.write('              <td class="del" style="' + cssStyleIfOnlyOneAssocLeadersGuide + '"><input id="del1" class="del disabled" type="button" name="del1" title="Remove size" /></td>');
                document.write('            </tr>');				
				
				if (data.nonDownloadableProducts.leadersGuide.length > 1) {
					document.write('            <tr class="addSize">');
					document.write('              <!-- Add button should have class add -->');
					document.write('              <td colspan="3"><input id="addSize" class="add" type="button" name="addSize" value="Add another item" title="Add another item" /></td>');
					document.write('            </tr>');
				}
                
           
            document.write('            <!-- END leader\'s guide display -->');
        };
        
        this.writeContent = function(){
        
            document.write('<div class="gridCol7Half">');
            document.write('      <!-- product name -->');
            document.write('      <h1>' + data.parent.name + '</h1>');
            document.write('      ');
            document.write('      <!-- BEGIN left column -->');
            document.write('      <div class="prodColA">');
            document.write('        <div class="prodModTop"><!-- for IE --></div>');
            document.write('        <div class="prodMod prodMain">');
            
            var _template = this.getTemplateType();
            
            if (_template == "IMAGE_GALLERY") {
                document.write('            <!-- BEGIN product image gallery -->');
                document.write('            <div class="prodGallery">');
                document.write('                <div class="field">');
                document.write('                <!-- Images for products go here. Mark the first image with class shown. -->');
                document.write('                <!-- Alt attributes for images are used to populate the image caption display. -->');
                
                this.writeImageGallery();
                
                document.write('                </div>');
                document.write('                <div class="prompt"><!-- for IE --></div>');
                document.write('                <div class="control"><a class="prev" href="#" title="Previous"><span><!-- for IE --></span></a><a class="next" href="#" title="Next"><span><!-- for IE --></span></a></div>');
                document.write('                <div class="caption"><div class="panel"><span class="name"></span><span class="count"></span><div class="clear"><!-- for IE --></div></div></div>');
                document.write('            </div>');
                document.write('            <!-- END product image gallery -->');
            }
            else 
                if (_template == "LOOK_INSIDE") {
                    document.write('        <!-- BEGIN look inside image -->');
                    document.write('        <!-- Apply viewLookInside rel attribute and lookInsideOverlayTrigger class to link. -->');
                    document.write('        <!-- Include id="lookInsideOverlay" div at bottom of page with look inside images -->');
                    document.write('        <a class="lookInsideOverlayTrigger" href="#" title="' + data.parent.name + '" rel="viewLookInside">');
                    document.write('        <img src="' + data.parent.imgURL + '" alt="Best Practices of Facilitation" />');
                    document.write('        <span class="lookInsideMask"><!-- for IE --></span><!-- Required to show "look inside" overlay -->');
                    document.write('        <span><!-- for IE --></span><!-- Required to show "look inside" overlay -->');
                    document.write('        </a>');
                    document.write('        <!-- END look inside image -->');
                }
                else {
                    if (data.parent.imgZoomURL) {
                        document.write('          <!-- BEGIN zoomable image -->');
                        document.write('          <!-- Specify zoomed image in href of link. Apply lightbox rel attribute and zoomable class to link. -->');
                        document.write('          <!-- Include id="lightbox" div at bottom of page. -->');
                        document.write('          <a class="zoomable" href="' + data.parent.imgZoomURL + '" title="' + data.parent.name + '" rel="lightbox">');
                        document.write('            <img src="' + data.parent.imgURL + '" alt="' + data.parent.name + '" />');
                        document.write('            <span><!-- for IE --></span><!-- Required to show "larger view" overlay -->');
                        document.write('          </a>');
                        document.write('          <!-- END zoomable image -->');
                    }
                    else {
                        document.write(' <div style="text-align:center; padding: 9px 0pt 18px;" > <img src="' + data.parent.imgURL + '" alt="' + data.parent.name + '" /></div>');
                    }
                }
            
            document.write('          <!-- product description -->');
            document.write('          <div class="desc">' + data.parent.description + '</div>');
            document.write('        </div>');
            document.write('        <div class="prodModBtm"><!-- for IE --></div>');
            document.write('        <div class="prodModTop"><!-- for IE --></div>');
            
            document.write('        <div class="prodMod prodRelated">');
            document.write('          <h5>Resources related to this product</h5>');
            document.write('          <!-- BEGIN related video -->');
            
            
            for (var i = 0; data.relatedResources && i < data.relatedResources.length; i++) {
                if (i === data.relatedResources.length - 1) 
                    data.relatedResources[i].divClass += ' last';
                
                switch (data.relatedResources[i].type) {
                    case 'PowerPoint':
                        document.write('          <div class="' + data.relatedResources[i].divClass + '">');
                        document.write('            <a class="' + data.relatedResources[i].aClass + '" href="http://grove.com/site/Powerpoint/' + data.relatedResources[i].document + '" title="' + data.relatedResources[i].linkText + '">' + data.relatedResources[i].linkText + '</a>');
                        document.write('            <p>' + data.relatedResources[i].description + ' </p>');
                        document.write('          </div>');
                        break;
                        
                    case 'PDF':
                        document.write('          <div class="' + data.relatedResources[i].divClass + '">');
                        document.write('            <a class="' + data.relatedResources[i].aClass + '" href="http://grove.com/site/pdfs/' + data.relatedResources[i].document + '" title="' + data.relatedResources[i].linkText + '">' + data.relatedResources[i].linkText + '</a>');
                        document.write('            <p>' + data.relatedResources[i].description + ' </p>');
                        document.write('          </div>');
                        break;
                        
                    case 'Web Page':
                        document.write('          <div class="' + data.relatedResources[i].divClass + '">');
                        document.write('            <a class="' + data.relatedResources[i].aClass + '" href="' + data.relatedResources[i].url + '" title="' + data.relatedResources[i].linkText + '">' + data.relatedResources[i].linkText + '</a>');
                        document.write('            <p>' + data.relatedResources[i].description + ' </p>');
                        document.write('          </div>');
                        break;
                        
                    case 'Video':
                        document.write('          <div class="' + data.relatedResources[i].divClass + '">');
                        document.write('            <a rel="viewVid' + data.relatedResources[i].id + '" href="' + data.relatedResources[i].url + '" class="' + data.relatedResources[i].aClass + '" title="' + data.relatedResources[i].linkText + ' ">');
                        document.write('              <img width="126px" height="96px" src="' + data.relatedResources[i].thumb + '" alt="' + data.relatedResources[i].linkText + '" />');
                        document.write('              <span class="vidPlayIcon">Running time: ' + data.relatedResources[i].runTime + '</span>');
                        document.write('            </a>');
                        document.write('            <p>' + data.relatedResources[i].description + ' </p>');
                        document.write('          </div>');
                        break;
                }
            }
            
            document.write('        </div>');
            document.write('        <div class="prodModBtm"><!-- for IE --></div>');
            document.write('        <div class="prodModTop2"><!-- for IE --></div>');
            document.write('        <div class="prodMod2 prodRelProds">');
            document.write('          <h5>Other products you might also consider&hellip;</h5>');
            document.write('          <!-- BEGIN list of related products -->');
            document.write('          <ul>');
            document.write('            <!-- Always include a title attribute with links. -->');
            
            for (var i = 0; data.associatedProducts && i < data.associatedProducts.length; i++) {
                document.write('            <li><a href="product_details.html?productid=' + data.associatedProducts[i].productId + '" title="' + data.associatedProducts[i].name + '">' + data.associatedProducts[i].name + '</a></li>');
            }
            
            document.write('          </ul>');
            document.write('          <!-- END list of related products -->');
            document.write('        </div>');
            document.write('        <div class="prodModBtm2"><!-- for IE --></div>');
            document.write('      </div>');
            document.write('      <!-- END left column -->');
            document.write('      <!-- BEGIN right column -->');
            document.write('      <div class="prodColB">');
            
            var childItemsCount = data.nonDownloadableProducts.childItems ? data.nonDownloadableProducts.childItems.length : 0;
            var hasAssocLeadersGuide = data.nonDownloadableProducts.leadersGuide.length > 0 ? true : false;
            
            if (childItemsCount > 0 || hasAssocLeadersGuide) {
                document.write('        <div class="prodModTop"><!-- for IE --></div>');
                document.write('        <div class="prodMod prodBuy">');
                document.write('          <h5>' + data.nonDownloadableProducts.title + '</h5>');
                document.write('          <p class="intro">' + data.nonDownloadableProducts.description + '</p>');
                
                document.write('          <!-- BEGIN add to cart form -->');
                document.write('          <!-- Javascript is looking for element with id addToCart -->');
                document.write('          <form id="addToCart" method="post" action="/app/site/backend/additemtocart.nl">');
                document.write('          <!-- Class name multiAddToCart identifies a multiple add to cart widget with a variable number of add to cart lines. -->');
                
                document.write('          <table class="multiAddToCart">');
                document.write('            <tr>');
                document.write('              <!-- Header should vary based on the type of product. -->');
                document.write('              <th class="item">' + data.nonDownloadableProducts.header + '</th>');
                document.write('              <th class="qty" colspan="2">Quantity</th>');
                document.write('            </tr>');
                document.write('            <!-- Class name template is required for repeatable rows. -->');
                
                
                
                var cssStyleIfNoChildItems = (childItemsCount > 1 ? "" : "background:none;");
                
                document.write('            <tr class="template">');
                document.write('              <td style="' + cssStyleIfNoChildItems + '">');
                document.write('                <!-- multiAddToCart item pulldowns should have id and name that follow the pattern "identifier#" and class name item -->');
                document.write('                <select id="item1" class="item" name="item1" style="display:' + ((data.nonDownloadableProducts.childItems && data.nonDownloadableProducts.childItems.length > 1) ? "block" : "none") + '">');
                
                for (var i = 0; data.nonDownloadableProducts.childItems && i < data.nonDownloadableProducts.childItems.length; i++) {
                    document.write('                  <option value="' + data.nonDownloadableProducts.childItems[i].id + '">' + data.nonDownloadableProducts.childItems[i].shortDescription + ': $' + data.nonDownloadableProducts.childItems[i].price + '</option>');
                }
                
                document.write('                </select>');
                
                if (data.nonDownloadableProducts.childItems && data.nonDownloadableProducts.childItems.length == 1) {
                    document.write('$' + data.nonDownloadableProducts.childItems[0].price);
                }
                document.write('              </td>');
                document.write('              <!-- multiAddToCart quantity fields should have id and name that follow the pattern "identifier#" and class name qty -->');
                document.write('              <td style="' + cssStyleIfNoChildItems + '"><input id="qty1" class="qty" type="text" name="qty1" maxlength="3" value="0" /></td>');
                document.write('              <!-- multiAddToCart delete buttons should have id and name that follow the pattern "identifier#" and class name del -->');
                document.write('              <!-- Class name disabled hides the delete button -->');
                document.write('              <td class="del" style="' + cssStyleIfNoChildItems + '"><input id="del1" class="del disabled" type="button" name="del1" title="Remove size" /></td>');
                document.write('            </tr>');
                
                
                if (childItemsCount > 1) {
                    document.write('            <tr class="addSize">');
                    document.write('              <!-- Add button should have class add -->');
                    document.write('              <td colspan="3"><input id="addSize" class="add" type="button" name="addSize" value="Add another item" title="Add another item" /></td>');
                    document.write('            </tr>');
                }
                
                if (!hasAssocLeadersGuide) {
                    document.write('            <tr class="addToCart">');
                    document.write('              <!-- Disabled class is applied to the add to cart button until a quantity is entered. -->');
                    document.write('              <td colspan="3"><input class="submit disabled" id="addToCartSubmit" type="submit" name="addToCart" value="" title="add to cart" /></td>');
                    document.write('            </tr>');
                }
                
                
                document.write('          </table>');
                
                if (hasAssocLeadersGuide) {
                    //document.write('          <div class="thick" style="' + (childItemsCount <= 1 ? "margin-top:-2px;" : "") + '"><!-- for IE --></div>');
                    
                    this.writeNonDownloadAssociatedLeagerGuides();
					
                    document.write('            <!-- END leader\'s guide display -->');
                                        
                    document.write('            <tr class="addToCart">');
                    document.write('              <!-- Disabled class is applied to the add to cart button until a quantity is entered. -->');
                    document.write('              <td colspan="3"><input class="submit disabled" id="addToCartSubmit" type="submit" name="addToCart" value="" title="add to cart" /></td>');
                    document.write('            </tr>');
                    document.write('          </table>');
                }
                
                document.write('          <input name="qtyadd" id="qtyadd" value="1" type="hidden">');
                document.write('          <input name="buyid" id="buyid" value="multi" type="hidden">');
                document.write('          <input name="multi" id="multi" value="" type="hidden">');
                
                document.write('          </form>');
                document.write('          <!-- END add to cart form -->');
                document.write('        </div>');
                
                document.write('        <div class="prodModBtm"><!-- for IE --></div>');
            }
            
            if (data.downloadableProducts.leadersGuides || data.downloadableProducts.graphicsGuides) {
            
                document.write('        <div class="prodModTopDl">');
                document.write('          <h5>Downloadable Products</h5>');
                document.write('          <p class="intro">Immediate downloads let you get to work</p>');
                document.write('        </div>');
                
                document.write('        <div class="prodMod prodDl">');
                document.write('          <!-- BEGIN downloadable form (optional) -->');
                document.write('          <!-- Javascript is looking for element with id download -->');
                document.write('          <form id="download" method="post" action="/app/site/backend/additemtocart.nl">');
                document.write('          <table>');
                
                if (data.downloadableProducts.leadersGuides) {
                    document.write('            <tr>');
                    document.write('              <!-- Header should vary based on the type of product. -->');
                    document.write('              <th class="item">' + (data.parent.mainDownloadItemHeader ? data.parent.mainDownloadItemHeader : "Associated Leader&#8217;s Guide") + '</th>');
                    document.write('              <th class="qty">Quantity</th>');
                    document.write('            </tr>');
                    document.write('            <tr>');
                    document.write('              <td>');
                    document.write('                <select id="leaderDlist" name="leaderDlist" style="display:' + ((data.downloadableProducts.leadersGuides && data.downloadableProducts.leadersGuides.length > 1) ? "block" : "none") + '">');
                    
                    for (var i = 0; i < data.downloadableProducts.leadersGuides.length; i++) {
                        document.write('                  <option value="' + data.downloadableProducts.leadersGuides[i].id + '">' + data.downloadableProducts.leadersGuides[i].description + ': $' + data.downloadableProducts.leadersGuides[i].price + '</option>');
                    }
                    document.write('                </select>');
                    if (data.downloadableProducts.leadersGuides && data.downloadableProducts.leadersGuides.length == 1) {
                        document.write(data.downloadableProducts.leadersGuides[0].description + ' $' + data.downloadableProducts.leadersGuides[0].price);
                    }
                    document.write('              </td>');
                    document.write('              <!-- Quantity fields should have class name qty -->');
                    document.write('              <td><input id="leaderDl" class="qty" type="text" name="leaderDl" maxlength="3" value="0" /></td>');
                    document.write('            </tr>');
                    //				document.write('              <td><label for="leaderDl">' + data.downloadableProducts.leadersGuide.description + ' $' + data.downloadableProducts.leadersGuide.price + '</label></td>');
                    //				document.write('              <!-- Quantity fields should have class name qty -->');
                    //				document.write('              <td><input id="leaderDl" class="qty" type="text" name="leaderDl" maxlength="3" value="0" /><input type="hidden" id="leaderDlItemId" name="leaderDlItemId" value="' + data.downloadableProducts.leadersGuide.id + '" /></td>');
                    //				document.write('            </tr>');
                }
                
                if (data.downloadableProducts.graphicsGuides) {
                    document.write('            <!-- BEGIN complete set display (optional) -->');
                    document.write('            <tr class="set">');
                    document.write('              <!-- Header should vary based on the type of product. -->');
                    //				document.write('              <th class="item">Complete Set of Graphic Guides</th>');
                    document.write('              <th class="item">Digital Graphic Guides (v 4.0)</th>');
                    document.write('              <th class="qty">Quantity</th>');
                    document.write('            </tr>');
                    document.write('            <tr>');
                    document.write('              <td>');
                    document.write('                <select id="dl" name="dl" style="display:' + ((data.downloadableProducts.graphicsGuides && data.downloadableProducts.graphicsGuides.length > 1) ? "block" : "none") + '">');
                    
                    for (var i = 0; i < data.downloadableProducts.graphicsGuides.length; i++) {
                        document.write('                  <option value="' + data.downloadableProducts.graphicsGuides[i].id + '">' + data.downloadableProducts.graphicsGuides[i].shortDescription + ': $' + data.downloadableProducts.graphicsGuides[i].price + '</option>');
                    }
                    
                    document.write('                </select>');
                    if (data.downloadableProducts.graphicsGuides && data.downloadableProducts.graphicsGuides.length == 1) {
                        document.write('$' + data.downloadableProducts.graphicsGuides[0].price);
                    }
                    document.write('              </td>');
                    document.write('              <!-- Quantity fields should have class name qty -->');
                    document.write('              <td><input id="dlQty" class="qty" type="text" name="dlQty" maxlength="3" value="0" /></td>');
                    document.write('            </tr>');
                    document.write('            <tr class="desc">');
                    document.write('              <!-- complete set description -->');
                    //				document.write('              <td colspan="2">These are digital PowerPoint versions of all ' + data.downloadableProducts.graphicsGuides.length + ' of our Graphic Guides. Fully customizable for your specific goals.</td>');
                    document.write('              <td colspan="2">These are digital PowerPoint versions of all of our Graphic Guides. Fully customizable for your specific goals.</td>');
                    document.write('            </tr>');
                    document.write('            <!-- END complete set display -->');
                }
                
                document.write('            <tr class="addToCart">');
                document.write('              <!-- Disabled class is applied to the add to cart button until a quantity is entered. -->');
                document.write('              <td colspan="2"><label for="license">To add to your cart, agree below</label><input class="submit disabled" id="downloadSubmit" type="submit" name="addToCartDl" value="" title="add to cart" /></td>');
                document.write('            </tr>');
                document.write('            <!-- BEGIN license agreement -->');
                document.write('            <tr class="agreement">');
                document.write('              <td colspan="2">');
                document.write('                <!-- Class name checkRequired forces the element to be checked before the form is submitted. -->');
                document.write('                <input id="license" class="checkRequired" type="checkbox" name="license" value="#" />');
                document.write('                <label for="license">');
                document.write('                  <!-- tabbedOverlayTrigger class identifies a link to open a tabbed overlay window. -->');
                document.write('                  <!-- The rel attribute of the trigger identifies the overlay and tabbed content to display in [overlay.id]-[tabbedContent.class] format. -->');
                document.write('                  <!-- Overlay content is included at the bottom of the page.  -->');
                document.write('                  I agree to the terms of the <a href="#" title="license agreement" class="tabbedOverlayTrigger" rel="viewTabOverlay-viewLicense">license agreement</a>.');
                document.write('                  <span>You must agree to the terms in the license agreement in order to purchase product downloads.</span>');
                document.write('                </label>');
                document.write('              </td>');
                document.write('            </tr>');
                document.write('            <!-- END license agreement -->');
                document.write('          </table>');
                
                document.write('          <input name="qtyadd" id="qtyadd" value="1" type="hidden">');
                document.write('          <input name="buyid" id="buyid" value="multi" type="hidden">');
                document.write('          <input name="multi" id="multi" value="" type="hidden">');
                
                document.write('          </form>');
                document.write('          <!-- END downloadable form -->');
                document.write('          <!-- tabbedOverlayTrigger class identifies a link to open a tabbed overlay window. -->');
                document.write('          <!-- The rel attribute of the trigger identifies the overlay and tabbed content to display in [overlay.id]-[tabbedContent.class] format. -->');
                document.write('          <!-- Overlay content is included at the bottom of the page.  -->');
                document.write('          <p class="spec"><a href="#" title="View technical specifications" class="tabbedOverlayTrigger" rel="viewTabOverlay-viewTechSpecs">View technical specifications</a></p>');
                document.write('        </div>');
                document.write('        <div class="prodModBtm"><!-- for IE --></div>');
            }
            document.write('      </div>');
            document.write('      <!-- END right column -->');
            document.write('    </div>');
            
        };
    }
    return { //public members
        getBuilder: function(){
            try {
                return new HTMLBuilder();
            } 
            catch (e) {
                alert(e.name + ' : ' + e.message);
            }
        }
    }
})();

