<!--

/*	
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	drobne fce aplikace actavia by ivosan; (C) ivo andrle

  	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

vSuppOK = (
	((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) >= 3 )) ||
	((navigator.appName == 'Microsoft Internet Explorer') && (parseInt(navigator.appVersion) >= 4 ))
);

var defStatus = '';

var statTimer 			= null;			//...timer - smazani status row
var statTimerRunning 	= false;			//...timer jede
var statNoTimer 		= false;			//...timer potlacen, nevyvolava se (Start)

var editorSelCol 		= '#FFFEE1';
var editorNoSelCol 		= 'transparent';

//...odpoved

	function doChallengeResponse() {
		if (document.login.hit.value == 0) {
			document.login.hit.value = 1;

			str = document.login.username.value + ":" + document.login.password.value + ":" + document.login.challenge.value;
			document.login.response.value = MD5(str);
			document.login.password.value = "";
			document.login.screenwidth.value = screen.width;
			document.login.submit();
		}
	}

	function confirmationYes() {
		if (document.confirmation.hit.value == 0) {
			document.confirmation.hit.value = 1;

			document.confirmation.confirmed.value = 1;
			document.confirmation.submit();
		}
	}

	function confirmationNo() {
		if (document.confirmation.hit.value == 0) {
			document.confirmation.hit.value = 1;

			document.confirmation.confirmed.value = 0;
			document.confirmation.submit();
		}
	}

	function confirmaction(txt) {
		if (document.confirmation.hit.value == 0) {
			document.confirmation.hit.value = 1;

			document.confirmation.action.value = txt;
			document.confirmation.submit();
		}
	}

//...status span - prostor pro mouseover
	function setStat(txt) {
		var stbar = document.getElementById('headMOver');
		stbar.innerHTML = txt;
		if (!statNoTimer) {
			if (statTimerRunning) {
				window.clearTimeout(statTimer);
			}
			if (txt != defStatus) {
				statTimer = window.setTimeout('setStat(defStatus, 1)', 999);
				statTimerRunning = true;
			} else statTimerRunning = false;
		}
	}

//...drobnosti

	function pageContainerHideShow (pgname, ThisIsShow) {
		var pagename = 'page_' + pgname;
		var ret = document.getElementById(pagename);
		if (ret)
			ret.style.display = (ThisIsShow ? 'block' : 'none');
	}

	function showHideByDeliveryType() {
		var Opt = document.userform.deliverytype.options;
		if (Opt.selectedIndex == -1) return true;
		var val = Opt[Opt.selectedIndex].value;
		var pg = document.getElementById('page_delinfo');
		if (pg)
			pg.style.display = (val > 0 ? 'block' : 'none');
	}

	function showHideByCompanyType() {
		var Opt = document.userform.companytype.options;
		if (Opt.selectedIndex == -1) return true;
		var val = Opt[Opt.selectedIndex].value;
		var pg = document.getElementById('page_fainfo');
		if (pg)
			pg.style.display = (val > 0 ? 'block' : 'none');
	}

	function noteFocus(item) {
		try {
			var ret = document.getElementById(item.name + 'Note');
			if (ret) {
				ret.style.color = "#999";
			}
		} catch (e) {
			return;
		}
	}

	function noteBlur(item) {
		try {
			var ret = document.getElementById(item.name + 'Note');
			if (ret) {
				ret.style.color = "#fff";
			}
		} catch (e) {
			return;
		}
	}

	function moFocus(item) {
		try {
			var ret = document.getElementById(item + 'Mover');
			if (ret) {
				ret.style.color = "#999";
			}
		} catch (e) {
			return;
		}
	}

	function moBlur(item) {
		try {
			var ret = document.getElementById(item + 'Mover');
			if (ret) {
				ret.style.color = "#fff";
			}
		} catch (e) {
			return;
		}
	}

	function SwapAutNames() {
		var val = document.forms['autsetting'].elements['fname'].value;
		document.forms['autsetting'].elements['fname'].value = document.forms['autsetting'].elements['lname'].value;
		document.forms['autsetting'].elements['lname'].value = val;
	}

	function changeClass(combo, artkey, atype, paraid) {
		try {
			var sclass = combo.options[combo.selectedIndex].value;
			var url = "/editor.php?artkey=" + artkey + "&type=" + atype + "&paraid=" + paraid + "&paraclass=" + sclass  + "&action=chtype";
			location.href = url;
		} catch (e) {
			return;
		}
	}

	function layComboChng(formname, valname, val, valtxt) {
		try {
			document.forms[formname].elements[valname].value = val;
			var ret = document.getElementById(formname + '_' + valname);
			if (ret) {
				ret.innerHTML = valtxt;
			}
		} catch (e) {
			return;
		}
	}

	function addRoleSubmit() {
		document.allactions.expiration.value = document.expform.expire.value;
		sendAllActAction('addrole');
	}

//...fce specificke pro revisions

	function callUploadAttachment(mode) {
		try {
			if (document.reviewform.hit.value == 0) {
				document.reviewform.hit.value = 1;
				document.reviewform.showupload.value = mode;
				document.reviewform.submit();
			}
		} finally {;
		};
	}

//...editor

function iEdClickRow(i) {
	try {
		var seleStat = isInArray(edSelRows, i);
		document.getElementById('eTr_'+i).style.background = (seleStat ? editorNoSelCol : editorSelCol);
		if (seleStat) {
			var wasChange = false;
			var newArr = new Array();
			for (id in edSelRows) {
				if (edSelRows[id] == i) {
					var wasChange = true;
				} else newArr.push(edSelRows[id]);
			}
			if (wasChange)
				edSelRows = newArr;
		} else {
			edSelRows.push(i);
		}
		iEdImplode();
	} finally {;}
}

function iEdClickRowFr(i) {
	try {
		edSelFr = i;
		if (edSelTo < edSelFr) 
			edSelTo = edSelMaxOrd;
		iEdReselectOnBorders();
		iEdImplode();
	} finally {;}
}

function iEdClickRowTo(i) {
	try {
		edSelTo = i;
		if (edSelFr > edSelTo) 
			edSelFr = edSelMinOrd;
		iEdReselectOnBorders();
		iEdImplode();
	} finally {;}
}

function iEdSelectAll() {
	try {
		edSelFr = edSelMinOrd;
		edSelTo = edSelMaxOrd;
		iEdReselectOnBorders();
	} finally {;}
}

function iEdUnselectAll() {
	try {
		edSelFr = 0;
		edSelTo = 0;
		iEdReselectOnBorders();
	} finally {;}
}

function iEdInvertSel() {
	try {
		var newArr = new Array();
		for (j=edSelMinOrd; j<=edSelMaxOrd; j++) {
			if (document.getElementById('eTr_'+j)) {
				var seleStat = isInArray(edSelRows, j);
				if (!seleStat)
					newArr.push(j);
				document.getElementById('eTr_'+j).style.background = (seleStat ? editorNoSelCol : editorSelCol);
			}
		}
		edSelRows = newArr;
		edSelFr = edSelMinOrd;
		edSelTo = edSelMaxOrd;
	} finally {;}
}

function iEdReselectOnBorders() {
	try {
		var wasChange = false;
		var newArr = new Array();
		for (id in edSelRows) {
			if (edSelRows[id] < edSelFr || edSelRows[id] > edSelTo) {
				var wasChange = true;
				if (document.getElementById('eTr_'+edSelRows[id]))
					document.getElementById('eTr_'+edSelRows[id]).style.background = editorNoSelCol;
			} else newArr.push(edSelRows[id]);
		}
		if (wasChange)
			edSelRows = newArr;
		for (j=edSelFr; j<=edSelTo; j++) {
			if (document.getElementById('eTr_'+j) && !isInArray(edSelRows, j)) {
				edSelRows.push(j);
				document.getElementById('eTr_'+j).style.background = editorSelCol;
			}
		}
	} finally {;}
}

function isInArray(arr, val) {
	for (i in arr)
		if (arr[i] == val)
			return true;
	return false;
}

function iEdImplode() {
	try {
		document.massedit.masskeys.value = edSelRows.join('~');
	} finally {;}
}

	function photoTagsCopy(addtags) {
		document.allactions.keyw.value = document.keyform.keyw.value;
		sendAllActAction(addtags ? 'addtags' : 'droptags');
	}


//-->