var awmzindex=20000; //prepise hodnotu pro awm

function ajax_process_request(request,script,params) {                                
  xmlHttp = createXmlHttpRequestObject();
	if (xmlHttpEnabled) {                  
		try {   
			if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {   
				switch (request) {
					case "ajax_pass_session_vars":
		       	xmlHttp.onreadystatechange = function () {resolve_pass_session_vars();}
						break;
					case "ajax_get_authResult":
		       	xmlHttp.onreadystatechange = function () {ajax_handle_authResult();}
						break;
					default:
		       	xmlHttp.onreadystatechange = function () {ajax_handle_response(request);}
				}
        xmlHttp.open("POST", script, true);
        xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        if (params!="") params="&"+params;
        params+="&app_client="+app_client;
				params+="&mns_session_id="+mns_session_id;
//        alert("request="+request+params);
        xmlHttp.send("request="+request+params);
      } else {
   	  	setTimeout("process_request(request,script,params);", 1000); 
   	  }
    }
    catch (e) {
			alert("Error: "+e.toString());
    }
	} else alert("Error xmlHttpEnabled not enabled.");
}

function ajax_handle_response(request) {
	if (xmlHttp.readyState==4) {
		if (xmlHttp.status==200) {
//			alert(request);
			switch(request) {
				// osetreni zadosti o rychly preklad dotazu
				case "requestQuickQueryTranslation":
					buildQuery(xmlHttp.responseText);
					break;
				case "requestAdvancedQueryTranslation_singleLine":
					document.getElementById("id_ed_"+lastTranslatedLine).value=xmlHttp.responseText;
					document.getElementById("id_ed_"+lastTranslatedLine).className="asf_txt_translated";
					document.getElementById("asf_translate_"+lastTranslatedLine).checked=false;
					translateAdvancedFormLine(lastTranslatedLine+1);
					break;
				case "requestSelectedTextTranslation":
					toggleMessage(MULTILING_TRANSLATION_HEADER1,xmlHttp.responseText,"close",-1,-1,"wt_msg",760,600);
					break;
				// osetreni pridani do seznamu
				case "addToSelection":
					if (xmlHttp.responseXML.documentElement.childNodes[0].nodeValue==parseInt(xmlHttp.responseXML.documentElement.childNodes[0].nodeValue)) {
						ajax_process_request("requestSelectionToolsUpdate",selectionScript,"");
					} else {
						alert(xmlHttp.responseXML.documentElement.childNodes[0].nodeValue);
					}
					break;
				case "removeFromSelection":
//					alert(xmlHttp.responseText);
					ajax_process_request("requestSelectionToolsUpdate",selectionScript,"");
					break;
				case "requestSelectionToolsUpdate":
//					document.getElementById("mysc_results").innerHTML=xmlHttp.responseText;
//					document.getElementById("selectionCount").innerHTML="("+xmlHttp.responseXML.documentElement.childNodes[0].nodeValue+")";
//					document.getElementById("selectionSaveLink").innerHTML="<a href=\"javascript:alert(123);\">uložit jako kolekci</a>";
//					document.getElementById("selectionSaveLink").setAttribute("class","regular");
//					if (!document.getElementById("selectionClearLink")) {
//						var newLi = document.createElement('li');
//						newLi.innerHTML="<a href=\"javascript:ajax_process_request(\'clearSelection\',selectionScript,\'\')\">zrušit výběr</a>";
//						newLi.id='selectionClearLink';
//						document.getElementById('selectionToolsArea').appendChild(newLi);
//					}

//					document.getElementById("pdlib").insertBefore(xmlHttp.responseXML.documentElement.childNodes[0],document.getElementsByTagName("h2")[1]);
//					document.getElementById("selectionToolsArea").appendChild(xmlHttp.responseXML.documentElement.childNodes[0]);
						
						//tak nakonec kvuli stylum jedine takhle

					document.getElementById("selectionToolsArea").innerHTML=xmlHttp.responseText;

//tenhle request se nedela, to bzlo kvuli seznamu ajaxem						ajax_process_request("requestSelectionListUpdate",selectionScript,"");
					break;
				case "requestSelectionListUpdate":
						//tak nakonec kvuli stylum jedine takhle
						document.getElementById("selectionListArea").innerHTML=xmlHttp.responseText;
					break;
				case "clearSelection":
//					document.getElementById("mysc_results").innerHTML=xmlHttp.responseText;
//					document.getElementById("selectionCount").innerHTML="";
//					document.getElementById("selectionSaveLink").setAttribute("class","disabled");
//					document.getElementById("selectionSaveLink").innerHTML="prázdný výběr";
//					var eraseElement = document.getElementById("selectionClearLink");
//					eraseElement.parentNode.removeChild(eraseElement);
						ajax_process_request("requestSelectionToolsUpdate",selectionScript,"");
						if (document.getElementById("selectionList") != null) removeNodeById("selectionList");
					break;
				case "clearAll":
					document.getElementById("mysc_results").innerHTML=xmlHttp.responseText;
					document.getElementById("selectionCount").innerHTML="";
					break;
				default:
			  	alert("Error: unknown request ("+request+")");
			}
		} else {
			alert("Error: xmlHttp.status!=200");
		}
	}
}

