<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="../../../theme/css/censusmain.css"/>
	<link rel="stylesheet" type="text/css" href="../../../theme/css/mqwizard.css"/>
	<link rel="stylesheet" type="text/css" href="../../../js/JQUERY/jquery-ui-1.10.2.custom.css"/>
	<!--MqRelPath--><link rel="stylesheet" type="text/css" href="/connect/theme/css/balloon.css"/><!--/MqRelPath--><!--MqAbsPath><link rel="stylesheet" type="text/css" href="<BASE_VD>/theme/css/balloon.css"/></MqAbsPath-->	
		
	<link rel="stylesheet" href="../../../js/jquery/jquery.ui.all.css">		
	<script type="text/javascript" src="../../../js/jquery/jquery-1.7.1.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.bgiframe-2.1.2.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.ui.core.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.ui.mouse.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.ui.draggable.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.ui.position.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.ui.resizable.js"></script>
	<script type="text/javascript" src="../../../js/jquery/jquery.ui.dialog.js"></script>

	<script type="text/javascript" src="../../../js/mqsysutils.js"></script>
	<script type="text/javascript" src="../../../js/mqformelements.js"></script>
	<script type="text/javascript" src="../../../js/mqlist.js"></script>
    <script type="text/javascript" src="../../../js/mqviewfields.js"></script>
    <script type="text/javascript" src="../../../js/mqrecordset.js"></script>
    <script type="text/javascript" src="../../../js/mqloaddata.js"></script>
    <script type="text/javascript" src="../../../js/xml.js"></script>
	<script type="text/javascript" src="../../../js/popupwindow.js"></script>
	<script type="text/javascript" src="../../../js/date.js"></script>
	<script type="text/javascript" src="../../../js/anchorposition.js"></script>
	<script type="text/javascript" src="../../../js/calendarpopup.js"></script>
	<script type="text/javascript" src="../../../js/window.js"></script>
	<script type="text/javascript" src="../../../js/autosuggest.js"></script>
	<script type="text/javascript" src="../../../js/cmqlookupitemint.js"></script>
	<script type="text/javascript" src="../../../js/initlookupitemint.js"></script>

