// Javascript Include file calcfees.js
// (c) copyright 2001 by The Othersiders Country Western Dance Club

// Code in this file calculates the current paypal fees

function calcFee(amount)
{
	var fee = 0.03 * amount + 0.30;
	if (fee<1) fee = 1;
	return fee;
}

function viewFees(dir)
{
	var w = window.open(dir+'fees.htm','fees','width=400,height=300,scrollbars=yes');
	w.focus();
}

function viewConvenienceCharges(dir)
{
	var w = window.open(dir+'convenchg.htm','fees','width=400,height=300,scrollbars=yes');
	w.focus();
}

function EmailHelp(dir)
{
	var w = window.open(dir+'paypal_help_email.htm','emailhelp',
		'scrollbars=yes,width=450,height=300');
	w.focus();
}

function nonUSinfo(dir)
{
	var w = window.open(dir+'paypal_help_nonus.htm','nonusinfo',
		'scrollbars=yes,width=450,height=300');
	w.focus();
}

function toCents(c) // changes 0.777777777 to 78
// changes 0.33333333 to 34 as PayPal seems to take the full extra penny
{
	c*=100;
	c = Math.floor(c + 0.99)
	return c;
}

function formatMoney(n,field)
//formats n as money (two decimal places) right justified in 'field' spaces
//to avoid justifying, use field=0
{
	var d = Math.floor(n);
	var c = toCents(n - d);
	// d now contains dollars, c contains cents
	if (c==100) //99 was raised to 100
	{
		d++;
		c = 0;
	}
	var st = d.toString();
	var stc = '.00';
	if (c!=0) //c is 1-99 inclusive
	{
		stc = c.toString();
		if (c<10)
			stc = '0' + stc; //add leading zero
		stc = '.' + stc; //prepend dec. point
	}
	st =  st + stc;
	while (st.length<field)
		st = ' ' + st;
	return st;
	
}