﻿//var contactInfoIsActive = false;

/****************************************
CONFIGURE RESUME POPUP
****************************************/
function ShowConfigureResumePopup(resumeId)
{
	InitializeResBuilderProxy();
	window.CurrentResumeId = resumeId;
	responseDivName = "ResumeConfigureResponseDiv";
	resBuilderProxy.GetControlHtml("ResumeConfigure", true, resumeId, 
		currentPersonId, 0, RenderPopup, HandlePopupError, 500);
}

function SaveConfigureResume()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;
	var templateRequired = false;

	if (!validText($get(ctrlPrefix + "ResumeName").value))
	{
		AddValidationSummaryItem(summary, "A valid Resume Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ResumeName");
	}

	var formatRequired = $get(ctrlPrefix + "OutputList").value.split("|")[1] == "1";
	
	if (formatRequired)
	{
		if ($get(ctrlPrefix + "HeaderFontList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Header Font is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "HeaderFontList");
		}

		if ($get(ctrlPrefix + "HeaderSizeList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Header Font Size is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "HeaderSizeList");
		}

		if ($get(ctrlPrefix + "SectionFontList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Section Font is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "SectionFontList");
		}

		if ($get(ctrlPrefix + "SectionSizeList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Section Font Size is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "SectionSizeList");
		}

		if ($get(ctrlPrefix + "BodyFontList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Body Font is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "BodyFontList");
		}

		if ($get(ctrlPrefix + "BodySizeList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Body Font Size is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "BodySizeList");
		}
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var data = window.CurrentResumeId + ":"
			+ SafeString($get(ctrlPrefix + "ResumeName").value) + ":"
			+ $get(ctrlPrefix + "OutputList").value.split("|")[0] + ":"
			+ $get(ctrlPrefix + "TemplateList").value.split("|")[0] + ":"
			+ $get(ctrlPrefix + "HeaderFontList").value + ":"
			+ $get(ctrlPrefix + "HeaderSizeList").value + ":"
			+ ($get(ctrlPrefix + "HeaderBoldCheckBox").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "HeaderItalicCheckBox").checked ? "1" : "0") + ":"
			+ $get(ctrlPrefix + "SectionFontList").value + ":"
			+ $get(ctrlPrefix + "SectionSizeList").value + ":"
			+ ($get(ctrlPrefix + "SectionBoldCheckBox").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "SectionItalicCheckBox").checked ? "1" : "0") + ":"
			+ $get(ctrlPrefix + "BodyFontList").value + ":"
			+ $get(ctrlPrefix + "BodySizeList").value + ":";

		if (typeof (form.ctl01$PopupWrapper$IncludeInSearchesList) != "undefined")
			data += (form.ctl01$PopupWrapper$IncludeInSearchesList[0].checked ? "1" : "0") + ":";
		else
			data += "0:";

		if (typeof (form.ctl01$PopupWrapper$IncludeInSEOList) != "undefined")
			data += (form.ctl01$PopupWrapper$IncludeInSEOList[0].checked ? "1" : "0") + ":";
		else
			data += "0:";

		if (typeof (form.ctl01$PopupWrapper$ForSearchesCheckBox) != "undefined")
			data += (form.ctl01$PopupWrapper$ForSearchesCheckBox.checked ? "1" : "0") + ":";
		else
			data += "1:";

		if (typeof (form.ctl01$PopupWrapper$ForSEOCheckBox) != "undefined")
			data += (form.ctl01$PopupWrapper$ForSEOCheckBox.checked ? "1" : "0") + ":";
		else
			data += "1:";

		if (typeof (form.ctl01$PopupWrapper$ForLinksCheckBox) != "undefined")
			data += (form.ctl01$PopupWrapper$ForLinksCheckBox.checked ? "1" : "0") + ":";
		else
			data += "1:";

		data += GetContactInfoElement();

		//the resumeOutputType variable tells the Print Preview
		//function whether to open the PrintHTML page or to
		//call a postback to print other types.
		var outputList = $get(ctrlPrefix + "OutputList");
		if (typeof (resumeOutputType) != "undefined")
		{
			if (outputList.options[outputList.selectedIndex].text == "HTML")
				resumeOutputType = "HTML";
			else
				resumeOutputType = "";
		}
		
		DoAjaxPostBack(configureResumeUpdatePanel, "SaveResume", data);
		CancelPopup();
	}
}

function OutputList_Change()
{
	var tempType = $get(ctrlPrefix + "OutputList").value.split("|")[1];
	FillTemplateList(tempType);
	ToggleFormatElements(tempType);
}

function FillTemplateList(templateType)
{
	var templateList = $get(ctrlPrefix + "TemplateList");
	ClearList(templateList);
	
	for (var i = 0; i < resultData.length; i++)
	{
		if (resultData[i].TemplateType.Id == templateType)
		{
			AppendList(templateList, resultData[i].Id, resultData[i].Descriptor);
		}
	}
}

function TemplateList_Change()
{
	var templateId = parseInt($get(ctrlPrefix + "TemplateList").value);
	var template = null;
	
	for (var i = 0; i < resultData.length; i++)
	{
		if (resultData[i].Id == templateId)
		{
			template = resultData[i];
			break;
		}
	}

	SelectListItem($get(ctrlPrefix + "HeaderFontList"), template.HeaderFontType.Id);
	SelectListItem($get(ctrlPrefix + "HeaderSizeList"), template.HeaderFontSize.Id);
	$get(ctrlPrefix + "HeaderBoldCheckBox").checked = template.HeaderIsBold;
	$get(ctrlPrefix + "HeaderItalicCheckBox").checked = template.HeaderIsItalic;
	SelectListItem($get(ctrlPrefix + "SectionFontList"), template.SectionFontType.Id);
	SelectListItem($get(ctrlPrefix + "SectionSizeList"), template.SectionFontSize.Id);
	$get(ctrlPrefix + "SectionBoldCheckBox").checked = template.SectionIsBold;
	$get(ctrlPrefix + "SectionItalicCheckBox").checked = template.SectionIsItalic;
	SelectListItem($get(ctrlPrefix + "BodyFontList"), template.BodyFontType.Id);
	SelectListItem($get(ctrlPrefix + "BodySizeList"), template.BodyFontSize.Id);
}

function SelectListItem(list, id)
{
	for (var i = 0; i < list.options.length; i++)
	{
		if (list.options[i].value == id)
		{
			list.options[i].selected = true;
			break;
		}
	}
}

function ToggleFormatElements(templateType)
{
	switch (templateType)
	{
		case "1":
			$get(ctrlPrefix + "HeaderFontList").disabled = false;
			$get(ctrlPrefix + "HeaderSizeList").disabled = false;
			$get(ctrlPrefix + "HeaderBoldCheckBox").disabled = false;
			$get(ctrlPrefix + "HeaderItalicCheckBox").disabled = false;
			$get(ctrlPrefix + "SectionFontList").disabled = false;
			$get(ctrlPrefix + "SectionSizeList").disabled = false;
			$get(ctrlPrefix + "SectionBoldCheckBox").disabled = false;
			$get(ctrlPrefix + "SectionItalicCheckBox").disabled = false;
			$get(ctrlPrefix + "BodyFontList").disabled = false;
			$get(ctrlPrefix + "BodySizeList").disabled = false;
			break;
		default:
			$get(ctrlPrefix + "HeaderFontList").disabled = true;
			$get(ctrlPrefix + "HeaderSizeList").disabled = true;
			$get(ctrlPrefix + "HeaderBoldCheckBox").disabled = true;
			$get(ctrlPrefix + "HeaderItalicCheckBox").disabled = true;
			$get(ctrlPrefix + "SectionFontList").disabled = true;
			$get(ctrlPrefix + "SectionSizeList").disabled = true;
			$get(ctrlPrefix + "SectionBoldCheckBox").disabled = true;
			$get(ctrlPrefix + "SectionItalicCheckBox").disabled = true;
			$get(ctrlPrefix + "BodyFontList").disabled = true;
			$get(ctrlPrefix + "BodySizeList").disabled = true;
			break;
	}
}

function GetContactInfoElement()
{
	var selectedVal = -1;
	var contactInfoList = form.elements["ctl01$PopupWrapper$ContactInfoList"];

	if (contactInfoList != null)
	{
		if (contactInfoList.length == undefined || contactInfoList.length == 0)
			selectedVal = 0;
		else
		{
			for (var i = 0; i < contactInfoList.length; i++)
			{
				if (contactInfoList[i].checked)
				{
					selectedVal = parseInt(contactInfoList[i].value);
					break;
				}
			}
		}
	}

	return selectedVal;
}

/****************************************
SAVE CONTACT INFO
****************************************/
function SaveContactInfo()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if ($get(ctrlPrefix + "SectionTitle") != null
		&&form.ctl01$PopupWrapper$DisplayTitleList[0].checked 
		&& !validText($get(ctrlPrefix + "SectionTitle").value))
	{
		AddValidationSummaryItem(summary, "A valid Section Title is required if Display Title is \"Yes\".");
		if (firstEl == null) firstEl = form.ctl01$PopupWrapper$DisplayTitleList[0];
	}

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "DisplayName").value))
	{
		AddValidationSummaryItem(summary, "A valid Display Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "DisplayName");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var sectionTitle = "";
		var displayTitle = 0;
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "SectionTitle") != null)
		{
			sectionTitle = SafeString($get(ctrlPrefix + "SectionTitle").value);
			displayTitle = form.ctl01$PopupWrapper$DisplayTitleList[0].checked ? "1" : "0";
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}
		
		var data = window.CurrentItemId + ":"
			+ window.CurrentResumeElementId + ":"
			+ sectionTitle + ":"
			+ displayTitle + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "DisplayName").value) + ":"
			+ $get(ctrlPrefix + "AddressList").value + ":"
			+ GetSelectedListItems(form, "PhoneList") + ":"
			+ GetSelectedListItems(form, "EmailList") + ":"
			+ $get(ctrlPrefix + "ContactMethodList").value + ":"
			+ $get(ctrlPrefix + "WhenAvailableList").value + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveContactInfo", data);
		CancelPopup();
	}
}

