/**
 * search-results.js file
 *
 * Provide a trim/expand function for vacancies in the search results page.
 * With IE6, If the benefits box drops below the vacancy description, sections
 * of the borders' sides disappear, so the substr(0,400) is sensitive.
 *
 * @author Adrian Hardy <dev@fuzzee.co.uk>
 * @copyright Adrian Hardy 2008
 */
$(document).ready(function(){
   $('p.vacancy-description').each(function(){
      var full_description = $(this).html();
      var short_description = full_description.substr(0,400);
      var obj_parent = $(this).parent();
      $(this).remove();

      $(obj_parent).append('<p class="vacancy-description short">'+short_description+'...</p>');

      $('td.more-info span',obj_parent.next()).click( function(){

         if ($('p.vacancy-description',obj_parent).is('.short')) {
            $('p.vacancy-description',obj_parent).remove();
            $(obj_parent).append('<p class="vacancy-description long">'+full_description+'</p>');
            $(this).text('less info');
         } else {
            $('p.vacancy-description',obj_parent).remove();
            $(obj_parent).append('<p class="vacancy-description short">'+short_description+'</p>');
            $(this).text('more info');
         }

      })

   });



});