//////////////////////////////////////////////////////////////////////////////////
function myszkaRuch() {
  document.getElementById(aktualnaPodpowiedz[now]).style.background = "#e64029";
}

function keydown(e){
    document.getElementById('podpowiedz').style.display='block';
    //document.getElementById('wojewodztwo').value='';
    var iKeyCode;
	if(aktualnaPodpowiedz.length == 0)return true;
	if (!e) {
		var e = window.event;
	}
	if (e.keyCode) {
		iKeyCode = e.keyCode;
	} else {
		if (e.which) {
			iKeyCode = e.which;
		}
	}
	if(iKeyCode == 13 && aktualnaPodpowiedz[now] != undefined)
	   return false;
	else
	   return true;
}

function sterujPomoc(e, wartosc) {
	var iKeyCode;
	if(aktualnaPodpowiedz.length == 0 || document.getElementById('podpowiedz').childNodes.length <= 1)return true;
	if (!e) {
		var e = window.event;
	}
	if (e.keyCode) {
		iKeyCode = e.keyCode;
	} else {
		if (e.which) {
			iKeyCode = e.which;
		}
	}
  var dl = aktualnaPodpowiedz.length;
  switch(iKeyCode) {
    case 38:
      now--;
      if(now<0)
        now=0;
      document.getElementById(aktualnaPodpowiedz[now==dl-1?now:now+1]).style.background = "#C11400";
      document.getElementById(aktualnaPodpowiedz[now]).style.background = "#e64029";
      document.getElementById('miasto').focus();
      break
    case 40:
      now<0?now=0:now++;
      if(now>dl-1)
        now=dl-1;
      document.getElementById(aktualnaPodpowiedz[now==0?0:now-1]).style.background = "#C11400";
      document.getElementById(aktualnaPodpowiedz[now]).style.background = "#e64029";
      document.getElementById('miasto').focus();
      break
    case 13:
      //document.getElementById('miasto').value = aktualnaPodpowiedz[now];
      //document.getElementById('miasto').focus();
      if(aktualnaPodpowiedz[now] != undefined){
          document.forms['myform'].miasto.value = aktualnaPodpowiedz[now];
          var form = document.forms['myform'];
          if(form.onsubmit())form.submit();
          $('podpowiedz').style.display = 'none';
          return false;
      }
      break
    case 37:
    case 39:
      break
    default:
      now=-1;
      pomoc(wartosc);
  }
  return true;
}
//////////////////////////////////////////////////////////////////////////////////
/*ustaw kursor*/
function fokus(elId) {
	document.getElementById(elId).focus();
}
function myFocus() {
  if(!$('miasto').disabled)$('miasto').focus();
}
/*wprowadz sugerowana nazwe*/
function suggest(myVal) {
	document.getElementById('miasto').value = myVal;
}
/*wynkcje opisujace reakcje pola selekt na wybor pola rabiobutton*/
function SelectOnLoad() {
  if(document.myform.type.checked == true)
	 document.myform.s_services.disabled = true;
	else
	 document.myform.s_type.disabled = true;
	 
	if(document.myform.city.checked == true)
	 document.myform.wojewodztwo.disabled = true;
	else
	 document.myform.miasto.disabled = true;
}

function SelectFromTypes() {
	document.myform.s_services.disabled = true;
	document.myform.s_type.disabled = false;
}
function SelectFromServices() {
	document.myform.s_services.disabled = false;
	document.myform.s_type.disabled = true;
}

function SelectFromCites() {
	document.myform.wojewodztwo.disabled = true;
	document.myform.miasto.disabled = false;
}
function SelectFromStates() {
	document.myform.wojewodztwo.disabled = false;
	document.myform.miasto.disabled = true;
}