function GetSelectedListItems(form, listName)
{
	var data = "";
	var concat = "";
	var listBox = $get(ctrlPrefix + listName);

	if (listBox != null)
	{
		for (var i = 0; i < listBox.options.length; i++)
		{
			if (listBox.options[i].selected)
			{
				data += concat + listBox.options[i].value;
				concat = "|";
			}
		}
	}

	return data;
}

function ResetList(listName)
{
	var listBox = $get(ctrlPrefix + listName);

	if (listBox != null)
	{
		listBox.selectedIndex = -1;
	}
}

/****************************************
ADDRESS POPUP
****************************************/
function ShowAddressPopup(addressId)
{
	InitializeResBuilderProxy();
	window.AddressId = addressId;
	responseDivName = "AddressEditResponseDiv";
	//contactInfoIsActive = true;
	resBuilderProxy.GetControlHtml("AddressEdit", true, addressId, 
		currentPersonId, 0, RenderPopup, HandlePopupError, 500);
}

function SaveAddress()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;
	var isUS = $get(ctrlPrefix + "CountryList").options[$get(ctrlPrefix + "CountryList").selectedIndex].text == "United States";

	if ($get(ctrlPrefix + "AddressTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Address Type is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "AddressTypeList");
	}

	if (!validText($get(ctrlPrefix + "Address1").value))
	{
		AddValidationSummaryItem(summary, "A valid Address 1 line is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Address1");
	}

	if ($get(ctrlPrefix + "Address2").value.length > 0 
		&& !validText($get(ctrlPrefix + "Address2").value))
	{
		AddValidationSummaryItem(summary, "Address 2 must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Address2");
	}

	if (!validText($get(ctrlPrefix + "City").value))
	{
		AddValidationSummaryItem(summary, "A valid City is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "City");
	}

	if (isUS && $get(ctrlPrefix + "StateList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "State is required if Country is U.S.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StateList");
	}

	if (!isUS && $get(ctrlPrefix + "Region").value.length > 0
		&& !validText($get(ctrlPrefix + "Region").value))
	{
		AddValidationSummaryItem(summary, "Region may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Region");
	}

	if (isUS && !validZipCode($get(ctrlPrefix + "PostalCode").value))
	{
		AddValidationSummaryItem(summary, "A valid Postal Code is required if Country is U.S.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "PostalCode");
	}

	if (!isUS && $get(ctrlPrefix + "PostalCode").value.length > 0 
		&& !validText($get(ctrlPrefix + "PostalCode").value))
	{
		AddValidationSummaryItem(summary, "Postal Code may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "PostalCode");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var data = window.AddressId + ":"
			+ currentPersonId + ":"
			+ $get(ctrlPrefix + "AddressTypeList").value + ":"
			+ ($get(ctrlPrefix + "AddressIsPrimaryList_0").checked ? "1" : "0") + ":"
			+ SafeString($get(ctrlPrefix + "Address1").value) + ":"
			+ SafeString($get(ctrlPrefix + "Address2").value) + ":"
			+ SafeString($get(ctrlPrefix + "City").value) + ":"
			+ $get(ctrlPrefix + "StateList").value + ":"
			+ SafeString($get(ctrlPrefix + "Region").value) + ":"
			+ SafeString($get(ctrlPrefix + "PostalCode").value) + ":"
			+ $get(ctrlPrefix + "CountryList").value + ":"
			+ (isUS ? "isUS" : "isNotUS")

		DoAjaxPostBack(addressUpdatePanel, "SaveAddress", data);
		RecycleContactInfo();
	}
}

/****************************************
PHONE POPUP
****************************************/
function ShowPhonePopup(phoneId)
{
	InitializeResBuilderProxy();
	window.PhoneId = phoneId;
	responseDivName = "PhoneEditResponseDiv";
	//contactInfoIsActive = true;
	resBuilderProxy.GetControlHtml("PhoneEdit", true, phoneId, currentPersonId, 0, RenderPopup, HandlePopupError, 500);
}

function SavePhoneNumber()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix  + "PhoneNumber").value))
	{
		AddValidationSummaryItem(summary, "A valid Phone Number is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix  + "PhoneNumber");
	}

	if ($get(ctrlPrefix  + "PhoneTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Phone Type is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix  + "PhoneTypeList");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		data = window.PhoneId + ":"
			+ SafeString($get(ctrlPrefix  + "PhoneNumber").value) + ":"
			+ $get(ctrlPrefix + "PhoneTypeList").value + ":"
			+ ($get(ctrlPrefix + "PhoneIsPrimaryList_0").checked ? "1" : "0") + ":"

		DoAjaxPostBack(phoneUpdatePanel, "SavePhone", data);
		RecycleContactInfo();
	}
}

/****************************************
EMAIL POPUP
****************************************/
function ShowEmailPopup(emailId)
{
	InitializeResBuilderProxy();
	window.EmailId = emailId;
	responseDivName = "EmailEditResponseDiv";
	//contactInfoIsActive = true;
	resBuilderProxy.GetControlHtml("EmailEdit", true, emailId, currentPersonId, 0, RenderPopup, HandlePopupError, 500);
}

function BeginSaveEmail()
{
	if (!validEmail($get(ctrlPrefix + "Email").value))
		SaveEmail("true");
	else if (window.EmailId == 0 || $get(ctrlPrefix + "Email").value.toLowerCase() != $get(ctrlPrefix + "DefaultEmail").value.toLowerCase())
		resBuilderProxy.EmailIsUnique($get(ctrlPrefix + "Email").value, SaveEmail, HandlePopupError);
	else
		SaveEmail("true");
}

function SaveEmail(result)
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (result.toLowerCase() == "false")
	{
		AddValidationSummaryItem(summary, "The email you entered is already in use. Please enter a different email.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Email");
	}

	if (!validEmail($get(ctrlPrefix + "Email").value))
	{
		AddValidationSummaryItem(summary, "A valid Email address is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Email");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		data = window.EmailId + ":"
			+ SafeString($get(ctrlPrefix + "Email").value) + ":"
			+ ($get(ctrlPrefix + "EmailIsPrimaryList_0").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "EmailIsIMList_0").checked ? "1" : "0") + ":"

		DoAjaxPostBack(emailUpdatePanel, "SaveEmail", data);
		RecycleContactInfo();
	}
} 

/****************************************
SAVE TEXT ELEMENT
****************************************/
window.SaveTextElement = function(textElementType)
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (window.CurrentResumeElementId > 0
		&& $get(ctrlPrefix + "DisplayTitleList_0").checked
		&& !validText($get(ctrlPrefix + "SectionTitle").value))
	{
		AddValidationSummaryItem(summary, "A valid Section Title is required if Display Title is \"Yes\".");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "DisplayTitleList_0");
	}

	if (!validText($get(ctrlPrefix + "ElementName").value))
	{
		AddValidationSummaryItem(summary, "A valid " + textElementType + " Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ElementName");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "TextEditor_ID");
	var text = editor.getHTML();

	if (text.length == 0)
	{
		AddValidationSummaryItem(summary, textElementType + " text is required.");
		if (firstEl == null) firstEl = editor;
	}

	if (firstEl != null)
	{
		ShowValidationSummary(responseDiv, summary, firstEl == editor ? null : firstEl);
	}
	else
	{
		var sectionTitle = "";
		var displayTitle = 0;
		var ordinum = 0;
		var pageBreak = 0;

		if (window.CurrentResumeElementId > 0)
		{
			sectionTitle = SafeString($get(ctrlPrefix + "SectionTitle").value);
			displayTitle = $get(ctrlPrefix + "DisplayTitleList_0").checked ? "1" : "0";
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ sectionTitle + ":"
			+ displayTitle + ":"
			+ SafeString($get(ctrlPrefix + "ElementName").value) + ":"
			+ SafeString(text) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(textElementUpdatePanel, "SaveTextElement", data);
		CancelPopup();
	}
}

/****************************************
GROUP SECTION POPUP
****************************************/
function ShowGroupSectionPopup(entityTypeId, resumeElementId)
{
	InitializeResBuilderProxy();
	window.CurrentResumeElementId = resumeElementId;
	responseDivName = "GroupSectionEditResponseDiv";

	var args = new ArgsHash();
	args.Add("isPopup", "true");
	args.Add("entityTypeId", entityTypeId);
	args.Add("resumeElementId", resumeElementId);
	args.Add("currentPersonId", currentPersonId);
	
	resBuilderProxy.GetSectionGroupEdit(args.Hash, RenderPopup, HandlePopupError, 500);
}

