    $(function () {
      ss(true);
      $('h1,h2,h3').each(function () {
        $(this).attr('title',$(this).text());
        genTitle(this);
      });
      $('#cgbdcls a').click(function () {
        $('#cgbdcls a').not(this).each(function () {
          $('body').removeClass($(this).text());
        });
        $('body').addClass($(this).text());
        $('h1,h2,h3').each(function () {
          genTitle(this);
        });
        return false;
      });
      $('.midcol:last h2').each(function () {
        var aid = $(this).attr('title').toLowerCase().replace(/ /g,"");
        //$(this).parent().prepend('<a name="'+aid+'"></a>');
        $(this).wrap('<a name="'+aid+'"></a>');
        $('ul#leftnav').append('<li><a href="#'+aid+'">'+$(this).attr('title')+'</a></li>');
      });
      $('.namechange').change(function () {
        $('#fullname').val($('#fname').val()+ ' '+$('#sname').val());
      });
      $('#entryform button').click(function () {
        var sv = $('#entryform input').serializeArray();
        $.post('/engineware/s/salespitchx/add',sv,function (d) {
          if (d == '1') {
            $('#entryform').fadeOut(200,function () {
              $('#entryform').html('<p class="intro">Thanks for entering!</p>').slideDown();
            });
          }
        });
      });
      if ($('#subheadcont').length) { // only on subpages
        $('#headeroverlay').mousemove(function (e) {
          var o = $(this).offset();
          if (e.pageX > o.left && e.pageX < (o.left + 320)) {
            if (e.pageY > o.top && e.pageY < (o.top + 45)) {
              $(this).css('cursor','pointer');
            }else{
              $(this).css('cursor','');
            }
          }else{
            $(this).css('cursor','');
          }
        }).click(function () {
          if ($(this).css('cursor') == 'pointer') {
            window.location = '/';
          }
        });
      }
    });
function genTitle(obj) {
          switch(obj.tagName) {
          case 'h1':
          case 'H1': s = 35; break;
          case 'h2':
          case 'H2': s = 18; break;
          case 'h3':
          case 'H3': s = 15; break;
          case 'h4':
          case 'H4': s = 12; break;
          case 'div':
          case 'DIV': return false;
        }
        var c =$(obj).css('color');
        if (c.substr(0,1) == '#') {
          c = c.substr(1);
        }else{
          c = rgbConvert(c);
        }
        $(obj).html('<img src="images/title.php?c='+c+'&b=FFFFFF&s='+s+'&text='+escape($(obj).attr('title'))+'"/>');
}
function rgbConvert(str) {
   str = str.replace(/rgb\(|\)/g, "").split(",");
   str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
   str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
   str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
   str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
   str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
   str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];
   return (str.join(""));
}
    function ss(firstrun) {
      var c = $('.headerimg:visible').length;
      var d = 1000; // fade duration
      var i = 3000; // time between image changes
      if (!firstrun) {
        if (c == 1) {
          $('.headerimg:last').fadeIn(d,function () { $('.headerimg').show(); });
        }else{
          $('.headerimg:visible:last').fadeOut(d);
        }
      }
      setTimeout('ss()',i);
    }
