// test na povinne parametry formulare
function checkMe(tf,text,pars)
{
	pole=pars.split(',');
	for(i=0;i<pole.length;i+=2)
	{
		if(eval('typeof  tf.'+pole[i])!='undefined'){
			if(eval('tf.'+pole[i]+'.value')=='')
			{
				alert(pole[(i+1)]+' '+text);
				eval('tf.'+pole[i]+'.focus()');
				return false;
			}
		}
	}
	return true;
}

// nove okno
function previewWindow(url, title)
{
	window.open(url, title, "toolbar=no,status=no,scrollbars=yes,resizable=yes,width=800,height=600");
}

function newwindow(url,title){
	window.open(url, title, "toolbar=yes,status=yes,scrollbars=yes,resizable=yes");
}


// vraci hodnotu z popup okna zpet do formulara
function backToForm(elName, newId, newName){

//	if (window.showModalDialog) {
//		dialogArguments.document.all(dialogArguments.elementFk).value = newId;
//		dialogArguments.document.all(dialogArguments.elementName).innerHTML = newName;
//	} else { //Netscape
		var opnr=window.opener;
		opnr.document.getElementById(elName+'_fk').value=newId;
		opnr.document.getElementById(elName+'_name').innerHTML=newName;	
//	}
	window.setTimeout('window.close()',10);
}

// smaza hodnoty z formulare u tematu 
function deleteFormInput(name){
	document.getElementById(name+'_fk').value='';
	document.getElementById(name+'_name').innerHTML='';
}

// Otevre okno pro vyber souboru (reuse)
function chooseFile(inpId){
//	if (window.showModalDialog) {
//		window.elementFk = inpId+'_fk';
//		window.elementName = inpId+'_name';
//		showModalDialog ("../fileman/files.asp?inpID="+inpId, window, "dialogheight=600px;dialogwidth=800px;status=no;toolbar=no;menubar=no;location=no;resizable=yes;scroll:yes")
//	} else {
		window.open("../fileman/files.asp?inpID="+inpId, 'zipWindow', 'width=800,height=600,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,')
//	}
}

function previewFoto(filePath){
	pole=get_element("specialPhotoDetail");
	pole.src=filePath;
}
function previewClear(filePath){
	pole=get_element("specialPhotoDetail")
	pole.src=filePath;
}

function get_element(name) {
	if (document.all) {
		return document.all[name];
	} else {
		return document.getElementById(name);
	}
}


function swapvisibility(divId){
	return swapVisibility(divId);
}
function swapVisibility(divId){
	pole=get_element(divId);
	if (pole.style.display=="none"){
		pole.style.display="";
	}else{
		pole.style.display="none";
	}
}

function predejVybraneObjednavky(srcName,descID){
	var elms, retv, elm;
	
	retv='0';
	elms=document.getElementsByName(srcName);
	for(var i=0;i<elms.length;i++){
		if(elms[i].checked) retv+=','+elms[i].value;
	}
	elm=document.getElementById(descID);
	elm.value=retv;	
}

function UkazAdresataUdaje(){
	var elms;
	
	elms=document.getElementsByName('adresatRadek');
	for(var i=0;i<elms.length;i++){
		if (elms[i].style.display==""){
			elms[i].style.display="none";
		}else{
			elms[i].style.display="";
		}
	}
}

function showHideFullSearch() {
    var maly = document.getElementById('searchBlockC_small')
    var velky = document.getElementById('searchBlockC_big')
    if (maly && velky) {
        if (maly.style.display == "none") {
            maly.style.display = "";
            velky.style.display = "none";
        } else {
            maly.style.display = "none";
            velky.style.display = "";
        }
    }
}

// Odstrani vsechny naseptavace
function odstranNaseptavace() {
    var naseptavaceNazvy = "searchText";  //oddelovat carkama bez mezer

    var mySplitResult = naseptavaceNazvy.split(",");
    for (i = 0; i < mySplitResult.length; i++) {
        if (document.getElementById('naseptavac_' + mySplitResult[i])) {
            document.getElementById('naseptavac_' + mySplitResult[i]).style.display = 'none';
        }
    }

}

