

<!--
function validate(string) {
    if (string == "") {
        return false;
    }
    if ($(":contains('[')", string) || $(":contains(']')", string)) {
        return false;
    }
    return true;
}
$(document).ready(function(){
 $('.bbcode a').live("click",function(){
  var text = $('textarea[id=cont]').getSelection().text;
  var tag = $(this).attr('class');
  // kolorki - wyzwalacza
//console.info(tag);
//console.info($('div.colors').is(":hidden") ? true : false);
  if (tag == 'colors' && $('div.colors').is(":hidden")) {
   $('div.colors').show();
   return false;
  // wypunktowanie
  } else if (tag == 'list') {
   if( text == '' ) {
    text = "# punkt 1\n# punkt 2\n# punkt 3\n"
   } else {
    elements = text.split("\n")
    text = "";
    $(elements).each(function(){
      text = text + "\n# " + this;
    });
    text = text + "\n"
   }
   $('textarea[id=cont]').replaceSelection(text);
   return false;
  // normalny "tag"  [tag]tekst[/tag]
  } else {
   $('div.colors').hide();
   if( text == '' ) {
    text = 'tutaj wstaw tekst'
   }
   text = '[' + tag + ']' + text + '[/' + tag + ']';
   $('textarea[id=cont]').replaceSelection(text);
   return false;
  }
 });
 // kolorki
 $('div.colors a').live("click",function(){
  var text = $('textarea[id=cont]').getSelection().text;
  var color = $(this).attr('class');
  if( text == '' ) {
   text = 'tutaj wstaw tekst'
  }
  text = '[color:' + color + ']' + text + '[/color]';
  $('textarea[id=cont]').replaceSelection(text);
  $('div.colors').hide();
  return false;
 });
});
//-->
