var citac_odeslanych = 0;
var citac_prijatych = 0;
var preteceni = 0;
function display_error(name,cont){
	if(document.getElementById('error_'+name)){
		document.getElementById('error_'+name).innerHTML = cont;
	}
}

function control_input(name,form_name,only_error,others){
	if(!others) others = "";
	elements = document.getElementsByName(name);
	element = elements[elements.length-1];
	if(!only_error || element.className.indexOf(' not_valid') != -1){
		processAjax(form_name,"value="+element.value+"&name="+name+"&citac="+citac_odeslanych+others)
		citac_odeslanych++;
	}
}
function processAjax(form_name,parameters) {
	var http_request = false;
    var request = "form_name="+form_name+"&"+parameters;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            try {
              http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (error) {
              http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
		
        http_request.onreadystatechange = function() {
		        if (http_request.readyState == 4) {
		            if (http_request.status == 200) {
			            if(http_request.responseText!=""){
							//alert(http_request.responseText);
							//if(document.getElementById('in')) document.getElementById('in').innerHTML = http_request.responseText;
							eval(http_request.responseText);
						}
		            }
		        }
	        };
        http_request.open('POST', '/neotaigniter/ajax/form', true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send(request);
}

/*function changeHeight (id,from,to,in_unit,speed) {
	//alert(document.getElementById(id).style.height+" "+to+in_unit + (from>to));
	if(!speed) var speed = 1;
	if(from<to && (document.getElementById(id).style.height != to+in_unit && document.getElementById(id).style.height!="")){
		//alert("a");
		for (i=0;i<101;i++){
			w = (from+(to-from)/100*i)+in_unit;
			document.getElementById(id).style.display ='block';
			//setTimeout("document.getElementById('"+id+"').style.display ='inherit'", Math.pow(i/(9*speed),2.5));
			setTimeout("document.getElementById('"+id+"').style.height = '"+ w + "'", Math.pow(i/(9*speed),2.5));
		}
	} else if (from>to && (document.getElementById(id).style.height != to+in_unit||document.getElementById(id).style.height=="")) {
		for (i=0;i<101;i++){
			w = (from-(from-to)/100*i)+in_unit;
			setTimeout("document.getElementById('"+id+"').style.height = '"+ w + "'", Math.pow(i/(9*speed),2.5));
			if(parseInt(w,10)==0) setTimeout("document.getElementById('"+id+"').style.display = 'none'", Math.pow(i/(9*speed),2.5));
		}
	}
}*/


