
function showMailFriendForm(url)
{
	showLayer('processUpdateMailFriendForm');
    new Ajax.Updater({success:'mailFriendFromDiv'}, url,
    {
        onComplete:function()
        {
            Element.hide('mailFriendFromDiv');
			hideLayer('processUpdateMailFriendForm');
            new Effect.Appear('mailFriendFromDiv',
            {
                duration:0.5
            }
                    )
        },
        method:'get',
        evalScripts:true,
        asynchronous:true
    }
            );
}

function cancelMailFriendForm()
{
    var d = $('mailFriendFromDiv');
    d.innerHTML = '';
}
function validateMailFriendFrom()
{
    var vErrors = "";
    var mailFriend = document.mailFriend;

    if (mailFriend.toName.value == null || mailFriend.toName.value == '')
    {
        vErrors = vErrors + '- <spring:message code="componentMessages.mailFriend.error.toName" />\n';
    }
    if (mailFriend.fromName.value == null || mailFriend.fromName.value == '')
    {
        vErrors = vErrors + '- <spring:message code="componentMessages.mailFriend.error.fromName" />\n';
    }
    if (mailFriend.fromAddress.value == null || mailFriend.fromAddress.value.indexOf('@') == -1)
    {
        vErrors = vErrors + '- <spring:message code="componentMessages.mailFriend.error.fromEmail" />\n';
    }
    if (mailFriend.toAddress.value == null || mailFriend.toAddress.value.indexOf('@') == -1)
    {
        vErrors = vErrors + '- <spring:message code="componentMessages.mailFriend.error.toEmail" />\n';
    }

    if (vErrors != "")
    {
        window.alert(vErrors)
    }
    else
    {
        mailFriend.submit();
    }
}

function processMailFriendForm()
{
    showLayer('processUpdateMailFriendForm');
	var div = $('mailFriendFromDiv');
    //document.insertReactionForm.submitreaction.disabled = true;
    var form = $('mailFriendFrom');
    var params = Form.serialize(form);
    new Ajax.Updater({success:div},
            form.action,
    {
        onComplete:function()
        {
            Element.hide(div);
			hideLayer('processUpdateMailFriendForm');
            new Effect.Appear(div);
            duration:0.5
        },
        asynchronous:true,
        parameters:params
    });

}
