var clientId = "sblog";
//var domain = "http://naor-pc.weblogic.sharedbook.com/serve/smartbtn/travelpod/";
//var domain = "http://127.0.0.1:8080/serve/smartbtn/" + clientId + "/";
var domain = "http://colowww.sharedbook.com/serve/smartbtn/" + clientId + "/";
//var domain = "http://betaqa.sharedbook.com/serve/smartbtn/" + clientId + "/";


function SharedBookSmartButton()
{
   // ***********  Private members  ***********

   var cookie_name = clientId + "_sbUserId";

   // Timer ID
   var tid = null;

   var printableUrl = document.location.href;

   var userIdFromCookie = null;

   // Members used to display the drop-down div.
   var sharedbook_timeout = 300;
   var sharedbook_closetimer = 0;
   var sharedbook_menuitem = 0;

   var remove_inner_html = "> Remove this Page";
   var add_inner_html = "> Add this Page";
   var remove_function = "javascript:sbSmartBtnObj.sharedbookRemoveArticle()";
   var add_function = "javascript:sbSmartBtnObj.sharedbookAddArticle()";
   var empty_function = function(){};

   var button_initial_off = domain + "images/sharedbook_state_img_off.gif";
   var button_initial_on = domain + "images/sharedbook_state_img_on.gif";
   var button_booked_off = domain + "images/booked_off.gif";
   var button_booked_on = domain + "images/booked_on.gif";
   var button_waiting = domain + "images/booked_animation_solo.gif";

   // Holds the "on" and "off" states that should be used at the moment.
   var button_on = button_initial_on;
   var button_off = button_initial_off;

   // To identify pressing "enter" in the email popup.
   var enter_key_code = "13";

   // **************************************************************************
   // Privileged functions (public with access to private methods)
   // **************************************************************************

   /**
    * Add article to the user's clipboard.
    */
   this.sharedbookAddArticle = function ()
   {
      // Make sure we have user ID.
      if(userIdFromCookie == null)
      {
         userIdFromCookie = getCookie(cookie_name);
         var userIdFromPrompt = "";
         if(userIdFromCookie == null)
         {
            // We don't have user ID, lets get it from the user.
            this.closeSharedbookMenu();
            this.openEmailPopup(onEmailEnteredForAddURL);
            return;
         }
      }
      else
      {
         // We do have user ID, lets add the article to the clipboard.
         handleAddURLwithEmail();
      }

      /**
       * Called from the email popup div, when submiting the form.
       */
      function onEmailEnteredForAddURL ()
      {
         closeEmailPopup();

         if (!validateEmailAddress())
            return;

         handleAddURLwithEmail();
      };

      /**
       * We have user ID, add the article to the clipboard.
       */
      function handleAddURLwithEmail()
      {
         // Returns "finished_add_multi_urls == "True"  "
         var add_article_url = domain + "add_multiple_urls_to_book.djs?user_id=" + escape(userIdFromCookie) + "&article_url=" + escape(printableUrl);
         var add_article_script = document.createElement('script');
         add_article_script.src = add_article_url;
         document.getElementsByTagName('head')[0].appendChild(add_article_script);

         // Change the main (left) button state to "in progress".
         document.getElementById("sharedbook_state_img").src = button_waiting;

         invalidateEntireBtnFunc();
         closeSharedbookMenu();

         // TODO: define max retries
         tid = setInterval(handleBtnState, 500);

         function handleBtnState()
         {
            // Waits for "add_multiple_urls_to_book.djs" to finish.
            if(typeof finished_add_multi_urls != 'undefined' && finished_add_multi_urls != null)
            {
               clearInterval(tid);
               tid = null;

               if(finished_add_multi_urls == "True")
               {
                  // Reset to allow subsequent requests that will use the same var.
                  finished_add_multi_urls = null;

                  changeBtnAfterAddArticle();
                  revalidateDropdownFunc();
               }
               else
               {
                  finished_add_multi_urls = null;
                  alert("Failed to add content to the book.");
               }
            }
         }
      }
   };

   /**
    * Remove an article from the user's clipboard.
    */
   this.sharedbookRemoveArticle = function ()
   {
      // TODO: WHAT HAPPENS IF COOKIES DISABLED ?
      if(userIdFromCookie == null)
      {
         // This shouldn't happen normally, but just in case, reset the button to its initial state.
         // Possible scenario: user added an article, then deleted the cookies, then clicked "remove".
         changeBtnAfterRemoveArticle();
      }

      // Remove the article from the clipboard, no need to wait for result since even if the article wasn't
      // found in the clipboard we consider it as "removed".
      var remove_article_url = domain + "remove_url_from_book.djs?user_id=" + escape(userIdFromCookie) + "&article_url=" + escape(printableUrl);
      var remove_article_script = document.createElement('script');
      remove_article_script.src = remove_article_url;
      document.getElementsByTagName('head')[0].appendChild(remove_article_script);

      changeBtnAfterRemoveArticle();

      this.closeSharedbookMenu();
   };

   /**
    * Finalize the user's selections.
    */
   this.sharedbookFinalizeBook = function ()
   {
      // Make sure we have user ID.
      if(userIdFromCookie == null)
      {
         userIdFromCookie = getCookie(cookie_name);
         var userIdFromPrompt = "";
         if(userIdFromCookie == null)
         {
            // No user ID, close the menu and open the email popup.
            this.closeSharedbookMenu();
            this.openEmailPopup(onEmailEnteredForFinalize);
            return;
         }
      }
      else
      {
         // We have user ID, let's go and finalize.
         handleFinalizeBookWithEmail();
      }

      // Called from the email popup div, on submit email.
      function onEmailEnteredForFinalize()
      {
         closeEmailPopup();

         if (!validateEmailAddress())
            return;

         // We have user ID, let's go and finalize.
         handleFinalizeBookWithEmail();
      }

      /**
       * Finalize book:
       * 1. Verifiy there is at least one article in the user's clipboard.
       * 2. Go to bridge page.
       */
      function handleFinalizeBookWithEmail()
      {
         // Verify there is at least one article in the user's clipboard.
         // This code generats "var articles_exists = 'True'" (or False).
         var finalize_article_url = domain + "verify_articles_in_book.djs?user_id=" + escape(userIdFromCookie);
         var finalize_article_script = document.createElement('script');
         finalize_article_script.src = finalize_article_url;
         document.getElementsByTagName('head')[0].appendChild(finalize_article_script);

         // TODO: define max retries
         tid = setInterval(handleFinalizeBook, 500);

         function handleFinalizeBook()
         {
            // Check if we got a response from "verify_articles_in_book.djs".
            if(typeof articles_exists != 'undefined' && articles_exists != null)
            {
               clearInterval(tid);
               tid = null;

               if(articles_exists == "True")
               {
                  // Reset to allow subsequent requests that will use the same var.
                  articles_exists = null;
                  document.location.href = domain + "bridge.djs?user_id=" + userIdFromCookie;
               }
               else
               {
                  articles_exists = null;
                  alert("Please add at least one page");
               }
            }
         }
      }
   };

   /**
    * Open the menu.
    */
   this.sharedbookMopen = function ()
   {
      // cancel close timer
      sharedbookMcancelclosetime();

      // close old layer
      if(sharedbook_menuitem)
      {
         sharedbook_menuitem.style.display = 'none';
      }

      // get new layer and show it
      sharedbook_menuitem = document.getElementById("sharedbook_menu");
      sharedbook_menuitem.style.display = '';

      setMainBtnStateOn();
   };

   /**
    * Close the menu.
    */
   this.sharedbookMclosetime = function ()
   {
      sharedbook_closetimer = window.setTimeout(sharedbookMclose, sharedbook_timeout);

      // close showed layer
      function sharedbookMclose()
      {
         if(sharedbook_menuitem)
         {
            sharedbook_menuitem.style.display = 'none';
         }
         // Change the button state to "off", unless an operation is pending or
         // the email popup is opened.
         if (tid == null &&
             document.getElementById('sb_email_popup').style.visibility != "visible")
            setMainBtnStateOff();
      }
   };

   /**
    * Switch the menu: click: open, click: close.
    */
   this.sharedbookSwitchMenu = function ()
   {
      this.expandDiv("sharedbook_menu");
   };

   /**
    * Open the email popup div, invalidate the button so user couldn't click or hover it
    * while the popup is opened.
    */
   this.openEmailPopup = function (func)
   {
      document.getElementById("sb_email_popup").style.visibility = "visible";
      document.getElementById("sb_email_popup_submit").onclick = func;

      setMainBtnStateOn();

      // Remove the functionality from the buttons.
      invalidateEntireBtnFunc();
   }

   /**
    * Close the email popup div, revalidate the button.
    */
   function closeEmailPopup ()
   {
      // In case it is opened in the background.
      closeSharedbookMenu();

      document.getElementById("sb_email_popup").style.visibility = "hidden";

      // Add the functionality to the buttons.
      revalidateDropdownFunc();

      revalidateMainBtn(add_function);
   }
   this.closeEmailPopup = closeEmailPopup;

   this.expandDiv = function (obj)
   {
      var el = document.getElementById(obj);
      if(el.style.display != "none")
      {
         el.style.display = 'none';
      }
      else
      {
         el.style.display = '';
      }
   }

   /**
    * Event handler for key down - invokes submit email when "enter" key was pressed.
    */
   this.onkeydownHandler = function (evt, win)
   {
      evt = win.event ? win.event : evt;
      if (evt.keyCode == enter_key_code)
      {
         stopEvent(evt);

         document.getElementById("sb_email_popup_submit").onclick();
      }
   }

   this.openLearnMore = function()
   {
      document.getElementById("sharedbook_menu").style.display = 'none';
      this.setVisible('learn-more');
   }

   /**
    * Close the menu.
    */
   function closeSharedbookMenu()
   {
      document.getElementById('sharedbook_menu').style.display = 'none';
   }
   this.closeSharedbookMenu = closeSharedbookMenu;

   /**
    * Clear the timeout for closing the menu.
    */
   function sharedbookMcancelclosetime ()
   {
      if(sharedbook_closetimer)
      {
         window.clearTimeout(sharedbook_closetimer);
         sharedbook_closetimer = null;
      }
   }
   this.sharedbookMcancelclosetime = sharedbookMcancelclosetime;

   this.setVisible = function (obj)
   {
      obj = document.getElementById(obj);
      obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
   };

   /**
    * Change the main (left) button to be in "on" state.
    */
   function setMainBtnStateOn(elmId ,state)
   {
      document.getElementById("sharedbook_state_img").src = button_on;
   }
   this.setMainBtnStateOn = setMainBtnStateOn;

   /**
    * Change the main (left) button to be in "off" state.
    */
   function setMainBtnStateOff(elmId ,state)
   {
      document.getElementById("sharedbook_state_img").src = button_off;
   }
   this.setMainBtnStateOff = setMainBtnStateOff;

   // **************************************************************************
   // Private functions
   // **************************************************************************
   function elementSetAtt(elm, name, value)
   {
      elm.setAttribute(name, value);
   }

   function createElement(name, value)
   {
      var elm = document.createElement("input");
      elementSetAtt(elm, "type", "hidden");
      elementSetAtt(elm, "name", name);
      elementSetAtt(elm, "value", value);
      return elm;
   }

   /**
    * Disable all functionality of the entire button (left and dropdown).
    */

   function invalidateEntireBtnFunc()
   {
      var drop_down_link = document.getElementById("sharedbook_dropdown_link");
      drop_down_link.onclick = empty_function;
      drop_down_link.onmouseover = empty_function;
      drop_down_link.onmouseout = empty_function;

      document.getElementById("sharedbook_main_link").href = "javascript: void(0)";
      invalidateMainBtnMouseEvents();
   }

   /**
    * Enable the functionality of the dropdown button.
    */
   function revalidateDropdownFunc()
   {
      var drop_down_link = document.getElementById("sharedbook_dropdown_link");
      drop_down_link.onclick = sbSmartBtnObj.sharedbookSwitchMenu;
      drop_down_link.onmouseover = sbSmartBtnObj.sharedbookMopen;
      drop_down_link.onmouseout = sbSmartBtnObj.sharedbookMclosetime;
   }

   /**
    * Set UI and functionality of the button after article was removed.
    */
   function changeBtnAfterRemoveArticle()
   {
      document.getElementById("sharedbook_add_article_btn").innerHTML = add_inner_html;
      document.getElementById("sharedbook_add_article_btn").href = add_function;
      button_off = button_initial_off;
      button_on = button_initial_on;

      revalidateMainBtn(add_function);
   }

   /**
    * Set UI and functionality of the button after article was added.
    */
   function changeBtnAfterAddArticle()
   {
      document.getElementById("sharedbook_add_article_btn").innerHTML = remove_inner_html;
      document.getElementById("sharedbook_add_article_btn").href = remove_function;
      button_off = button_booked_off;
      button_on = button_booked_on;

      revalidateMainBtn(remove_function);
   }

   /**
    * Enable the functioanlity of the main (left) button.
    */
   function revalidateMainBtn(func)
   {
      document.getElementById("sharedbook_state_img").src = button_off;
      document.getElementById("sharedbook_main_link").href = func;
      revalidateMainBtnMouseEvents();
   }

   /**
    * Enable mouse events on the main (left) button.
    */
   function revalidateMainBtnMouseEvents()
   {
      document.getElementById("sharedbook_main_link").onmouseover = sbSmartBtnObj.setMainBtnStateOn;
      document.getElementById("sharedbook_main_link").onmouseout = sbSmartBtnObj.setMainBtnStateOff;
   }

   /**
    * Disable mouse events on the main (left) button.
    */
   function invalidateMainBtnMouseEvents()
   {
      document.getElementById("sharedbook_main_link").onmouseover = empty_function;
      document.getElementById("sharedbook_main_link").onmouseout = empty_function;
   }

   function setCookie(value)
   {
      // Find the domain:
      // "blog.sharedbook.com".match(/(\S*\.)*(\S+[\.]\S+)/) would result:
      // ["blog.sharedbook.com", "blog.", "sharedbook.com"]

      fullDomain = document.domain;
      cookie_domain = fullDomain.match(/(\S*\.)*(\S+[\.]\S+)/)[2];
      var cookieCommand = cookie_name + "=" + escape(value) + "; path=/; domain=" + cookie_domain + "; expires=Fri, 31 Dec 2099 23:59:59 GMT";

      document.cookie = cookieCommand;
   }
   function getCookie()
   {
      var dc = document.cookie;
      var cname = cookie_name + "=";

      if(dc.length > 0)
      {
         begin = dc.indexOf(cname);
         if(begin != -1)
         {
            begin += cname.length;
            end = dc.indexOf(";", begin);
            if(end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));
         }
      }
      return null;
   }

   function validateEmailAddress()
   {
      // TODO: VALIDATE EMAIL ADDRESS
      var userIdFromPrompt = document.getElementById("sb_email_addr").value;
      if(userIdFromPrompt == '')
      {
         return false;
      }

      setCookie(userIdFromPrompt);
      userIdFromCookie = userIdFromPrompt;

      return true;
   }

   function stopEvent (evt)
   {
      //IE
      if(typeof(window.event) != "undefined")
      {
         evt.cancelBubble = true;
         evt.returnValue = false;
      }
      //FF
      else
      {
         evt.preventDefault();
         evt.stopPropagation();
      }
   }


}

