$(document).ready(function() {


  $(".button").mouseover(function() {
     $(this).css('background-color','#F8FF7F');
   });

   $(".button").mouseout(function() {
     $(this).css('background-color','#eee');
   });

   $("input").mouseover(function() {
     $(this).css('background-color','#F8FF7F');
   });

   $("input").mouseout(function() {
     if ($(this).attr('type')=='submit') {
        $(this).css('background-color','#eee');
     } else {
        $(this).css('background-color','#fff');
     }
   });

   $("textarea").mouseover(function() {
     $(this).css('background-color','#F8FF7F');
   });

   $("textarea").mouseout(function() {
     $(this).css('background-color','#fff');
   });

  $("textarea").focus(function() {

     $(this).css('height','200px');
     $(this).css('width','100%');
     $(this).css("background", "none");
     $(this).css('border','2px solid #BBDAFD');

     $(this).css('background-color','#fff');
   });

   $("textarea").blur(function() {
     $(this).css('background-color','#fff');
     $(this).css('border','1px solid #000');
     if ($(this)[0].value == '') {
        $(this).css("background", "url(img/zirkel.gif) center center no-repeat")
        $(this).css('height','40px');
        $(this).css('width','280px');
        $(this).css('background-color','#fff');

     }
   });

   $("input").focus(function() {
      $(this).css('border','2px solid #BBDAFD');
   });

    $("input").blur(function() {

     $(this).css('border','1px solid #000');
   });

 $("#new_br").click(function(){
   var $new_html = '<br clear="all"/>';
       $new_html +='<p>';
       $new_html +='<input type="hidden" name="ready" value="not">';
       $new_html +='<input type="hidden" name="action" value="br">';
       $new_html +='<input type="submit" value="Absatz erzwingen"></p>';
       $new_html +='</p>';
   $("#comment_input_extra").html($new_html);
 });

  $("#new_link").click(function(){
   var $new_html = '<br clear="all"/>';
       $new_html +='<p><table>';
       $new_html +='<input type="hidden" name="ready" value="not">';
       $new_html +='<input type="hidden" name="action" value="url">';
       $new_html +='<tr><td>Link*:</td><td><input type="text" name="url" style="width:400px;"></td></tr>';
       $new_html +='<tr><td>Text:</td><td><input type="text" name="url_text" style="width:400px;"></td></tr>';
       $new_html +='<tr><td><input type="submit" value="einfügen"></td></p>';
       $new_html +='</table></p>';
   $("#comment_input_extra").html($new_html);
 });

 $("#new_img").click(function(){
   var $new_html = '<br clear="all"/>';
       $new_html +='<p><table>';
       $new_html +='<input type="hidden" name="ready" value="not">';
       $new_html +='<input type="hidden" name="action" value="img">';
       $new_html +='<tr><td>Link*:</td><td><input type="text" name="url" style="width:400px;"></td></tr>';
       $new_html +='<tr><td>Align:</td><td> <input type="radio" name="align" value="right"> Rechts<br><input type="radio" name="align" value="left"> Links<br></td></tr>';
       $new_html +='<td></td>';
       $new_html +='<tr><td><input type="submit" value="einfügen"></td></p>';
       $new_html +='</table></p>';
   $("#comment_input_extra").html($new_html);
 });

    $("#new_quote").click(function(){
   var $new_html = '<br clear="all"/>';
       $new_html +='<p><table>';
       $new_html +='<input type="hidden" name="ready" value="not">';
       $new_html +='<input type="hidden" name="action" value="quote">';
       $new_html +='<tr><td>Von:</td><td><input type="text" name="pers" style="width:150px;"></td></tr>';
       $new_html +='<tr><td>Zitat*:</td><td> <textarea name="quote_text" rows="3" cols="50"></textarea></td></tr>';
       $new_html +='<tr><td><input type="submit" value="einfügen"></td></p>';
       $new_html +='</table></p>';
   $("#comment_input_extra").html($new_html);
 });



 var $hasloaded=0;
 $("#select_img").toggle(function(evt){
            if ($hasloaded==0){
            $hasloaded=1;
                    var $id = $(this).attr('id')
                    var $user = $(this).attr('user')
                    var $target = $(this).attr('target')
                    var $string = 'id='+ $id+'&user='+ $user+'&target='+ $target;

                   $.get('js/ajax/getimgbyuser.php', $string, function($daten,$status){
                       var $newHTML;
                       if ($status=='success'){
                          $newHTML = $daten;

                       } else{
                          $newHTML = "<div>Fehler</div>";
                       }
                    $("#"+$id).after($newHTML);
                    //$("#"+$id).css('background-color','#111');
                    });
                    evt.preventDefault();
            } else  {
            $(".getimgbyuser").show();
            }

   },
   function(){
   $(".getimgbyuser").hide();
   }

   );


  $("#subtext").change(function(){
   });
});  //document ready


 //
