var test = ['anesteziolog','chirurg','dentální hygienista','dermatolog', 'dětský psycholog', 'diabetolog', 'diagnostika', 'domácí ošetřovatel', 'endokrinolog', 'gastroenterolog', 'genetik', 'gynekolog', 'hematolog', 'imunolog', 'internista', 'kardiolog', 'kožní' , 'logoped', 'neurolog', 'oční', 'onkolog', 'ortodontista', 'ortoped'];  // delete
var navDuration = 200;

window.onload = function()
{
  
  $("#search_type").autocomplete(test,
	  {
		  minChars: 0
		}
	); //nahradit "test" url zdroje


	//inicializace filtru
	if ($('#slider1').length)
	{
	  $('#slider1').slider({
		  range: 'min',
		  step:  "5",
		  slide: function(event, ui) {$('#slider1 .ui-slider-handle').text(ui.value+'km');}
		});
		$('#slider1 .ui-slider-handle').text('0km');
		
		$('#slider2').slider({
		  range: 'min',
		  slide: function(event, ui) {$('#slider2 .ui-slider-handle').text(ui.value+'%');}
		});
		$('#slider2 .ui-slider-handle').text('0%');
		
		$('#slider3').slider({
		  range: 'min',
		  slide: function(event, ui) {$('#slider3 .ui-slider-handle').text(ui.value+'%');}
		});
		$('#slider3 .ui-slider-handle').text('0%');
	}
	
	if ($('#slider4').length)
	{
		$('#slider4').slider({
			range: "min",
			value: 5,
			min: 5,
			max: 50,
		  slide: function(event, ui) {$('#slider4 .ui-slider-handle').text(ui.value);}
		});
		$('#slider4 .ui-slider-handle').text('5');
	}

	if ($('#slider-rate').length)
	{	
		$('#slider-rate').slider({
			range: "min",
			value: 50,
			min: 0,
			max: 100,
		  slide: function(event, ui) {$('#slider-rate .ui-slider-handle').text(ui.value+'%');}
		});
		$('#slider-rate .ui-slider-handle').text('50%');
	}

	//inicializace listu
	if ($('#resultsList').length)
	{
	  var rows = $('#resultsList .row');
	  for (i = 0, l = rows.length; i < l; i++)
		{
		  $(rows[i]).hover(
		    function() {$(this).addClass('hover');},
		    function() {$(this).removeClass('hover');}
			);
		}
	}
	
	if ($('.paging').length)
	{
	  var el = $('.paging');
	  el.css('width', 'auto');
	  var child = el.children();
	  child = $(child[child.length - 2]);
	  el.css('width', (child.position().left+child.outerWidth()+20)+'px');
	}
}

function updateMatched()
{
  $('#search_matched').load('results.php', {type: $('#search_type').val(), place: $('#search_place').val()}); //nahradit adresou skriptu
}

function filterCatClick(el)
{
  el = $(el);
  el.next().toggleClass('hidden');
	el.toggleClass('opened');
}


$(document).ready(function() {  

  	// SLIDER PAGE -------------------------------------------------------------------------------------------
    $(".slide-right").pageSlide({ width: "300px", direction: "right"});


  	// #feat links ---------------------------------------------------------------------------------------------------
  	$("#feat-link").click(function(){    
  	  $(this).animate({ left : '300px', duration : 'normal' }); 
  	  $(this).addClass("active");
  	  $(this).addClass("pageslide-close");
  	  //$(this).hasClass("active").removeClass("active");
  	});       

  	// #feat links ---------------------------------------------------------------------------------------------------
  	$("#pageslide-body-wrap").click(function(){    
  	  $("#feat-link.active").animate({ left : '0', duration : 'normal' }); 
  	  //$(this).toggleClass("active");
  	  $("#feat-link.active").removeClass("active");
  	  $("#feat-link.active").removeClass("pageslide-close");
  	}); 

  	// FAQ ---------------------------------------------------------------------------------------------------
  	$("#faq li").click(function(){    
  	  $(this).find("div").slideToggle("slow")
  	  $(this).toggleClass("active");
  	  $(this).hasClass("active").removeClass("active");
  	});       

	// DROPDOWN MENU  ---------------------------------------------------------------------------------------------------
	$("#mainMenu ul li a").hover(function() { //When trigger is clicked...
	
	$(this).parent().find("li:first").addClass('first'); // add class first
		$(this).parent().find("li:last").addClass('last'); // add class last
		
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul").slideDown('normal').show(); //Drop down the subnav on click
	
		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul").slideUp('normal'); //When the mouse hovers out of the subnav, move it back up
		});
	
		//Following events are applied to the trigger (Hover events for the trigger)
		});
			
	// CLEAR INPUT VALUE  ---------------------------------------------------------------------------------------------------
	$('input, textarea').each(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('Title'));
		}
	}).focus(function () {
		$(this).removeClass('inputerror');
		if ($(this).val() == $(this).attr('Title')) {
			$(this).val('');
		}
	}).blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('Title'));
		}
	});
		
	$("a.fancybox").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});

	$(".fancybox-html").fancybox({
		'autoScale'			: false,	
		'height'        : 475,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'type'				  : 'iframe'
	});

	$(".fancybox-html-small").fancybox({
    'autoDimensions'	: false,
		'width'         	: 530,
		'height'        	: 170,	
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
						
});

// HEADER PAGE SLIDER ---------------------------------------------------------------------------------------------------
jQuery('#slider-box').cycle({
  fx: 'fade', // transition fx
  speed: 700, // transitions speed
	pause: 1000, // pause between slides
	pager:  '#slide-pager',
});	

