$(document).ready(function () {
  $('table.list tbody tr.stripped:odd').addClass('even');
	$('table.list tbody tr.stripped:even').addClass('odd');
	$('table.fieldset tbody tr:odd').addClass('even');
	$('table.fieldset tbody tr:even').addClass('odd');
	
	$('table.list tr.stripped').hover(function() {
		//hide others
		$('table.list tr.action').hide().removeClass('highlight');
		$('table.list tr').removeClass('highlight');
    $(this).addClass('highlight').find('+ tr.action').show().addClass('highlight');
  });
  
	
   $('a.editable_tb').click(function(){
     tb_show('Edycja', this.getAttribute('rel'), false);
   })

  // $('.wymeditor').wymeditor({ lang: 'pl', logoHtml: '', skin: 'compact' });  
		
	$('a.cmptext-form-cancel').click(function() {
		$('#form_'+this.getAttribute('title')).hide();
		$('#slot_'+this.getAttribute('title')).show();
    return false;
  });

  $('form.cmptext-remote-form').submit(function() {
		var related_container = $(this).attr('id').replace('form_', '');
    var params = {};
    
    $(this).find("textarea")
    .each(function() {
      // alert(this.id);
      if (tinyMCE.getInstanceById(this.id))
      {
          tinyMCE.execCommand('mceFocus', false, this.id);                    
          tinyMCE.execCommand('mceRemoveControl', false, this.id);
          tinyMCE.triggerSave();
      }
    });
    
    $(this).find("input, textarea")
    .each(function() {
      params[ this.name || this.parentNode.name ] = this.value;
    });
    $.post(this.getAttribute('action'),
          params,
          function(fromServer) {
					 $('#form_'+related_container).hide();
					 $('#slot_'+related_container).html(fromServer).show();
     });
     return false;
  })
	
	

})