<title></title>
		
	<script type="text/javascript">

		if(g_MqRef.MqBrowser){
			if(g_MqRef.MqBrowser.ie && g_MqRef.MqBrowser.major<=6){
				document.write('<link rel="stylesheet" type="text/css" href="../../../theme/css/CensusMainQuirks.css"/>');
			}
		}

		var MSG_FIELD_REQUIRES_CAPTION="You must enter a Field Caption.";
		var MSG_FIELD_REQUIRES_DISPLAY_CAPTION="You must enter a Display Caption.";
		var MSG_NAVIGATE_AWAY = "Any unsaved changes will be lost.";
		
		var FIELD_ID_LABEL_CAPTION="8";
		var FIELD_ID_DISPLAY_CAPTION="20";
		var FIELD_ID_RO_GROUPS="999";
		
		//Configuration constants
		var CONFIG_TABLE_DS_TYPE = 3;
		var CONFIG_FIELD_CAPTION = 0;
		var CONFIG_TABLE_NAME = 1;
		var CONFIG_FIELD_NAME = 2;
		var m_blnAddField=<WC@ADD_FIELD></WC@ADD_FIELD>;
		var m_lngFieldID="<WC@FIELD_ID></WC@FIELD_ID>";
		var m_strDtsFieldFields="<WC@DTS_FIELD_FIELDS></WC@DTS_FIELD_FIELDS>";
		var m_blnSaving = false;
		var m_blnDataChanged = false;
		var m_blnCaptionSet=false;
		
		var FIELD_COL_ADD=999999;
		
		if(m_blnAddField){
			document.title="Add Field";
		}else{
			document.title="Update Field";
		}
		var m_MqList=new MqList();
		var m_objMqButton=new MqButton();
		
		var m_objRef;
		if(parent){
			m_objRef=parent;
		}
		
		var m_objViewFields= new CMqFieldCol();
		var m_objLoadDataMgr;
    
		var m_strFieldDataXML="<WC@FIELD_XML_DATA>1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;32</WC@FIELD_XML_DATA>";
		var m_strROGroups="<WC@RO_GROUPS></WC@RO_GROUPS>";
		var m_oFieldValuesRs;

		var m_strWinID=parseInt( Math.random() * 1000);
		var m_objLookupItemInfoColl=new Array();
		var DEFAULT_VALUE_DELIM=";";
		var m_objViewFieldRef = document; //Was parent before. Must handle this when sharing.
		var m_strPathToAdminHTML = "../../../HTML/";
		
		var m_objAutoSuggest = new CMqAutoSuggest();
		
		m_objAutoSuggest.Initialize("", document);
		
		var FIELD_ID_FIELD_VALUE_TABLE=11;
		var FIELD_ID_FIELD_VALUE_TABLE_DS_TYPE=12;
		var FIELD_ID_IS_READONLY=13;
		
		function MqOpenURL(strURL,strName, strFeatures,blnGetIDText,blnAsChildWin, blnAsModalWin, lngWidth, lngHeight)
		{               
			var MAX_URL_LEN=2020;
			if (!strName){
				strName="_blank";
			}
				
			if (!strFeatures){
				strFeatures="toolbar=no,directories=no,resizable=yes,scrollbars=yes";
			}
				
					
				var objMacros=new CMqMacros();
				if(objMacros){
					strURL=objMacros.ResolveFieldMacros(strURL,m_objLoadDataMgr,true,blnGetIDText);
				}
								
				var objURIUtils=new CMqURIUtils();
				if(objURIUtils){
					strURL=objURIUtils.AddURIProtocol(strURL);
				}
				if (strURL.length>MAX_URL_LEN){
					strURL=strURL.substr(0,MAX_URL_LEN);
				}
				if(blnAsChildWin){
					if(blnAsModalWin){
						OpenModalWindow(strURL, lngWidth, lngHeight, false);
					}else{
						OpenChildWindow(strURL,strName,strFeatures);
					}
				}else{
					window.open(strURL,strName,strFeatures);
				}
		}
		
		function AddURLButton(strURL,strCSSClassName,strFieldID, strFieldName, objDocumentRef)
        {
			var strTooltipButton="";
			var URL_BUTTON_NAME="RC";
			var RC_CSS_CLASS_NAME="RemoteControl";
			var strURLButtonName;
			var objString=new MqString();
			var USER_DETAILS_CLASS_NAME ="UserDetails";
			var BROWSE_ALT_CHOICE_LIST_CLASS_NAME ="BrowseAlternateChoiceList";
			var strButtonAction="MqOpenURL('"+strURL+"')";
			var strButtonNamePostfix;
			
			if (RC_CSS_CLASS_NAME==objString.Left(strCSSClassName,RC_CSS_CLASS_NAME.length)){
				strTooltipButton="Start a remote control session";
			}else{			
				if(USER_DETAILS_CLASS_NAME.toLowerCase()==objString.Left(strCSSClassName,USER_DETAILS_CLASS_NAME.length).toLowerCase()){
					strTooltipButton="Details";
					strButtonAction=strURL;
				}else{	
					if(BROWSE_ALT_CHOICE_LIST_CLASS_NAME.toLowerCase()==objString.Left(strCSSClassName,BROWSE_ALT_CHOICE_LIST_CLASS_NAME.length).toLowerCase()){
						strTooltipButton="Select value";
						strButtonAction=strURL;
						strButtonNamePostfix="_SelVal";
					}else{
						strTooltipButton="Connect to Internet address";
					}
				}
			}
					
			if(m_objMqButton){	
				if(strFieldName){
					if(strButtonNamePostfix){
						strURLButtonName=strFieldName+strButtonNamePostfix;
					}else{
						strURLButtonName=URL_BUTTON_NAME+strFieldName;
					}
				}else{
					strURLButtonName=URL_BUTTON_NAME+strFieldID;		
				}
				
				m_objMqButton.WriteButtonHTML(strURLButtonName,strButtonAction,strCSSClassName,false,m_objMqButton.STATE_1,strTooltipButton, null, objDocumentRef);
			}
        }		
		
		function GetBoundControl(lngFieldID)
		{
			var objElement;
			
			if(lngFieldID){
				var objField=m_objViewFields.Field(lngFieldID);//m_objViewFieldRef
				if(objField.GetBoundControl){
					var objElement = document.getElementById(objField.GetBoundControl());
				}
			}
			
			return objElement;
		}
		
		function LoadLargeListOrCombo(lngFieldID, strFieldCaption, strSearchResultsURL, strTableName, blnAutoComplete, lngRecordsPerPage, strFieldName, blnHideAddNewButton, lngWidth, lngHeight)
		{ 
			var blnShowWin=false;
			if(parent){
				if(parent.objRecord){
					if(parent.objRecord.GetRecordId() > 0){
						blnShowWin=true;
					}else{
						blnShowWin=false;
						if(parent.objFeatures){
							if(parent.objFeatures.getFeature(parent.FEATURE_SUBMIT)){
								blnShowWin=true;
							}
						}
					}
				}else{
					blnShowWin=true;
				}
			}
			
			if(blnShowWin){
				var objField
				if(lngFieldID==FIELD_ID_RO_GROUPS){
					objField=new CMqField(FIELD_ID_RO_GROUPS,FIELD_ID_RO_GROUPS,CTRL_TYPE_LARGE_LIST,true);
				}else{
					objField=m_objViewFields.Field(lngFieldID);//m_objViewFieldRef
				}
				if (objField){
					
					lngFieldID=lngFieldID+FIELD_COL_ADD; //if we pass a valid field id, it will try to load the dts field object, so change it temporarily
					
					var arrSelectedIDs;
					var arrSelectedValues;
					var blnMultiSelect;
					var fnSetValue=SetComboOrListValue;
					var strWorkflowValues="";
					var objHTMLElement;

					var objFormElement=new CMqFormElement();
					
					objFormElement.Initialize(objField.GetBoundControl(),objField.GetControlType(),'document');
					var lngControlType=objFormElement.GetControlType();

					if(lngControlType==CTRL_TYPE_LARGE_COMBO){
						blnMultiSelect=false;
						arrSelectedIDs=Array(objFormElement.GetValue());
					}else{  
						if(lngControlType==CTRL_TYPE_TEXT){
							blnMultiSelect=false;
							arrSelectedValues=Array(objFormElement.GetValue());
						}else{  // CTRL_TYPE_LARGE_LIST
							blnMultiSelect=true;
							var strValue = objFormElement.GetValue();
							if (strValue && strValue.length > 0)
							{
								var varValues=strValue.split(DEFAULT_VALUE_DELIM);
								if (varValues.length > 0){
									arrSelectedValues = new Array();
								}
								for(var lngIndex=0;lngIndex<varValues.length;lngIndex++)
								{
									arrSelectedValues[lngIndex]=varValues[lngIndex];
								}
							}
						}
					}
					
					objHTMLElement=objFormElement.GetElement();
					
					if(objHTMLElement){
						strWorkflowValues=objHTMLElement.getAttribute("MqWrkFlwVals");
					}

					InitLookupItemVals(lngFieldID, arrSelectedIDs, arrSelectedValues, fnSetValue, blnMultiSelect, strFieldCaption, strWorkflowValues, strSearchResultsURL, blnAutoComplete, lngRecordsPerPage, strFieldName, blnHideAddNewButton);
					
					if(!lngWidth){
					if(blnMultiSelect){
						lngWidth=800;
					}else{
						lngWidth=650;
					}
					}
					if(!lngHeight){
						if(blnMultiSelect){
							lngHeight=570;
						}else{
							lngHeight=500;
						}
					}
					
					var strWinFeatures=GetWinFeaturesToCenter(lngWidth, lngHeight); 
					
					if(!blnAutoComplete){
						if(blnMultiSelect){
							MqOpenURL(m_strPathToAdminHTML + "TmplLookupItemMultiSelect.htm?TBL=" + g_MqRef.MqStr.MqEncodeURIComponent(strTableName) + "&FID=" + lngFieldID,"ChoicesList"+lngFieldID+m_strWinID,"scrollbars=no,resizable=yes,toolbar=no,directories=no" + strWinFeatures, false, true, true, lngWidth, lngHeight);
						}else{
							MqOpenURL(m_strPathToAdminHTML + "TmplLookupItem.htm?TBL=" + g_MqRef.MqStr.MqEncodeURIComponent(strTableName) + "&FID=" + lngFieldID,"ChoicesList"+lngFieldID+m_strWinID,"scrollbars=no,resizable=yes,toolbar=no,directories=no" + strWinFeatures, false, true, true, lngWidth, lngHeight);
						}
					}else{
						return m_strPathToAdminHTML + "TmplLookupItemCompact.htm?TBL=" + g_MqRef.MqStr.MqEncodeURIComponent(strTableName) + "&FID=" + lngFieldID;
					}
				} 
			}
		}
	
	function SetComboOrListValue(lngFieldID, arrSelectedIDs, arrSelectedValues)
	{
		var strSelectedIDs;
		var strSelectedValues;
		
		if (lngFieldID)
		{
			lngFieldID=lngFieldID-FIELD_COL_ADD; //if we pass a valid field id, it will try to load the dts field object, so change it temporarily
			
			var objField
			if(lngFieldID==FIELD_ID_RO_GROUPS){
				objField=new CMqField(FIELD_ID_RO_GROUPS,FIELD_ID_RO_GROUPS,CTRL_TYPE_LARGE_LIST,true);
			}else{
				objField=m_objViewFields.Field(lngFieldID);
			}

			var objFormElement=new CMqFormElement();
			objFormElement.Initialize(objField.GetBoundControl(),objField.GetControlType(),'document');
			var lngControlType=objFormElement.GetControlType();
			
			if(lngFieldID==FIELD_ID_FIELD_VALUE_TABLE){
				if(arrSelectedIDs){
					if(arrSelectedIDs.length>0){
						//choice list, set the DS Type
						SetFieldValue(FIELD_ID_FIELD_VALUE_TABLE_DS_TYPE, arrSelectedIDs[0]);
					}
				}
			}
			
			if (lngControlType == CTRL_TYPE_LARGE_COMBO)
			{
				strSelectedIDs = "";
				strSelectedValues = "";
				
				if(arrSelectedIDs && arrSelectedValues){
					strSelectedIDs = arrSelectedIDs[0];
					strSelectedValues = arrSelectedValues[0];
				}
					
				objFormElement.SetValueToLargeCombo(objFormElement.GetElement(), strSelectedIDs, strSelectedValues, lngFieldID);
			}
			else
			{
				var selectedValues="";
				for (var i=0; i < arrSelectedValues.length; i++)
				{
					if (i > 0){
						selectedValues += DEFAULT_VALUE_DELIM;
					}
					
					selectedValues += arrSelectedValues[i];
				}
				objFormElement.SetValue(selectedValues);
			}
			
			var objHTMLElement = objFormElement.GetElement();
			if (objHTMLElement && objHTMLElement.onchange)
			{
				objHTMLElement.onchange();
			}
			else
			{
				parent.OnRecordChanged(lngFieldID);
			}
		}
	}
	
		/** AUTOSUGGEST ADDITIONS STOP **/

		function OnLoadBody()
		{
			var objHeaderText=document.getElementById("HeaderText");
		
			if(objHeaderText){
				if(m_blnAddField){
					objHeaderText.innerHTML="Add Field";
				}else{
					objHeaderText.innerHTML="Update Field";
				}
			}
			
			LoadData();		
			
						        
			if(m_blnAddField){
				SetFieldValue("6", 10);
				SetFieldValue("7", 50);
				SetFieldValue("23", 0);	
				SetFieldValue(FIELD_ID_IS_READONLY, false);	
				SetFieldValue("14", true);	
				SetFieldValue("15", true);	
				SetFieldValue("18", true);	
				
				HideField("1", true);
				HideField("2", true);
				HideField("3", true);
				HideField("4", true);
				HideField("27", true);
				HideField("28", true);
				HideField("29", true);
				HideField("30", true);
			}else{
				DisableField("6", true);
				DisableField("7", true);
				m_blnCaptionSet=true;
				
				var blnReadOnly=GetFieldValue(FIELD_ID_IS_READONLY);
				SetFieldValue(FIELD_ID_IS_READONLY, !blnReadOnly);
			}	
			
			OnDataTypeChanged();
			OnCheck_IsRequired();
			OnCheck_IsReadOnly();
			var objCaption=document.getElementById(FIELD_ID_LABEL_CAPTION);
			
			if(objCaption){
				objCaption.focus();
			}
		}
		
		
		function LoadData()
		{
			var objRecordset=new CMqRecordset(m_strDtsFieldFields,m_objViewFields.GetFieldIDName()); 
			m_objViewFields.Load(objRecordset);

			
			if(m_strFieldDataXML.length>0){
				m_oFieldValuesRs=new CMqRecordset(m_strFieldDataXML,m_objViewFields.GetFieldIDName());	
			}
			m_objLoadDataMgr= new CMqLoadDataMgr(m_objViewFields,"document");
				
			m_objLoadDataMgr.Load(m_oFieldValuesRs);
			
			SetROGroups(m_strROGroups);
		}
		
		function SaveField()
		{
			var strWCI;
			var strRecordInfo;
			var strROGroups;

			if(m_objRef){
				if(m_blnDataChanged){
					if(ValidateValues()){
						if(RequiredFieldsAreFilledIn()){
							strRecordInfo=m_objLoadDataMgr.GetDataForSave(true);
							
							//we save if it's enabled, but show if it's read-only, so switch on save
							var blnReadOnly=GetFieldValue(FIELD_ID_IS_READONLY);
							strRecordInfo=strRecordInfo.replace(FIELD_ID_IS_READONLY+"="+blnReadOnly, FIELD_ID_IS_READONLY+"="+!blnReadOnly);
							
							strROGroups=GetROGroups();
							m_blnSaving = true;
									
							if(m_blnAddField){
								strWCI="wciAddField";
							}else{
								strWCI="wciUpdateField";
							}
							

							var co=m_objRef.mobjHTTPrequest.Get(m_objRef.mstrCurrentLocation + 
								"WCMqFields.ASP?WCI=" + strWCI + "&Proj=" + m_objRef.GetProjectID() + 
								"&FID=" + m_lngFieldID + "&RI=" + 
								g_MqRef.MqStr.MqEncodeURIComponent(strRecordInfo) +
								"&ROG=" + g_MqRef.MqStr.MqEncodeURIComponent(strROGroups));
				
							if (co!=m_objRef.mobjHTTPrequest.CANCEL_PROCESS){
																	
								var objResponse=m_objRef.mobjHTTPrequest.Response(co);
								if (objResponse){
									if (objResponse.HasErrors()){
										objResponse.ProcessErrors("",true);
									}else{
										var lngFieldID=m_lngFieldID;
										if(m_blnAddField){
											lngFieldID=co;
										}
										m_objRef.LoadFieldsListByProject(null, null, lngFieldID);
										CloseWindow();
									}
								}
							}	
						}
					}
				}else{
					CloseWindow();
				}
			}
		}
	

		function SetROGroups(strGroups)
		{
			var objFormElement=new CMqFormElement();
					
			objFormElement.Initialize(FIELD_ID_RO_GROUPS,CTRL_TYPE_LARGE_LIST,'document');
			
			objFormElement.SetValue(strGroups);
		}
		
		function GetROGroups()
		{
			var objFormElement=new CMqFormElement();
					
			objFormElement.Initialize(FIELD_ID_RO_GROUPS,CTRL_TYPE_LARGE_LIST,'document');
			
			return objFormElement.GetValue();
		}
		
		function RequiredFieldsAreFilledIn()
		{
			var blnReturn=false;
			if(FieldIsFilled(FIELD_ID_LABEL_CAPTION, MSG_FIELD_REQUIRES_CAPTION)){
				if(FieldIsFilled(FIELD_ID_DISPLAY_CAPTION, MSG_FIELD_REQUIRES_DISPLAY_CAPTION)){
					blnReturn = true;
				}
			}
			
			return blnReturn;
		}
		
		function FieldIsFilled(strElementName, strRequiredMsg)
		{
			var objTxtCtrl;
			objTxtCtrl=document.getElementById(strElementName);
			
			if(objTxtCtrl){
				if(objTxtCtrl.value.length>0){
					return true;
				}else{
					if(strRequiredMsg.length>0){
						alert(strRequiredMsg);
						objTxtCtrl.focus();
					}
					return false;
				}	
			}
		}
		
		function KeyPressed(e)
		{			
			if(e){	
				if(e.keyCode == 13){
					if(!EvtSrcCtrlIsMemo(e)){
						SaveField();
					}
				}else{
					if(e.keyCode == 27){
						window.close()
					}
				}
			}
		}
		
		function EvtSrcCtrlIsMemo(e)
		{
			var MEMO_TYPE="textarea";
			
			var objElement;
			var blnReturn=false;
					
			if(e.srcElement){
				objElement=e.srcElement;
			}else{
				if(e.target){
					objElement=e.target;
				}
			}
					
			if(objElement){
				blnReturn = (objElement.type==MEMO_TYPE);
			}
			
			return blnReturn;
		}
		
		function VerifyValue(ctrlName,strNewValue)
		{
			//This function is here for the calendar so we can 
			//share the code. Same as function in CensusMain.js
											
			var ctrl=document.getElementById(ctrlName);
							
			if(ctrl){
				ctrlvalue = ctrl.value;
				if (ctrlvalue !=  strNewValue){
					ctrl.value = strNewValue;
				}
			}
		}
				
		 function WindowClosing()
		 {
			if(m_blnDataChanged && !m_blnSaving){
				return MSG_NAVIGATE_AWAY;
			}
		 }
		 
		 function DataChanged(lngFieldID)
		 {
			m_blnDataChanged = true;
			ValueChanged(lngFieldID);
		 }	
		 
		 function ValueChanged(lngFieldID)
		 {
			m_objLoadDataMgr.SetFieldChanged(lngFieldID);
		 }
		 
		 function SetDisplayCaption()
		 {
			if(!m_blnCaptionSet){
				var objDisplayCaption=document.getElementById(FIELD_ID_DISPLAY_CAPTION);
				var objCaption=document.getElementById(FIELD_ID_LABEL_CAPTION);
				
				if(objDisplayCaption && objCaption){
					objDisplayCaption.value=objCaption.value;
					ValueChanged(FIELD_ID_DISPLAY_CAPTION);
				}
			}
		 }
		 
		 function OnDataTypeChanged()
		 {
			var lngDataType=GetFieldValue("6");
			var DATA_TYPE_BOOL=1;
			var DATA_TYPE_CURR=5;
			var DATA_TYPE_DATE=8;
			var DATA_TYPE_MEMO=12;
			var DATA_TYPE_TIME=101;
			var DATA_TYPE_SC=103;
			var DATA_TYPE_MC=104;
			
			if(lngDataType==DATA_TYPE_SC || lngDataType == DATA_TYPE_MC){
				HideField("11", false);
				HideField("24", false);
				
				if(!m_blnAddField){
					HideField("29", false);
					HideField("30", false);
				}
			}else{
				DisableField("11", true);
				HideField("11", true);
				HideField("24", true);
				HideField("29", true);
				HideField("30", true);
			}
			if(lngDataType==DATA_TYPE_DATE || lngDataType==DATA_TYPE_SC || lngDataType == DATA_TYPE_MC ||
					lngDataType==DATA_TYPE_MEMO || lngDataType==DATA_TYPE_CURR || lngDataType==DATA_TYPE_BOOL ||
					lngDataType==DATA_TYPE_TIME){
				DisableField("7", true);
			}else{
				if(m_blnAddField){
					DisableField("7", false);
				}
			}
		 }
		 
		 function DisableField(lngFieldID, blnDisable)
		 {
			var objFormElement=new CMqFormElement();
			var objField = document.getElementById(lngFieldID);
			if(objField){
				objFormElement.Initialize(lngFieldID,objFormElement.GetControlType(objField),document);
				objFormElement.Disable(blnDisable, objField, document);
			}
		 }
		 
		 function HideField(lngFieldID, blnHide)
		 {
			var objFieldCaption = document.getElementById("MqFC_"+lngFieldID);
			var objField = document.getElementById("MqF_"+lngFieldID);
			if(objFieldCaption && objField){
				if(blnHide){
					objFieldCaption.style.display="none";
					objField.style.display="none";
				}else{
					objFieldCaption.style.display="";
					objField.style.display="";
				}
			}
		 }
		 
		 function SetFieldValue(lngFieldID, varValue)
		 {
			var objFormElement=new CMqFormElement();
			var objField = document.getElementById(lngFieldID);
			
			if(objField){
				objFormElement.Initialize(lngFieldID,objFormElement.GetControlType(objField),document);
				objFormElement.SetValue(varValue);
				ValueChanged(lngFieldID);
			}
		 }
		 
		 
		 function GetFieldValue(lngFieldID)
		 {
			var retVal="";
			
			var objFormElement=new CMqFormElement();
			var objField = document.getElementById(lngFieldID);
			if(objField){
				objFormElement.Initialize(lngFieldID,objFormElement.GetControlType(objField),document);
				retVal=objFormElement.GetValue();
			}
			return retVal;
		 }
		 
		 function OnCheck_IsRequired()
		 {
		 	if(GetFieldValue(10)==true){
				SetFieldValue(18, true);
				DisableField(18, true);
				
				SetFieldValue(FIELD_ID_RO_GROUPS, "");
				DisableField(FIELD_ID_RO_GROUPS, true);
				DisableButton(FIELD_ID_RO_GROUPS, true);
			}else{
				DisableField(18, false);
				
				DisableField(FIELD_ID_RO_GROUPS, false);
				DisableButton(FIELD_ID_RO_GROUPS, false);
			}
		 }
		 
		 function OnCheck_IsReadOnly()
		 {
		 	if(GetFieldValue(FIELD_ID_IS_READONLY)==true){
				SetFieldValue(FIELD_ID_RO_GROUPS, "");
				DisableField(FIELD_ID_RO_GROUPS, true);
				DisableButton(FIELD_ID_RO_GROUPS, true);
			}else{				
				DisableField(FIELD_ID_RO_GROUPS, false);
				DisableButton(FIELD_ID_RO_GROUPS, false);
			}
		 }
		 
		 function DisableButton(strFieldName, blnDisabled)
		 {
			var objElementButton=document.getElementById(m_objMqButton.GetButtonHTMLName(strFieldName + "_SelVal"));
			
			if(objElementButton){
				if(blnDisabled){
					m_objMqButton.Disable(objElementButton);
				}else{
					m_objMqButton.Enable(objElementButton);
				}
			}
		 }
		 
		 function HandleDisplayFlag()
		 {
			var objDisplayCaption=document.getElementById(FIELD_ID_DISPLAY_CAPTION);
			if(objDisplayCaption){
				if(objDisplayCaption.value!=""){
					m_blnCaptionSet=true;
				}
			}
		 }
		 
		 function ValidateValues()
		 {
			var blnReturn=true;
			
			var objCaption=document.getElementById(FIELD_ID_LABEL_CAPTION);
			if(objCaption){
				if(ContainsNonAsciiChars(objCaption.value)){
					alert(g_MqRef.RESX["FLD_EDITOR.CAPTION_ONLY_ASCII"]);
					objCaption.focus();
					blnReturn=false;
				}
			}
			
			if (blnReturn)
			{
				
				if (m_objLoadDataMgr.FieldsChanged()[FIELD_ID_FIELD_VALUE_TABLE])
				{
					blnReturn=confirm(g_MqRef.RESX["FLD_EDITOR.CONFIRM_CHOICE_TABLE_CHANGE"]);
				}
			}
			return blnReturn;
		 }
		 
		 function ContainsNonAsciiChars(strString)
		 {
			var blnReturn=false;
			var strTemp;
			for (var x=0; x<strString.length;x++){
				strTemp=strString.substr(x,1);
				if (strTemp.toString().charCodeAt(0)>127){
					blnReturn=true;
					break;
				}				
			}
			return blnReturn;
		 }

	</script>
