function nothing(){
}

function is_MSIE() {
	if (navigator.userAgent.indexOf("MSIE")!= -1) 
	return(1); else return(0); 
}

function jump(where) {
  document.location.href=where;
}

function send_request(req,par) {
	document.qsf.request.value=req;        
	document.qsf.param.value=par;
	document.qsf.submit();
}

function go_home() { 
	document.qsf.request.value='';
	document.qsf.param.value='';           
	document.qsf.submit();	
}
function quick_search() {   
	if ((document.qsf.sf_queryLine.value == '... hledej') || (document.qsf.sf_queryLine.value == '... search'))
		document.qsf.sf_queryLine.value = '';
	if (document.qsf.qsf_where[1].checked) {
		document.qsf.request.value = 'quick_search';  
	} else { 
		
/*         J Y X O		      */                    
/*  document.qsf.action='http://jyxo.cz/s?q='+ document.qsf.sf_queryLine.value +'+domain%3Awww.cmvu.cz&d=cz'; //?q=lada&d=cz'; */

/*         G O O G L E		  */                    
    document.qsf.q.value = document.qsf.sf_queryLine.value;
    document.qsf.action='http://www.google.com/search';  //?hl=cs&lr=lang_cs&as_sitesearch=cmvu.cz&q='+document.qsf.sf_queryLine.value;
	}				
}

/*********************************/
/*                               */
/*       ADVANCED SEARCH         */
/*                               */
/*********************************/

