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 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 galleryNext() {
	obj = getElement('gallery');
	if(obj != null) {
		imgcurrent++;
		if(imgcurrent > imgend) {
			imgcurrent = imgstart;
		}
		obj.src = gallerydir + '/' + imgcurrent + '.jpg';
		gallerySetCount();
	}
}
function galleryPrevious() {
	obj = getElement('gallery');
	if(obj != null) {
		imgcurrent--;
		if(imgcurrent < imgstart) {
			imgcurrent = imgend;
		}
		obj.src = gallerydir + '/' + imgcurrent + '.jpg';
		gallerySetCount();
	}
}
function gallerySetCount() {
	setSpanText('gallerycount', "Image " + imgcurrent + " of " + imgend);
}
function galleryInit() {
	obj = getElement('gallery');
	if(obj != null) {
		obj.src = gallerydir + '/' + imgstart + '.jpg';
		gallerySetCount();
	}
}