</head>
<iframe id="ifraCal" style="position:absolute;visibility:hidden;width:150px;height:170px;padding:0px;z-index:10;" frameborder="1"></iframe>
<iframe id="ifrAutoSuggest" src="blank.htm" style="position: absolute;width: 400px; height: 181px;z-index: 16;display: none; border: 1px solid gray;overflow: none" frameborder="0" ></iframe>
<body class="ToolbarBody" style="margin:0px" onload="OnLoadBody()" onclick="m_objAutoSuggest.Hide()" onunload="OnBeforeNavigate();" onbeforeunload="return WindowClosing()" onkeypress="KeyPressed(event)" onresize="m_objAutoSuggest.Reposition()">

	<table width="100%" height="30" class="HeaderTop" marginwidth="0" cellpadding="0" cellspacing="0" border="0">	
		<tr>
			<td width="100%" align="left">
				<div id="HeaderText" class="SmallHeaderText">Add Field</div>
			</td>
		</tr>
	</table>
				
<table width="98%" style="margin-left:10px; margin-right:10px;table-layout: fixed">

<tr>
	<td width="20%" class="requiredfield">Field Caption:</td>
	<td width="30%"style="padding-top:5px">
		<input type="text" name="8" id="8" class="TextBoxWidth" 
			onmouseover="this.className='TextBoxWidthHover';" onmouseout="this.className='TextBoxWidth';" 
			maxlength="255" onchange="DataChanged(FIELD_ID_LABEL_CAPTION)" onkeyup="SetDisplayCaption()" onblur="HandleDisplayFlag()">
	</td>	
	<td width="20%" class="requiredfield">Caption in Forms:</td>
	<td width="30%"style="padding-top:5px">
		<input type="text" name="20" id="20" class="TextBoxWidth" 
			onmouseover="this.className='TextBoxWidthHover';" onmouseout="this.className='TextBoxWidth';" 
			maxlength="255" onchange="DataChanged(FIELD_ID_DISPLAY_CAPTION)">
	</td>	
