$(document).ready(function() {
		$("body").addClass("jsok");
		$("a[rel='external']").attr({target: "_blank"});
		$(".dnldlist td a").attr({target: "_blank"});

		$('table tr:odd').addClass('odd');

		//labelify
			$("#user,#pass").labelify({
			text: "label",
			labelledClass: "labelhi"
		});

		// transparent png for IE6
		$('#nav .pngfix').ifixpng();

		// adds overlay for product focus img
		$('#aside .product a.img, .home .product a.img').append('<img src="./front/img/aside-product-img.gif" alt="" class="over" />')

		// news cycler
		$('#news').cycle({
				fx: "fade",
				timeout: 3000,
				speed: 500,
				fastOnEvent:   0,
				pager:  '#newspager',
				pagerEvent: 'click',
				pause: 1,
				pauseOnPagerHover: 1,
				pagerAnchorBuilder: function(idx, slide) {
					return '#newspager li:eq(' + idx + ') a';
				}
		});

		// make block clickable
		$('.jablotool').click(function(){
			var link = $(this).find('a').attr('href');
			window.open(link);
			return false;
		});

	$('.dnldbanner').click(function(){
			var link = $(this).find('a').attr('href');
			window.location(link);
			return false;
		});		

		$('.support').click(function(){
			var link = $(this).find('a').attr('href');
			location.href = link;
			return false;
		});

//		$('.i1').append('<div id="intro1ab"><img src="./front/img/intro1a.jpg" alt="" /><img src="./front/img/intro1b.jpg" alt="" /></div>');

/*		$('#intro1ab').cycle({
				fx: "fade",
				timeout: 3000,
				speed: 1500
		});
*/
		$('.i1, .i2, .i3').hover(function(){
                $(this).addClass('hover');
			},function(){
				$(this).removeClass('hover');
			}).click(function(){
				var link = $(this).find('a.butt').attr('href');
				location.href = link;
			});

        //print
		$('.en .print').html("<a href='#'>Print page</a>");
		$('.print').click(function(){
			window.print();
			return false;
		});

		$("#tabs").tabs({
				fx:{opacity:'toggle',duration:'fast'},
/* - vypíná / zapíná pamatování si posledních otevřených TABů v detailu produktu.  
				cookie: {name:$('#tabs').attr('class'),expires:30},
*/
				show: function(event, ui) {
					$('#bts').hide().css('top', $("#footer").offset().top - 330 + 'px').fadeIn();
				}
		});
  
		// nyroModal
		$("a[href$='jpg'], a[href$='png'], a[href$='gif'], a[href$='bmp']").nyroModal();
		$("a[href$='JPG'], a[href$='PNG'], a[href$='GIF'], a[href$='BMP']").nyroModal();

		// add bts image on left side
		$("#center").append("<img src='./front/img/bts.gif' id='bts' />")
		$('#bts').css('top', $("#footer").offset().top - 330 + 'px').fadeIn(2000);


		// carousel
		$(".carousel").jCarouselLite({
			circular: false,
			visible: 4,
			btnNext: ".next",
			btnPrev: ".prev"
		});

		//pirate
		$('.piratefilter select').sSelect();
		
		//faq
		$('.faqfilter select').sSelect();

		//downloads
		$('.dnldfilter select').sSelect();

		$('.searchfilter select').sSelect();

		//partner
		$('#pcid').sSelect().change(function(){
				//$("#cont option:eq(0)").attr("selected", "selected");
				//$("#areas option:eq(0)").attr("selected", "selected");
				$('#partner').submit();
		});
		$('#cont').sSelect().change(function(){
				$("#areas option:eq(0)").attr("selected", "selected");
				//$("#pcid option:eq(0)").attr("selected", "selected");
				$('#partner').submit();
		});

		$('#areas').sSelect({ddMaxHeight: '200px'}).change(function(){
		    //$("#pcid option:eq(0)").attr("selected", "selected");
				$('#partner').submit();
		});

        // partners - velikost pozadi DIVu
		var evro = $('#evropa').height() + 24;
		$('#evropadiv').css('height',evro+'px');

		var afri = $('#afrika').height() + 24;
		$('#afrikadiv').css('height',afri+'px');
		
        var asie = $('#asie').height() + 24;
		$('#asiediv').css('height',asie+'px');
		
		var aust = $('#australie').height() + 24;
		$('#australiediv').css('height',aust+'px');
		
		var nort = $('#north').height() + 24;
		$('#northdiv').css('height',nort+'px');

		var sout = $('#south').height() + 24;
		$('#southdiv').css('height',sout+'px');

        $('#savemyhome').hover(
            function() {
                $('#savemyhomeli').css('background-image', 'url(front/img/jkit-bg4.png)');
            },
            function() {
                $('#savemyhomeli').css('background-image', 'url(front/img/jkit-bg.png)');
        });

        $('#helpme').hover(
            function() {
                $('#helpmeli').css('background-image', 'url(front/img/jkit-bg4.png)');
            },
            function() {
                $('#helpmeli').css('background-image', 'url(front/img/jkit-bg.png)');
        });

        $('#turnmeon').hover(
            function() {
                $('#turnmeonli').css('background-image', 'url(front/img/jkit-bg4.png)');
            },
            function() {
                $('#turnmeonli').css('background-image', 'url(front/img/jkit-bg.png)');
        });
        
        $('#savemyhomeli').hover(
            function() {
                $('#savemyhomeli').css('background-image', 'url(front/img/jkit-bg4.png)');
            },
            function() {
                $('#savemyhomeli').css('background-image', 'url(front/img/jkit-bg.png)');
        });

        $('#helpmeli').hover(
            function() {
                $('#helpmeli').css('background-image', 'url(front/img/jkit-bg4.png)');
            },
            function() {
                $('#helpmeli').css('background-image', 'url(front/img/jkit-bg.png)');
        });

        $('#turnmeonli').hover(
            function() {
                $('#turnmeonli').css('background-image', 'url(front/img/jkit-bg4.png)');
            },
            function() {
                $('#turnmeonli').css('background-image', 'url(front/img/jkit-bg.png)');
        });

		//reference
		$('.ref').hide();
		$('.ref:first').show();
		$('.clients a').click(function(){
			$('.ref').hide();
			$($(this).attr('href')).show();
			//return false;
		});

    $('.answer .answertext').css('display','none');
  	$('.faqs h3').click(function(){
  	  //$(this).parents('.faqs').next('.answertext').slideToggle(); 
		  $(this).parents('.faqs').children('.answer').children('.answertext').slideToggle();
		  var img = $(this).children('img').attr('src');
		  if(img == './front/img/faq-top2.gif'){
		    $(this).children('img').attr('src', './front/img/faq-top.gif');
		  }
		  else{
        $(this).children('img').attr('src', './front/img/faq-top2.gif');
      }
		  //$('.faqs h3 img').attr('src')='./front/img/faq-top1.gif';
  	});
  	
  	$('.answertext .top').click(function(){
  	  //$(this).parents('.faqs').next('.answertext').slideToggle(); 
		  $(this).parents('.faqs').children('.answer').children('.answertext').slideToggle();
		  return false;
  	});
  	
   	$('.faqs h3').hover(function() {$(this).addClass('hover');}, function() {$(this).removeClass('hover'); }); 


// pohybuje s prvkem tooltip při pohybu myši
   $(document).mousemove(function(e){
      $('#atrtitle').css({top:e.pageY+7,left:e.pageX-143});
   }); 

// po najetí myši na odkaz  
   $('.dnledit [title]').mouseover(function(e){                 // po najetí myší na odkaz s title
      $(this).after('<div id="atrtitle"></div>');        // přidá za něj DIV s ID tooltip
      var ttext = $(this).attr("title");                // uloží title do proměnné
      $(this).attr({title:""});                         // vymaže title (aby se nezobrazovala klasická windwos)
      $('#atrtitle').text(ttext).show().fadeTo(800,0.8); // zobrazení a něco pro efekt :-)
   }); 

   $('.dnledit [title]').mouseout(function(e){                 // po odjetí myší z odkazu s title
      $(this).attr({title:$('#atrtitle').text()});      // zapíše atribut title zpátky k odkazu (aby jej bylo možno znovu použít)
      $('#atrtitle').hide().remove();                    // skryje DIV s ID tooltip a potom ho odstraní
   }); 


});
