// CSS Support
jQuery(document).ready(function($) {
  $('a[@href^="http"]').not('[@href^="http://keystone-si.com/"]').attr({target:"_blank"}).addClass('external');
  $('table.stripe tr:odd td').css({'backgroundColor':'#E5E1DE'});
  $('div[id^="comment-"]:eq(0)').css({'margin':'0'});
});

// Rollover
jQuery(document).ready(function($) {
  $("img[src*='rollover']").not("[src*='_on.']").each(function(){
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    $(this).hover(
      function(){this.src = imgsrc_on;},
      function(){this.src = imgsrc;}
    );
  });
});

// Scroll
jQuery(document).ready(function($) {
  $('a[href^=#]').click(function() { 
  var href= this.hash; 
  var $target = $(href == '#top' ? 'body' : href);
  if($target.size()) {
  var top = $target.offset().top;
  $($.browser.safari ? 'body' : 'html').animate({scrollTop:top}, 800, 'swing');
  }
  return false;
  });
});

// Blog Date
jQuery(document).ready(function($) {
  $('.postdate').each(function(index,dom) {
    var res = $(dom).text().match( /\d+/g );
    var year = res[0];
    var month = res[1];
    var date = res[2];
    var html = '<div class="date">';
    html += '<span class="month"><img height="20" width="44" src="/wp-content/themes/keystone/images/month'+month+'.gif" /></span>';
    html += '<span class="day"><img height="30" width="44" src="/wp-content/themes/keystone/images/day'+date+'.gif" /></span>';
    html += '<span class="year"><img height="50" width="16" src="/wp-content/themes/keystone/images/year'+year+'.gif" /></span>'
    html += '</div>'
    $(dom).parents("div.entrybox").prepend(html);
  });
  $('.postdate').remove();
});