</tr>
<tr>
	<td valign="top" class="normalfield" style="padding-top:5px">Tab:</td>
	<td style="padding-top:5px" colspan="3">
		<select id="23" class="SpanTwoWidthOne" onchange="DataChanged(23)">
			<WC@CLV23>nDestinationTabID</WC@CLV23>
        </select>
	</td>
</tr>
<tr>
	<td colspan="4" >
		<div class="HorDividerLine" style="width:95%"></div>
	</td>
</tr>
<tr>
	<td id="MqFC_3" valign="top" class="disabledfield" style="padding-top:5px">Stored in DB:</td>
	<td id="MqF_3" style="padding-top:5px">
		<div name="3" id="3" class="readOnlyStyle"> </div>
	</td>
	<td id="MqFC_2" valign="top" class="disabledfield" style="padding-top:5px">Stored in Table:</td>
	<td id="MqF_2" style="padding-top:5px">
		<div name="2" id="2" class="readOnlyStyle"> </div>
	</td>
</tr>
<tr>
	<td id="MqFC_1" width="20%" class="disabledfield">Field ID:</td>
	<td id="MqF_1" style="padding-top:5px">
		<div name="1" id="1" class="readOnlyStyle"> </div>
	</td>
	<td id="MqFC_4" width="20%" class="disabledfield">Field Name:</td>
	<td id="MqF_4" style="padding-top:5px" colspan="3">
		<div name="4" id="4" class="readOnlyStyle"> </div>
	</td>
