var colones_por_euro = 650;
var colones_por_dolar = 490;
var ie5 = document.all && document.getElementById;
var ns6 = document.getElementById && !document.all;
var mouseX = 0;
var mouseY = 0;
function getMouseXY(e)
{
    if ( ie5 )
    { // grab the x-y pos.s if browser is IE
        mouseX = event.clientX + document.body.scrollLeft;
        mouseY = event.clientY + document.body.scrollTop;
    }else
    {  // grab the x-y pos.s if browser is NS
        mouseX = e.pageX;
        mouseY = e.pageY;
    }
    // catch possible negative values in NS4
    mouseX = ( mouseX < 0 ) ? 0 : mouseX;
    mouseY = ( mouseY < 0 ) ? 0 : mouseY;
    return true;
}

function mouseStuff()
{
    if ( ! ie5 )
        document.captureEvents( Event.MOUSEMOVE );
    document.onmousemove = getMouseXY;
}
//Initialization
mouseStuff();

function priceInfo( thePrice )
{
    var ayudaObj = document.getElementById( 'myayudaobj' );
    ayudaObj.style.left = mouseX;
    ayudaObj.style.top = mouseY + 20;
    ayudaObj.style.visibility = 'visible';

    var myInfoObj = document.getElementById( 'the_price' );
    myInfoObj.innerHTML = '&cent;' + moneyFormat( thePrice );

    var myInfoObj = document.getElementById( 'the_service_tax' );
    myInfoObj.innerHTML = '&cent;' + moneyFormat( thePrice * 0.1 );

    var myInfoObj = document.getElementById( 'the_sales_tax' );
    myInfoObj.innerHTML = '&cent;' + moneyFormat( thePrice * 0.13 );

    var myInfoObj = document.getElementById( 'the_total' );
    myInfoObj.innerHTML = '&cent;' + moneyFormat( thePrice * 1.23 );

    var myInfoObj = document.getElementById( 'the_total_dolar' );
    myInfoObj.innerHTML = '$' + moneyFormat( thePrice * 1.23 / colones_por_dolar );

    var myInfoObj = document.getElementById( 'the_total_euro' );
    myInfoObj.innerHTML = '&euro;' + moneyFormat( thePrice * 1.23 / colones_por_euro );

}

function ayudaOver( theText )
{
    var ayudaObj = document.getElementById( "myayudaobj" );
    ayudaObj.style.left = mouseX;
    ayudaObj.style.top = mouseY + 20;
    ayudaObj.style.visibility = "visible";
    var ayudaMsg = document.getElementById( "myayudamsg" );
    ayudaMsg.innerHTML = theText;
}

function ayudaOut()
{
    var ayudaObj = document.getElementById( "myayudaobj" );
    ayudaObj.style.visibility="hidden";
}

function addCommas( nStr )
{
    nStr += '';
    x = nStr.split( '.' );
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while ( rgx.test( x1 ) )
    {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}

function moneyFormat( theNumber )
{
    return addCommas( theNumber.toFixed( 2 ) );
}
