Q:

How can i print modal form (popup window) with php echo function?

Ok i have next problem. When form was submitted i have two echo functions. First echo function print popup window with text "Your message has been sent", and the other one "Error. Please fill form again." That popup window (or modal, hovever) need to be activated on that echo functions, i have code when that popup window open on form submit, but i need that popup window to be "printed" on screen in echo functions, after form was submitted. Anyone? thank you brothers.
PHP:
// If everything is OK...
      if( !empty($name) && !empty($email) && !empty($message) ) {

          // ...send message:
          $from = "From: $name<$email>\r\nReturn-path: $email";
          $subject = "Message from the client.";
          mail("someone@company.gr", $subject, $message, $from);

              echo '
              <!-- Message about success -->
              <script type="text/javascript">

                  $(document).ready(function(){msg_sent()}});

              </script>
              <!-- End -->';

HTML:
<!-- HTML form -->
<form action="index.php" method="post" enctype="multipart/form-data" id="form">
<input type="text" name="name" class="ime" placeholder="Unesite Vaše ime" maxlength="25"       value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" />
  <input type="text" name="email" class="email_a" placeholder="Unesite Vaš email" maxlength="35" value="<?php
  if(isset($_POST['email'])) echo $_POST['email']; ?>" />
  <textarea name="message" class="poruka" placeholder="Vaša poruka..." value="<?php if(isset($_POST['message'])) echo $_POST['message'] ?>"></textarea>
  <input type="submit" name="submit" class="posalji" value="Pošalji" />
  </form>
  <!-- The end -->

<div id="alertBox">
        <p class="title">Congrats!</p>
        <p class="txt">Your message has been sent.</p>
        <p class="ok">OK</p>
</div>

CSS:
/* Popup */
#meni #alertBox {
    position: absolute;
    top: 200%;
    left: 50%;
    width: 400px;
    height: 200px;
    margin-left: -200px;
    margin-top: -200px;
    border: 3px solid #c5c5c5;
    border-radius: 2px;
    background-color: #fff;
    display: none;
    z-index: 100; }
/* Kraj */

/* Title */
#alertBox .title {
 float: left;
 margin-left: 159px;
 margin-top: 9px;
 font-family: Tahoma, Helvetica, sans-serif;
 font-size: 17px;
 color: #333;
 text-align: center; }
/* Kraj */

/* Text */
#alertBox .txt {
 float: left;
 margin-left: 117px;
 margin-top: 7px;
 font-family: Tahoma, Helvetica, sans-serif;
 font-size: 16px;
 color: #333;
 text-align: center; }
/* Kraj */

/* OK button */
#alertBox .ok {
 float: left;
 margin-left: 161px;
 margin-top: 65px;
 font-family: Tahoma, Helvetica, sans-serif;
 font-size: 16px;
 color: #fff;
 background-color: #00ccff;
 padding: 4px 13px;
 border: none;
 border-radius: 2px;
 cursor: pointer;
 opacity: 1.0;
 filter: alpha(opacity="100"); }
/* Kraj */

/* OK button (hover effect) */
#alertBox .ok:hover {
 opacity: 0.8;
 filter: alpha(opacity="80"); }

JScript:
$(document).ready(function()
{
      $('#form').submit(function(e)
       {
           e.preventDefault();
            msg_sent();
        });
    $('.ok').click(function()
      {
                          $('#alertBox').fadeOut()
       });
 });
function msg_sent()
{
    $('#alertBox').fadeIn();
}

A:

When submitting the form this way the output will replace the current page.
What you probably want to do is submit it as an AJAX call and put the resulting text in the alert.
jQuery API info is here: http://api.jquery.com/jQuery.post/
Quick example:
$('#form').submit(function(e) { 
    e.preventDefault();
    $.post('index.php', $("#form").serialize(), function(data, textStatus, jqXHR) {
        $('#alertBox').html(textStatus).fadeIn();
    });
});

