/* ADD-THIS JS */

$(document).ready(function(){

   /* ##########   INSERT ADD THIS CSS INTO HEADER #################################### */

         var headID = document.getElementsByTagName("head")[0];
         var cssNode = document.createElement('link');
         cssNode.type = 'text/css';
         cssNode.rel = 'stylesheet';
         cssNode.href = 'http://www.cisco.com/cdc_content_elements/scripts/addthis/addthis.css';
         cssNode.media = 'screen';
         headID.appendChild(cssNode);

   /* ##########   SET ADD THIS VARS #################################### */

         addthis_pub = 'CorpWebMktg';
         addthis_logo = 'http://www.cisco.com/swa/i/logo.gif';
         addthis_options = 'email, technorati, delicious, digg, twitter, more';

   /* ##########   INSERT ADD THIS JS INTO HEADER #################################### */

         var headID = document.getElementsByTagName("head")[0];
         var newScript = document.createElement('script');
         newScript.type = 'text/javascript';
         newScript.src = 'http://s7.addthis.com/js/152/addthis_widget.js';
         headID.appendChild(newScript);

   /* ##########   CREATE ADD THIS HOLDER #################################### */

         var addthisdiv = document.createElement('div');
         addthisdiv.setAttribute('id','addthis');

   /* ##########   GET SCRIPT OPTIONS #################################### */

         var addThisScriptName = 'addthis.js';
         var addThisScripts = document.getElementById("addthiscript");
         var addThisOptions = '';

            srcurl = addThisScripts.src;
               if (index = srcurl.indexOf("?")) { addThisOptions = srcurl.substr(index+1, srcurl.length); }


         addThisSetOptions( addThisOptions );

         function addThisGetValue ( key, str, delim )
         {
            var out = ''
            var start = -1;
            var end = -1;
            start = str.indexOf(key)

               if ( start > -1 )
                  {
                     start += (key.length + 1);
                     end = str.indexOf(delim, start);
                     if ( end > -1 ) { out = str.substring(start, end); }
                     else { out = str.substring(start); }
                  }
               else { out = ''; }
            return out;
         }

         function addThisSetOptions( addopt )
         {
          /* div id */
         	str = addThisGetValue ( 'div', addopt, '&' );
         	if ( str != '') { addThisDivId = str; } else {addThisDivId ="";}
          /* generic option */
         	str = addThisGetValue ( 'class', addopt, '&' );
         	if ( str != '') { addThisClass = str; } else { addThisClass = "noncustom";}
          /* generic option */
         	str = addThisGetValue ( 'hider', addopt, '&' );
         	if ( str != '') { addThisHider = str; } else { addThisHider = "false";}
        }

/* ##########   DETERMINE WHICH DIV ADD THIS SHOULD BE ADDED TO #################################### */

   if(addThisDivId != "")
   {
   var frmwrktitls = document.getElementById(addThisDivId);
   }

   if(addThisDivId=="framework-content-titles"  && addThisClass == "noncustom")
      {
      frmwrktitls.appendChild(addthisdiv);
      $("#addthis").addClass("addnorm");
      insertAddThis();
      }

   if(addThisDivId=="framework-content-right"  && addThisClass == "noncustom")
      {
      $("#framework-content-right").prepend(addthisdiv);
      $("#addthis").addClass("addstyle2");
      insertAddThis();
      }

   if(addThisDivId=="framework-content-main"  && addThisClass == "noncustom")
      {
      $("#framework-content-main").prepend(addthisdiv);
      $("#addthis").addClass("addstyle3");
      insertAddThis();
      }

   if(addThisDivId != "" && addThisClass=="addthiscustom")
      {
      $(frmwrktitls).prepend(addthisdiv);
      $("#addthis").addClass("addthiscustom");
      insertAddThis();
      }



   /* ##########   ADD OUR ADDTHIS CODE TO OUR NEW DIV #################################### */
         function insertAddThis()
         {
         document.getElementById("addthis").innerHTML = "<a href=\"http://www.addthis.com/bookmark.php\" onmouseover=\"return addthis_open(this, '', '[URL]', '[TITLE]')\" onmouseout=\"addthis_close()\" onclick=\"return addthis_sendto()\"><img src=\"http://www.cisco.com/cdc_content_elements/scripts/addthis/addthis.jpg\" id=\"addthisimg\" border='0' alt='' /></a>";
         }

 if(addThisHider=="true")
 {
 $("#addthis").hover (
      function () {document.getElementById('rssmodule').style.visibility="hidden";  },
      function () {setTimeout('document.getElementById("rssmodule").style.visibility="visible"',800); }
    );
  }

});


