/*
by slim. provides javascript action for newsletter_subscribe_form.asp
*/

function newsletter_subscribe() {
	var elm, email, name;

	email = "";
	name = "Abonat";

	//get email
	elm = jQuery("#nsf_email");
	if (elm != null)
		if (elm.val() != elm.attr("title"))
		email = elm.val();

	if (email == "") {
		alert("Trebuie sa completezi adresa ta de Email!");
		return false;
	}

	//get name
	elm = jQuery("#nsf_name");
	if (elm != null)
		if (elm.val() != elm.attr("title"))
		name = elm.val();

	//waiting...
	elm = jQuery("#nsf_waiting");
	if (elm != null) {
		elm.css("display", "block");
		elm = jQuery("#nsf_fields");
		if (elm != null)
			elm.css("display", "none");
	}

	//ajax
	var dat = new Date();
	jQuery.get("newsletter_subscribe.asp", { eml: email, nme: name, tm: dat.getTime() }, function(data) {
		if (data == "51180") {
			//success
		} else {
			//failed
		}

		elm = jQuery("#nsf_waiting");
		if (elm != null)
			elm.css("display", "none");

		elm = jQuery("#nsf_confirmed");
		if (elm != null)
			elm.css("display", "block");

	});
	return false;
}