function SaveGroupSection()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if ($get(ctrlPrefix + "ShowTitleList_0").checked 
		&& !validText($get(ctrlPrefix + "SectionTitle").value))
	{
		AddValidationSummaryItem(summary, "A valid Section Title is required if Display Title is \"Yes\".");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "SectionTitle");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var data = window.CurrentResumeElementId + ":"
			+ SafeString($get(ctrlPrefix + "SectionTitle").value) + ":"
			+ ($get(ctrlPrefix + "ShowTitleList_0").checked ? "1" : "0") + ":";

		if ($get(ctrlPrefix + "ShowDatesList") != null)
			data += ($get(ctrlPrefix + "ShowDatesList_0").checked ? "1" : "0") + ":";
		else
			data += "0:";
			
		if ($get(ctrlPrefix + "ShowCommentsList") != null)
			data += ($get(ctrlPrefix + "ShowCommentsList_0").checked ? "1" : "0") + ":";
		else
			data += "0:";

		if ($get(ctrlPrefix + "OrderByList") != null || $get(ctrlPrefix + "MultiplePositionsList_0") != null)
		{
			if ($get(ctrlPrefix + "OrderByList") != null)
			{
				data += $get(ctrlPrefix + "OrderByList").value + " "
				+ ($get(ctrlPrefix + "OrderDirList_0").checked ? "asc" : "desc") + ":";
			}
			else if ($get(ctrlPrefix + "MultiplePositionsList_0") != null)
			{
				var val = null;
				
				for (var i = 0; i <= 2; i++)
				{
					var li = $get(ctrlPrefix + "MultiplePositionsList_" + i);
					if (li.checked)
					{
						val = li.value;
						break;
					}
				}

				if (val == null) val = 1;
				data += val + ":";
			}
		}
		else
			data += ":";

		data += $get(ctrlPrefix + "OrdinumList").value + ":"
			+ GetPageBreakSelection();

		DoAjaxPostBack(rightUpdatePanel, "SaveResumeElement", data);
		CancelPopup();
	}
}

