$(document).ready(function() {

$("#block-user-1 h2").click(function(){
  $('#block-user-1 ul.menu').toggle();
  $("#block-user-1 ul.menu li").hover(
    function () {
      $(this).addClass('on');
    },
    function () {
      $(this).removeClass('on');
    }
  );
  return false;
});

$("body.page-forum h1.title").html("Conversations");

$(".block-user_relationship_blocks").find("h2:contains('Relationships')").each(function(){
  $(this).text($(this).text().replace(/Relationships/, "Friends"));
});

$(".section-myfriends").find("h1:contains('relationships')").each(function(){
  $(this).text($(this).text().replace(/relationships/, "Friends"));
});
$("#breadcrumb").find("a:contains('relationships')").each(function(){
  $(this).text($(this).text().replace(/relationships/, "Friends"));
});
$("ul.tabs").find("span:contains('Bio')").each(function(){
  $(this).text($(this).text().replace(/Bio/, "Edit my Bio"));
});
$("#friend_list").find("a:contains('Add')").each(function(){
  $(this).text($(this).text().replace(/Add/, "Add as friend"));
});

$('.view-item-sg-ratings').hover(function() {
  $(this).addClass('on');
}, function() {
  $(this).removeClass('on');
});

$('.view-item-sp-ratings').hover(function() {
  $(this).addClass('on');
}, function() {
  $(this).removeClass('on');
});

$('#dashboard li').hover(function() {
  $(this).addClass('on');
}, function() {
  $(this).removeClass('on');
});
$('#block-block-29 li').hover(function() {
  $(this).addClass('on');
}, function() {
  $(this).removeClass('on');
});

$('.view-content-bookmarks-1 tr').hover(function() {
  $(this).addClass('on');
}, function() {
  $(this).removeClass('on');
});

$("body.not-front").find('.sp_widgetSelect').hover(function() {
  $(this).addClass('on');
}, function() {
  $(this).removeClass('on');
});

$("body.not-front").find("#sp_widgetSelect1").click(function(){
  window.location='/category/savvypack/heart-savvy';
});
$("body.not-front").find("#sp_widgetSelect2").click(function(){
  window.location='/category/savvypack/body-savvy';
});
$("body.not-front").find("#sp_widgetSelect3").click(function(){
  window.location='/category/savvypack/character';
});
$("body.not-front").find("#sp_widgetSelect4").click(function(){
  window.location='/category/savvypack/street-savvy';
});
$("body.not-front").find("#sp_widgetSelect5").click(function(){
  window.location='/category/savvypack/mission-savvy';
});
 
$("body.front").find("#sp_widgetSelect1").mouseover(function(){
  $("#SavvyPackTop p").hide();
  $(".sp_widgetSelect").removeClass('on');
  $("#sp_widgetSelect1").addClass('on');
  $('#sp_widget1').show();
});
$("body.front").find("#sp_widgetSelect2").mouseover(function(){
  $("#SavvyPackTop p").hide();
  $(".sp_widgetSelect").removeClass('on');
  $("#sp_widgetSelect2").addClass('on');
  $('#sp_widget2').show();
});
$("body.front").find("#sp_widgetSelect3").mouseover(function(){
  $("#SavvyPackTop p").hide();
  $(".sp_widgetSelect").removeClass('on');
  $("#sp_widgetSelect3").addClass('on');
  $('#sp_widget3').show();
});
$("body.front").find("#sp_widgetSelect4").mouseover(function(){
  $("#SavvyPackTop p").hide();
  $(".sp_widgetSelect").removeClass('on');
  $("#sp_widgetSelect4").addClass('on');
  $('#sp_widget4').show();
});
$("body.front").find("#sp_widgetSelect5").mouseover(function(){
  $("#SavvyPackTop p").hide();
  $(".sp_widgetSelect").removeClass('on');
  $("#sp_widgetSelect5").addClass('on');
  $('#sp_widget5').show();
});

/*fixing defect from fivestar rating */
$('body.node-type-story .image-attach-body').clone(true).prependTo('.node .content').addClass('show');

$("#search-box").append('<div id="search-box-link"><a href="/topics">Browse<br/>Topics</a></div>');
$("#search-block-form").append('<div id="search-box-link"><a href="/topics">Browse<br/>Topics</a></div>');

$('ul').find('sf-menu').superfish({
opacity: 1.0
});
        
});

//SEARCH BOX
$(function(){ 
  $('#edit-keys').hint();
})
$(function(){ 
  $('#edit-search-theme-form-keys').hint();
})
$(function(){ 
  $('#edit-search-block-form-keys').hint();
})
jQuery.fn.hint = function() {
  return this.each(function(){
    var t = $(this); // get jQuery version of 'this'
    var title = 'search hundreds of articles';
    
    if (title) { // only apply logic if the element has the attribute
      
      // on focus, set value to blank if current value matches title attr
      t.focus(function(){
        if (t.val() == title) {
          t.val('');
          t.removeClass('blur');
        }
      })

      // on blur, set value to title attr if text is blank
      t.blur(function(){
        if (t.val() == '') {
          t.val(title);
          t.addClass('blur');
        }
      })

      // clear the pre-defined text when form is submitted
      t.parents('form:first()').submit(function(){
        if (t.val() == title) {
          t.val('');
          t.removeClass('blur');
        }
      });

      // now change all inputs to title
      t.blur();
    }
  })				
}
//E. SEARCH BOX