// JavaScript Document
function navRollOver(obj, state) {
	if(obj != "navMembers"){
		if(state == "off"){
		  document.getElementById(obj).className = "navOff navRightDashes";
		}
		else{
		  document.getElementById(obj).className = "navOn navRightDashes";
		}
	} else {
		if(state == "off"){
		  document.getElementById(obj).className = "navOff";
		}
		else{
		  document.getElementById(obj).className = "navOn";
		}
	}
}


//resizes iframe to fit text
function calcHeight()
{

  document.getElementById('bframe').height = 0;
  //find the height of the internal page
  var the_height=
    document.getElementById('bframe').contentWindow.
      document.body.scrollHeight + 30;

  //change the height of the iframe
  document.getElementById('bframe').height=
      the_height;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//formats currency
function tidy (y){
    max_length=12;//max_length= length of text input
    spacing="$ ";
    x=Math.floor(y);
    xx=y-x;
    xx=xx+"00.00"//xx=the cents only (with zeroes).
    a=xx.indexOf(".");
    q=x+xx.substring(a,a+3);
    ql= (q.length<max_length)?(max_length-q.length):0;   
    r=(y)?spacing.substring(0,ql)+q:"";
    return (r);
}
function formatCurrency( num ) {
	var isNegative = false;
	num = num.toString().replace(/\\$|\\,/g,'');
	if( isNaN( num ) ) {
	num = "0";
	}
	if ( num < 0 ) {
	num = Math.abs( num );
	isNegative = true;
	}
	cents = Math.floor( ( num * 100 + 0.5 ) % 100 );
	num = Math.floor( ( num * 100 + 0.5 ) / 100 ).toString();
	if ( cents < 10 ) {
	cents = "0" + cents;
	}
	for ( 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 ) );
	}
	
	var result = '$' + num + '.' + cents;
	if ( isNegative ) {
	result = "-" + result;
	}
	return " " + result;
}

