function c43_getIdxThumbnail(e){
  newLink = $(e).attr('href');
  newImg = $(e).find('img').attr('src').split('&size=tiny').join('&size=small');
  newTxt = $(e).attr('rel');
  
  $("#content_43 .thumbs a[href='"+$("#content_43 .featured a.img").attr('href')+"']").stop().animate({ opacity: 0.5 }, 500);
  $("#content_43 .thumbs a[href='"+newLink+"']").stop().animate({ opacity: 1 }, 200);
  $("#content_43 .featured a.img").attr('href', newLink);
  $("#content_43 .featured a.img img").attr('src', newImg);
  $("#content_43 .featured p").html(newTxt);
}

$(document).ready(function(){

  //mls search form
  $("input[name='content_43[mlsNumber]']")
    .focus(function(){
      curVal = $.trim($(this).val());
      if( curVal == 'MLS Number' ){ $(this).val(''); }
    })
    .blur(function(){
      curVal = $.trim($(this).val());
      if( curVal == '' ){ $(this).val('MLS Number'); }
    });
  
  //thumbnail functions
  $("#content_43 .thumbs a")
    .css({ opacity: 0.5 })
    .mouseover(function(){
      thisLink = $(this).attr('href');
      currentLink = $("#content_43 .featured a.img").attr('href');
      if( thisLink != currentLink ){
        $(this).stop().animate({ opacity: 1 }, 100);
      }
    })
    .mouseout(function(){
      thisLink = $(this).attr('href');
      currentLink = $("#content_43 .featured a.img").attr('href');
      if( thisLink != currentLink ){
        $(this).stop().animate({opacity: 0.5 }, 500);
      }
    })
    .click(function(){
      c43_getIdxThumbnail(this);
      return false;
    });
  $("#content_43 .thumbs a[href='"+$("#content_43 .featured a.img").attr('href')+"']").stop().css({ opacity: 1 });
  
  //previous link
  $("#content_43 .featured a.prev").click(function(){
    firstLink = $("#content_43 .thumbs a:first").attr('href');
    currentLink = $("#content_43 .featured a.img").attr('href');
    if( firstLink == currentLink ){
      $("#content_43 .thumbs a:last").trigger('click');
    }else{
      $("#content_43 .thumbs a[href='"+currentLink+"']").prev().trigger('click');
    }
  });
  
  //next link
  $("#content_43 .featured a.next").click(function(){
    lastLink = $("#content_43 .thumbs a:last").attr('href');
    currentLink = $("#content_43 .featured a.img").attr('href');
    if( lastLink == currentLink ){
      $("#content_43 .thumbs a:first").trigger('click');
    }else{
      $("#content_43 .thumbs a[href='"+currentLink+"']").next().trigger('click');
    }
  });
});