
/**
Function adds smilie shortcut to the textbox with id = posting_text
*/
function sm(smilie_shortcut)
{
    $("posting_comment").value = $("posting_comment").value + smilie_shortcut;
}

function checkPosting()
{
    var name_check    = checkPostingName();
    var comment_check = checkPostingComment();

    if (name_check == true && comment_check == true) {
        return true;
    }
    else {
        return false;
    }
}

function checkPostingComment()
{
    if ($("posting_comment").value.blank() == true) {
        alert("Du musst schon einen Eintrag schreiben!");
        return false;
    }
    return true;
}

function checkPostingName()
{
    if ($("posting_name").value.blank() == true) {
        alert("Zumindest einen Namen solltest du angeben!");
        return false;
    }
    return true;
}

function clearElement(object, val)
{
    if (object.value == val) {
    	object.value = "";
    }
}

function checkNlSubscribe()
{
	$("nl_response").update('<div style="text-align:center;"><img src="/images/progress.gif" alt="progressicon" /></div>');
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	email = document.forms["nl_form"].elements["nl_email"].value;
	name  = document.forms["nl_form"].elements["nl_name"].value;
	if(reg.test(email) == false) {
		alert('Ungültige Email Adresse!');
		document.forms["nl_form"].elements["nl_email"].focus();
		document.forms["nl_form"].elements["nl_email"].value = email;
	} else {
		var request = new Ajax.Request(
				"/subscribenl",
				{
                    method      : "post",
                    parameters  :
                    {
                        "email" : email,
                        "name"  : name
                    },
                    onSuccess   : nlResponse
                }
            );
	}
	return false;
}

function nlResponse(transport) {
    $("nl_response").update(transport.responseText);
}

