$(document).ready(function(){
	$(".mp3").jmp3({
		"filepath": "/sound/"
	});

	// initialize send form
	var options = {
            target: '',
            dataType: 'html',
            url: '/cgi-bin/moochTone.pl' };

        $('#toneForm').submit(function() {
                $(this).ajaxSubmit(options);
		$("#sendMoochTone").hide("slow");
                return false;
            });
	
});

function clearMoochTone () {
    $("#sendMoochTone").hide("slow");
}

function sendMoochTone (sndPath) {
    $('#tonePhone').removeClass('err');
    $('#tonePhone').val('');
    $("#sendMoochTone").show("slow");
    $("#tonePath").val(sndPath);
}

function sendTone() {
    phone = $('#tonePhone').val();
    var value = phone.replace(/\D/g, '');

    if (value.match(/^\d{10}$/)) {
	pageTracker._trackPageview('/moochtone/' + $("#tonePath").val())
	$('#tonePhone').val('1' + value);
        $('#toneForm').submit();
    }
    else {
	$('#tonePhone').addClass('err');
    }
}