</tr>
<tr>
	<td valign="top" class="normalfield" style="padding-top:5px">Data Type:</td>
	<td style="padding-top:5px">
		<select id="6" class="ComboBoxWidth" onchange="OnDataTypeChanged();DataChanged(6)">
			<WC@CLV6>nDataType</WC@CLV6>
        </select>
	</td>
	<td valign="top" class="normalfield" style="padding-top:5px">Data Size:</td>
	<td style="padding-top:5px">
		<input type="text" name="7" id="7" class="TextBoxWidth" 
			onmouseover="this.className='TextBoxWidthHover';" onmouseout="this.className='TextBoxWidth';" 
			maxlength="255" onchange="DataChanged(7)">
	</td>
</tr>
<tr>
	<td id="MqFC_11" valign="top" class="normalfield" style="padding-top:5px">Choice Table:</td>
	<td id="MqF_11" style="padding-top:5px" valign="top">
		
		<div  class='FieldWithButton'>
			<input type="text" name="11" id="11" class="TextBoxWidth" style='position:absolute;width: 76%;'
			onmouseover="this.className='TextBoxWidthHover';" onmouseout="this.className='TextBoxWidth';" 
			maxlength="255" onchange="DataChanged(11)"></input>
			<script type='text/javascript'>AddURLButton('LoadLargeListOrCombo(11, \'Choice Table\',\'WCDisplayChoices.asp?WCI=DisplayChoices&TBL=tblDtsFieldValueTables%3BtblDtsFieldValueTables&DS=64%3B16&CO=0%3B0&AddFld=%27No%27%20AS%20IsGlobal%3B%27Yes%27%20AS%20IsGlobal\',\'tblDtsFieldValueTables\')','BrowseAlternateChoiceList','11','11');</script>
		</div>
		<input type="hidden" name="12" id="12" onchange="DataChanged(12)"></input>
	</td>
