$(document).ready(function() {
 
$('#contact_submit').click(function(event) { 
	  text = $('#cf_text').val();
	  name = $('#cf_name').val();
	  phone = $('#cf_phone').val();
	  email = $('#cf_email').val();
	  subject = $('#cf_subject').val();
	  url = $('#cf_url').val();
	
	  var msg = '';
    if(!name) { 
      msg = msg + 'Musíte zadat Vaše jméno\n';
    }
    if(!email) { 
      msg = msg + 'Musíte zadat Váš email\n';
    }
    if(!text) { 
      msg = msg + 'Musíte zadat text dotazu\n';
    }
    
    if(msg) {
      alert(msg);
      return false;
    }
   
    $.get(base_url + '/jquery_php/contact_form_send_email.php', 
      {text: text, name: name, phone: phone, email: email, subject: subject, url: url },
      function(data) {       
        
         if(data) {
           $('#ok_row').show();          
           $('#cf_text').val('');
           $('#cf_contact_form_ext').hide();
           $('#contact_form_content .submit_cover').hide();
         }
	    } 
    );
    
    return false;
	});
	$('#cf_send_again').click(function(event) { 
	    $('#ok_row').hide();
      $('#cf_contact_form_ext').show();  
	    $('#contact_form_content .submit_cover').show();
	    return false;
		});
		
		$('#cf_title_toggle').click(function(event) { 
	    $('#contact_form_content').toggle();  
	    return false;
		});
		
	$('#cms_send_email').click(function(event) { 
	    $('#form_email2friend').toggle();  
	    return false;
		});
		
	$('#e2f_send_again').click(function(event) { 
	    $('#e2f_cover').show();  
	    $('#ok_row_e2f').hide();
	    return false;
		});
	
	$('#email2friend_submit').click(function(event) { 
	  name = $('#e2f_name').val();
	  email = $('#e2f_email').val();
	  name_recip = $('#e2f_name_recipient').val();
	  email_recip = $('#e2f_email_recipient').val();
	  subject = $('#e2f_subject').val();
	  url = $('#e2f_url').val();
	
	  var msg = '';
    if(!name) { 
      msg = msg + 'Musíte zadat Vaše jméno\n';
    }
    if(!email) { 
      msg = msg + 'Musíte zadat Váš email\n';
    }
    if(!name_recip) { 
      msg = msg + 'Musíte zadat jméno příjemce\n';
    }
    if(!email_recip) { 
      msg = msg + 'Musíte zadat email příjemce\n';
    }
    if(msg) {
      alert(msg);
      return false;
    }
   
    $.get(base_url + '/jquery_php/email2friend_send.php', 
      {name: name, email: email, name_recip: name_recip, email_recip:email_recip, subject: subject, url: url },
      function(data) {              
         if(data) {
           $('#e2f_cover').hide();          
           $('#e2f_name_recipient').val('');
           $('#e2f_email_recipient').val('');
           $('#ok_row_e2f').show();
         }
	    } 
    );
    
    return false;
	});

	
	$('.cp_jquery_save').change(function(event) { 
	   name = $(this).attr('name');
	   value = $(this).val();
	   id = $('#id').val();
	   
     $.get(base_url + '/jquery_php/online_jquery_save.php', 
      {id:id, name: name, value: value, table: 'ti_data', step: 4},
      function(data) {              
	      
      } 
    );
   
  });
  
  $('.cp_jquery_ch_save').click(function(event) { 
    if($(this).is(":checked")) {
      value = 1;
    } else {
      value = 0;
    }
    name = $(this).attr('name');
    id = $('#id').val();
    $.get(base_url + '/jquery_php/online_jquery_save.php', 
      {id:id, name: name, value: value, table: 'ti_data', step: 4},
      function(data) {              
	    } 
    );
    
  });


  // END CP -----------
	$('.show_dialog_box_help').click(function(event) { 
      var a_title = $(this).attr('title');
      $("#dialog_box_help").dialog({title: a_title, modal: true, width: 600, closeOnEscape: true});
      return false;
  });
  
})

