// check, ci je setnute blade_root_path - ak nie, setneme na /
if(!window.blade_root_path)
  blade_root_path = "/";

// reload obrazku
function refresh_image_code(idcko) {
	otaznik = $("#" + idcko).attr('src').indexOf('?');
	tmp = $("#" + idcko).attr('src')
	if(otaznik)
	  tmp.substr(0, otaznik);
	$("#" + idcko).attr('src', blade_root_path + 'images/preloading.gif');
	$("#" + idcko).attr('src', tmp + '?' + Math.random());
}

// odoslanie kontaktneho formulara
function submit_kontakt_form(form) {
  // preloading
  

  //$.blockUI({message: $('#preloading-kontakt')});

  form.ajaxSubmit({success : over_kontakt, clearForm : false, resetForm : false});
  
  //$.unblockUI();
  
  // preskorlujeme k h1
  var destination = 0;
  if($("h1").length)
  	destination = $("h1").offset().top;
  $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 200, function() {
	//window.location.hash = "kotva-scroll";
  });
}

// overenie kontaktneho formulara
function over_kontakt(responseText, statusText) {
  $("#message-kontakt").hide();
  
  if(responseText.indexOf("OK") > -1) {
	  $("#kontakt-formular-showhide").hide();
	  $("#message-kontakt-sent").show();
	  // tracker
	  if(responseText.indexOf("tpp") > -1)
	    pageTracker._trackPageview('registracia-uchadzac-fulltime');
	  if(responseText.indexOf("brigada") > -1)
	    pageTracker._trackPageview('registracia-uchadzac-parttime');
	  if(responseText.indexOf("spolocnost") > -1)
	    pageTracker._trackPageview('registracia-uchadzac-zamestnavatel');
  }
  else {
	  $("#message-kontakt").text(responseText);
	  $("#message-kontakt").show();
  }
}

// tlac brigady - iba otvorenie okna
function brigada_print(linka) {
	window.open(linka, '', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=no,status=no,height=600,width=600');
}

// tlac tpp - iba otvorenie okna
function tpp_print(linka) {
	window.open(linka, '', 'toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=no,status=no,height=600,width=600');
}

function show_picture(source) {
  window.open(blade_root_path + "picture_show.php?source=" + source, "", "toolbar=no,menubar=no,location=no,directories=no,scrollbars=no,resizable=no,status=no");
}

function over(obj) {
  //var thisimg = document.getElementById(imgID);
  obj.src = obj.src.replace(/(\.[a-z0-9]+)$/i,'-hover$1');
}

function out(obj) {
  //var thisimg = document.getElementById(imgID);
  //thisimg.src = thisimg.src.replace(/-hover(\.[a-z0-9]+)$/i,'$1');
  obj.src = obj.src.replace(/-hover(\.[a-z0-9]+)$/i,'$1');
}

jQuery(document).ready(function() {

// zadefinujeme si slovensku lokalizaciu pre datepicker
		$.datepicker.regional['sk'] = {
			closeText: 'Zavrieť',
			prevText: '&#x3c; Predchádzajúci',
			nextText: 'Nasledujúci &#x3e;',
			currentText: 'Dnes',
			monthNames: ['Január','Február','Marec','Apríl','Máj','Jún',
			'Júl','August','September','Október','November','December'],
			monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún',
			'Júl','Aug','Sep','Okt','Nov','Dec'],
			dayNames: ['Nedel\'a','Pondelok','Utorok','Streda','Štvrtok','Piatok','Sobota'],
			dayNamesShort: ['Ned','Pon','Uto','Str','Štv','Pia','Sob'],
			dayNamesMin: ['Ne','Po','Ut','St','Št','Pia','So'],
			weekHeader: 'Ty',
			dateFormat: 'dd.mm.yy',
			firstDay: 0,
			isRTL: false,
			showMonthAfterYear: false,
//			showButtonPanel: true,
			yearSuffix: ''};
			//setneme sk nastavenia ako defaultne
		$.datepicker.setDefaults($.datepicker.regional['sk']);
		
		// nastup mozny od -  zvolime minimalny datum na dnesny den
		$("input.termin_od, input.termin_do").datepicker({minDate: 0});
});
