/*
 *
 *	Faultless jQuery functions
 *		Stuart Swope
 */
 
/* showToolbar enables the toolbar functionality if the user has javascript */ 
jQuery.showActions = function () {
   var actions = '<!-- AddThis Button BEGIN -->\n\
                     <a href="http://www.addthis.com/bookmark.php?v=20" onmouseout="addthis_close()" onclick="return addthis_sendto()" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')"><img src="graphics/icon_print.gif" width="16" height="16" alt="Share" /></a>\n\
                     <a href="http://www.addthis.com/bookmark.php?v=20" onmouseout="addthis_close()" onclick="return addthis_sendto()" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')">Share</a>\n\
                     <script type="text/javascript" src="https://s7.addthis.com/js/200/addthis_widget.js"><\/script>\n';
   jQuery(actions).appendTo('#topNav');
};

/* Enable home tab interface*/
jQuery.enableHomeTabs = function () {
   jQuery('#searchBoxNav li a').click(function() {
      //parse out the name of the link that was clicked
      var clicked_link = jQuery(this).attr('id').split("-");
      
      var link_name = clicked_link[0];
      jQuery("#searchBoxNav li a").css("background-color", "#edf3f6");
      jQuery(this).css("background-color", "#d5e0e7");
      jQuery('.search-description').hide();
      jQuery('#' + link_name).show();

      return false;
   });
};
/* Show help tooltips for caster store menus. */
jQuery.showHelp = function () {
   if (window.XMLHttpRequest) { /* ie6 ignore */
      jQuery('.menuHelp').hover(function() {
         //parse out the name of the link that was clicked
         var hover_item = jQuery(this).attr('id').split("-");
         var id = hover_item[1];
         
         var position = jQuery(this).offset();
         position['left'] += 50;
         position['top'] += 0;
         jQuery('#help-' + id).fadeIn(400).css(position);
   
         return false;
      },
      function() { 
         var hover_item = jQuery(this).attr('id').split("-");
         var id = hover_item[1];
   
         jQuery('#help-' + id).fadeOut(400);
         return false;
      });
   }
};

jQuery(document).ready(function() {
   jQuery.noConflict();
   jQuery.enableHomeTabs();
   jQuery.showActions();
   jQuery.showHelp();
});