function formatcurrency(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return "$" + s;
}

function getElement(element) {
	if (document.getElementById) {
		return document.getElementById(element);
	}	
	else if (document.all) {
		return document.all(element);
	}
	else if (document.layers){
		return document.layers[element];
	}
	else {
		return null;
	}
}

function getDocElement(doc, element) {
	if (doc.getElementById) {
		return doc.getElementById(element);
	}	
	else if (doc.all) {
		return doc.all(element);
	}
	else if (doc.layers){
		return doc.layers[element];
	}
	else {
		return null;
	}
}

function setSpanText(id, text) {
	var spanObj = getElement(id);
	spanObj.innerHTML = text;
}

function changeCountry(akey, aval, theform, prefix) {
	var elname = "document." + theform.name + "." + prefix + "state";
	var selobj = eval(elname);

	for(j=selobj.length; j >= 0; j--) {
		selobj.options[j] = null;
	}

	selobj.options.length = 0;
	for(i=0; i < akey.length; i++) {
		selobj.options[i] = new Option( aval[i], akey[i] );
	}
}

function borderit(which,color){
	//if IE 4+ or NS 6+
	if (document.all||document.getElementById){
		which.style.borderColor=color;
	}
}

function openwin(htmlFile, win_width, win_height) {
	thewin=open("","NewWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width="+win_width+",height="+win_height);
	thewin.location = htmlFile;
}

function toggleDisplay(id) {
	obj = getElement(id);
	if(obj != null) {
		if( obj.style.display == '') {
			obj.style.display = 'none';
			objImg = getElement('arrow'+id);
			if(objImg != null) {
				objImg.src = "images/arrowUP.gif";
			}
		} else {
			obj.style.display = '';
			objImg = getElement('arrow'+id);
			if(objImg != null) {
				objImg.src = "images/arrowDOWN.gif";
			}
		}
	}

	for(i = 1; i < 99; i++) {
		obj = getElement('cat' + i);
		if(obj == null) {
			break;
		} else if( ('cat' + i) != id ) {
			obj.style.display = 'none';
			objImg = getElement('arrowcat'+i);
			if(objImg != null) {
				objImg.src = "images/arrowUP.gif";
			}

		}
	}

}

function toggleDisplaySubCat(catid, subcatid) {
	// show the category
	obj = getElement(catid);
	if(obj != null) {
		obj.style.display = '';
		objImg = getElement('arrow'+catid);
		if(objImg != null) {
			objImg.src = "images/arrowDOWN.gif";
		}
	}

	obj = getElement(subcatid);
	if(obj != null) {
		if( obj.style.display == '') {
			obj.style.display = 'none';
			objImg = getElement('arrow'+subcatid);
			if(objImg != null) {
				objImg.src = "images/arrowUP.gif";
			}
		} else {
			obj.style.display = '';
			objImg = getElement('arrow'+subcatid);
			if(objImg != null) {
				objImg.src = "images/arrowDOWN.gif";
			}
		}
	}

	// hide all other categories
	for(i = 1; i < 99; i++) {
		obj = getElement('cat' + i);
		if(obj == null) {
			break;
		} else if( ('cat' + i) != catid ) {
			obj.style.display = 'none';
			objImg = getElement('arrowcat'+i);
			if(objImg != null) {
				objImg.src = "images/arrowUP.gif";
			}

		}
	}

	// hide all other subcategories
	for(i = 1; i < 99; i++) {
		obj = getElement('subcat' + i);
		if(obj == null) {
			break;
		} else if( ('subcat' + i) != subcatid ) {
			obj.style.display = 'none';
			objImg = getElement('arrowsubcat'+i);
			if(objImg != null) {
				objImg.src = "images/arrowUP.gif";
			}

		}
	}
}