function checkLength(o,min,max) {

			if ( o.val().length > max || o.val().length < min ) {
				o.addClass('ui-state-error');
				updateTips("Length of " + n + " must be between "+min+" and "+max+".");
				return false;
			} else {
				return true;
			}

		}

$(document).ready(function(){
  $(".gallery a").flyout();
  
  
  
  $("#dialog").dialog({
			bgiframe: true,
			autoOpen: false,
			height:450,
      width:400,
			modal: true,
			buttons: {
				'Lähetä': function() {
              $.post("send.php", {
                nimi : $("#name").val(),
                yritys : $("#yritys").val(),
                puhelinnumero : $("#puhelinnumero").val(),
                email : $("#email").val(),
                osoite : $("#osoite").val(),
                viesti : $("#viesti").val() });
                    $(this).dialog('close');
                    $('#dialog2').dialog('open');
					
				},
				"Peruuta": function() {
					$(this).dialog('close');
				}
			}
		});
		
		$("#dialog2").dialog({
			bgiframe: true,
			modal: true,
      autoOpen: false,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
		
  $('.palaute').click(function() {
    $('#dialog').dialog('open');
  });



})





