/****************************************
SAVE POSITION
****************************************/
window.SavePosition = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;
	var firstTab = "info";

	if (!validText($get(ctrlPrefix + "PositionName").value))
	{
		AddValidationSummaryItem(summary, "A valid Position Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "PositionName");
	}

	if ($get(ctrlPrefix + "EmployerList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Employer is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EmployerList");
	}

	if ($get(ctrlPrefix + "Organization").value.length > 0
		&& !validText($get(ctrlPrefix + "Organization").value))
	{
		AddValidationSummaryItem(summary, "Organization may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Organization");
	}

	if ($get(ctrlPrefix + "CountryList").value == "233" && $get(ctrlPrefix + "StateList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "State is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StateList");
	}

	if ($get(ctrlPrefix + "CountryList").value != "233"
		&& $get(ctrlPrefix + "Region").value.length > 0
		&& !validText($get(ctrlPrefix + "Region").value))
	{
		AddValidationSummaryItem(summary, "Region may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Region");
	}

	if (!validText($get(ctrlPrefix + "City").value))
	{
		AddValidationSummaryItem(summary, "A valid City is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "City");
	}

	if (!validText($get(ctrlPrefix + "StartDate").value))
	{
		AddValidationSummaryItem(summary, "A valid Start Date is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StartDate");
	}

	if (!$get(ctrlPrefix + "IsCurrent").checked)
	{
		if ($get(ctrlPrefix + "EndDate").value.length == 0)
		{
			AddValidationSummaryItem(summary, "Either End Date or Is Current is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "EndDate");
		}
		else if (!validText($get(ctrlPrefix + "EndDate").value))
		{
			AddValidationSummaryItem(summary, "End Date may only contain valid text.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "EndDate");
		}
	}

	var editor = $get("CE_" + ctrlPrefix + "PositionEditor_ID");
	var description = "";

	//The CuteEditorInitialize method is called when a hidden
	//gif at the bottom of the editor is loaded. IE loads all
	//images when the page loads. The other browsers don't
	//load the images until they're displyed. So, the initialize
	//routine isn't called until the PosDesc tab is clicked.
	//That means the getHTML method isn't available so we can't
	//test the description. What follows is the logic for the 
	//workaround:

	//If the editor is uninitialized (that is, it's not IE
	//and the PosDesc pane hasn't been displayed) and this is
	//not a new Position, then get the description we squirreled
	//away in a hidden field.
	if (editor.getHTML == undefined)
	{
		if (window.CurrentItemId > 0)
			description = $get(ctrlPrefix + "PositionDescription").value;
	}
	else
		description = editor.getHTML();

	if (description.length == 0)
	{
		AddValidationSummaryItem(summary, "Position Description is required.");
		if (firstEl == null)
		{
			firstEl = editor;
			firstTab = "desc";
		}
	}

	if (firstEl != null)
	{
		ToggleTabs(firstTab);
		ShowValidationSummary(responseDiv, summary, firstEl == editor ? null : firstEl);
	}
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "PositionName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Title").value) + ":"
			+ $get(ctrlPrefix + "EmployerList").value + ":"
			+ SafeString($get(ctrlPrefix + "Organization").value) + ":"
			+ $get(ctrlPrefix + "CountryList").value + ":"
			+ $get(ctrlPrefix + "StateList").value + ":"
			+ SafeString($get(ctrlPrefix + "Region").value) + ":"
			+ SafeString($get(ctrlPrefix + "City").value) + ":"
			+ SafeString($get(ctrlPrefix + "StartDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "EndDate").value) + ":"
			+ ($get(ctrlPrefix + "IsCurrent").checked ? "1" : "0") + ":"
			+ ordinum + ":"
			+ pageBreak + ":"
			+ SafeString(description)

		DoAjaxPostBack(rightUpdatePanel, "SavePosition", data);
		CancelPopup();
	}
}

function PosCountryList_Change(countryList)
{
	var stateDiv = $get(ctrlPrefix + "StateDiv");
	var regionDiv = $get(ctrlPrefix + "RegionDiv");

	if (countryList.value == "233")
	{
		stateDiv.style.display = "block";
		regionDiv.style.display = "none";
	}
	else
	{
		stateDiv.style.display = "none";
		regionDiv.style.display = "block";
	}

	$get(ctrlPrefix + "StateList").selectedIndex = 0;
	$get(ctrlPrefix + "Region").value = "";
}

/****************************************
MANAGE EMPLOYERS POPUP
****************************************/
function ShowEmployersPopup(fromPosition)
{
	if (fromPosition)
		SavePositionInfo();
	
	InitializeResBuilderProxy();
	window.EmployerId = 0;
	responseDivName = "ManageEmployersResponseDiv";
	resBuilderProxy.GetControlHtml("ManageEmployers", true, window.CurrentResumeElementId, 
		currentPersonId, 0, RenderPopup, HandlePopupError, 550);
}

var posInfo = null;
var fromEmployers = false;

function SavePositionInfo()
{
	var editor = $get("CE_" + ctrlPrefix + "PositionEditor_ID");
	var description = "";

	//if the editor hasn't been initialized, get the PosDesc
	//from the hidden field; otherwise, get it from the editor.
	if (editor.getHTML == undefined)
		description = $get(ctrlPrefix + "PositionDescription").value;
	else
		description = editor.getHTML();

	posInfo = {
		"Name": $get(ctrlPrefix + "PositionName").value,
		"Ordinum": $get(ctrlPrefix + "OrdinumList") != null ? $get(ctrlPrefix + "OrdinumList").value : "0",
		"Title": $get(ctrlPrefix + "Title").value,
		"EmployerId": $get(ctrlPrefix + "EmployerList").value,
		"Organization": $get(ctrlPrefix + "Organization").value,
		"CountryId": $get(ctrlPrefix + "CountryList").value,
		"StateId": $get(ctrlPrefix + "StateList").value,
		"Region": $get(ctrlPrefix + "Region").value,
		"City": $get(ctrlPrefix + "City").value,
		"StartDate": $get(ctrlPrefix + "StartDate").value,
		"EndDate": $get(ctrlPrefix + "EndDate").value,
		"IsCurrent": $get(ctrlPrefix + "IsCurrent").checked ? true : false,
		"Description": description
	};
}

//function CuteEditor_OnInitialized(editor)
//{
//	//fromEmployers is set in the RecyclePositionPopup
//	//method when the Manager Employers dialog is closed
//	//and the Position Edit dialog is reopened.
//	if (typeof (fromEmployers) != "underfined" && fromEmployers == true)
//	{
//		ReloadPositionInfo();
//		fromEmployers = false;
//	}
//}

function ReloadPositionInfo()
{
	if (posInfo.Name.length > 0)
		$get(ctrlPrefix + "PositionName").value = posInfo.Name;
	
	if ($get(ctrlPrefix + "OrdinumList") != null)
		$get(ctrlPrefix + "OrdinumList").value = posInfo.Ordinum;
	
	if (posInfo.Title.length > 0)
		$get(ctrlPrefix + "Title").value = posInfo.Title;
		
	if (posInfo.EmployerId > 0)
		$get(ctrlPrefix + "EmployerList").value = posInfo.EmployerId;
		
	if (posInfo.Organization.length > 0)
		$get(ctrlPrefix + "Organization").value = posInfo.Organization;
		
	if (posInfo.CountryId > 0)
		$get(ctrlPrefix + "CountryList").value = posInfo.CountryId;
		
	if (posInfo.StateId > 0)
		$get(ctrlPrefix + "StateList").value = posInfo.StateId;
		
	if (posInfo.Region.length > 0)
		$get(ctrlPrefix + "Region").value = posInfo.Region;
		
	if (posInfo.City.length > 0)
		$get(ctrlPrefix + "City").value = posInfo.City;
		
	if (posInfo.StartDate.length > 0)
		$get(ctrlPrefix + "StartDate").value = posInfo.StartDate;
		
	if (posInfo.EndDate.length > 0)
		$get(ctrlPrefix + "EndDate").value = posInfo.EndDate;
		
	$get(ctrlPrefix + "IsCurrent").checked = posInfo.IsCurrent;

	if (posInfo.Description.length > 0)
	{
		//if the Cute Editor hasn't been initialized then write
		//directly to its TextArea that contains its contents.
		var editor = $get("CE_" + ctrlPrefix + "PositionEditor_ID");
		if (editor != null && editor.setHTML)
			editor.setHTML(posInfo.Description);
		else
			$get(ctrlPrefix.replace(/_/g, "$") + "PositionEditor").value = posInfo.Description;
	}

	posInfo = null;
}

function EmployersEdit_Click()
{
	var list = $get(ctrlPrefix + "EmployerList");
	if (list.selectedIndex == -1)
		alert("Please select an item from the list");
	else
	{
		$get("TextBoxLabel").innerHTML = "Make changes and click Save:";
		$get("SaveButton").value = "Save";
		$get("EditBox").value = list.options[list.selectedIndex].text;
		window.EmployerId = list.value;
	}
}

function EmployersDelete_Click()
{
	var list = $get(ctrlPrefix + "EmployerList");
	if (list.selectedIndex == -1)
		alert("Please select an item from the list");
	else
	{
		var msg = "This action will delete the selected Employer if it is not "
			+ "associated with a position. If it is associated, you must "
			+ "disassociate it from all positions and then attempt the "
			+ "delete again. Click OK to continue or click Cancel to abort "
			+ "the delete action.";

		if (confirm(msg))
		{
			var args = new ArgsHash();
			args.Add("currentPersonId", currentPersonId);
			args.Add("EmployerId", list.value);

			resBuilderProxy.UpdateEmployers("DeleteEmployer", args.Hash, HandleEmployerUpdate, HandlePopupError, "AddEmployer");
		}
	}
}

function EmployersAdd_Click()
{
	var editBox = document.getElementById("EditBox");
	if (editBox.value.length == 0)
		alert("Please enter a value in the text box");
	else
	{
		var args = new ArgsHash();
		args.Add("currentPersonId", currentPersonId);
		args.Add("EmployerId", window.EmployerId);
		args.Add("EmployerName", SafeString(editBox.value));

		resBuilderProxy.UpdateEmployers("SaveEmployer", args.Hash, HandleEmployerUpdate, HandlePopupError, "AddEmployer");
		window.EmployerId = 0;
	}
}

function EmployersCancel_Click()
{
	$get("EditBox").value = "";
	$get("TextBoxLabel").innerHTML = "Enter a new employer and click Add:";
	$get("SaveButton").value = "Add";
	window.EmployerId = 0;
}

function HandleEmployerUpdate(result, userContext, methodName)
{
	if (result.length == 0)
		ShowEmployersPopup(false);
	else
		$get(responseDivName).innerHTML = result;
}

function RecyclePositionPopup()
{
	fromEmployers = true;
	ShowEditPopup('Position', window.CurrentResumeElementId, window.CurrentItemId, 600);
}

/****************************************
EMPLOYER DETAILS
****************************************/
function ShowEmployerDetails(resumeElementId, employerId, detailId)
{
	InitializeResBuilderProxy();
	window.CurrentResumeElementId = resumeElementId;
	window.EmployerId = employerId;
	window.EmployerDetailId = detailId;
	responseDivName = "EmployerDetailsResponseDiv";
	resBuilderProxy.GetControlHtml("EmployerDetails", true, resumeElementId,
		currentPersonId, employerId + "|" + detailId, RenderPopup, HandlePopupError, 550);
}

function SaveEmployerDetails()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if ($get(ctrlPrefix + "Location").value.length > 0
		&& !validText($get(ctrlPrefix + "Location").value))
	{
		AddValidationSummaryItem(summary, "Location must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Location");
	}

	if ($get(ctrlPrefix + "StartDate").value.length > 0
		&& !validText($get(ctrlPrefix + "StartDate").value))
	{
		AddValidationSummaryItem(summary, "Start Date must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StartDate");
	}

	if ($get(ctrlPrefix + "EndDate").value.length > 0
		&& !validText($get(ctrlPrefix + "EndDate").value))
	{
		AddValidationSummaryItem(summary, "End Date must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EndDate");
	}

	if ($get(ctrlPrefix + "IsCurrent").checked)
		$get(ctrlPrefix + "EndDate").value = "";

	if ($get(ctrlPrefix + "EndDate").value.length > 0)
		$get(ctrlPrefix + "IsCurrent").checked = false;

	var editor = $get("CE_" + ctrlPrefix + "EmployerEditor_ID");
	var description = editor.getHTML();
	
	if (Trim($get(ctrlPrefix + "Location").value).length == 0
		&& Trim($get(ctrlPrefix + "StartDate").value).length == 0
		&& Trim($get(ctrlPrefix + "EndDate").value).length == 0
		&& Trim(description).length == 0)
	{
		AddValidationSummaryItem(summary, "You cannot save an empty form. To delete the details, click on the Delete button.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Location");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var data = window.CurrentResumeElementId + ":"
			+ window.EmployerId + ":"
			+ window.EmployerDetailId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Location").value) + ":"
			+ SafeString($get(ctrlPrefix + "StartDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "EndDate").value) + ":"
			+ ($get(ctrlPrefix + "IsCurrent").checked ? "1" : "0") + ":"
			+ SafeString(description) + ":"

		if ($get(ctrlPrefix + "OnSaveList_1") == null)
			data += "2";
		else
			data += $get(ctrlPrefix + "OnSaveList_0").checked ? "1" : "2";

		DoAjaxPostBack(rightUpdatePanel, "SaveEmployerDetail", data);
		CancelPopup();
	}
}

function DeleteEmployerDetails(detailId)
{
	var msg = "This action will permanently delete this Employer Detail "
		+ "record and will disassociate it from any resume with which "
		+ "it is currently associated. There is no undo function "
		+ "for this action. Click OK to continue or click Cancel to "
		+ "abort the delete action.";

	if (confirm(msg))
	{
		DoAjaxPostBack(rightUpdatePanel, "DeleteEmployerDetail", detailId);
		CancelPopup();
	}
}

/****************************************
SAVE FUNCTIONAL
****************************************/
window.SaveFunctional = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "FunctionTitle").value))
	{
		AddValidationSummaryItem(summary, "A valid Function Title is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "FunctionTitle");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "FunctionalEditor_ID");
	var description = editor.getHTML();

	if (description.length == 0)
	{
		AddValidationSummaryItem(summary, "Functional Description is required.");
		if (firstEl == null) firstEl = editor;
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl == editor ? null : firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ ordinum + ":"
			+ pageBreak + ":"
			+ SafeString($get(ctrlPrefix + "FunctionTitle").value) + ":"
			+ SafeString(description)

		DoAjaxPostBack(rightUpdatePanel, "SaveFunctional", data);
		CancelPopup();
	}
}
/****************************************
SAVE SKILL
****************************************/
window.SaveSkill = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "SkillName").value))
	{
		AddValidationSummaryItem(summary, "A valid Skill Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "SkillName");
	}

	if ($get(ctrlPrefix + "LevelList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Skill Level is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "LevelList");
	}

	if ($get(ctrlPrefix + "FirstUsedList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Year First Used is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "FirstUsedList");
	}

	if ($get(ctrlPrefix + "LastUsedList").selectedIndex == 0 
		&& !$get(ctrlPrefix + "IsCurrentCheckBox").checked)
	{
		AddValidationSummaryItem(summary, "Either select Year Last Used or check Is Current");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "LastUsedList");
	}

	if ($get(ctrlPrefix + "IsCurrentCheckBox").checked)
		$get(ctrlPrefix + "LastUsedList").selectedIndex = 0;

	if ($get(ctrlPrefix + "LastUsedList").selectedIndex > 0)
		$get(ctrlPrefix + "IsCurrentCheckBox").checked = false;

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "SkillName").value) + ":"
			+ $get(ctrlPrefix + "LevelList").value + ":"
			+ $get(ctrlPrefix + "FirstUsedList").value + ":"
			+ $get(ctrlPrefix + "LastUsedList").value + ":"
			+ ($get(ctrlPrefix + "IsCurrentCheckBox").checked ? "1" : "0");

		DoAjaxPostBack(rightUpdatePanel, "SaveSkill", data);
		CancelPopup();
	}
}

