jQuery(document).ready(function($) {
	swapValue = [];
	$(".swap-value").each(function(i){
	   swapValue[i] = $(this).val();
	   $(this).focus(function(){
		  if ($(this).val() == swapValue[i]) {
			 $(this).val("");
		  }
		  $(this).addClass("focus");
	   }).blur(function(){
		  if ($.trim($(this).val()) == "") {
			 $(this).val(swapValue[i]);
		 $(this).removeClass("focus");
		  }
	   });
	});
	
	$("#rtms_contacts_save").validate({
		rules: {
			rtms_title: {
				required: true
			},
			rtms_fname: {
				required: true,
				minlength: 3,
				lettersonly: true
			},
			rtms_lname: {
				required: true,
				minlength: 3,
				lettersonly: true
			},
			rtms_position: {
				required: true,
				minlength: 3
			},
			rtms_company: {
				required: true,
				minlength: 5
			},
			rtms_email: {
				required: true,
				email: true
			},
			rtms_telephone: {
				required: false,
				minlength: 6,
				integer: true
			},
			rtms_message: {
				required: true,
				minWords: 5
			}	
		}
	});
	

	
});

function rtms_contacts_submit(url) 
{	
	
	var str = "rtms_title=" + encodeURI(jQuery("#rtms_title").val()) + "&rtms_fname=" + encodeURI(jQuery("#rtms_fname").val()) + "&rtms_lname=" + encodeURI(jQuery("#rtms_lname").val()) + "&rtms_position=" + encodeURI(jQuery("#rtms_position").val()) + "&rtms_company=" + encodeURI(jQuery("#rtms_company").val()) + "&rtms_email=" + encodeURI(jQuery("#rtms_email").val()) + "&rtms_telephone=" + encodeURI(jQuery("#rtms_telephone").val()) + "&rtms_message=" + encodeURI(jQuery("#rtms_message").val());
	
	//alert(str);
	
	jQuery.ajax({
		type: "POST",
		url: url + "rtms-contacts-save.php",
		async: true,
		data: str,
		success: function(msg) {
			alert("Kontaktanfrage wurde gespeichert.");
		}
	});	
	
	
}
