var base_url = 'http://www.stronydlafirm.eu/';

$(document).ready(function(){
   
   $('#helpmail_upper_bar').click(function(){
      $('#helpmail_button').click();  
   });
   
   $('#helpmail_button').click(function(){
    if($('#helpmail_content').css('display') == 'block'){
        $('#helpmail_content').hide();
        $(this).removeClass('helpmail_open').removeClass('helpmail_close').addClass('helpmail_open');
    }else{
        $('#helpmail_content').show();
        $(this).removeClass('helpmail_open').removeClass('helpmail_close').addClass('helpmail_close');
    }
    return false;
   });
   
   $('#helpmail_name').focus(function(){
    if($(this).val() == 'Imię i nazwisko...'){
        $(this).val('');
    }
   });
   
   $('#helpmail_name').blur(function(){
    if($(this).val() == ''){
        $(this).val('Imię i nazwisko...');
    }
   });
   
      $('#helpmail_email').focus(function(){
    if($(this).val() == 'Adres e-mail...'){
        $(this).val('');
    }
   });
   
   $('#helpmail_email').blur(function(){
    if($(this).val() == ''){
        $(this).val('Adres e-mail...');
    }
   });
   
      $('#helpmail_phone').focus(function(){
    if($(this).val() == 'Telefon...'){
        $(this).val('');
    }
   });
   
   $('#helpmail_phone').blur(function(){
    if($(this).val() == ''){
        $(this).val('Telefon...');
    }
   });
   
      $('#helpmail_message').focus(function(){
    if($(this).val() == 'Wpisz treść zapytania...'){
        $(this).val('');
    }
   });
   
   $('#helpmail_message').blur(function(){
    if($(this).val() == ''){
        $(this).val('Wpisz treść zapytania...');
    }
   });
   
   $('#helpmail_form').submit(function(){ 
        $('#helpmail_ajax').show(250);
        $('#helpmail_close').hide();
        $.ajax({
           type: 'post',
           url: base_url+'helpmail/helpmail_ajax.php',
           data: $('#helpmail_form').serialize(),
           dataType: 'json',
           success: function(j){
                if(!j.ok){
                    $('#helpmail_loader').hide(); 
                    $('#helpmail_response ul').html(j.msg);
                    $('#helpmail_response ul').show();    
                    $('#helpmail_close').show();
                }else{
                    $('#helpmail_loader').hide();
                    $('#helpmail_response ul').html(j.msg);
                    $('#helpmail_close').hide();
                }
           } 
        });        
        return false;
   });
    
    
    $('#helpmail_close').click(function(){
       $('#helpmail_ajax').hide(250);
       $('#helpmail_response ul').html('');
       $('#helpmail_close').hide();
       return false;
    });
});