function resolve_pass_session_vars() {
	if (xmlHttp.readyState==4) {
		if (xmlHttp.status==200) {
			mns_session_id=xmlHttp.responseXML.documentElement.getElementsByTagName("mnsSessionId")[0].childNodes[0].nodeValue;
			var uname=xmlHttp.responseXML.documentElement.getElementsByTagName("mnsUserName")[0];
			if (uname.childNodes[0]) mns_user_name=uname.childNodes[0].nodeValue;
		}
	}
}

function removeCollection(tit,target) {
	document.permDeleteItemForm.remTarget.value=target;
	if (tit!="") {
		document.getElementById("permDeleteItemTitle").innerHTML=tit;
		document.getElementById("permDeleteItemTitlePar").style.display="block";
	} else {
		document.getElementById("permDeleteItemTitlePar").style.display="none";
	}
	MW_permDeleteItem();
//	var remove=window.confirm(question);
//	if (remove) document.location.href=target;
}

function removeNodeById(id) {
var NParent, NNested, NThrowaway;
NNested = document.getElementById(id);
NParent = NNested.parentNode;
NThrowaway = NParent.removeChild(NNested);}

// vyhledove nasledujici funjkce pro hledani presunout do mns.js nebo i vys
// taky odstranit prime tetxty, ted neni cas

function adjustMethodsCombination(sel) {
//	alert(sel.id);
	switch (sel.id) {
		case "id_global_dia":
//alert('Temporarily disbaled.');
//sel.checked=false;
return;
//			alert(sel.value);
			if (sel.value!=0 && (document.getElementById('chb_tolerance').checked || document.getElementById('chb_variace').checked)) {
				var cnf=window.confirm("This action will disable the graphemes extension and writing/typing tolerance options.\n\nContinue anyway?");
				if (cnf) {
					document.getElementById('chb_tolerance').checked=false;
					document.getElementById('chb_variace').checked=false;
				} else {
					sel[0].selected=true;
				}
			}
			break;
		case "chb_tolerance":
alert('Temporarily disbaled.');
sel.checked=false;
return;
//			alert(sel.checked);
			if (sel.checked && document.getElementById('id_global_dia').value!=0) {
				var cnf=window.confirm("This action will disable the tolerance of diacritics option.\n\nContinue anyway?");
				if (cnf) {
					document.getElementById('id_global_dia')[0].selected=true;
				} else {
					sel.checked=false;
				}
			}
			break;
		case "chb_variace":
alert('Temporarily disbaled.');
sel.checked=false;
return;
			if (sel.checked && document.getElementById('id_global_dia').value!=0) {
				var cnf=window.confirm("This action will disable the tolerance of diacritics option.\n\nContinue anyway?");
				if (cnf) {
					document.getElementById('id_global_dia')[0].selected=true;
				} else {
					sel.checked=false;
				}
			}
			break;
	}
}

function adjustDiaTolerance() {
	if (document.getElementById('id_global_dia').value==2) document.getElementById('id_global_dia')[1].selected=true;
}


