/***
 * console.log fix for machines not running firebug.
 *
 */
if (typeof(console) == 'undefined') {
    var console = {
        log: function() {},
        info: function() {},
        warn: function() {},
        error: function() {},
        time: function() {}
    };
}
else if (typeof(console.log) == 'undefined') {
    console.log = function() {};
}


function displayImage(index, parent){
     var images = document.getElementById(parent).getElementsByTagName("div");
    for(var i = 0; i < images.length; i++) {
      var image = images[i];
      if (image.className != 'pimage')  { continue }
      if(i == index-1) {
        image.style.display="block";
      }
      else {
        image.style.display="none";
      }
    }
}

function formatCurrency(num) {
    //alert('formatting number '+num);
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num)) {
        num = "0";
    }
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10) {
        cents = "0" + cents;
    }
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {
        num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
    }
    //return (((sign)?'':'-') + '$' + num + '.' + cents);
    return (((sign)?'':'-') + num + '.' + cents);
}