/****************************************
SAVE EDUCATION
****************************************/
window.SaveEducation = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "SchoolName").value))
	{
		AddValidationSummaryItem(summary, "A valid School Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "SchoolName");
	}

	if (!validText($get(ctrlPrefix + "Location").value))
	{
		AddValidationSummaryItem(summary, "A valid Location is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Location");
	}

	if ($get(ctrlPrefix + "DepartmentName").value.length > 0
		&& !validText($get(ctrlPrefix + "DepartmentName").value))
	{
		AddValidationSummaryItem(summary, "Department Name must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "DepartmentName");
	}

	if ($get(ctrlPrefix + "Degree").value.length > 0
		&& !validText($get(ctrlPrefix + "Degree").value))
	{
		AddValidationSummaryItem(summary, "Degree must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Degree");
	}

	if ($get(ctrlPrefix + "Major").value.length > 0
		&& !validText($get(ctrlPrefix + "Major").value))
	{
		AddValidationSummaryItem(summary, "Major must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Major");
	}

	if ($get(ctrlPrefix + "Minor").value.length > 0
		&& !validText($get(ctrlPrefix + "Minor").value))
	{
		AddValidationSummaryItem(summary, "Minor must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Minor");
	}

	if ($get(ctrlPrefix + "StartDate").value.length > 0
		&& !validText($get(ctrlPrefix + "StartDate").value))
	{
		AddValidationSummaryItem(summary, "Start Date must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StartDate");
	}

	if ($get(ctrlPrefix + "EndDate").value.length > 0
		&& !validText($get(ctrlPrefix + "EndDate").value))
	{
		AddValidationSummaryItem(summary, "End Date must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EndDate");
	}

	if ($get(ctrlPrefix + "IsCurrentCheckBox").checked)
		$get(ctrlPrefix + "EndDate").value = "";

	if ($get(ctrlPrefix + "EndDate").value.length > 0)
		$get(ctrlPrefix + "IsCurrentCheckBox").checked = false;

	if ($get(ctrlPrefix + "Grade").value.length > 0
		&& !validText($get(ctrlPrefix + "Grade").value))
	{
		AddValidationSummaryItem(summary, "Grade must contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Grade");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "Comments_ID");
	var comments = editor.getHTML();

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "SchoolName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Location").value) + ":"
			+ SafeString($get(ctrlPrefix + "DepartmentName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Degree").value) + ":"
			+ SafeString($get(ctrlPrefix + "Major").value) + ":"
			+ SafeString($get(ctrlPrefix + "Minor").value) + ":"
			+ SafeString($get(ctrlPrefix + "StartDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "EndDate").value) + ":"
			+ ($get(ctrlPrefix + "IsCurrentCheckBox").checked ? "1" : "0") + ":"
			+ SafeString($get(ctrlPrefix + "Grade").value) + ":"
			+ SafeString(comments) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveEducation", data);
		CancelPopup();
	}
}

/****************************************
SAVE TRAINING
****************************************/
window.SaveTraining = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "CourseName").value))
	{
		AddValidationSummaryItem(summary, "A valid Course Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "CourseName");
	}

	if (!validText($get(ctrlPrefix + "ProviderName").value))
	{
		AddValidationSummaryItem(summary, "A valid Provider Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ProviderName");
	}

	if (!validText($get(ctrlPrefix + "Location").value))
	{
		AddValidationSummaryItem(summary, "A valid Location is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Location");
	}

	if (!validText($get(ctrlPrefix + "DateCompleted").value))
	{
		AddValidationSummaryItem(summary, "A valid Date Completed is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "DateCompleted");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "Comments_ID");
	var comments = editor.getHTML();

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "CourseName").value) + ":"
			+ SafeString($get(ctrlPrefix + "ProviderName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Location").value) + ":"
			+ SafeString($get(ctrlPrefix + "DateCompleted").value) + ":"
			+ SafeString(comments) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveTraining", data);
		CancelPopup();
	}
}

/****************************************
SAVE LICENSE
****************************************/
window.SaveLicense = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "Title").value))
	{
		AddValidationSummaryItem(summary, "A valid Title is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Title");
	}

	if (!validText($get(ctrlPrefix + "IssuingAuthority").value))
	{
		AddValidationSummaryItem(summary, "A valid Issuing Authority is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "IssuingAuthority");
	}

	if ($get(ctrlPrefix + "FirstIssued").value.length > 0
		&& !validText($get(ctrlPrefix + "FirstIssued").value))
	{
		AddValidationSummaryItem(summary, "Date First Issued may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "FirstIssued");
	}

	if ($get(ctrlPrefix + "ValidFrom").value.length > 0
		&& !validText($get(ctrlPrefix + "ValidFrom").value))
	{
		AddValidationSummaryItem(summary, "Valid From Date may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ValidFrom");
	}

	if ($get(ctrlPrefix + "ValidTo").value.length > 0
		&& !validText($get(ctrlPrefix + "ValidTo").value))
	{
		AddValidationSummaryItem(summary, "Valid To Date may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ValidTo");
	}

	if ($get(ctrlPrefix + "IsCurrentCheckBox").checked)
		$get(ctrlPrefix + "ValidTo").value = "";

	if ($get(ctrlPrefix + "ValidTo").value.length > 0)
		$get(ctrlPrefix + "IsCurrentCheckBox").checked = false;

	var editor = document.getElementById("CE_" + ctrlPrefix + "Description_ID");
	var description = editor.getHTML();

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Title").value) + ":"
			+ SafeString($get(ctrlPrefix + "IssuingAuthority").value) + ":"
			+ SafeString($get(ctrlPrefix + "FirstIssued").value) + ":"
			+ SafeString($get(ctrlPrefix + "ValidFrom").value) + ":"
			+ SafeString($get(ctrlPrefix + "ValidTo").value) + ":"
			+ ($get(ctrlPrefix + "IsCurrentCheckBox").checked ? "1" : "0") + ":"
			+ SafeString(description) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveLicense", data);
		CancelPopup();
	}
}