/*
function toggleMiscForASF() {
	alert(document.getElementById('glob_methods').style);
	if (document.getElementById('glob_methods').style.display=="none") {
		document.getElementById('glob_methods').style.display="block";
		document.getElementById('asf_misc_switch').innerHTML="hide";
		document.getElementById('asf_misc').style.borderBottomWidth="1px";
		document.getElementById('asf_misc_show').value="yes";
	} else {
		document.getElementById('glob_methods').style.display="none";
		document.getElementById('asf_misc_switch').innerHTML="show";
		document.getElementById('asf_misc').style.borderBottomWidth="0px";
		document.getElementById('asf_misc_show').value="no";
	}
}

function toggleCollForASF() {
//	alert(document.getElementById('glob_methods').style);
	if (document.getElementById('glob_colls').style.display=="none") {
		document.getElementById('glob_colls').style.display="block";
		document.getElementById('asf_coll_switch').innerHTML="hide";
		document.getElementById('asf_coll').style.borderBottomWidth="1px";
		document.getElementById('asf_colls_show').value="yes";
	} else {
		document.getElementById('glob_colls').style.display="none";
		document.getElementById('asf_coll_switch').innerHTML="show";
		document.getElementById('asf_coll').style.borderBottomWidth="0px";
		document.getElementById('asf_colls_show').value="no";
	}
}
*/
function toggleMessage(msgHeader,msgText,msgConfirm,cX,cY,elmid,mW,mH) {
//	alert(cX+", "+cY);
	if (mW === undefined) mW=500;
	if (mH === undefined) mH=300;
	defaultMsgText = "This is a message.";
	if (msgHeader === undefined) msgHeader="Message";
	if (msgText === undefined) msgText=defaultMsgText;
	if (msgConfirm === undefined) msgConfirm="close";
	if (elmid === undefined) elmid="wt_msg";
	if (cX === undefined) cX=-1;
	if (cY === undefined) cY=-1;
	document.getElementById(elmid+"_header").innerHTML=msgHeader;
	document.getElementById(elmid+"_text").innerHTML=msgText;
		document.getElementById(elmid).style.width=mW+"px";
	if (cX>-1) {
		document.getElementById(elmid).style.left=cX-mW/2+wtf_scrollLeft()+"px";
	} else {
		document.getElementById(elmid).style.left=Math.round((wtf_clientWidth()-mW)/2)+wtf_scrollLeft()+"px";
	}
	if (cY>-1) {
		document.getElementById(elmid).style.top=cY+20+wtf_scrollTop()+"px";
	} else {
		document.getElementById(elmid).style.top=Math.round((wtf_clientHeight()-mH)/2)+wtf_scrollTop()+"px";
//		document.getElementById(elmid).style.top=Math.round((wtf_clientHeight()-mH)/2)+wtf_scrollTop()+"px";
//		document.getElementById(elmid).style.height=mH+"px";
	}
	switch (msgConfirm) {
		case "close":
			document.getElementById(elmid+"_button").style.display="inline";
			document.getElementById(elmid+"_button").value="Close";
			break;
		case "ok":
			document.getElementById(elmid+"_button").style.display="inline";
			document.getElementById(elmid+"_button").value="OK";
			break;
		case "cancel":
			document.getElementById(elmid+"_button").style.display="inline";
			document.getElementById(elmid+"_button").value="Cancel";
			break;
		default:
			document.getElementById(elmid+"_button").style.display="none";
	}
	if (document.getElementById(elmid).style.display=="block") {
		if (msgText==defaultMsgText) document.getElementById(elmid).style.display="none";
	} else {
		document.getElementById(elmid).style.display="block";
	}
}

function toggleMessage_simple(msgHeader,msgText,nearElm) {
	var defaultMsgText="This is a message.";
	if (msgHeader === undefined) msgHeader="Message";
	if (msgText === undefined) msgText=defaultMsgText;
	var elmid="wt_msg_simple";
	if (nearElm) {
		document.getElementById(elmid).style.left=findPosition(nearElm,1)+"px";
		document.getElementById(elmid).style.top=findPosition(nearElm,0)+10+"px";
		document.getElementById(elmid+"_header").innerHTML=msgHeader;
		document.getElementById(elmid+"_text").innerHTML=msgText;
	}
	if (document.getElementById(elmid).style.display=="block") {
		if (msgText==defaultMsgText) document.getElementById(elmid).style.display="none";
	} else {
		document.getElementById(elmid).style.display="block";
	}
}


