url = "/";


Array.prototype.in_array = function ( obj ) {
	var len = this.length;
	for ( var x = 0 ; x <= len ; x++ ) {
		if ( this[x] == obj ) return true;
	}
	return false;
}

function highlight(that,file,w){
	if (w == 1) {
		that.style.color = "#fffeff";
		that.style.backgroundImage = "url('"+ url +"images/menus/" + file + "-a.png')";
	}
	if (w == 0) {
		that.style.color = "#3283c5";
		that.style.backgroundImage = "url('" + url + "images/menus/" + file + ".png')";
	}
}


function anketaHlasuj(anketa,id){
 
  var url = "anketa.php";
  
  var params = "anketa=" + anketa + "&id=" + id;
  var obj = document.getElementById("anketa-inner");
  
  if (window.XMLHttpRequest) {
    http = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    http = new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  http.open("POST", url, true);
  //Send the proper header information along with the request
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  http.onreadystatechange = function() {//Call a function when the state changes.
  	if(http.readyState == 4 && http.status == 200) {
      obj.innerHTML = http.responseText;
  	}
  }

  http.send(params);
  
}


function kalendarOpen(month,year,todo,highlight){
 
  var url = "kalendar.php";
  
  var params = "month=" + month + "&year=" + year + "&posted=true&todo="+todo+"&highlight="+highlight;
  var obj = document.getElementById("kalendar");
  
  if (window.XMLHttpRequest) {
    http = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    http = new ActiveXObject("Microsoft.XMLHTTP");
  }
  
  http.open("POST", url, true);
  //Send the proper header information along with the request
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  http.onreadystatechange = function() {//Call a function when the state changes.
  	if(http.readyState == 4 && http.status == 200) {
      obj.innerHTML = http.responseText;
  	}
  }

  http.send(params);

}

function kalendarWindow(what){
  var obj = document.getElementById("kalendar-rezervace");
  if(what==1)
    obj.style.visibility = "visible";
  else
    obj.style.visibility = "hidden";
}

function kalendarSetDate(date){
  document.forms['rezervaceform']['date'].value = date;

}


function checkForm(form,names){
	var pole = names.split(" ");
	i=0;
	while (i >= 0) {
		if(!form[i]){
			break;
		}
		
		if(form[i].type == "radio"){
			answ = "f";
			var names = document.getElementsByName(form[i].name);
			for(x=0;x <= names.length - 1;x++){
				if(names[x].checked==true)
					answ = "t";
			}
			if(answ == "f"){
				alert('Vyplňte všechny položky!');
				return false;
			}
		}
	
    if(form[i].value=="" && pole.in_array(form[i].name)){
			alert('Vyplňte všechny údaje!');
			return false;
		}		
		i++;
	}
	return true;
}
