// JavaScript Document
function send_form(name) {
	var n = document.getElementById(name+'_name').value;
	var e = document.getElementById(name+'_mail').value;
	var d = document.getElementById(name+'_description').value;
	if (n == "" || e == "" || d == "") {
		alert("Please complete the form before submitting!");
		return false;
	}
	validate_email(e);
	ajax_send(name);
	
}

function validate_email(email) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(address) == false) {
		alert('Please enter a valid email address!');
		return false;
   	}
}

function ajax_send(name) {
	new Event(e).stop();
 	var id = name+'_msg';
	/**
	 * This empties the log and shows the spinning indicator
	 */
	var log = $(id).empty().addClass('loader');
 
	/**
	 * send takes care of encoding and returns the Ajax instance.
	 * onComplete removes the spinner from the log.
	 */
	this.send({
		update: log,
		onComplete: function() {
			log.removeClass('loader');
		}
	});
}

function send_to(name)  {
	var get = name;
	var sym = '@';
	var url = window.location.hostname;
	url = url.replace(/www./,'');
	
	var str = name + sym + url;
	window.location = 'mailto:'+str;
}
	