/******* skripty pro multilingual **************/
		function uniqueArr(a) {
		 temp = new Array();
		 for(i=0;i<a.length;i++){
		  if(!contains(temp, a[i])){
		   temp.length+=1;
		   temp[temp.length-1]=a[i];
		  }
		 }
		 return temp;
		}

		function contains(a, e) {
		 for(j=0;j<a.length;j++)if(a[j]==e)return true;
		 return false;
		}

		function getLang(code) {
			var lang="";
			switch (code) {
				case "nl":
					lang="Dutch";
					break;
				case "en":
					lang="English";
					break;
				case "fr":
					lang="French";
					break;
				case "pl":
					lang="Polish";
					break;
				case "el":
					lang="Greek";
					break;
				case "de":
					lang="German";
					break;
				case "cs":
					lang="Czech";
					break;
				case "it":
					lang="Italian";
					break;
				case "sv":
					lang="Swedish";
					break;
				case "es":
					lang="Spanish";
					break;
				case "pt":
					lang="Portuguese";
					break;
				case "sk":
					lang="Slovak";
					break;
				case "sh":
					lang="sh";
					break;
				case "uk":
					lang="Ukrainian";
					break;
				case "da":
					lang="Danish";
					break;
				case "ja":
					lang="Japanese";
					break;
				case "zh":
					lang="Chinese";
					break;
				case "ur":
					lang="Chinese";
					break;
				case "ar":
					lang="Arabic";
					break;
				case "bg":
					lang="Bulgarian";
					break;
				case "fa":
					lang="Persian";
					break;
				case "sh":
					lang="sh";
					break;
				case "ru":
					lang="Russian";
					break;
				case "hi":
					lang="Hindi";
					break;
				case "ko":
					lang="Korean";
					break;
				default:
					lang=code;
			}
			return lang;
		}
		
		function listAvailableLangs(from,mode) {
			var tos="";
			var x=0;
			if (mode=='option') {
				document.getElementById("lpTo").innerHTML="";
			}
			for (i=0;i<lp.length;i++) {
				if (lp[i].substr(0,2)==from) {
					x++;
					switch (mode) {
						case "option":
							opt = document.createElement("option");
							opt_txt = document.createTextNode(getLang(lp[i].substr(3,2)));
							opt.appendChild(opt_txt);
							opt.setAttribute("value", lp[i].substr(3,2));
							document.getElementById("lpTo").appendChild(opt);
							break;
						case "str":
							if (x>1) tos=tos+"_";
							tos=tos+lp[i].substr(3,2);
							break;
					}
				}
			}
			return tos;
		}
		
		function prepareTranslation() {
			if (document.getElementById("whatTranslate1").checked) {
				translateSelection();
			}	else {
				translateWholeRecord();
			}
		}

		function translateWholeRecord() {
			document.getElementById("trForm").lp.value=document.getElementById("lpFrom").value+"_"+document.getElementById("lpTo").value;
			document.getElementById("trForm").docId.value=docId;
			document.getElementById("trForm").submit();
		}
		
		function buildQuery(ql) {
			document.getElementById("qs_line").value=ql;
			document.getElementById("x1").checked=true;
			document.getElementById("x1").value=0;
//			alert(ql);
			quick_search();
			document.qsf.request.value="quick_search";
			document.qsf.submit();
		}

		function trInfo() {
//			alert("Toto je demonstrace prvotní integrace API Systran Enterprise server.\nProtože T3.4 (Improvement and generalization of UNICODE treatment in Manuscriptorium) je rozpracovaný, hledání v UNICODE zatím není možné. \nProto multilinguální hledání může způsobit chybové chování, je-li v přeloženém textu znak, který vyhledávání momentálně nemůže obsáhnout.");
			document.getElementById("trInfo").innerHTML="<img src='http://enrich.systran.fr/images/processing.gif' alt='Powered by Systran'/><br/>Translating query";
		}

		function draw_availableLangs() {
			document.write("<select id=\"lpqtFrom\">");
			for (i=0;i<lpFrom.length;i++) {
				document.write("<option value=\""+lpFrom[i]+"\"");
				if (currLang==lpFrom[i]) document.write(" selected=\"selected\"");
				document.write(">"+getLang(lpFrom[i])+"</option>")
			}
			document.write("</select>");
		}
		
	function translateAdvancedForm() {
		for (i=0;i<countQueryLines;i++) {
			if (document.getElementById("asf_translate_"+i).checked) {
				if (document.getElementById("id_ed_"+i).value!="") {
					document.getElementById("id_ed_"+i).className="asf_txt_translating";
				} else {
					document.getElementById("asf_translate_"+i).checked=false;
				}
			}
		}
		lastTranslatedLine=0;
		translateAdvancedFormLine(lastTranslatedLine);
	}

function translateAdvancedFormLine(i) {
//	alert("tring to translate "+i);
	if (i<countQueryLines) {
		lastTranslatedLine=i;
		if (!document.getElementById("asf_translate_"+i).checked) {
			i++;
//			alert("... not translating");
			translateAdvancedFormLine(i);
		} else if (document.getElementById("id_ed_"+i).value!="") {
//			alert(document.getElementById("id_ed_"+i).value);
//			alert("... going to translate");
			ajax_process_request('requestAdvancedQueryTranslation_singleLine',qt_script,'&tql='+document.getElementById("id_ed_"+i).value+'&lpFrom='+document.getElementById('lpqtFrom').value+'&'+'lpTo='+listAvailableLangs(document.getElementById('lpqtFrom').value,'str'));
		}
	}
}

