var sectionFormObject = {

	getPodoblastList : function (oblastElem)
	{
		if(XMLHttpRequestObject && oblastElem.value != "0")
		{
		    var url = "./ajaxcall.php?f=getPodoblast&id_oblast=" + oblastElem.value;
		    ajaxCall(url, sectionFormObject.fillPodoblastList);
  		}
	},

	fillPodoblastList : function ()
	{
		if (XMLHttpRequestObject.readyState == 4 &&
			XMLHttpRequestObject.status == 200)
		{
			sectionFormObject.fillSelectorList("podoblast", XMLHttpRequestObject.responseText.split("#"));
		}
	},

	fillSelectorList : function (id, iList)
	{
		var list = document.getElementById(id);
	    if (list)
	    {
	        // Remove old items
	        for (i = list.options.length - 1; i > 0; i--)
	        {
	            if (list.options[i].value != "0")
	            {
	                list.options[i] = null;
				}
			}
		}
		// Fill new items
    	for (i = 0; i < iList.length; i++)
    	{
    		var pList = iList[i].split("|");
    		var oOption = document.createElement("OPTION");
    		oOption.text = pList[1];
    		oOption.value = pList[0];
    		list.options.add(oOption);
    	}
	},

	oblastSelect : function (id_oblast)
	{
	    var oblastSelElem = document.getElementById("oblast");
	    oblastSelElem.value = id_oblast;
	    sectionFormObject.getPodoblastList(oblastSelElem);

		return false;
	}
};


function go() {
	box = document.getElementById("form02").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "aktuality?per_page="+destination;
}

function go02() {
	box = document.getElementById("form022").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "aktuality?per_page="+destination;
}

function go2() {
	box = document.getElementById("form02").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "ubytovani?per_page="+destination;
}

function go22() {
	box = document.getElementById("form022").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "ubytovani?per_page="+destination;
}

function go3() {
	box = document.getElementById("form02").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "top-vylety?per_page="+destination;
}

function go32() {
	box = document.getElementById("form022").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "top-vylety?per_page="+destination;
}

function go4() {
	box = document.getElementById("form02").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "top-turisticke-cile?per_page="+destination;
}
function go42() {
	box = document.getElementById("form022").select04;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "top-turisticke-cile?per_page="+destination;
}

function go5() {
	box = document.getElementById("form05").select05;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "search?per_page="+destination;
}

function go52() {
	box = document.getElementById("form052").select05;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = "search?per_page="+destination;
}

function openPopupWindow(theUrl, width, height)
{
  window.open(encodeURI(theUrl), "_blank", "toolbar=no,scrollbars=no,location=no,status=no,width="+width+",height="+height+",resizable=0,screenX=150,screenY=50", false);
}

function openPopupWindow2(theUrl, width, height)
{
  window.open(encodeURI(theUrl), "_blank", "toolbar=no,scrollbars=yes,location=no,status=yes,resizable=1,screenX=150,screenY=50", false);
}

function checkUbytovaniForm() {
  if (document.getElementById('jmeno').value=='') {
    alert('Jméno musí být před odesláním vyplněno.');
    document.getElementById('jmeno').focus();
    return false;
  };
  if (document.getElementById('prijmeni').value=='') {
    alert('Příjmení musí být před odesláním vyplněno.');
    document.getElementById('prijmeni').focus();
    return false;
  };
  if (document.getElementById('email').value=='') {
    alert('e-mail musí být před odesláním vyplněn.');
    document.getElementById('email').focus();
    return false;
  };
  if (document.getElementById('telefon').value=='') {
    alert('Telefon musí být před odesláním vyplněn.');
    document.getElementById('telefon').focus();
    return false;
  };
  if (document.getElementById('adresa').value=='') {
    alert('Adresa musí být před odesláním vyplněna.');
    document.getElementById('adresa').focus();
    return false;
  };
  return true;
}

function checkFulltext () {
  if (document.getElementById('searchFor').value.length<3) {
    alert ('hledaný text musí být nejméně tři znaky dlouhý');
    document.getElementById('searchFor').focus();
    return false
  } else
    return true
}
