function DoJSPopup(strURL,strWindowName,intWidth,intHeight)
{
    if (intWidth == null)
        intWidth = 600;
    if (intHeight == null)
        intHeight = 600;
    if (strWindowName == null)
        strWindowName = "jswindow";

    var objPopupWindow = window.open(strURL, strWindowName, 'toolbar=yes,location=no,resizable=yes,status=yes,scrollbars=yes,width='+intWidth+',height='+intHeight);
    objPopupWindow.focus();
}

function DoJSToolPopup(strURL,strWindowName,intWidth,intHeight)
{
    if (intWidth == null)
        intWidth = 600;
    if (intHeight == null)
        intHeight = 600;
    if (strWindowName == null)
        strWindowName = "jswindow";

    var objPopupWindow = window.open(strURL, strWindowName, 'toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width='+intWidth+',height='+intHeight);
    objPopupWindow.focus();
}

function CheckCategorySelection(objSelect, strSubCategorySelectName)
{
	var strID = objSelect.id;
	var objSubCategorySelect = null;
	
	var objSubCategorySelectList = document.getElementsByName(strSubCategorySelectName);
	
	for (var i=0; i<objSubCategorySelectList.length; i++)
	{
		objSubCategorySelect = objSubCategorySelectList[i];
		if (objSubCategorySelect.id == (strID+objSelect.value))
		{
			objSubCategorySelect.disabled = false;
			objSubCategorySelect.style.display = "inline";
		}
		else
		{
			objSubCategorySelect.disabled = true;
			objSubCategorySelect.style.display = "none";
		}
	} 
}

function UpdateMakePrivateField(intFieldNumber)
{
    var objTextInput = document.getElementById("txtField" + intFieldNumber);
    var objChkInput = document.getElementById("chkField" + intFieldNumber);
    var objHiddenInput = document.getElementById("hiddenField" + intFieldNumber);
    
    var strTxtValue = trim(objTextInput.value);
    objHiddenInput.value = strTxtValue.replace(",","@@comma@") + "," + (objChkInput.checked ? 1 : 0);
}

function trim(str)
{
	return str.replace(/^\s*|\s*$/g,"");
}

var intValidateTextFieldTimeout = 0;

function ValidateTextFieldHandler(event) {
    var txtField = event.element();
    if (intValidateTextFieldTimeout > 0) {
        window.clearTimeout(intValidateTextFieldTimeout);
        intValidateTextFieldTimeout = 0;
    }
    intValidateTextFieldTimeout = window.setTimeout("ValidateTextField('" + txtField.id + "');", 300);
}

function ValidateTextField(fieldID) {
    var txtField = $(fieldID);
    var maxlength = Number(Element.readAttribute(txtField, "maxlength"));
    var notificationfieldID = Element.readAttribute(txtField, "notificationfield");
    var notificationfield = $(notificationfieldID);

    if (txtField.value.length > maxlength) {
        txtField.value = txtField.value.substr(0, maxlength);
    }

    notificationfield.innerHTML = (maxlength - txtField.value.length);
}

