function showFormEnviar(form) {
	var ck = 0;
	for (var i=0; i<form.childNodes.length; i++) {
		if (form.childNodes[i]["id"] && 
			form.childNodes[i]["id"] == "sendTable") {
			form.childNodes[i].style.display = form.childNodes[i].style.display == '' ? 'none' : '';
			ck = 1;
			break;
		}
	}
	if (ck == 0) {
		obj = new formEnviar(form);
		obj.build();
	}
}
function formEnviar(form) {
	this.form = form;
	this.fields = new Array();
	this.addField("Meu nome", "name", "text", Get_Cookie("nome_user_restrito"));
	this.addField("Meu email", "from", "text", Get_Cookie("email_user_restrito"));
	this.addField("Enviar para", "to", "text");
	this.addField("Mensagem", "mymsg", "textarea");
	this.addField("", "", "button", "Enviar");
}
formEnviar.prototype.addField = function(label, name, type, value) {
	ix = this.fields.length;
	this.fields[ix] = new Array();
	this.fields[ix]["label"] = label;
	this.fields[ix]["name"] = name;
	this.fields[ix]["type"] = type;
	this.fields[ix]["value"] = value ? value.replace("+", " ") : "";
}
formEnviar.prototype.build = function() {
	table = document.createElement("TABLE");
	table.id = "sendTable";
	table.className = "texto";
	table.style.border = "1px solid gray";
	table.bgColor = "white";
	table.width = "100%";
	this.form.appendChild(document.createElement("P"));
	this.form.appendChild(table);
	var tbody = document.createElement("TBODY");
	table.appendChild(tbody);
	for (var i=0; i<this.fields.length; i++) {
		var tr = document.createElement("TR");
		tbody.appendChild(tr);
		var td = document.createElement("TD");
		td.style.padding = "10px";
		td.style.paddingRight = "0px";
		if (i > 0) td.style.paddingTop = "0px";
		td.vAlign = "top";
		td.noWrap = true;
		td.appendChild(document.createTextNode(this.fields[i]["label"] + (this.fields[i]["label"] != "" ? ":" : "")))
		tr.appendChild(td);
		var td = document.createElement("TD");
		td.style.padding = "10px";
		if (i > 0) td.style.paddingTop = "0px";
		td.width = "100%";
		tr.appendChild(td);
		if (this.fields[i]["type"] == "textarea") {
			var input = document.createElement("TEXTAREA");
			input.rows = 4;
		} else {
			var input = document.createElement("INPUT");
			input.type = this.fields[i]["type"];
			input.style.maxWidth = "200px";
		} 
		if (this.fields[i]["type"] == "button") {
			th = this;
			input.onclick = function() { th.ckForm(); }
			input.className = "submit";
		} else {
			input.className = "form";
			input.style.width = "100%";
		}
		input.name = this.fields[i]["name"];
		input.value = this.fields[i]["value"];
		td.appendChild(input);
	}
}
formEnviar.prototype.ckForm = function() {
	var msg = "";
	for (var i=0; i<this.fields.length; i++) {
		if (this.fields[i]["name"] != "") {
			var val = this.getFieldVal(this.fields[i]["name"]);
			if (val == "")
				msg += "O campo " + this.fields[i]["label"].toUpperCase() + " deve ser preenchido.\n";
			else if ((this.fields[i]["name"] == "from" || this.fields[i]["name"] == "to") &&
				!this.ckMail(val))
				msg += "O campo " + this.fields[i]["label"].toUpperCase() + " foi preenchido com um e-mail inválido.\n";
		}
	}
	if (msg != "")
		alert(msg)
	else
		this.form.submit();
}
formEnviar.prototype.getFieldVal = function(name) {
	if (document.all) {
		for (var i=0; i<this.form.length; i++) {
			if (this.form[i].name == name) {
				return this.form[i].value;
				break;
			}
		}
	} else
		return this.form[name].value;
}
formEnviar.prototype.ckMail = function(email) {
	ER = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,64}(\.[a-z0-9-]{2,64})*\.[a-z]{2,4}$");
	return ER.test(email);
}