function forwardTo(aid, url){
    var form = $('forwardto_' + aid);

    if (valid_alphanum(form.friends_name.value) && valid_email(form.friends_email.value)){ 
        var params = [];
        params.push('aid=' + form.aid.value);
        params.push('ptid=' + form.ptid.value);
        params.push('url=' + encodeURIComponent(form.url.value));
        params.push('friends_email=' + encodeURIComponent(form.friends_email.value));
        params.push('friends_name=' + encodeURIComponent(form.friends_name.value));

        new Ajax.Request(url, {
            method: 'post',
            parameters: params.join('&'),
            onComplete: function(req){
                var resp = req.responseText;
                if(resp.indexOf('<status>invalid') != -1){
                    alert('An error ocurred.'); // will never happend
                }
                else if(resp.indexOf('<status>fail') != -1){
                    alert('We are experiencing technical difficulties and cannot send your email at this time. Please try again later or contact the webmaster for assistance.');
                }
                else if(resp.indexOf('<status>sent') != -1){
                    alert('Your email has been sent to ' + form.friends_name.value + ', click on "Forward to a friend" to send another');
                    try{
                        form.friends_email.value = '';
                        form.friends_name.value = '';
                        togglediv('emailform_' + aid);
                    } catch(e){;}
                }
            }
        });
    } 
    else{ 
        alert('Please enter both the name and valid email address in the boxes provided.'); 
    }
    return false;
}
