$(document).ready(function(){
$('#content').tabs({fxSlide: true, fxFade: true, fxSpeed: 'normal'});


/* pridanie class hover pre li ak je nad nou kurzor     */
$("#content li.tips > h4").hover(
  function () {
    $(this).parent("li").addClass("hover");
	$(this).siblings("div").fadeIn('slow').addClass("hover");
  },
  function () {
    $(this).parent("li").removeClass("hover");
	$(this).siblings("div").slideUp('normal').removeClass("hover");
  }
);


/* tooltip pre aktivny li 
$('ul li.tips')
$('ul li.tips').qtip({
   content: 'This is an active list element',
   show: 'mouseover',
   hide: 'mouseout'
})

*/

/* MORE BUTTON - rozba¾ovanie dalsich poloziek v stlpci*/ 
$("a.more").click(function(event){
	event.preventDefault();            //vylucenie znovunacitania stranky
	var ide = $(this).attr("id").replace('m_','s_');
	$("ul#" + ide).toggle('slow');
//	$(this).text(ide);              //prepise text tlacidla s  ID-ul ktore otvara
});


/* definicia stylu  pre tooltip*/  
$.fn.qtip.styles.mystyle = { // Last part is the name of the style
	width: 400,
	background: '#AFD4FF',
	color: 'black',
	border: {
		width: 1,
		radius: 5,
		color: '#AFD4FF'
	},
	tip: 'topLeft',
	name: 'dark' // Inherit the rest of the attributes from the preset dark style
};

/* zobrazenie tooltipu 
$('#content li.tips > h4 > a').each(function() {
	$(this).qtip({
		style: { name: 'mystyle' },
		position: {
			corner: {
				target: 'bottomLeft',
				tooltip: 'topLeft'
			}
		},
		content: {
			text: '',
			method: 'get',
		}
    })
});*/ 

/* YOUTUBE VIDEO  tooltip  - blbokovanie znovunacitania pri kliknuti, nechat pred  youtube each function*/    
$('li.tips > a[href*="youtube."]').click(function(event){
	event.preventDefault();            //vylucenie znovunacitania stranky
});

/* YOUTUBE VIDEO  tooltip */ 
   // Use each method to gain access to all youtube links
   $('li.tips > a[href*="youtube."]').each(function()   {

      // Grab video ID from the url
      var videoID = $(this).attr('href').replace('http://', '').replace('www.', '').replace('youtube.com/?v=', '');

      // Create content using url as base
      $(this).qtip(
      {
	  		content: {
			text: '<div id="youtube-embed-'+videoID+'">You need Flash player 8+ to view this video.</div>',
			method: 'get',
			title: {
				text: $(this).text(), // Give the tooltip a title using each elements text
				button: 'X' // Show a close link in the title
			}
		},
         // Create content DIV with unique ID for swfObject replacement

         position: {
            corner: {
               tooltip: 'bottomMiddle', // ...and position it center of the screen
               target: 'topMiddle' // ...and position it center of the screen
            }
         },
         show: {
            when: 'click', // Show it on click...
            solo: true // ...and hide all others when its shown
         },
         hide: 'unfocus', // Hide it when inactive...
         style: {
            width: 435,
            height: 275,
            padding: 0,
            tip: true,
            name: 'mystyle'
         },
         api: {
            onRender: function()
            {
               // Setup video paramters
               var params = { allowScriptAccess: 'always', allowfullScreen: 'false' };
               var attrs = { id: 'youtube-video-'+videoID };

               // Embed the youtube video using SWFObject script
               swfobject.embedSWF('http://www.youtube.com/v/'+videoID+'&enablejsapi=1&playerapiid=youtube-api-'+videoID,
                                 'youtube-embed-'+videoID, '425', '264', '8', null, null, params, attrs);
            },

            onHide: function(){
               // Pause the vide when hidden
               var playerAPI = this.elements.content.find('#youtube-video-'+videoID).get(0);
               if(playerAPI && playerAPI.pauseVideo) playerAPI.pauseVideo();
            }
         }
      }
      ).attr('href', '#');
   });






});  // DOM READY