/****************************************
SAVE MILITARY
****************************************/
window.SaveMilitary = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;
	var firstTab = "info";

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if ($get(ctrlPrefix + "CountryList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Country Served is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "CountryList");
	}

	if (!validText($get(ctrlPrefix + "Branch").value))
	{
		AddValidationSummaryItem(summary, "A valid Branch is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Branch");
	}

	if ($get(ctrlPrefix + "Unit").value.length > 0
		&& !validText($get(ctrlPrefix + "Unit").value))
	{
		AddValidationSummaryItem(summary, "Unit may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Unit");
	}

	if (!validText($get(ctrlPrefix + "RankAchieved").value))
	{
		AddValidationSummaryItem(summary, "A valid Rank Achieved is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "RankAchieved");
	}

	if (!validText($get(ctrlPrefix + "StartDate").value))
	{
		AddValidationSummaryItem(summary, "A valid Start Date is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StartDate");
	}

	if ($get(ctrlPrefix + "EndDate").value.length == 0
		&& !$get(ctrlPrefix + "IsCurrentCheckBox").checked)
	{
		AddValidationSummaryItem(summary, "Either enter an End Date or check the Is Current box.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EndDate");
	}

	if ($get(ctrlPrefix + "IsCurrentCheckBox").checked)
		$get(ctrlPrefix + "EndDate").value = "";

	if ($get(ctrlPrefix + "EndDate").value.length > 0)
		$get(ctrlPrefix + "IsCurrentCheckBox").checked = false;

	if ($get(ctrlPrefix + "EndDate").value.length > 0
		&& !validText($get(ctrlPrefix + "EndDate").value))
	{
		AddValidationSummaryItem(summary, "End Date may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EndDate");
	}

	if ($get(ctrlPrefix + "DischargeStatus").value.length > 0
		&& !validText($get(ctrlPrefix + "DischargeStatus").value))
	{
		AddValidationSummaryItem(summary, "Discharge Status may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "DischargeStatus");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "MilitaryEditor_ID");
	var description = "";

	if (editor.getHTML == undefined)
	{
		if (window.CurrentItemId > 0)
			description = $get(ctrlPrefix + "MilitaryDescription").value;
	}
	else
		description = editor.getHTML();

	if (description.length == 0)
	{
		AddValidationSummaryItem(summary, "Description of Duties is required.");
		if (firstEl == null)
		{
			firstEl = editor;
			firstTab = "desc";
		}
	}

	if (firstEl != null)
	{
		ToggleTabs(firstTab);
		ShowValidationSummary(responseDiv, summary, firstEl == editor ? null : firstEl);
	}
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "CountryList").value) + ":"
			+ SafeString($get(ctrlPrefix + "Branch").value) + ":"
			+ SafeString($get(ctrlPrefix + "Unit").value) + ":"
			+ SafeString($get(ctrlPrefix + "RankAchieved").value) + ":"
			+ SafeString($get(ctrlPrefix + "StartDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "EndDate").value) + ":"
			+ ($get(ctrlPrefix + "IsCurrentCheckBox").checked ? "1" : "0") + ":"
			+ ordinum + ":"
			+ pageBreak + ":"
			+ SafeString($get(ctrlPrefix + "DischargeStatus").value) + ":"
			+ SafeString(description)

		DoAjaxPostBack(rightUpdatePanel, "SaveMilitary", data);
		CancelPopup();
	}
}

/****************************************
SAVE PATENT
****************************************/
window.SavePatent = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "Title").value))
	{
		AddValidationSummaryItem(summary, "A valid Title is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Title");
	}

	if (!validText($get(ctrlPrefix + "Inventors").value))
	{
		AddValidationSummaryItem(summary, "A valid Inventors response is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Inventors");
	}

	if (!validText($get(ctrlPrefix + "IssuingAuthority").value))
	{
		AddValidationSummaryItem(summary, "A valid Issuing Authority is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "IssuingAuthority");
	}

	if ($get(ctrlPrefix + "Number").value.length > 0
		&& !validText($get(ctrlPrefix + "Number").value))
	{
		AddValidationSummaryItem(summary, "Patent Number may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Number");
	}

	if ($get(ctrlPrefix + "StatusTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Patent Status is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StatusTypeList");
	}

	if (!validDate($get(ctrlPrefix + "StatusDate")))
	{
		AddValidationSummaryItem(summary, "A valid Status Date is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StatusDate");
	}

	if ($get(ctrlPrefix + "Link").value.length > 0
		&& !ValidateUrlClassic($get(ctrlPrefix + "Link")))
	{
		AddValidationSummaryItem(summary, "Link must be a valid URL.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Link");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "Description_ID");
	var description = editor.getHTML();

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Title").value) + ":"
			+ SafeString($get(ctrlPrefix + "Inventors").value) + ":"
			+ SafeString($get(ctrlPrefix + "IssuingAuthority").value) + ":"
			+ SafeString($get(ctrlPrefix + "Number").value) + ":"
			+ $get(ctrlPrefix + "StatusTypeList").value + ":"
			+ SafeString($get(ctrlPrefix + "StatusDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "Link").value) + ":"
			+ ordinum + ":"
			+ pageBreak + ":"
			+ SafeString(description)

		DoAjaxPostBack(rightUpdatePanel, "SavePatent", data);
		CancelPopup();
	}
}

/****************************************
PUBLICATION
****************************************/
window.SavePublication = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "Title").value))
	{
		AddValidationSummaryItem(summary, "A valid Title is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Title");
	}

	if ($get("OtherTypeDiv").style.display == "block"
		&& $get(ctrlPrefix + "OtherTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Other Type is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "OtherTypeList");
	}

	if ($get(ctrlPrefix + "RoleTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Publication Role is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "RoleTypeList");
	}

	if (!validText($get(ctrlPrefix + "Publisher").value))
	{
		AddValidationSummaryItem(summary, "A valid Publisher/Periodical is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Publisher");
	}

	if ($get("LocationDiv").style.display == "block"
		&& !validText($get(ctrlPrefix + "PublisherLocation").value))
	{
		AddValidationSummaryItem(summary, "A valid Location is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "PublisherLocation");
	}

	if (!validText($get(ctrlPrefix + "PublicationDate").value))
	{
		AddValidationSummaryItem(summary, "A valid Publication Date is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "PublicationDate");
	}

	if ($get(ctrlPrefix + "Volume").value.length > 0
		&& !validText($get(ctrlPrefix + "Volume").value))
	{
		AddValidationSummaryItem(summary, "Volume may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Volume");
	}

	if ($get(ctrlPrefix + "Edition").value.length > 0
		&& !validText($get(ctrlPrefix + "Edition").value))
	{
		AddValidationSummaryItem(summary, "Edition may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Edition");
	}

	if ($get(ctrlPrefix + "Chapter").value.length > 0
		&& !validText($get(ctrlPrefix + "Chapter").value))
	{
		AddValidationSummaryItem(summary, "Chapter may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Chapter");
	}

	if ($get(ctrlPrefix + "PageNumber").value.length > 0
		&& !validText($get(ctrlPrefix + "PageNumber").value))
	{
		AddValidationSummaryItem(summary, "Page Number may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "PageNumber");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Title").value) + ":"
			+ $get(ctrlPrefix + "PublicationTypeList").value + ":"
			+ $get(ctrlPrefix + "OtherTypeList").value + ":"
			+ $get(ctrlPrefix + "RoleTypeList").value + ":"
			+ SafeString($get(ctrlPrefix + "Publisher").value) + ":"
			+ SafeString($get(ctrlPrefix + "PublisherLocation").value) + ":"
			+ SafeString($get(ctrlPrefix + "PublicationDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "Volume").value) + ":"
			+ SafeString($get(ctrlPrefix + "Issue").value) + ":"
			+ SafeString($get(ctrlPrefix + "Edition").value) + ":"
			+ SafeString($get(ctrlPrefix + "Chapter").value) + ":"
			+ SafeString($get(ctrlPrefix + "PageNumber").value) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SavePublication", data);
		CancelPopup();
	}
}

function PublicationType_Change(el)
{
	var type = el.options[el.selectedIndex].text;
	switch (type)
	{
		case "Article":
			$get("OtherTypeDiv").style.display = "none";
			$get("PublisherLabel").innerHTML = "Periodical";
			$get("PublisherLocationLabel").innerHTML = "Location";
			$get("LocationDiv").style.display = "none";
			$get("PublicationDateLabel").innerHTML = "Publication Date";
			$get("VolumeDiv").style.display = "block";
			$get("IssueDiv").style.display = "block";
			$get("EditionDiv").style.display = "none";
			$get("ChapterDiv").style.display = "none";
			$get("PageNumberDiv").style.display = "block";
			$get("PageNumberLabel").innerHTML = "Page Number";
			break;
		case "Book":
			$get("OtherTypeDiv").style.display = "none";
			$get("PublisherLabel").innerHTML = "Publisher";
			$get("PublisherLocationLabel").innerHTML = "Location";
			$get("LocationDiv").style.display = "block";
			$get("PublicationDateLabel").innerHTML = "Publication Date";
			$get("VolumeDiv").style.display = "none";
			$get("IssueDiv").style.display = "none";
			$get("EditionDiv").style.display = "block";
			$get("ChapterDiv").style.display = "block";
			$get("PageNumberDiv").style.display = "block";
			$get("PageNumberLabel").innerHTML = "Number of Pages";
			break;
		case "Conference Paper":
			$get("OtherTypeDiv").style.display = "none";
			$get("PublisherLabel").innerHTML = "Event Name";
			$get("PublisherLocationLabel").innerHTML = "Conference Location";
			$get("LocationDiv").style.display = "block";
			$get("PublicationDateLabel").innerHTML = "Conference Date";
			$get("VolumeDiv").style.display = "none";
			$get("IssueDiv").style.display = "none";
			$get("EditionDiv").style.display = "none";
			$get("ChapterDiv").style.display = "none";
			$get("PageNumberDiv").style.display = "none";
			break;
		case "Other":
			$get("OtherTypeDiv").style.display = "block";
			$get("PublisherLabel").innerHTML = "Published By";
			$get("PublisherLocationLabel").innerHTML = "Location";
			$get("LocationDiv").style.display = "block";
			$get("PublicationDateLabel").innerHTML = "Publication Date";
			$get("VolumeDiv").style.display = "none";
			$get("IssueDiv").style.display = "none";
			$get("EditionDiv").style.display = "none";
			$get("ChapterDiv").style.display = "none";
			$get("PageNumberDiv").style.display = "block";
			$get("PageNumberLabel").innerHTML = "Number of Pages";
			break;
	}
}
/****************************************
SPEECH
****************************************/
window.SaveSpeech = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "Title").value))
	{
		AddValidationSummaryItem(summary, "A valid Title is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Title");
	}

	if ($get(ctrlPrefix + "SpeechTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Speech Type is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "SpeechTypeList");
	}

	if ($get(ctrlPrefix + "EventTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Event Type is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EventTypeList");
	}

	if (!validText($get(ctrlPrefix + "EventName").value))
	{
		AddValidationSummaryItem(summary, "A valid Event Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EventName");
	}

	if (!validText($get(ctrlPrefix + "Location").value))
	{
		AddValidationSummaryItem(summary, "A valid Location is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Location");
	}

	if (!validText($get(ctrlPrefix + "EventDate").value))
	{
		AddValidationSummaryItem(summary, "A valid Event Date is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EventDate");
	}

	if ($get(ctrlPrefix + "Link").value.length > 0
		&& !ValidateUrlClassic($get(ctrlPrefix + "Link")))
	{
		AddValidationSummaryItem(summary, "Link must contain a properly formatted URL.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Link");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Title").value) + ":"
			+ $get(ctrlPrefix + "SpeechTypeList").value + ":"
			+ $get(ctrlPrefix + "EventTypeList").value + ":"
			+ SafeString($get(ctrlPrefix + "EventName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Location").value) + ":"
			+ SafeString($get(ctrlPrefix + "EventDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "Link").value) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveSpeech", data);
		CancelPopup();
	}
}
/****************************************
LANGUAGE
****************************************/
window.SaveLanguage = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if ($get(ctrlPrefix + "LanguageList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Language is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "LanguageList");
	}

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		if ($get(ctrlPrefix + "OrdinumList") != null)
			ordinum = $get(ctrlPrefix + "OrdinumList").value;

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ $get(ctrlPrefix + "LanguageList").value + ":"
			+ ($get(ctrlPrefix + "SpeakList_0").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "ReadList_0").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "WriteList_0").checked ? "1" : "0") + ":"
			+ ordinum;

		DoAjaxPostBack(rightUpdatePanel, "SaveLanguage", data);
		CancelPopup();
	}
} 
/****************************************
AWARD
****************************************/
window.SaveAward = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "Title").value))
	{
		AddValidationSummaryItem(summary, "A valid Title is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Title");
	}

	if (!validText($get(ctrlPrefix + "IssuingAuthority").value))
	{
		AddValidationSummaryItem(summary, "A valid Issuing Authority is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "IssuingAuthority");
	}

	if (!validText($get(ctrlPrefix + "AwardDate").value))
	{
		AddValidationSummaryItem(summary, "A valid Award Date is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "AwardDate");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "Comments_ID");
	var comments = editor.getHTML();

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Title").value) + ":"
			+ SafeString($get(ctrlPrefix + "IssuingAuthority").value) + ":"
			+ SafeString($get(ctrlPrefix + "AwardDate").value) + ":"
			+ SafeString(comments) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveAward", data);
		CancelPopup();
	}
}
/****************************************
ASSOCIATION
****************************************/
window.SaveAssociation = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "Name").value))
	{
		AddValidationSummaryItem(summary, "A valid Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Name");
	}

	if ($get(ctrlPrefix + "AssociationTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Association Type is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "AssociationTypeList");
	}

	if ($get(ctrlPrefix + "Role").value.length > 0
		&& !validText($get(ctrlPrefix + "Role").value))
	{
		AddValidationSummaryItem(summary, "Role may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Role");
	}

	if (!validText($get(ctrlPrefix + "StartDate").value))
	{
		AddValidationSummaryItem(summary, "A valid Start Date is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "StartDate");
	}

	if ($get(ctrlPrefix + "EndDate").value.length == 0
		&& !$get(ctrlPrefix + "IsCurrentCheckBox").checked)
	{
		AddValidationSummaryItem(summary, "Either enter an End Date or check the Is Current box.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "EndDate");
	}

	if ($get(ctrlPrefix + "IsCurrentCheckBox").checked)
		$get(ctrlPrefix + "EndDate").value = "";

	if ($get(ctrlPrefix + "EndDate").value.length > 0)
		$get(ctrlPrefix + "IsCurrentCheckBox").checked = false;

	if ($get(ctrlPrefix + "Link").value.length > 0
		&& !ValidateUrlClassic($get(ctrlPrefix + "Link")))
	{
		AddValidationSummaryItem(summary, "Link must be a valid Web address.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Link");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "Comments_ID");
	var comments = editor.getHTML();

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Name").value) + ":"
			+ $get(ctrlPrefix + "AssociationTypeList").value + ":"
			+ SafeString($get(ctrlPrefix + "Role").value) + ":"
			+ SafeString($get(ctrlPrefix + "StartDate").value) + ":"
			+ SafeString($get(ctrlPrefix + "EndDate").value) + ":"
			+ ($get(ctrlPrefix + "IsCurrentCheckBox").checked ? "1" : "0") + ":"
			+ SafeString($get(ctrlPrefix + "Link").value) + ":"
			+ SafeString(comments) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveAssociation", data);
		CancelPopup();
	}
}
/****************************************
REFERENCE
****************************************/
window.SaveReference = function()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;

	if (!validText($get(ctrlPrefix + "ItemName").value))
	{
		AddValidationSummaryItem(summary, "A valid Item Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ItemName");
	}

	if (!validText($get(ctrlPrefix + "Name").value))
	{
		AddValidationSummaryItem(summary, "A valid Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Name");
	}

	if ($get(ctrlPrefix + "ReferenceTypeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Reference Type is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ReferenceTypeList");
	}

	if (!validText($get(ctrlPrefix + "Title").value))
	{
		AddValidationSummaryItem(summary, "A valid Title/Relationship is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Title");
	}

	if ($get(ctrlPrefix + "Company").value.length > 0
		&& !validText($get(ctrlPrefix + "Company").value))
	{
		AddValidationSummaryItem(summary, "Company may only contain valid text.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Company");
	}

	if (($get(ctrlPrefix + "Phone1").value.length > 0
		&& $get(ctrlPrefix + "Phone1TypeList").selectedIndex == 0)
		|| ($get(ctrlPrefix + "Phone1").value.length == 0
		&& $get(ctrlPrefix + "Phone1TypeList").selectedIndex > 0))
	{
		AddValidationSummaryItem(summary, "If entering Phone 1, both Phone 1 and its Type are required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Phone1");
	}
	else if ($get(ctrlPrefix + "Phone1").value.length > 0
		&& !validAnyPhone($get(ctrlPrefix + "Phone1").value))
	{
		AddValidationSummaryItem(summary, "Phone 1 must be a valid phone number.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Phone1");
	}

	if (($get(ctrlPrefix + "Phone2").value.length > 0
		&& $get(ctrlPrefix + "Phone2TypeList").selectedIndex == 0)
		|| ($get(ctrlPrefix + "Phone2").value.length == 0
		&& $get(ctrlPrefix + "Phone2TypeList").selectedIndex > 0))
	{
		AddValidationSummaryItem(summary, "If entering Phone 2, both Phone 2 and its Type are required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Phone2");
	}
	else if ($get(ctrlPrefix + "Phone2").value.length > 0
		&& !validAnyPhone($get(ctrlPrefix + "Phone2").value))
	{
		AddValidationSummaryItem(summary, "Phone 2 must be a valid phone number.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "Phone2");
	}

	if ($get(ctrlPrefix + "ReferenceEmail").value.length > 0
		&& !validEmail($get(ctrlPrefix + "ReferenceEmail").value))
	{
		AddValidationSummaryItem(summary, "Email is not valid.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ReferenceEmail");
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "Comments_ID");
	var comments = editor.getHTML();

	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var ordinum = 0;
		var pageBreak = 0;

		if ($get(ctrlPrefix + "OrdinumList") != null)
		{
			ordinum = $get(ctrlPrefix + "OrdinumList").value;
			pageBreak = GetPageBreakSelection();
		}

		var data = window.CurrentResumeElementId + ":"
			+ window.CurrentItemId + ":"
			+ SafeString($get(ctrlPrefix + "ItemName").value) + ":"
			+ SafeString($get(ctrlPrefix + "Name").value) + ":"
			+ $get(ctrlPrefix + "ReferenceTypeList").value + ":"
			+ SafeString($get(ctrlPrefix + "Title").value) + ":"
			+ SafeString($get(ctrlPrefix + "Company").value) + ":"
			+ SafeString($get(ctrlPrefix + "Phone1").value) + ":"
			+ $get(ctrlPrefix + "Phone1TypeList").value + ":"
			+ SafeString($get(ctrlPrefix + "Phone2").value) + ":"
			+ $get(ctrlPrefix + "Phone2TypeList").value + ":"
			+ SafeString($get(ctrlPrefix + "ReferenceEmail").value) + ":"
			+ SafeString(comments) + ":"
			+ ordinum + ":"
			+ pageBreak;

		DoAjaxPostBack(rightUpdatePanel, "SaveReference", data);
		CancelPopup();
	}
}
/****************************************
LINK CONFIG
****************************************/
function ShowLinkConfigPopup(linkId)
{
	InitializeResBuilderProxy();
	window.LinkId = linkId;
	responseDivName = "LinkConfigResponseDiv";
	resBuilderProxy.GetControlHtml("LinkConfig", true, linkId,
		currentPersonId, 0, RenderPopup, HandlePopupError, 500);
}

