// --------- JQUERY  ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------
$(document).ready(function() 
{

   // Match all <A/> links with a title tag and use it as the content (default).
   /*
         title: {
            text: 'Nápověda:',
            button: false
         }
   */
   $('.abubble').removeData('qtip') .qtip({
      
      content: {
         text: $('#'+$('.abubble').attr('title')).html(), 

      },
      position: {
         my: 'right top', // Use the corner...
         at: 'top right', // ...and opposite corner
         target: 'mouse'
      },

      style: {
         classes: 'ui-tooltip-shadow ui-tooltip-tipped'
      }
   });
   
   $('#btnSumitForum, .nComments').removeData('qtip') .qtip({
      content: {
         text: "<img src='/img/oselNapis.gif' alt='Napiš'/>", 

      },
      position: {
         my: 'right bottom',
         at: 'bottom right',
         target: 'mouse'
      },

      style: {
         width: { min: 160 },
         classes: 'ui-tooltip-shadow ui-tooltip-tipped'
      }
   });
   

   $('.aanswers').removeData('qtip') .qtip({
      content: {
         text: "<img src='/img/oselPremysli.gif' alt='Přemýšlím'/>", 

      },
      position: {

         my: 'left middle',
         at: 'middle left',
         adjust: { x: 190, y: 10 }
      },

      style: {
         width: { min: 160 },
         classes: 'ui-tooltip-shadow ui-tooltip-tipped'
      }
   });

   $('#sText').removeData('qtip') .qtip({
      content: {
         text: "<img src='/img/oselPremysli.gif' alt='Přemýšlím'/>", 

      },
      position: {

         my: 'left middle',
         at: 'middle left',
         adjust: { x: 250, y: 10 }
      },

      style: {
         width: { min: 160 },
         classes: 'ui-tooltip-shadow ui-tooltip-tipped'
      }
   });
   
   
   $('#gallery a').lightBox();
    /*$('.container .flying-text').css({opacity:0}); //set all text opacity to 0
    $('.container .active-text').animate({opacity:1, marginLeft: '350px'}, 4000); //animate first text
    var int = setInterval(changeText, 5000); // call changeText function every 5 seconds
    
    function changeText(){
      var $activeText = $('.container .active-text'); //get current text
      var $nextText = $activeText.next();  //get next text
      if($activeText.next().length == 0) $nextText = $('.container .flying-text:first'); //if it is last text, loop back to first text
      $activeText.animate({opacity:0}, 1000); //set opacity 0 to animated text
      $activeText.animate({marginLeft: "-100px"}); //set animated text position to default
      //animate next text
      $nextText.css({opacity: 0}).addClass('active-text').animate({opacity:1, marginLeft: "350px"}, 4000, function(){
        $activeText.removeClass('active-text');
      });
    }*/
    
    $('.rdcolorbox').click(function(){
      var sValue = $(this).attr('value');
      var sBorder, sBackground;
      switch(sValue)
      {
        case 'red': sBorder = '#C7295A'; sBackground = '#C7295A'; break;
        case 'green': sBorder = '#ADB167'; sBackground = '#ADB167'; break;
        case 'blue': sBorder = '#21C2E4'; sBackground = '#21C2E4'; break;
        case 'orange': sBorder = '#DE9D43'; sBackground = '#DE9D43'; break;
        case 'yellow': sBorder = '#BBA301'; sBackground = '#BBA301'; break;
        case 'braun': sBorder = '#FFFF00'; sBackground = '#794D00'; break;
      }
      $(".form").css({'border':'3px solid '+sBorder, 'background-color':sBackground});
    });
    
    /* -- PhotoGallery - user -- */
    $('#btnNewPhotoInGallery').click(function(){
      if($('#append').attr('class')<5)
      {
        $('#SendPhotoInGallery').css({'display':'inline'});
        var sHTML = $('#append').html();
        $('#frmPhotoGallery').append(sHTML);
        $('#append').attr('class', ($('#append').attr('class')*1) + 1);
      }
      else
      {
        $('#btnNewPhotoInGallery').css({'display':'none'})
      }
    });
    
    $('#createnewgallery').click(function(){
      $('#frmcreatenewgallery').css({'display':'inline'});
    });
    
    $('.star').rating({
      callback: function(value, link){
        alert(value);
        $('#res').load(value);
        $('.star').rating('disable');
      }
    });
});

// ---------------------------------------------------------------------------------------------------------

