// Get Exercises Based on Select Box
function getexercises() {
	
	$('#exercises').html('<img src="/images/throbber.gif">');
	$('#exercises').show();

	$.ajax({
		type: "POST",
		url: "/ajax/selectexercises.cfm",
		cache: false,
		data: "muscleID=" + $('#muscles').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#exercises').html(msg);
				$('#exercises').show();
	
				}
			}

	});

}

// Insert User Created Exercise
function createuserexercise() {
	
	$('#createdexercise').html('<img src="/images/throbber.gif">');
	$('#createdexercise').show();

	$.ajax({
		type: "POST",
		url: "/ajax/insertuserexercise.cfm",
		cache: false,
		data: "exercisename=" + $('#exercisename').val() + "&" + "musclegroup=" + $('#musclegroup').val() + "&" + "exercisedesc=" + $('#exercisedesc').val() + "&" + "personID=" + $('#personID').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#createdexercise').html(msg);
	
				}
			}

	});

}

// Get Chart
function getchart() {
	
	$('#thechart').html('<img src="/images/throbber.gif">');
	$('#thechart').show();

	$.ajax({
		type: "POST",
		url: "/ajax/selectchart.cfm",
		cache: false,
		data: "getchart=" + $('#getchart').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#thechart').html(msg);
	
				}
			}

	});
	
	if ($('#getchart').val() == 1) {
		$('.charttype').html("Body Weight Tracking");
	}
	else if ($('#getchart').val() == 2) {
		$('.charttype').html("Run Tracking");
	}
	else if ($('#getchart').val() == 3) {
		$('.charttype').html("PFT Tracking");
	}

}

// Get Workouttype
function getworkouttype() {
	
	$('#theworkouts').html('<img src="/images/throbber.gif">');
	$('#theworkouts').show();

	$.ajax({
		type: "POST",
		url: "/ajax/selectworkouttype.cfm",
		cache: false,
		data: "getworkouttype=" + $('#getworkouttype').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#theworkouts').html(msg);
	
				}
			}

	});
	
	if ($('#getworkouttype').val() == 1) {
		$('.workouttype').html("All Workouts");
	}
	else if ($('#getworkouttype').val() == 2) {
		$('.workouttype').html("Premium Workouts");
	}
	else if ($('#getworkouttype').val() == 3) {
		$('.workouttype').html("FREE Workouts");
	}

}

// Update Weight
function updateweight() {
	
	$('#weight1box').html('<img src="/images/throbber.gif">');

	$.ajax({
		type: "POST",
		url: "/ajax/updateweight.cfm",
		cache: false,
		data: "newweight=" + $('#newweight').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#mynewweight').html(msg);
				$('#weight1box').hide();
				$('#showform').hide();
	
				}
			}

	});

}
// Chart Distance
function chartdistance() {
	
	$('#thechart').html('<img src="/images/throbber.gif">');
	$('#thechart').show();

	$.ajax({
		type: "POST",
		url: "/ajax/chartdistance.cfm",
		cache: false,
		data: "getchart=" + $('#getchart').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#thechart').html(msg);
	
				}
			}

	});

}
// Chart Pace
function chartpace() {
	
	$('#thechart').html('<img src="/images/throbber.gif">');
	$('#thechart').show();

	$.ajax({
		type: "POST",
		url: "/ajax/chartpace.cfm",
		cache: false,
		data: "getchart=" + $('#getchart').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#thechart').html(msg);
	
				}
			}

	});

}
// Chart Calories
function chartcalories() {
	
	$('#thechart').html('<img src="/images/throbber.gif">');
	$('#thechart').show();

	$.ajax({
		type: "POST",
		url: "/ajax/chartcalories.cfm",
		cache: false,
		data: "getchart=" + $('#getchart').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#thechart').html(msg);
	
				}
			}

	});

}
// Chart Time
function charttime() {
	
	$('#thechart').html('<img src="/images/throbber.gif">');
	$('#thechart').show();

	$.ajax({
		type: "POST",
		url: "/ajax/charttime.cfm",
		cache: false,
		data: "getchart=" + $('#getchart').val(),
		success: function(msg){
			
			if ($.trim(msg).length) {
				
				$('#thechart').html(msg);
	
				}
			}

	});

}

// Export Run
function exportrun() {

	$.ajax({
		type: "POST",
		url: "/ajax/runexport.cfm",
		cache: false,
		data: "runfrom=" + $('#runfrom').val() + "&" + "runto=" + $('#runto').val(),
		success: function(data){
				$("#runchart").html(data);
			} 

	});

}

// Get All Workouts
function getallworkouts() {

	$.ajax({
		type: "POST",
		url: "/ajax/getallworkouts.cfm",
		cache: false,
		success: function(data){
				$("#workoutsdisplay").html(data);
			} 

	});

}

// Get FREE Workouts
function getfreeworkouts() {

	$.ajax({
		type: "POST",
		url: "/ajax/getfreeworkouts.cfm",
		cache: false,
		success: function(data){
				$("#workoutsdisplay").html(data);
			} 

	});

}

// Get Premium Workouts
function getpremiumworkouts() {

	$.ajax({
		type: "POST",
		url: "/ajax/getpremiumworkouts.cfm",
		cache: false,
		success: function(data){
				$("#workoutsdisplay").html(data);
			} 

	});

}