function allowMultilingualSearch(elm) {
	if (elm.checked) {
		document.getElementById("allow_multilingual_settings").className="allow_trans_block";
		for (i=0;i<countQueryLines;i++) {
			document.getElementById("asf_translate_"+i).className="allow_trans_inline";
		}
	} else {
		document.getElementById("allow_multilingual_settings").className="allow_trans_disabled";
		for (i=0;i<countQueryLines;i++) {
			document.getElementById("asf_translate_"+i).className="allow_trans_disabled";
		}
	}
}

function translateSelection() {
	var txt = '';
	if (window.getSelection) {
		txt = window.getSelection();
	} else if (document.getSelection) {
		txt = document.getSelection();
	} else if (document.selection) {
		txt = document.selection.createRange().text;
	}
  else return;
  if (txt=='') {
		toggleMessage(MULTILING_TRANSLATION_HEADER1,MULTILING_NOT_SELECTED);
  } else {
		toggleMessage(MULTILING_TRANSLATION_HEADER1,MULTILING_WAIT+" <img src='http://enrich.systran.fr/images/processing.gif' alt='Powered by Systran'/>","close",-1,-1,"wt_msg",760);
		ajax_process_request('requestSelectedTextTranslation',st_script,'&tql='+txt+'&lpFrom='+document.getElementById('lpFrom').value+'&'+'lpTo='+document.getElementById('lpTo').value+'&'+'envLang='+translate_envLang);
  }
}

/************************* Skripty prevzate z adresy *******************************/
/*   http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html   */
/***********************************************************************************/

function wtf_clientWidth() {
  return wtf_filterResults (window.innerWidth ? window.innerWidth : 0, document.documentElement ? document.documentElement.clientWidth : 0,document.body ? document.body.clientWidth : 0);
}

function wtf_clientHeight() {
  return wtf_filterResults (window.innerHeight ? window.innerHeight : 0,document.documentElement ? document.documentElement.clientHeight : 0,document.body ? document.body.clientHeight : 0);
}

function wtf_scrollLeft() {
	return wtf_filterResults (window.pageXOffset ? window.pageXOffset : 0,document.documentElement ? document.documentElement.scrollLeft : 0,document.body ? document.body.scrollLeft : 0);
}

function wtf_scrollTop() {
	return wtf_filterResults (window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0);
}

function wtf_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

/* javascript pro odblokovani robotu */

function openRecord(docid) {
	//za tohle mne Karel asi prasti... OPRAVIT!!!
//	document.location.href="index.php?request=request_document&docId="+docid;
	document.location.href="http://www.manuscriptorium.com/apps/main/en/index.php?request=request_document&docId="+docid;
}

function openRecord2(docid) {
	//za tohle mne Karel asi prasti... OPRAVIT!!!
//	document.location.href="../index.php?request=request_document&docId="+docid;
	document.location.href="http://www.manuscriptorium.com/apps/main/index.php?request=request_document&docId="+docid;
}

function openFacsimile(docid) {
	//za tohle mne Karel asi prasti... OPRAVIT!!!
//	document.location.href="index.php?request=show_tei_digidoc&docId="+docid;
	document.location.href="http://www.manuscriptorium.com/apps/main/en/index.php?request=show_tei_digidoc&docId="+docid;
}


var idx_tmp_line;
var idx_tmp_line1;
var idx_is_open=false;
function clb_show_index(line_id) {
	idx_tmp_line = document.getElementById(line_id); 
	idx_tmp_line1 = $('#'+line_id); 
//  alert($(idx_tmp_line1).offset().left+", "+$(idx_tmp_line1).position().left);
  var newY = $(idx_tmp_line1).position().top + $(idx_tmp_line1).outerHeight();
  var newX = $(idx_tmp_line1).position().left;

  $('#sf_indexArea_left').css('top', (newY + 1) + 'px'); //cislo spojeno s css
	$('#sf_indexArea_left').css('left', (newX - 61) + 'px'); //cislo spojeno s css
  $('#sf_indexArea').css('left', newX + 'px'); //cislo spojeno s css
  $('#sf_indexArea').css('top', (newY - 2) + 'px'); //cislo spojeno s css
	$('#sf_indexArea_right').css('top', (newY - 25) + 'px'); //cislo spojeno s css
	$('#sf_indexArea_right').css('left', (newX + $(idx_tmp_line1).outerWidth()) + 'px'); //cislo spojeno s css
	selId="id_fields_"+line_id.substring(6);
	$('#sf_indexArea_table').css('width', $(idx_tmp_line1).outerWidth() + "px"); //cislo spojeno s css prave casti a sirkou obrazku:)
	idx_is_open=true;
} 