</tr>
<tr>
	<td id="MqFC_24" valign="top" class="normalfield" style="padding-top:5px">Choice Table Where:</td>
	<td id="MqF_24" style="padding-top:5px;" colspan="3">
		<input type="text" rows="3" name="24" id="24" class="TextBoxWidth" style='width:95%;'
			onmouseover="this.className='TextBoxWidthHover';" onmouseout="this.className='TextBoxWidth';" 
			maxlength="255" onchange="DataChanged(24)">
	</td>

</tr>
<tr>
	<td id="MqFC_MISSING VALUE" valign="top" style="pad-ding-top:5px" data-balloon-pos="right" data-balloon-length="large"
	data-balloon="Default field values automatically insert the value of the field when a new record is created. You can use exact values or a formula. Exact values can be numbers, text, etc: “45”, “Enter text here”. Formulas can &nbsp;&nbsp;&nbsp; (1) Use the value of another field in the same record:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<F.ID:Owner>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (2) Use a macro:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <Today>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  (3) Use a combination of macros:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<Asset Type Abbrev><Asset Type Count>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
	>	<font  class="normalfield">Default Value:</font></td>
	
	<td style="padding-top:5px" colspan="3">
		<input type="text" name="32" id="32" class="MemoFieldWidth" 
			onmouseover="this.className='MemoFieldWidth';" onmouseout="this.className='MemoFieldWidth';" 
			maxlength="255" onchange="DataChanged(32)">
	</td>
