// Formats number as money.
// (123456.789).format_money(2,',','.') -> 123.456,79
Number.prototype.format_money = function(c, d, t){
var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
   return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
 };
 


/**
 * Tabs.
 */
 
var tabs_el = '';
var tabs_list = [];

function tabs_make( el ) {
  var ref = '';
  
  tabs_el = el;
  $(el).addClass("tabs");
  $(el+" UL LI").each(function(i, li){
    ref = $(li).contents("A").attr("href");
    $(li).contents("A").click(function(){
      tabs_select( $(this).attr("href") );
      return false;
    });
    tabs_list.push( ref );
  });
  jQuery.each(tabs_list, function(i, ref){
    $(ref).hide();
  });
  tabs_select( tabs_list[0] );
}

function tabs_select( ref ) {
  $(tabs_el+" DIV").hide();
  $(tabs_el+" LI.selected").removeClass("selected");
  $(tabs_el+" "+ref).show();
  $(tabs_el+" LI:has(A[href='"+ref+"'])").addClass("selected");
}

/*
 * Stylize external link using jQuery
 */
$(function(){
  $("A[href^='http://']").not(
    "A[href^='http://rosbiotech.com'], A[href^='http://rosbiotech.com'], A:has(IMG)"
  ).after("<img src='/i/link.external.gif' width=12 height=12>").attr("target","_blank");
});

/*
 * Set up jQuery.Validation
 */
$(function(){
  $("#validatedform").validate();
});