// Important: client name turns to directory name, keep it lower case !
var sbSmartBtnObj = new SharedBookSmartButton();

var dws = ""

dws +='<style>';
dws +='#sharedbook_main {';
dws +='	margin:0px 0px 0px 40px;';
dws +='	padding:0;';
dws +='	z-index: 30;';
dws +='	font: bold 11px Arial, Helvetica, sans-serif;';
dws +='}';
dws +='#sharedbook_menu {';
//dws +='	visibility: hidden;';
dws +='	display:block;';
dws +='	margin: 0;';
dws +='	padding: 0;';
dws +='	position:relative;';
dws +='	top:-5px;';
dws +='	left:-27px;';
dws +='	width:125px;';
dws +='}';
dws +='.black {';
dws +='	color:#333;';
dws +='	text-decoration:none;';
dws +='}';
dws +='.sharedbook_cursor {';
dws +='	cursor:pointer;';
dws +='	cursor:hand;';
dws +='}';
dws +='a:active, a:focus {';
dws +='	outline:none;';
dws +='}';
dws +='#sb_email_popup {';
dws +='	position:relative;';
dws +='	top:-5px;';
dws +='	left:-41px;';
dws +='	width:170px;';
dws +='}';
dws +='.sb_email_content {';
dws +='	width: 172px;';
dws +='	background: url(' + domain + 'images/emailbox_middle.gif) top left;';
dws +='	font:normal 9px/12px Arial, Helvetica, sans-serif;';
dws +='	text-align:left;';
dws +='	margin-bottom: 0px;';
dws +='}';
dws +='#learn-more {';
dws +='	position: relative;';
dws +='	left: -35px;';
dws +='	top: -140px;';
dws +='	visibility: hidden;';
dws +='	width: 150px;';
dws +='	font:normal 9px/12px Arial, Helvetica, sans-serif;';
dws +='	border: 1px solid #8dc63f;';
dws +='	background:#ffffff;';
dws +='	padding: 5px;';
dws +='	z-index:10000;';
dws +='}';
dws +='#learn-more p {';
dws +='	margin:0;';
dws +='}';
dws +='.sb_email_content_title {';
dws +='	position: absolute;';
dws +='	padding:3px 0px 0px 8px;';
dws +='	font-size:11px;';
dws +='	margin:0;';
dws +='	font-weight:bold;';
dws +='	text-align: left;';
dws +='	width: 172px;';
dws +='	color: #000;';
dws +='	background: url(' + domain + 'images/emailbox_top.gif) no-repeat ;';
dws +='	height: 5px;';
dws +='}';
dws +='.sb_email_text {';
dws +='	padding: 30px 5px 3px 5px;';
dws +='	color: #333;';
dws +='	font-size:9px;';
dws +='	margin-bottom: 0px;';
dws +='	background: url(' + domain + 'images/emailbox_bottom.jpg) no-repeat left bottom;';
dws +='}';
dws +='.dropdown-content {';
dws +='	width: 123px;';
dws +='	background: url(' + domain + 'images/popup_middle.gif) top left;';
dws +='	font:normal 9px/12px Arial, Helvetica, sans-serif;';
dws +='	text-align:left;';
dws +='	margin-bottom: 10px;';
dws +='}';
dws +='.dd-content_title {';
dws +='	position: absolute;';
dws +='	margin:0;';
dws +='	text-align: left;';
dws +='	width: 123px;';
dws +='	background: url(' + domain + 'images/popup_top.gif) no-repeat ;';
dws +='	height: 4px;';
dws +='}';
dws +='.dd-text {';
dws +='	padding: 12px 0px 12px 12px;';
dws +='	margin-bottom: 0px;';
dws +='	clear:both;';
dws +='	background: url(' + domain + 'images/popup_bottom.gif) no-repeat left bottom;';
dws +='}';
dws +='.dd-link {';
dws +='	margin: 18px 0px;';
dws +='	color: #3a82b8;';
dws +='	font-size:11px;';
dws +='	line-height:145%;';
dws +='	text-decoration:none;';
dws +='}';
dws +='#sb_email_popup p {';
dws +='	margin:5px;';
dws +='}';
dws +='.sb_email_texta {';
dws +='	margin: 2px 3px 5px 2px;';
dws +='}';
dws +='.sb_email_why  {';
dws +='	text-decoration: underline;';
dws +='	font-size:9px;';
dws +='	color: #3a82b8;';
dws +='	padding:8px 3px ;';
dws +='	cursor:pointer;';
dws +='	cursor:hand;';
dws +='}';
dws +='a:hover.sb_email_why  {';
dws +='	text-decoration: none;';
dws +='}';
dws +='#sb_email_popup_submit  {';
dws +='	text-decoration: none;';
dws +='	color: #fff;';
dws +='	background:#3a82b8;';
dws +='	padding:2px 3px ;';
dws +='	margin:10px 3px;';
dws +='}';
dws +='a:hover#sb_email_popup_submit, a:hover.dd-link {';
dws +='	color:#F90;';
dws +='}';
dws +='.sb_email_smaller {';
dws +='	font-size:9px;';
dws +='}';
dws +='sb_email_bigger {';
dws +='	font-size:14px;';
dws +='}';
dws +='.sb_email_error_text {';
dws +='	color:red;';
dws +='	font-size:9px;';
dws +='}';
dws +='</style>';

