/* 
  REQUIREMENTS
  =============================================================
    jQuery JavaScript Library ("Packed" version, to save space)
    http://docs.jquery.com/Downloading_jQuery#Current_Release
    
  INCLUDE
  =============================================================
    <script type="text/javascript" src="/jquery-1.2.6.pack.js"></script>
    <script type="text/javascript" src="/productListPoints.js"></script>
*/

$( document ).ready( function() {
  
  $( 'div.product-list-price' ).each( function( item ) {
    
    var costPrice = $( this ).find( "span.product-list-cost-value" );
    var salePrice = $( this ).find( "span.product-list-sale-value" );
    var price;
    
    if ( salePrice.length > 0 ) {
      price = salePrice.text();      
    } else if ( costPrice.length > 0 ) {
      price = costPrice.text();
    }
    
    if ( price ) {
      price = price.replace( /\$|,/ig, '' );
      
      if ( ! isNaN( price ) ) {
        var points = Math.round( price * 10000 / 10000 + 10 ) * 100;
      
        $( this ).append( '<div style="font-weight:bold;margin-top:10px"><a style="font-weight:bold" title="What are EQuick Points?" href="/equick-points.aspx">EQuick Points:</a> ' + points + '</div>' );
      }
    }
  });

});

