	/*
	 * File 	checks.js 
	 * 
	 * Description	Form Validation Functions + AJAX POST
	 *
	 * Author	Dragos Dobrota
	 */
	var error = false;
	
	// Checks if there is a valid email address (not empty and w/ '@')
	function verifyData(){
		var obj = this.FormEmailNotify.email
		error = false;
		if (obj.value.length == 0){
			displayError(obj, 'Please enter an e-mail address!');
			return false;
		}
		if (obj.value.indexOf("@", 1) == -1) {
			displayError(obj, 'Please enter a valid e-mail address!');
			return false;
		}
		return !error;
	}
		
	function displayError(elem, msg){
		if (error)
			return;
		 window.alert(msg);
 		 elem.select();
    	 elem.focus();
		 error = true;
	}


    function processNotification() {
        if ( !verifyData() ) // do some checks
            return false;
        // send the request
        new Ajax.Request("scripts/DictionaryEmailAddNotifyAddress.php",
            { 
            method: 'post', 
            postBody: 'email='+ $F('email'),
            onComplete: showResponse 
            });
        }

    function showResponse(req){ // display the results
        $('notificationShow').innerHTML= req.responseText;
        setInterval(removeNotification, 5000); // after 5 seconds clear the text
    }

    function removeNotification() {
        $('notificationShow').innerHTML = "";
    }