dws +='<!-- SharedBook Smart Button START -->';
dws +='<div id="sharedbook_main">';
dws +='   <a href="javascript:sbSmartBtnObj.sharedbookAddArticle()" id="sharedbook_main_link" onmouseover="sbSmartBtnObj.setMainBtnStateOn();" onmouseout="sbSmartBtnObj.setMainBtnStateOff()" style="margin: 0pt; padding: 0pt;"><img id="sharedbook_state_img" src="' + domain + 'images/sharedbook_state_img_off.gif" alt="" style="border:0px none #eeeeee; margin: 0pt; padding: 0pt;"></a>';
dws +='<a id="sharedbook_dropdown_link" style="margin: 0pt; padding: 0pt;" onclick="sbSmartBtnObj.sharedbookSwitchMenu()" onmouseover="sbSmartBtnObj.sharedbookMopen()" onmouseout="sbSmartBtnObj.sharedbookMclosetime();" class="sharedbook_cursor"><img src="' + domain + 'images/dropdown_off.gif" alt="" style="border:0px none #eeeeee; margin: 0pt; padding: 0pt;"id="dropdown"></a>';
dws +='     <div style="display: none;" id="sharedbook_menu" onmouseover="sbSmartBtnObj.setMainBtnStateOn();sbSmartBtnObj.sharedbookMcancelclosetime()" onmouseout="sbSmartBtnObj.sharedbookMclosetime();">';
dws +='		<div class="dropdown-content">';
dws +='	   <div class="dd-content_title"></div>';
dws +='	    <div class="dd-text">';
dws +='        <a href="javascript:sbSmartBtnObj.sharedbookAddArticle()" id="sharedbook_add_article_btn" class="dd-link">> Add this Page</a><br />';
dws +='        <a href="javascript:sbSmartBtnObj.sharedbookFinalizeBook()" id="sharedbook_finalize_btn" class="dd-link">> Finalize My Choices</a><br />';
dws +='        <a id="sharedbook_learn_more_btn" href="javascript:void(0)" onclick="sbSmartBtnObj.openLearnMore();" class="dd-link">> Learn More</a>';
dws +='        </div></div>';
dws +='</div>';

