function feedadmin_select() {
    document.getElementById("feedadmin_select").style.display = 'inline';
}

function feedadmin_unselect() {
    document.getElementById("feedadmin_select").style.display = 'none';
} 

function feedadminemail() {

		var number = $( "#numbere" ),
            comment = $( "#commente" ),
			name = $("#namee"),
			email = $("#emaile"),
			phone = $("#phonee"),
			tips = $( ".validateTips" );

		function updateTips( t ) {
			tips
				.text( t )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				tips.removeClass( "ui-state-highlight", 1500 );
			}, 500 );
		}


		function checkRegexp( o, regexp, n ) {
			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass( "ui-state-error" );
				updateTips( n );
				return false;
			} else {
				return true;
			}
		}

		$( "#dialog-message-email" ).dialog({
			autoOpen: false,
			modal: false,
			buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
			}
		});


		$( "#feedback_support_email" ).dialog(
		{
		autoOpen: false,
		
		width: 360,
		modal: false,
		buttons: 
			{
				"Oтправить": function() 
				{
					var dialog = $( this )
					var bValid = true;
				    if (document.getElementById("feedadmin_select").style.display == 'inline') bValid = bValid && checkRegexp( comment, /^(.{10,})$/im, "Введите комментарий" ) && checkRegexp( number, /^([a-z0-9-]{5,})$/i, "Введите номер заказа или накладной" );
                    else bValid = bValid && checkRegexp( comment, /^(.{10,})$/im, "Введите комментарий" );
                    
                    
                    if ( bValid ) 
					{
						$.ajax(
						{
							  type: 'POST',
							  url: "/feedback_admin_email.php",
							  data: $("#feedback_support_email>form").serialize(),
							  success: function(data){
								  if (data.result == "ok"){
									dialog.dialog( "close" );
									$( "#dialog-message-email" ).dialog("open")} 
								   else {updateTips( "При отправке сообщения возникла ошибка" )}
							  },
							  dataType: "json"
						 });

						return false;

					}
				}
			 } 
		});

	}
