// JavaScript Document

function DeleteHorse(horseID, horseName)
{
	confirmed = window.confirm("Click OK to Delete the Horse (" + horseName + "). Click Cancel to stop.");

	if (confirmed)
	{
		//Delete Item
		var cfcAsAjax1 = new ajaxAdminProxy();
		var result = cfcAsAjax1.DeleteHorse(horseID);
		
		if (result)
		{
			window.alert("Horse Deleted");
			window.location='?page=horses';
		}
		else
		{
			window.alert("Deletion of Horse Failed");
		}
		
	} 
	
	return false;
}

function DeleteBreedingReport(horseID,Season,horseName)
{
	confirmed = window.confirm("Click OK to Delete the " + Season + " Breeding Report for " + horseName + ". Click Cancel to stop.");

	if (confirmed)
	{
		
		//Delete Item
		var cfcAsAjax1 = new ajaxAdminProxy();
		var result = cfcAsAjax1.DeleteBreedingReport(horseID,Season);
		
		if (result)
		{
			window.alert("Breeding Report Deleted");
			window.location='?page=horseDetails&horseId=' + horseID;
		}
		else
		{
			window.alert("Deletion of Breeding Report Failed");
		}
	} 
	else 
	
	return false;
}

function DeleteFoalingReport(reportID,horseID,reportDate,horseName)
{
	confirmed = window.confirm("Click OK to Delete the " + reportDate + " Foaling Report for " + horseName + ". Click Cancel to stop.");

	if (confirmed)
	{
		//Delete Item
		var cfcAsAjax1 = new ajaxAdminProxy();
		var result = cfcAsAjax1.DeleteFoalingReport(reportID);
		
		if (result)
		{
			window.alert("Foaling Report Deleted");
			window.location='?page=horseDetails&horseId=' + horseID;
		}
		else
		{
			window.alert("Deletion of Foaling Report Failed");
		}
	} 
	else 
	
	return false;
}

function DeleteHorseReport(reportID,horseID,reportDate,horseName)
{
	confirmed = window.confirm("Click OK to Delete the " + reportDate + " Horse Report for " + horseName + ". Click Cancel to stop.");

	if (confirmed)
	{
		//Delete Item
		var cfcAsAjax1 = new ajaxAdminProxy();
		var result = cfcAsAjax1.DeleteHorseReport(reportID);
		
		if (result)
		{
			window.alert("Horse Report Deleted");
			window.location='?page=horseDetails&horseId=' + horseID;
		}
		else
		{
			window.alert("Deletion of Horse Report Failed");
		}
	} 
	
	return false;
}

function DeleteImage(imageID,imageName,exists,horseID,horseName)
{
	if(exists)
	{
		confirmed = window.confirm("Click OK to Delete the Image: " + imageName + " for " + horseName + ". Click Cancel to stop.");
	}
	else
	{
		confirmed = window.confirm("Click OK to Delete the Missing Image Link: " + imageName + " for " + horseName + ". Click Cancel to stop.");
	}
	if (confirmed)
	{
		//Delete Item
		var cfcAsAjax1 = new ajaxAdminProxy();
		var result = cfcAsAjax1.DeleteImage(imageID,imageName,exists);
		
		if (result)
		{
			if(exists)
			{
				window.alert("Horse Image Deleted");
			}
			else
			{
				window.alert("Missing Image Link Deleted");
			}
			
			window.location='?page=horseDetails&horseId=' + horseID;
		}
		else
		{
			if(exists)
			{
				window.alert("Deletion of Horse Image Failed");
			}
			else
			{
				window.alert("Deletion of Missing Image Link Failed");
			}
			
		}
	} 
	
	return false;
}

function RemoveImage(imageID,imageName,horseID,horseName)
{
	confirmed = window.confirm("Click OK to Remove the Image: " + imageName + " for " + horseName + ". Click Cancel to stop.");
	
	if (confirmed)
	{
		//Delete Item
		var cfcAsAjax1 = new ajaxAdminProxy();
		var result = cfcAsAjax1.RemoveImage(imageID,imageName);
		
		if (result)
		{
			window.alert("Horse Image Removed");
			window.location='?page=horseDetails&horseId=' + horseID;
		}
		else
		{
			window.alert("Removal of Horse Image Failed");
			
		}
	} 
	
	return false;
}
