function OnLoadForm()
{
	window.resizeTo(450,220);
	
	var objTxtColor=document.getElementById("txtColor");
	
	if(objTxtColor){
		objTxtColor.value=m_strColorVal;
		window.resizeBy(0,200);
	}
	
	var objCboType=document.getElementById("cboType");
	
	if(objCboType){
		var lngCount;
		for(lngCount=0; lngCount<objCboType.options.length; lngCount++){
			if(objCboType.options[lngCount].value==m_lngTypeVal){
				objCboType.options[lngCount].selected=true;
			}
		}
		window.resizeBy(0,50);
	}
	
	var objDepValCaption=document.getElementById("DepValCaption");
	if(objDepValCaption){
		objDepValCaption.innerHTML=mstrDepValFldCaption;
	}
	
	var objDepValList=document.getElementById("DepValList");
	if(objDepValList){
		objDepValList.innerHTML="<select name='cboDepVal' id='cboDepVal' class='AdminComboBoxWidth'>" +
									mstrDepValOptions + "</select>";
	}
	
	var objCboDepVal=document.getElementById("cboDepVal");
	if(objCboDepVal){
		var lngCount;
		for(lngCount=0; lngCount<objCboDepVal.options.length; lngCount++){
			if(objCboDepVal.options[lngCount].value==m_lngDepVal){
				objCboDepVal.options[lngCount].selected=true;
			}
		}
	}
	
	SetColor();
	
	SetFocus();
}

function SetFocus()
{
    var objTxtInput=document.getElementById("renameRow");
	
	if(objTxtInput){
		objTxtInput.focus();
	}
}

function SetColor()
{
	var objColorSample=document.getElementById("ColorSample");
	var objTxtColor=document.getElementById("txtColor");
	var objType=document.getElementById("cboType");
	
	if(objColorSample){
		if(objTxtColor){
			if(objType){
				try{
					objColorSample.style.background=objTxtColor.value;
					
				}catch(e){
					alert(MSG_INVALID_COLOR);
					objTxtColor.focus();
					return false;
				}
				var lngType=objType.options[objType.selectedIndex].value;
					
				if(lngType=="1"){
					objColorSample.innerHTML="<img src='../../../theme/images/images/flag.gif'>";
					objColorSample.style.border="1px solid #000000";
					objColorSample.style.width="20px";
					objColorSample.style.height="16px";
					
				}else{
					objColorSample.innerHTML="Text";
					objColorSample.style.background="transparent";
					objColorSample.style.color=objTxtColor.value;
					objColorSample.style.border="none";
				}
			}
		}
	}
}

function Pressed(e)
{
    if(e.keyCode == 13){
		RenameRow();
	}else{
		if(e.keyCode == 27){
			opener.CloseChildWindow(WIN_RENAME_ROW);
		}
	}
} 

function RenameRow()
{
	var objTxtRenameRow=document.getElementById("renameRow");
	if(objTxtRenameRow){
		var strValue=objTxtRenameRow.value;
		if (strValue === ""){
		    window.alert(MSG_ENTER_CHOICE);
		    SetFocus();
		}else{
			var objAppTable=opener.mobjTable;
			var objRequest=opener.mobjHTTPrequest;
			var strProj = opener.GetProject();
			var strTableToRenameRow = opener.GetTable();
			var strOldRowID = escape(opener.GetSelectedItem(0));
			var strNewRow = g_MqRef.MqStr.MqEncodeURIComponent(strValue);
			var strColor="";
			var lngType=0;
			var lngDepVal=0;
			
			var objTxtColor=document.getElementById("txtColor");
			if(objTxtColor){
				strColor=g_MqRef.MqStr.MqEncodeURIComponent(objTxtColor.value);
			}
			
			var objCboType=document.getElementById("cboType");
			if(objCboType){
				lngType=objCboType.options[objCboType.selectedIndex].value;
			}
			
			var objCboDepVal=document.getElementById("cboDepVal");
			if(objCboDepVal){
				lngDepVal=objCboDepVal.options[objCboDepVal.selectedIndex].value;
			}
			
			var strCurrentLocation=opener.mstrCurrentLocation;
			var strMessage=objRequest.Get(strCurrentLocation + "WCMQeDict.ASP?WCI=eDictRenameRow&Proj=" 
						+ strProj + "&TableName=" + strTableToRenameRow + "&OldFieldID=" + strOldRowID 
						+ "&NewFieldValue=" + strNewRow + "&Color=" + strColor + "&Type=" + lngType + "&DepVal=" + lngDepVal);
	
			if (strMessage==VALUE_RENAMED_MSG){
				opener.GetFieldListByTable();
				opener.CloseChildWindow(WIN_RENAME_ROW);
			}else{
				if(strMessage!=HTTP_REQ_CANCEL_PROCESS){
					alert(strMessage);
				}
			}
		}
	}
}