function update_ql_marks(ql, edit_id) {
	var noOfCharsVisible=51;
	var charWidth=8;
	var paddingLeft = $('#'+edit_id).position().left + 2;
	insertMarkHalfWidth=4;
	var mark = document.getElementById("sf_indexArea_indicators");
	var mark2 = document.getElementById("idx_alert_button");
	var insertMark = document.getElementById("sf_indexArea_insert_mark");
    addPath = (index_config.lang == 'cs') ? '' : '../';

	if (idx_is_open) {
		startCoord=paddingLeft+charWidth*startPos-ql.scrollLeft;
		endCoord=charWidth*endPos-ql.scrollLeft;
		if (startCoord<paddingLeft) startCoord=paddingLeft;
		if (endCoord>ql.offsetWidth) endCoord=ql.offsetWidth;
//document.getElementById("tetsStuff").innerHTML="startPos: "+startPos+" endPos: "+endPos+" alertStatus: "+alertStatus+" insertStatus: "+insertStatus+" idx_current_line "+idx_current_line;
//document.getElementById("tetsStuff").innerHTML+="<br/>startCoord: "+startCoord+", paddingLeft: "+paddingLeft;
//document.getElementById("tetsStuff").innerHTML+="<br/>endCoord: "+endCoord+", ql.offsetWidth: "+ql.offsetWidth;
		switch (alertStatus) {
			case "G": //zelena
				mark.className="ok";
        $(mark2).attr('src', addPath + 'img/idx_alert_ok.png');
				break;
			case "R": //cervena
				mark.className="ko";
        $(mark2).attr('src', addPath + 'img/idx_alert_ko.png');
				break;
			default: //zluta
				mark.className="x";
        $(mark2).attr('src', addPath + 'img/idx_alert_x.png');
		}
		if (startCoord<ql.offsetWidth) {
			mark.style.display="block";
			insertMark.style.display="block";
			mark.style.top = $('#'+edit_id).position().top + $('#'+edit_id).outerHeight()+"px";
			mark.style.left=startCoord+"px";
			mark.style.width=endCoord-startCoord+paddingLeft+"px";
			insertMark.style.top=mark.style.top;
			switch (insertStatus) {
				case 2: //vlevo
					insertMark.style.left=startCoord-insertMarkHalfWidth+"px";
					break;
				case 1: //vpravo
					insertMark.style.left=startCoord+endCoord-startCoord+paddingLeft-insertMarkHalfWidth+"px";
					break;
				default: //vprostred
					insertMark.style.left=startCoord+Math.round((endCoord-startCoord+paddingLeft)/2)-insertMarkHalfWidth+"px";
			}
		} else {
			mark.style.display="none";
			insertMark.style.display="none";
		}

//		alert(mark.style.left+" x "+mark.style.top);
//		startCoord=8*startPos-ql.scrollLeft+"px";
//		endCoord=8*endPos-ql.scrollLeft+"px";
//		mark.style.left=startCoord;
//		mark.style.width=endCoord-startCoord;
//		if (elm.selectionStart<51) {
//			elm.style.backgroundPosition=8*elm.selectionStart+"px";
//		} else {
//			elm.style.backgroundPosition=8*(elm.selectionStart-noOfCharsVisible)+"px";
//		}
	} else {
		mark.style.width="0px";
	}
}

function hide_idx_window() {
	hide_window("sf_indexArea_left");
	hide_window("sf_indexArea");
	hide_window("sf_indexArea_right");
	hide_window("sf_indexArea_indicators");
	hide_window("sf_indexArea_insert_mark");
	idx_is_open=false;
	idx_tmp_line.style.backgroundImage="none";
  $('#asf_srch').removeAttr('disabled');
}

function get_help(forwhat, mylang) {
	var path="";
	switch (mylang) {
		case "cs":
			path="docs/mns_guide_index_cs.pdf"; 
			break;
		default:
			path="../docs/mns_guide_index_en.pdf";
	}
	var helpWin=window.open(path,'mns20help');
}