function SaveLinkConfig()
{
	var responseDiv = $get(responseDivName);
	var summary = GetValidationSummary(responseDiv);
	var firstEl = null;
	var templateRequired = false;

	if (!validText($get(ctrlPrefix + "LinkName").value))
	{
		AddValidationSummaryItem(summary, "A valid Link Name is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "LinkName");
	}

	if ($get(ctrlPrefix + "ResumeList").selectedIndex == 0)
	{
		AddValidationSummaryItem(summary, "Resume is required.");
		if (firstEl == null) firstEl = $get(ctrlPrefix + "ResumeList");
	}

	var formatRequired = $get(ctrlPrefix + "OutputList").value.split("|")[1] == "1";

	if (formatRequired)
	{
		if ($get(ctrlPrefix + "HeaderFontList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Header Font is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "HeaderFontList");
		}

		if ($get(ctrlPrefix + "HeaderSizeList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Header Font Size is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "HeaderSizeList");
		}

		if ($get(ctrlPrefix + "SectionFontList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Section Font is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "SectionFontList");
		}

		if ($get(ctrlPrefix + "SectionSizeList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Section Font Size is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "SectionSizeList");
		}

		if ($get(ctrlPrefix + "BodyFontList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Body Font is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "BodyFontList");
		}

		if ($get(ctrlPrefix + "BodySizeList").selectedIndex == 0)
		{
			AddValidationSummaryItem(summary, "Default Body Font Size is required.");
			if (firstEl == null) firstEl = $get(ctrlPrefix + "BodySizeList");
		}
	}

	var editor = document.getElementById("CE_" + ctrlPrefix + "GuestMessage_ID");
	var message = editor.getHTML();

	if (message.length > 1000)
	{
		AddValidationSummaryItem(summary, "Guest Message may not exceed 1,000 characters.");
		//if (firstEl == null) firstEl = $get(ctrlPrefix + "BodySizeList");
	}
	if (firstEl != null)
		ShowValidationSummary(responseDiv, summary, firstEl);
	else
	{
		var data = window.LinkId + ":"
			+ SafeString($get(ctrlPrefix + "LinkName").value) + ":"
			+ $get(ctrlPrefix + "ResumeList").value + ":"
			+ $get(ctrlPrefix + "OutputList").value.split("|")[0] + ":"
			+ $get(ctrlPrefix + "TemplateList").value.split("|")[0] + ":"
			+ $get(ctrlPrefix + "HeaderFontList").value + ":"
			+ $get(ctrlPrefix + "HeaderSizeList").value + ":"
			+ ($get(ctrlPrefix + "HeaderBoldCheckBox").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "HeaderItalicCheckBox").checked ? "1" : "0") + ":"
			+ $get(ctrlPrefix + "SectionFontList").value + ":"
			+ $get(ctrlPrefix + "SectionSizeList").value + ":"
			+ ($get(ctrlPrefix + "SectionBoldCheckBox").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "SectionItalicCheckBox").checked ? "1" : "0") + ":"
			+ $get(ctrlPrefix + "BodyFontList").value + ":"
			+ $get(ctrlPrefix + "BodySizeList").value + ":"
			+ ($get(ctrlPrefix + "IsActiveList_0").checked ? "1" : "0") + ":"
			+ ($get(ctrlPrefix + "SuppressContactList_0").checked ? "1" : "0") + ":"
			+ SafeString(message);

		DoAjaxPostBack(rightUpdatePanel, "SaveLinkConfig", data);
		CancelPopup();
	}
}
/****************************************
SUPPORT METHODS
****************************************/
function ShowEditPopup(elementName, resumeElementId, itemId, width)
{
	InitializeResBuilderProxy();
	window.CurrentResumeElementId = resumeElementId;
	window.CurrentItemId = itemId;
	responseDivName = elementName + "EditResponseDiv";

	resBuilderProxy.GetControlHtml(elementName + "Edit", true, resumeElementId,
		currentPersonId, itemId, RenderPopup, HandlePopupError, width);
}

function DebugPopupResults(result, userContext, methodName)
{
	document.getElementById("DebugDiv").innerHTML = result;
}

function RecycleContactInfo()
{
	if (typeof (recycleContactInfoPopup) != "undefined" && recycleContactInfoPopup == true)
		ShowEditPopup("ContactInfo", window.CurrentResumeElementId, window.CurrentItemId, 550);
	else
		CancelPopup();
}

function ToggleTabs(which)
{
	if (which == "info")
	{
		$get("TabInfo").className = "TabOn";
		$get("TabDesc").className = "TabOff";
		$get("TabDivInfo").style.display = "block";
		$get("TabDivDesc").style.display = "none";
	}
	else
	{
		$get("TabInfo").className = "TabOff";
		$get("TabDesc").className = "TabOn";
		$get("TabDivInfo").style.display = "none";
		$get("TabDivDesc").style.display = "block";
	}
	
	window.scrollBy(0, 1);
}

function GetPageBreakSelection()
{
	var val = 0;
	
	for (var i = 0; i <= 2; i++)
	{
		if ($get(ctrlPrefix + "PageBreakList_" + i).checked)
		{
			val = i;
			break;
		}
	}

	return val;
}

/****************************************
POPUP ELEMENTS
****************************************/
function GetPopupInstructions(msg)
{
	var div = document.createElement("div");
	div.className = "Instructions";
	div.innerHTML = msg;
	return div;
}

function GetResponseDiv(id)
{
	var div = document.createElement("div");
	div.className = "ResponseDiv";
	div.id = id;
	return div;
}

function GetFieldSet(label)
{
	var fieldSet = document.createElement("fieldset");
	var legend = document.createElement("legend");
	legend.innerHTML = label;
	fieldSet.appendChild(legend);
	return fieldSet;
}

function GetTextBox(id, label, isRequired, maxLength, infoMarkId, infoMarkWidth, infoMarkHeight)
{
	var outerDiv = GetOuterDivWithLabel(label, isRequired);
	var controlDiv = GetControlDiv();

	var textBox = document.createElement("input");
	textBox.id = id;
	textBox.type = "text";
	textBox.className = "BoxElement";
	textBox.maxLength = maxLength;

	controlDiv.appendChild(textBox);

	if (infoMarkId.length > 0)
	{
		controlDiv.appendChild(GetInfoMark(infoMarkId, infoMarkWidth, infoMarkHeight));
	}

	outerDiv.appendChild(controlDiv);
	return outerDiv;
}

function GetContactInfoList(id, label, isRequired, infoMarkId, infoMarkWidth, infoMarkHeight, addLinkMethod)
{
	var outerDiv = GetOuterDivWithLabel(label, isRequired);
	var controlDiv = GetControlDiv();

	var listDiv = document.createElement("div");
	listDiv.id = id;
	listDiv.style.styleFloat = "left";

	controlDiv.appendChild(listDiv);

	var imDiv = document.createElement("div");
	imDiv.style.styleFloat = "left";
	imDiv.style.padding = "3px 0 0 6px";

	imDiv.appendChild(GetInfoMark(infoMarkId, infoMarkWidth, infoMarkHeight));
	controlDiv.appendChild(imDiv);

	var linkDiv = document.createElement("div");
	linkDiv.style.clear = "both";
	linkDiv.style.textIndent = "18px";

	var addLink = document.createElement("a");
	addLink.className = "InfoLink";
	addLink.innerHTML = "Add " + label;
	addLink.style.lineHeight = "20px";
	addLink.href = "javascript:" + addLinkMethod;

	linkDiv.appendChild(addLink);
	controlDiv.appendChild(linkDiv);
	outerDiv.appendChild(controlDiv);
	return outerDiv;
}

function GetDropDownList(id, label, isRequired, infoMarkId, infoMarkWidth, infoMarkHeight)
{
	var outerDiv = GetOuterDivWithLabel(label, isRequired);
	var controlDiv = GetControlDiv();

	var list = document.createElement("select");
	list.id = id;
	list.className = "ListElement";

	var item = document.createElement("option");
	item.value = "0";
	item.Text = "";

	list.appendChild(item);
	controlDiv.appendChild(list);

	if (infoMarkId.length > 0)
		controlDiv.appendChild(GetInfoMark(infoMarkId, infoMarkWidth, infoMarkHeight));

	outerDiv.appendChild(controlDiv);
	return outerDiv;
}

function GetBooleanSwitch(id, ctrlLabel, selectedValue, infoMarkId, infoMarkWidth, infoMarkHeight)
{
	var outerDiv = GetOuterDivWithLabel(ctrlLabel, false);
	var controlDiv = GetControlDiv();

	//Yes button
	var label = document.createElement("label");
	label.setAttribute("for", id + "1");
	label.className = "CheckElement";

	var radio = "<input type=\"radio\" id=\"" + id + "1\" name=\"" + id + "\" value=\"1\"";
	if (selectedValue == 1) radio += " checked=\"checked\"";
	radio += " />Yes"

	label.innerHTML = radio;
	controlDiv.appendChild(label);

	//No button
	label = document.createElement("label");
	label.setAttribute("for", id + "0");
	label.className = "CheckElement";

	radio = "<input type=\"radio\" id=\"" + id + "0\" name=\"" + id + "\" value=\"0\"";
	if (selectedValue == 0) radio += " checked=\"checked\"";
	radio += " />No"

	label.innerHTML = radio;
	controlDiv.appendChild(label);

	if (infoMarkId.length > 0)
		controlDiv.appendChild(GetInfoMark(infoMarkId, infoMarkWidth, infoMarkHeight));

	outerDiv.appendChild(controlDiv);
	return outerDiv;
}

function GetRichTextEditor(id, label, isRequired, infoMarkId, infoMarkWidth, infoMarkHeight)
{
	var outerDiv = document.createElement("div");
	outerDiv.className = "FormElementDiv";

	var rteLabel = document.createElement("div");
	rteLabel.className = "Instructions";
	rteLabel.style.margin = "6px 0 0 0";
	if (isRequired) label += "<span class=\"ReqStar\">*</span>";
	label += ":";
	rteLabel.innerHTML = label;

	if (infoMarkId.length > 0)
		rteLabel.appendChild(GetInfoMark(infoMarkId, infoMarkWidth, infoMarkHeight));

	outerDiv.appendChild(rteLabel);

	var text = document.createElement("textarea");
	text.id = id;
	text.className = "RichTextElement";

	outerDiv.appendChild(text);
	return outerDiv;
}

function GetOuterDivWithLabel(label, isRequired)
{
	var outerDiv = document.createElement("div");
	outerDiv.className = "FormElementDiv";

	if (isRequired)
		label += "<span class=\"ReqStar\">*</span>";
	label += ":";

	var labelDiv = document.createElement("div");
	labelDiv.className = "FormElementLabel";
	labelDiv.innerHTML = label;

	outerDiv.appendChild(labelDiv);
	return outerDiv;
}

function GetControlDiv()
{
	var controlDiv = document.createElement("div");
	controlDiv.className = "FormElementControl";
	return controlDiv;
}

function GetInfoMark(infoMarkId, infoMarkWidth, infoMarkHeight)
{
	var IM = document.createElement("a");
	IM.href = "javascript:void(0);";
	IM.className = "InfoLink";
	IM.onmouseover = function() { ShowInfoBox(infoMarkId, infoMarkWidth, infoMarkHeight) };
	IM.tabindex = "-1";
	IM.innerHTML = "&nbsp;?&nbsp;";
	IM.style.marginLeft = "3px";
	return IM;
}

function GetButtons(showSave, saveHandler, showCancel, cancelHandler)
{
	var buttonDiv = document.createElement("div");
	buttonDiv.className = "FormButtons";
	buttonDiv.style.marginTop = "12px";

	if (showSave)
	{
		var saveButton = document.createElement("input");
		saveButton.type = "button";
		saveButton.className = "Button";
		saveButton.value = "Save";
		saveButton.onclick = saveHandler;
		buttonDiv.appendChild(saveButton);
	}

	if (showCancel)
	{
		var cancelButton = document.createElement("input");
		cancelButton.type = "button";
		cancelButton.className = "Button";
		cancelButton.value = "Cancel";
		cancelButton.style.marginLeft = "3px";
		cancelButton.onclick = cancelHandler;
		buttonDiv.appendChild(cancelButton);
	}

	return buttonDiv;
}

function FillDropDownList(result, userContext, methodName)
{
	var list = $get(userContext);

	for (var i = 0; i < result.length; i++)
	{
		var option = document.createElement("option");
		option.value = result[i].Id;
		option.text = result[i].Descriptor;
		list.add(option);
	}
}

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
 