dws +='<div id="sb_email_popup" style="visibility: hidden;" onmouseover="sbSmartBtnObj.setMainBtnStateOn();" >';
dws +='	<div class="sb_email_content" >';
dws +='		<div class="sb_email_content_title">We save all your selections<br />using your eMail Address:</div>';
dws +='		<div class="sb_email_text">';
dws +='		<form style="margin:0 0 5px 0;padding:0;" method="POST" action="">';
dws +='			<p class="sb_email_error_text" id="sb_email_error_text"></p><!--Please enter a valid email address-->';
dws +='			<input name="sb_email_addr" id="sb_email_addr" type="text" onkeydown="sbSmartBtnObj.onkeydownHandler(event, window);" size="18" maxlength="35" class="sb_email_texta"><br />';
dws +='			<a id="sb_email_popup_submit" href="javascript:void(0)">Enter</a>';
dws +='		</form>';
dws +='		<a onclick="sbSmartBtnObj.expandDiv(\'sb_email_why\');" class="sb_email_why">Why do you need this?</a>';
dws +='		<div style="display:none;" id="sb_email_why" class="sb_email_expanded" >';
dws +='		<p class="sb_email_smaller">We save all your choices, so you can take your time choosing them. Using your email address, we\'ll store all everything and allow you to come back at any time.</p>';
dws +='		<p class="sb_email_smaller">Don\'t worry, we won\'t share this with anyone.</p>';
dws +='	</div>';
dws +='	<div align="right">';
dws +='		<a href="javascript:sbSmartBtnObj.closeEmailPopup();" class="black">Cancel <img src="' + domain + 'images/cancel.gif" alt="Cancel" border="0" align="baseline" style="border:0px none #eeeeee;"/></a></div>';
dws +='	</div>';
dws +='</div>';
dws +='</div>';

