function blankParent()
{
    var parentTextBox = document.getElementById('parentPageString');
    var selectbox = document.getElementById('newSpaceKey');
    var space = selectbox.options[selectbox.selectedIndex].value;
    var currentSpace = '$generalUtil.htmlEscapeQuotes($spaceKey)';

    if(currentSpace != space)
    {
        parentTextBox.value='';
    }
    else
    {
        parentTextBox.value='$!parentPageString';
    }
}

function publishFormData(formField, containerDiv, contentDiv)
{
    var formFieldValue = '';
    if (formField.type == 'select-one')
    {
        formFieldValue = formField.options[formField.selectedIndex].text;
        }
    else
        formFieldValue = formField.value;

    if (formField.value != "")
    {
        contentDiv.innerHTML = formFieldValue;
        containerDiv.style.display = '';
    }
    else
    {
        containerDiv.style.display = 'none';
    }
}

function highlight(element)
{
    new Effect.Highlight(element,{endcolor:"#F0F0F0"});
}

// Method checks whether the captchaResponse textfield is empty.
function checkCaptchaResponse()
{
    var captchaTextField = document.getElementById('captchaResponse');

    if (captchaTextField != null && captchaTextField.value == '')
    {
        document.getElementById("captchaError").style.display = "block";
        document.getElementById("captchaResponse").focus();
        return false;
    }
    else
    {
        return true;
    }
}


/* this function will be invoced when the form gets submitted.
*/
function pageFormSubmit() 
{
    if($('location_div').style.display == 'block')
        $('locationShowing').value = 'true';

    // The permissions div may not appear if the user isn't able to assign permissions (e.g. anonymous)
    if($('permissions_div') && $('permissions_div').style.display == 'block')
        $('restrictionsShowing').value = 'true';

    if($('labels_div').style.display == 'block')
        $('labelsShowing').value = 'true';

    return checkCaptchaResponse();
}

function newsFormSubmit()
{
    return checkCaptchaResponse();
}