</tr>
<tr>
	<td colspan="4" >
		<div class="HorDividerLine" style="width:95%" ></div>
	</td>
</tr>
<tr>
	<td id="MqFC_29" valign="top" class="disabledfield" style="padding-top:5px">ID Field Name:</td>
	<td id="MqF_29" style="padding-top:5px">
		<div name="29" id="29" class="readOnlyStyle"> </div>
	</td>
	<td id="MqFC_30" valign="top" class="disabledfield" style="padding-top:5px">Value Field Name:</td>
	<td id="MqF_30" style="padding-top:5px">
		<div name="30" id="30" class="readOnlyStyle"> </div>
	</td>
</tr>
<tr >
	<td id="MqFC_27" valign="top" class="disabledfield" style="padding-top:5px">Container Type:</td>
	<td id="MqF_27" style="padding-top:5px">
		<div name="27" id="27" class="readOnlyStyle"> </div>
	</td>
	<td id="MqFC_28" valign="top" class="disabledfield" style="padding-top:5px">Control Type:</td>
	<td id="MqF_28" style="padding-top:5px">
		<div name="28" id="28" class="readOnlyStyle"> </div>
	</td>
</tr>
<tr>
	<td colspan="4" >
		<div class="HorDividerLine" style="width:95%" ></div>
	</td>
