function createMinMax(thisid) {

    var value = $('#'+thisid).val();
    var exploded = value.split('-');

    if (typeof(exploded[0]) != 'undefined') {
        $('#lmn').val(exploded[0]);
    } else {
        $('#lmn').val('');
    }

    if (typeof(exploded[1]) != 'undefined') {
        $('#lmx').val(exploded[1]);
    } else {
        $('#lmx').val('');
    }

}


function getDestinations(region_id,typ){

    //region_id = $("#rgc").value();
    //alert(region_id);

    $("#dsc").load("ajax/getDestinations.php", {"region_id":region_id,"typ":typ});
}

function changeForm(form_type){
    switch(form_type){
        case 'p':
            showAll(800);
          break;
        case 'h':
            sel = new Array('odlet');
            showHotel(sel);
          break;
        case 'f':
            sel = new Array('dlzka-pobytu','stravovanie','kategoria','nazov-hotela');
            showFlight(sel);
          break;
    }
}

function showHotel(sel){
    showAll(10);
    hide(sel);
}

function showFlight(sel){
    showAll(10);
    hide(sel)
}

function hide(sel){
    for ( var i in sel ){
        $("#" + sel[i]).fadeOut(800);
    }
}

function showAll(dur){
    $("#ck div:hidden").fadeIn(dur);
}



function animatePrices(){
    pole = ["5","6","2","7","3","6","9","2","1","4","8","3","7","4","6","3","9","3","2","7","6","2","7","3","6","9","2","9","3","2"];
    pole2 = ["8","2","8","6","3","7","5","3","6","7","8","9","0","7","0","2","9","3","2","7","7","5","3","6","7","8","9","0","9","8"];
    pole3 = ["9","3","2","8","3","4","9","3","1","9","8","6","7","0","6","7","0","6","8","9","9","3","1","9","8","6","7","0","6","5"];
    pole4 = ["5","6","2","7","3","6","9","2","1","4","8","3","7","4","6","3","9","3","2","7"];
    pole5 = ["5","6","2","7","3","6","9","2","1","4","8","3","7","4","6","3","9","3","2","7"];
    
    i = 0;
    
    setTimeout(function(){myFunction(pole,"c1",i,10,$("#c1").attr('class'))},1000);
    setTimeout(function(){myFunction(pole2,"c2",i,15,$("#c2").attr('class'))},1000);
    setTimeout(function(){myFunction(pole,"c3",i,20,$("#c3").attr('class'))},1000);
    setTimeout(function(){myFunction(pole3,"c4",i,22,$("#c4").attr('class'))},100);

    setTimeout(function(){myFunction(pole,"c5",i,13,$("#c5").attr('class'))},100);
    setTimeout(function(){myFunction(pole2,"c6",i,15,$("#c6").attr('class'))},100);
    setTimeout(function(){myFunction(pole,"c7",i,20,$("#c7").attr('class'))},100);
    setTimeout(function(){myFunction(pole2,"c8",i,25,$("#c8").attr('class'))},100);

    setTimeout(function(){myFunction(pole,"c9",i,20,$("#c9").attr('class'))},100);
    setTimeout(function(){myFunction(pole2,"c10",i,22,$("#c10").attr('class'))},100);
    setTimeout(function(){myFunction(pole3,"c11",i,26,$("#c11").attr('class'))},100);
    setTimeout(function(){myFunction(pole,"c12",i,30,$("#c12").attr('class'))},100);
}

function myFunction(pole,sel,i,limit,finish){
  klasa = "n" + pole[i];
  
  i++;
  if(i == limit){
      $("#"+sel).removeClass().addClass(finish);
      return 0;
  }
  $("#"+sel).removeClass().addClass(klasa);
  
  setTimeout(function(){myFunction(pole, sel, i, limit, finish)},100);
}

$(document).ready(function() {
  $('#registracia a.registrovat').click(function(){
      $(this).hide();
      $('#registracia #reg-form').fadeIn('slow');
  });
});

function sendForm(){
  
  if(checkForm($('#rform'))){       
      $('#rform').submit();
  }
  else{       
      alert("Všetky polia musia byť korektne vyplnené !")
  }
}
/*
var name = "#boxik";
var menuYloc = null;

$(document).ready(function() {

			menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))
			$(window).scroll(function () {
				offset = menuYloc+$(document).scrollTop()+"px";
				$(name).animate({top:offset},{duration:500,queue:false});
			});

                        


	$('input.toggle').click(function(){
		var box_id='box_'+$(this).attr('id');
		$(this).is(':checked') && $('#'+box_id).slideDown('slow') || $('#'+box_id).slideUp('slow');
	 });

	// hover and focus
	$('input.text,textarea').hover(function(){
		$(this).addClass('hover');
	},
	function(){
		$(this).removeClass('hover');
	});

	$('input.text,textarea').focus(function() {
		$(this).addClass('focus');
	});
	$('input.text,textarea,select').blur(function() {
		$(this).removeClass('focus');
	});
});
*/