dws +='<!-- Learn More Popup-->';
dws +='<div id="learn-more">';
dws +='   <p class="bigger" align="center"><b style="font-weight:bold;font-size:11px;">Book It &ndash; Learn More</b></p>';
dws +='   <p><i>What\'s "Book It"?</i></p>';
dws +='   <p>Now you can include any page on our site in a custom-published book. Just look for the "Book It" button at the top of the page, and click.</p><br />';
dws +='   <p><i>Then What?</i></p>';
dws +='   <p>We\'ll ask you for a username so we can remember you, and we\'ll save all the pages you\'d like to keep.</p><br />';
dws +='   <p><i>How Do I Make This Book?</i></p>';
dws +='   <p>Click "Finalize Choices" to view the pages you\'ve selected. You can include them all, or delete ones you don\'t need. Then, you can select your book cover, add a dedication (if you like) and upload a photo for the cover (if you like.) Click "Preview Your Book" and sit back while we do the work.</p><br />';
dws +='   <p><i>Can I See It Before I Order?</i></p>';
dws +='   <p>See it? Not only can you see it, you can personalize it further if you wish. Add notes, stories, photos, whatever you want. It\'s your book! You make it your way.</p><br />';
dws +='   <div id="close" align="right" ><a href="javascript:sbSmartBtnObj.setVisible(\'learn-more\')" id="button" >Continue</a></div>';
dws +='</div>';
dws +='</div>';

dws +='<!-- SharedBook Smart Button END -->';

if (!window.smartBtnGM)
{
   document.write(dws);
}
else
{
   smartBtnGM.buttonContainerElement.innerHTML += dws
   //alert(window.trEle.innerHTML.substring(0,80));
}
