$(document).ready(function() {
   // linky, ktore maju class 'blank' sa otvaraju v novom okne
   $('a.blank').click(function(){
      this.target = "_blank";
   });

	tooltip();
  	$('#footer .fox, #services .website, #services .graphic, #services .visit, #services .conversion, #references .client .head, #references .preview .head, #references a.open,.servicesBox ul li a, .servicesBox h2, body#drupal .textPage p.drupal, .twitterBox .sidebarBox h2 a').ifixpng();	
   $('body#drupal .textPage p.drupal span, .trust h3 span, .awards h3 span, .seo h3 span, .independence h3 span, .modules h3 span').ifixpng();
   $('.sliderTop, .sliderTitle, .slider .navigation a.prev, .slider .navigation a.next').ifixpng();
   		
	// Nastavime default hodnoty pre formulare
	$('body.sk #formMeno').DefaultValue('Meno');
	$('body.sk #formKontakt').DefaultValue('Váš e-mail');
	$('body.sk #formText').DefaultValue('Text');

   $('body.cs #formMeno').DefaultValue('Jméno');
	$('body.cs #formKontakt').DefaultValue('Váš e-mail');
	$('body.cs #formText').DefaultValue('Text');
	
	// Zapnutie lightboxu 
	$('.preview a').lightbox();
	
	// Zmeny zoznamu sluzieb
	$('#serviceList').cycle({
		fx: 'fade',
    	timeout: 5000, 
    	delay:  -2000,
    	cleartypeNoBg: true
	});
	
	$('#hasWebsite').parent().parent().find('div.hide').hide();
	$('#hasWebsite').click(function() {
		$(this).parent().parent().find('div.hide').toggle();
	});
   
   // Otvaranie otazok/odpovedi v Castych otazkach
   $('.openContent .itemContent').hide();
   $('.openContent .itemHead a').click(function(){
      thisOpened = $(this).parents('.itemHead').hasClass('itemOpened');
      
      $('.openContent .itemContent').slideUp();   
      $('.openContent .itemHead').removeClass('itemOpened');
      
      if (!thisOpened){
         $(this).parents('.itemHead').addClass('itemOpened');
         $(this).parents('.item').children('.itemContent').slideDown();
      }
   });
   
   // Kontrola domeny cez AJAX v Castych otazkach - 11.8.2009
   $('#check-domain').click( function() {
   	// Vymazem obsah z div-u pre report
   	$('#report').empty();
   	// Ulozenie url adresy z input-u do premennej
   	input = $('#domainName').val();
   	// AJAX dotaz   		
   	$.ajax({
   		type: "GET",
   		url: "/check-domain.php",
   		data: "domain-name=" + input,
   		success: function(value){
     			if (value == '1')
     				$('#report').append('<p class="report message">Doména <strong>' + input + '</strong> je voľná na registráciu</p>');
   			else if (value == '0')
   				$('#report').append('<p class="report error">Doména <strong>' + input + '</strong> je obsadená</p>');
   			else if (value == '-1')
   				$('#report').append('<p class="report error">Formát URL adresy nie je správny</p>');
   		}
 		});
 	});

 	// Striedanie farebneho a ciernobieleho obrazku pri hover efekte
	$('.client .image').hover(
		function() {
			$(this).find('.references-image').stop().hide();
		},
		function() {
			$(this).find('.references-image').stop().show();
		}
	);
   
   // Rozbaľovací box drupal
	$('.itemContent').hide();
	$('.whyDrupal .itemContentClose a.closeItem').hide();

	$('.whyDrupal .item h3 a').click(function() {
	  if($(this).hasClass('active')){
      $(this).removeClass('active');
      $(this).parents('.item').find('.itemContent').slideUp();
      $(this).parents('.item').find('.itemContentClose a.closeItem').fadeOut()
     } else { 
      $(this).addClass('active');
      $(this).parents('.item').find('.itemContent').slideDown(function(){
         $(this).parents('.item').find('.itemContentClose a.closeItem').fadeIn();
      });             
      }
      return false;
	});
	
	$('.whyDrupal .itemContentClose a.closeItem').click(function(){
      if($(this).parents('.item').find('h3 a').hasClass('active')){
         $(this).fadeOut()
         $(this).parents('.item').find('h3 a').removeClass('active');
         $(this).parents('.item').find('.itemContent').slideUp();  
      } 
      return false;
   });            
});
