// GSM Events Javascript
function formatCurrency(strValue)
{
        strValue = strValue.toString().replace(/\$|\,/g,'');
        dblValue = parseFloat(strValue);

        blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
        dblValue = Math.floor(dblValue*100+0.50000000001);
        intCents = dblValue%100;
        strCents = intCents.toString();
        dblValue = Math.floor(dblValue/100).toString();
        if(intCents<10)
                strCents = "0" + strCents;
        for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
                dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
                dblValue.substring(dblValue.length-(4*i+3));
        return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}


function showText(inValue) {
	if (inValue == "more") {
		document.getElementById('fulltext').style.display = "block";
		document.getElementById('summarytext').style.display = "none";
	} else {
		document.getElementById('fulltext').style.display = "none";
		document.getElementById('summarytext').style.display = "block";
	}
}

function showImage(inPicture) {
	document.getElementById('largeimage').src = inPicture;
}

function swapImage(inID, inImage) {
	document.getElementById(inID).src = inImage;
}

function clearContact() {
	document.contactForm.contactname.value = "";
	document.contactForm.address.value = "";
	document.contactForm.city.value = "";
	document.contactForm.state.value = "";
	document.contactForm.zip.value = "";
	document.contactForm.email.value = "";
	document.contactForm.phone.value = "";
	document.contactForm.contactmethod.value = "";
	document.contactForm.sponsor.value = "";
	document.contactForm.registration.value = "";
	document.contactForm.generalinfo.value = "";
	document.contactForm.message.value = "";
}

function clearDonation() {
	var verifyarray = ['firstname', 'lastname', 'cardtype', 'cardnumber', 'expdate', 'cvvcode', 'address', 'city', 'state', 'zip', 'email'];
	var counter = 0;
	while (counter < verifyarray.length) {
		document.donate.getElementById(verifyarray[counter]).value = "";
		counter++;
	}
}

function clearRegistration() {
	var verifyarray = ['name', 'gender', 'birthdate', 'address1', 'city', 'state', 'zip', 'email', 'telephone', 'billingname', 'billingaddress1', 'billingcity', 'billingstate', 'billingzip', 'billingemail', 'billingtelephone', 'nameoncard', 'cardnumber', 'expdate', 'cvvcode'];
	var counter = 0;
	while (counter < verifyarray.length) {
		document.register.getElementById(verifyarray[counter]).value = "";
		counter++;
	}
}

function setPrice(inAmount, turnedon) {
	var currenttotal= document.getElementById('totalamount').innerHTML;
	currenttotal = currenttotal.replace('$', '');
	var price = inAmount;
	price = price.replace('$', '');
	if (turnedon == true)
	{
		currenttotal = currenttotal.replace(',', '');
		currenttotal = parseFloat(price) + parseFloat(currenttotal);
	}
	
	if (turnedon == false)
	{
		currenttotal = currenttotal.replace(',', '');
		currenttotal = parseFloat(currenttotal) - parseFloat(price);
	}
	document.getElementById('totalamount').innerHTML = formatCurrency(currenttotal);
	document.register.amount.value = formatCurrency(currenttotal);
	
}