function is_empty(str) { if (!str || str.length < 1) return false; return true;}
function empty_query_string(str) {
  result = is_empty(str.value);
  if (result == false) {
    alert("Zadejte dotaz");
    str.focus();
    return false;
  } else {
    return true;
  }
}
function toggle_hidden_params(position) {
	$("#tech_param_"+position+" > ul > .hiddenrest").toggle();
   //.css("display","list-item");
}
function paging(formname, id) {
	document.getElementById(formname).event_paging.value = id;
	document.getElementById(formname).submit();
}
function fill_click(entity) {entity.select();}
function show_forum_form(id_auction_forum){
	document.getElementById("auctionQuery").style.display = 'block';
	document.getElementById('queryString').focus();
	document.getElementById('parentQuery').value = id_auction_forum;	
}
function forum_select_all(){
	var rows = document.getElementsByName('query_selection[]');
	var checkbox;	
   for (var i=0; i < rows.length; i++ )	{
		checkbox = rows[i];
		if( checkbox && checkbox.type == 'checkbox' ){checkbox.checked = true;}
	}
}
function switch_display(to_hide, to_show, display_style) {
	if (to_hide) {document.getElementById(to_hide).style.display = "none";}
	if (to_show) {document.getElementById(to_show).style.display = display_style;}
}
function open_popup(link, title, width, height) {
	window.open(link,title,'scrollbars=yes,location=no,width='+width+',height='+height+'');
}
// time counter
function p (i)	{return Math.floor(i / 10) + "" + i % 10;}
function trunc (i) {var j = Math.round(i * 100);return Math.floor(j / 100) + (j % 100 > 0 ? "." + p(j % 100) : "");}
function CounterTime() {}		
CounterTime.prototype.setServerTime = function(datum) {
   this.servertime = new Date(datum.replace(/-/g, "/"));
}					
CounterTime.prototype.setEndsTime = function(datum) {
   this.endtime = new Date(datum.replace(/-/g, "/"));
}
CounterTime.prototype.synchronizeWith = function(url) {
   this.synchronizeWithUrl = url;
}					
CounterTime.prototype.bindWith = function(elm) {
   this.elm = elm;
}
CounterTime.prototype.setDifference = function() {
   var date1 = this.servertime;
   var date2 = this.endtime;
   this.difference = date2.getTime() - date1.getTime();						
}               					
CounterTime.prototype.redraw = function() 
{
   this.difference -= 1000;	   
   var sec = this.difference
                  
   if (isNaN(sec))
   {  
      this.elm.innerHTML = "aukce ukončena"; 	 
   	return;
   }
   if (sec < 0)
   {
      this.elm.innerHTML = "aukce ukončena";	 
   	return;
   }
   
   var second = 1000, minute = 60 * second, hour = 60 * minute, day = 24 * hour;
   
   var days = Math.floor(sec / day);
   sec -= days * day;
   var hours = Math.floor(sec / hour);
   sec -= hours * hour;
   var minutes = Math.floor(sec / minute);
   sec -= minutes * minute;
   var seconds = Math.floor(sec / second);						
   this.elm.innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s";
}
CounterTime.prototype.run = function() {
   cntr = this;
   if (this.difference > 0) {
   	this.redraw();							
   	window.clearTimeout(this.timeout);
   } else {
   	this.elm.innerHTML = "aukce ukončena"; 
   	return;
   }
   this.timeout = window.setTimeout('cntr.run()', 1000);
}
