  //Dodawanie nowego rekordu
  function show_kartka(values) {

     $("#dialog").html(values);
     $("#dialog").dialog({
        width:520,
        height:400,
        modal:true,
        overlay: {opacity: 0.9, background: "black"}
     });
     $("#dialog").parent("").show();
     $("#dialog").dialog("open");
     $("#dialog").show();
  };

  function close_kartka() {

     $("#dialog").dialog("close");

  };
  
  
  
  
  
  
  function check_form_contact(){
    if( parseInt($('#name').val().length) < 3)         {alert("Proszę podać imię i nazwisko."); return false;}
    if( parseInt($('#company').val().length) < 2)      {alert("Proszę podać nazwę firmy."); return false;}
    if( parseInt($('#address').val().length) < 3)      {alert("Proszę podać  adres."); return false;}
    if( parseInt($('#email').val().length) < 3)        {alert("Proszę podać  e-mail."); return false;}
    if( parseInt($('#telephone').val().length) < 3)    {alert("Proszę podać  telefon."); return false;}
    if( parseInt($('#query').val().length) < 3)        {alert("Proszę podać preferowaną formę kontaktu."); return false;}
    if( parseInt($('#message').val().length) < 3)      {alert("Proszę podać pytanie."); return false;}
    send_form_contact();
  };
  
  
  
  
 function send_form_contact(){
  var name, company, address, telephone, email,  query, message;

  name      =  $("#name").val();
  company   =  $("#company").val();
  address   =  $("#address").val();
  telephone =  $("#telephone").val();
  email     =  $("#email").val();
  query     =  $("#query").val();
  message   =  $("#message").val();

  $.post(
    "/data/ajax/contact.php",
    {send_form_contact:1,  name:name,  company:company,  address:address, telephone:telephone, email:email, query:query, message:message, },
    function(){
      alert("Dziękujemy, wiadomość została wysłana. Odpowiedź prześlemy niezwłocznie.");


    $("#name").val("");
    $("#company").val("");
    $("#address").val("");
    $("#telephone").val("");
    $("#email").val("");
    $("#query").val("");
    $("#message").val("");
  
  
  });
     return true;

};





function show_menu(element){
  $("#"+element).toggle();
}

function hide_menu(element){
  $("#"+element).hide();
}




  function add_user() {
    var email, help;

    email = $("#NewsletterText").val();
   help = $.ajax({
      url: "/data/ajax/newsletter.php?add_user="+email,
      async: false
    }).responseText;

    alert("Dziękujemy, adres został dodany do naszej bazy");
    $("#NewsletterText").val("");
   return true;
  };




  function remove_user() {
    var email, help;

   email = $("#NewsletterText").val();
   help = $.ajax({
      url: "/data/ajax/newsletter.php?remove_user="+email,
      async: false
    }).responseText;

    alert("Adres został usunięty z naszej bazy");
    $("#NewsletterText").val("");
   return true;
  };
  
  
  
  
  
  
  
  
  
  
function change_background(image, idx){
  var idx, image;
  $("#dupas_"+idx).css("background", " url("+image+")");

};



  function check_form(){
  var checkBox = document.getElementById('regulamin');
    if(checkBox.checked == false)          {alert("Proszę zaakceptować regulamin."); return false;}
  
    if( parseInt($('#xfirstname').val().length) < 3)         {alert("Proszę podać imię."); return false;}
    if( parseInt($('#xlastname').val().length) < 3)          {alert("Proszę podać nazwisko."); return false;}
    if( parseInt($('#xemail').val().length) < 3)             {alert("Proszę podać e-mail."); return false;}
    if( parseInt($('#message').val().length) < 3)           {alert("Proszę podać wiadomość."); return false;}
    return true;
  };





  function check_form2(){
  var checkBox = document.getElementById('zgoda');
    if(checkBox.checked == false)          {alert("Proszę zaakceptować regulamin."); return false;}

    if( parseInt($('#firstname').val().length) < 3)         {alert("Proszę podać imię."); return false;}
    if( parseInt($('#lastname').val().length) < 3)          {alert("Proszę podać nazwisko."); return false;}
    if( parseInt($('#email').val().length) < 3)             {alert("Proszę podać e-mail."); return false;}


    if($('#firstname').val() == "wpisz swoje imię")         {alert("Proszę podać imię."); return false;}
    if($('#lastname').val() == "wpisz swoje nazwisko")      {alert("Proszę podać nazwisko."); return false;}
    if($('#email').val() == "wpisz adres e-mail")           {alert("Proszę podać e-mail."); return false;}

    return true;
  };
  











  function check_form3(){
  var checkBox = document.getElementById('regulamin');
    if(checkBox.checked == false)          {alert("Proszę zaakceptować regulamin."); return false;}

    if( parseInt($('#xfirstname').val().length) < 3)         {alert("Proszę podać imię."); return false;}
    if( parseInt($('#xlastname').val().length) < 3)          {alert("Proszę podać nazwisko."); return false;}
    if( parseInt($('#xemail').val().length) < 3)             {alert("Proszę podać e-mail."); return false;}

    if( parseInt($('#date_time').val().length) < 3)         {alert("Proszę podać godzinę."); return false;}

    return true;
  };
  function go_to_url( href )
  {
    if ( document.all ) {this.window.location.href( href );}
    else {this.window.location.href = href;}
  }

  

function checksearch(defaultValue, obj) {
    if (obj.value == defaultValue) {obj.value = '';}
}



function insertsearch(defaultValue, obj){
    if (obj.value == "") {obj.value = defaultValue;}
}

function show_element(element){
  $("#"+element).show();
}

function hide_element(element){
  $("#"+element).hide();
}


  $(document).ready(function(){



   $(".MenuTopParent").mouseover(function(){
        $(this).children().show();
      }).mouseout(function(){
        $(this).children().hide();
   });





  });
  
  
  
  