</tr>
<tr>
	<td valign="top" class="normalfield" style="padding-top:5px">Is Required:</td>
	<td width="30%" style="padding-top:5px">
		<input type="checkbox" name="10" id="10" onclick="OnCheck_IsRequired(); DataChanged(10)">
	</td>
	<td valign="top" class="normalfield" style="padding-top:5px">Show in Choice Lists:</td>
	<td width="30%" style="padding-top:5px">
		<input type="checkbox" name="15" id="15" onclick="DataChanged(15)">
	</td>
</tr>
<tr>
	<td valign="top" class="normalfield" style="padding-top:5px">Is Visible:</td>
	<td width="30%" style="padding-top:5px">
		<input type="checkbox" name="18" id="18" onclick="DataChanged(18)">
	</td>
	<td valign="top" class="normalfield" style="padding-top:5px">Maintain Revision History:</td>
	<td width="30%" style="padding-top:5px">
		<input type="checkbox" name="14" id="14" onclick="DataChanged(14)">
	</td>
</tr>
<tr>
	<td valign="top" class="normalfield" style="padding-top:5px">Is Read-Only:</td>
	<td width="30%" valign="top" style="padding-top:5px">
		<input type="checkbox" name="13" id="13" onclick="OnCheck_IsReadOnly();DataChanged(FIELD_ID_IS_READONLY)">
	</td>
	<td valign="top" class="normalfield" style="padding-top:5px">Read-Only For:</td>
	<td width="30%" style="padding-top:5px">
		<div class="FieldWithButton">
			<textarea  class='LargeList' mqcontroltype='LargeList' multiline readonly style="height:60px;"  name='999' id='999' width='30' onchange="DataChanged(FIELD_ID_RO_GROUPS)"></textarea>
			<script type='text/javascript'>
				AddURLButton('LoadLargeListOrCombo(' + FIELD_ID_RO_GROUPS + ', \'Groups\',\'WCDisplayChoices.asp?WCI=DisplayChoices&TBL=tblGroup&DS=16&CO=0\',\'tblGroups\', null, null, null, null, null, null, true)','BrowseAlternateChoiceList',FIELD_ID_RO_GROUPS,FIELD_ID_RO_GROUPS, null, m_objRef);
			</script>
		</div>
	</td>
</tr>
<tr>
	<td colspan="4" >
		<div class="HorDividerLine" style="width:100%" ></div>
	</td>
</tr>
<tr>
	<td colspan="4" >
	<div style="float:right">
		<script type="text/javascript">
		document.write(m_objMqButton.GetTextButtonHTML("Close",g_MqRef.RESX['BUTTON_CLOSE'],"CloseWindow();","", null, "", g_MqRef.RESX['BUTTON_CLOSE_TT']));
		</script>
	</div>
	<div style="float:right;margin-right:10px">
		<script type="text/javascript">												
		document.write(m_objMqButton.GetTextButtonHTML("Ok",g_MqRef.RESX['BUTTON_OK'],"SaveField();","", null, "", g_MqRef.RESX['BUTTON_OK_TT']));
		</script>
	</div>
	</td>
</tr>

</table>
<input type="hidden" name="txtUploadDir" id="txtUploadDir" value=""> 

<div style="visibility: hidden;display:none">
		<div id="dialog-modal" style="width:100%;height:100%;padding:0px;margin:0px;overflow:hidden">
			<iframe id="dialog-modal-url" width="100%" height="100%" marginWidth="0" marginHeight="0" frameBorder="0" scrolling="auto"></iframe>
		</div>
		<div id="dialog-modal-orig-width" name="dialog-modal-orig-width" style="display:none"></div>
		<div id="dialog-modal-orig-height" name="dialog-modal-orig-height" style="display:none"></div>
	</div>
</body>
</html>