﻿/// <reference path="GeoReps.js" />

/// <summary>
/// GeoReps.Web.UI.UserControls.Listing javascript namespace definition
/// </summary>
GeoReps.Web.UI.UserControls.Listing = {};

GeoReps.Web.UI.UserControls.Listing.isCompanyCreated = function(clientID)
{
	var returnValue = false;

	try
	{
		var combo = $find(clientID);

		if (combo)
		{
			var text = combo.get_text();
			var value = combo.get_value();

			// user has not selected a company
			if (value.length == 0 && text.length == 0)
			{
				alert("Please select a company first");
			}
			// user has typed in a new company name
			else if (value.length == 0 && text.length > 0)
			{
				var message;

				message = "The company selected is new, would like it saved first?\n"
				+ "Click 'OK' to save the company and continue adding a new user, or\n"
				+ "Click 'Cancel' to select an existing company.";

				returnValue = confirm(message);
			}
			// user has selected an existing company
			else returnValue = true;
		}
	}
	catch (e)
	{
		alert("The following error(s) occurred:\n\n" + e.message);
	}

	return returnValue;
}