function set_visibility(on) {
	if (on==0) {
		document.getElementById("select").style.visibility = "hidden";
		document.getElementById("select2").style.visibility = "hidden";
		document.getElementById("select3").style.visibility = "hidden";
		document.getElementById("select4").style.visibility = "hidden";
		document.getElementById("select7").style.visibility = "hidden";
		document.getElementById("select8").style.visibility = "hidden";
		document.getElementById("select9").style.visibility = "hidden";   
	} else {
		document.getElementById("select").style.visibility = "visible";
		document.getElementById("select2").style.visibility = "visible";
		document.getElementById("select3").style.visibility = "visible";
		document.getElementById("select4").style.visibility = "visible";
		document.getElementById("select7").style.visibility = "visible";
		document.getElementById("select8").style.visibility = "visible";
		document.getElementById("select9").style.visibility = "visible";
	}		
}
/* !!!!! Zjistí abs. souřadnice objektu na HTML stránce !!!! pType=0 top, pType=1 left */
function findPosition(obj,pType) {
	cur = 0;
	if(obj.offsetParent) {		
		while(obj.offsetParent) {
			cur+=pType?obj.offsetLeft:obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	return cur;
}

function show_index(id, line_id) {             
	var ln = document.getElementById(line_id); 
	if (line_id == "text11")  
		var newY = findPosition(ln,0) - document.getElementById(id).offsetHeight - 3; 
  else
		var newY = findPosition(ln,0) + ln.offsetHeight + 3; 	
	var newX = findPosition(ln,1);                        

	if (is_MSIE() == 1) set_visibility(0);
	document.getElementById(id).style.top = newY+"px"; 
	document.getElementById(id).style.left = newX+"px";
}

function hide_window(id) {
	if (is_MSIE() == 1) set_visibility(1);
	document.getElementById(id).style.top = "-2000px";
	document.getElementById(id).style.left = "-2000px";
}

function loadImg(imgName) {
  var img=new Image();
  img.src=imgName;
  return img;
}

function displayError(where,msg) {
	document.getElementById(where).innerHTML = msg;
}

function displayText(where,msg) {
	document.getElementById(where).innerHTML = msg;
} 

function clearSearchForm() {
	document.qsf2.text.value =""; 
	document.qsf2.select10.selectedIndex = 0;
	document.qsf2.text2.value =""; 
	document.qsf2.select11.selectedIndex = 0;
	document.qsf2.text3.value =""; 
	document.qsf2.select12.selectedIndex = 0;
	document.qsf2.text4.value =""; 
	document.qsf2.text12.value =""; 
	document.qsf2.select13.selectedIndex = 0;
	document.qsf2.select3.selectedIndex = 0;
	document.qsf2.select14.selectedIndex = 0;
	document.qsf2.text5.value =""; 
	document.qsf2.select5.selectedIndex = 0;
	document.qsf2.text6.value =""; 
	document.qsf2.select15.selectedIndex = 0;
	document.qsf2.select21.selectedIndex = 0;
	document.qsf2.select16.selectedIndex = 0;
	document.qsf2.select2.selectedIndex = 0;
	document.qsf2.select17.selectedIndex = 0;
	document.qsf2.select4.selectedIndex = 0;
	document.qsf2.select18.selectedIndex = 0;
	document.qsf2.select7.selectedIndex = 0;
	document.qsf2.select19.selectedIndex = 0;
	document.qsf2.select8.selectedIndex = 0;
	document.qsf2.select20.selectedIndex = 0;
	document.qsf2.select9.selectedIndex = 0;
	document.qsf2.select6.selectedIndex = 0;
	document.qsf2.text11.value =""; 	
}

/*********************************/
/*                               */
/*        Okno prohlizece        */
/*                               */
/*********************************/   

window.onresize = window_onresize;

function window_onresize() { 
	hide_window('sf_indexArea');
}

/*********************************/
/*                               */
/*           A J A X             */
/*                               */
/*********************************/

var index_element_id;

var current_index_field_num = 23; /* cs globalni index */
var current_index_edit_id;
var current_index_edit_value;

var xmlHttpEnabled = false; // Proměnná určuje, zda je možno použít xmlHttpRequestObject

// Inicializace XML HTTP Request objektu 
var xmlHttp = null;  //createXmlHttpRequestObject(); !!! pro IE7 a pravdepodobne jeste za urcitych jinych okolnosti musi vytvoreni objektu probehnout pri kazdem volani call_index !!!
 
function createXmlHttpRequestObject() {
  var xmlHttp1;
  try {                 
    xmlHttp1 = new XMLHttpRequest();
  }
  catch(E) {            
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp1; i++) {
      try { 
        xmlHttp1 = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {}
    }    
  }
  if (!xmlHttp1) xmlHttpEnabled = false;
  else {                                             
  	xmlHttpEnabled = true;
    return xmlHttp1;
  }
}  

function call_index(sessId, script, request, edit_id, edit_value, field_num, index_id, lang) {    
	index_element_id = index_id;           
	if (field_num >= 0)	{
		current_index_field_num = field_num;
		current_index_edit_id = edit_id;
		current_index_edit_value = edit_value;
	}
	
	xmlHttp = createXmlHttpRequestObject();
	
	if (xmlHttpEnabled) {                  
		try {   
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {      
       	xmlHttp.onreadystatechange = write_index;                  // Priradi funkci pro obsluhu odezvy      				
        params = "sessionId=" + sessId + "&request=" + request + "&idx_field=" + current_index_field_num + "&edit_id=" + current_index_edit_id + "&value=" + current_index_edit_value + "&language="+lang; 
        xmlHttp.open("POST", script, true);    												
        xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        xmlHttp.send(params);
      } else {   
   	  	setTimeout("call_index('" + sessId + "', '" + script + "', '" + request + "', '" + current_index_edit_id + "', '" + current_index_edit_value + "', '" + current_index_field_num + "', '" + index_id + "', '" + lang + "');", 1000); 
   	  }
    }
    catch (e) {
      displayError(index_id, e.toString());
    }
	} else displayError(index_id,'<p>Pro tento typ prohlizece je index bohuzel nedostupny</p>');		
}

function write_index() {       
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {  
		  displayText(index_element_id,xmlHttp.responseText);
		}
	}
}
  
/*********************************/
/*                               */
/*           I N D E X           */
/*                               */
/*********************************/
/*

function index_row_click(row_id,edit_id) { 
		
	var row = document.getElementById(row_id).innerHTML;       
	var edit = document.getElementById(edit_id);       
  edit.value += ' '+ row;
}

*/

function index_row_click(row_id,edit_id) { 
		
	var row = document.getElementById(row_id).innerHTML;       
	var edit = document.getElementById(edit_id);       
// Prevezmi puvodni obsah	editacni radky
	var tx = edit.value;
// Zjisti, zda text konci mezerou
	if (tx.charAt(tx.length-1) == " ") {
// Pokud ano, pridej obsah radky indexu za puvodni obsah editacni radky
		edit.value += row;
	} else {
// pokud je to heslovy index, stejnym zpusobem musime najit apostrof
		if (tx.charAt(tx.length-1) == "'") {
// najdi predchozi apostrof	
			var p = tx.lastIndexOf("'",tx.length-2);
			if (p	< 0) {
// pokud predchazejici apostrof neni -> najdi posledni mezeru a od ni to prepis
				var p = tx.lastIndexOf(" ",tx.length-2);
				if (p < 0) p = 0; else p++;
			}					
		 	tx = tx.substr(0,p);
		 	edit.value = tx + row;
		} else {
// v tomto pripade neni posledni znak ani mezera ani apostrof			
// musime tedy najit posici posledni mezery zprava			
			var p = tx.lastIndexOf(" ");
			if (p < 0) {
// zadna mezera neni, -> nahradime obsah editacni radky radkou indexu
				edit.value = row;
			} else {
// Vyjmeme text za mezerou a ke zbytku pridame radku indexu
				tx = tx.substr(0,p+1);
				edit.value = tx + row;
			}
		}
	}
	edit.focus();
}








function change_index(i) {
//	alert('index = '+i);
}