/*function manageEventArchive(){
}

function newEvent(){
	var tdArray = document.getElementsByTagName("td"); 
	var maxId = 1;
	for(i=tdArray.length-1;i>=0;i--){
		if(tdArray[i].className == "editorFieldListTd id"){
			var id = parseInt(tdArray[i].innerHTML.replace(/^[\s\n\t]+|[\n\t\s]+$/g,""));
			if(id > maxId)
				maxId=id;
		}
	}
	var newId = maxId + 1;
	if(highlightedObject!=null){
		var cells = highlightedObject.cells;
		before = "&before=" + cells[0].innerHTML.replace(/^[\s\n\t]+|[\n\t\s]+$/g,"");
	}else
		before = "";
	window.location = editorLocation + "?section=aktualnosci" + "&edit=tresc" + before + "&id=" + newId + "&new=1";
}

function editEvent(){
	if(highlightedObject!=null){
		var cells = highlightedObject.cells;
		window.location = editorLocation + "?section=aktualnosci" + "&edit=tresc" + "&id=" + cells[0].innerHTML.replace(/^[\s\n\t]+|[\n\t\s]+$/g,"");
	}else
		alert(noHighlightMessage);
}

function removeEvent(){
	if(highlightedObject!=null){
		var cells = highlightedObject.cells;
		window.location = editorLocation + "?section=aktualnosci" + "&remove=true" + "&id=" + cells[0].innerHTML.replace(/^[\s\n\t]+|[\n\t\s]+$/g,"");
	}else
		alert(noHighlightMessage);
}

function editEventIntroduction(){
	window.location = editorLocation + "?section=aktualnosci" + "&edit=wstep";	
}*/
function isHighlighted(highlightID){
	var retainers = document.getElementsByName(highlightID);
	for(j=0; j<retainers.length; j++)
		if(retainers[j] == null || retainers[j].value == null || retainers[j].value.length == 0)
			return false;
	return true;
}

function setInput(retainerID, value, submit){
	if(submit==null)
		submit=true;
	var retainers = document.getElementsByName(retainerID);
	for(j=0; j<retainers.length; j++){
		retainers[j].value = value;
		//alert(retainers[j].value);
		if(submit)
			retainers[j].form.submit();
		return true;
	}
	return false;
}

function getInput(retainerID){
	var retainers = document.getElementsByName(retainerID);
	for(j=0; j<retainers.length; j++)
		return retainers[j].value;
	return null;
}

function levelUp(retainerID,filenameID,fileParentID){
	var retainers = document.getElementsByName(retainerID);
	for(j=0; j<retainers.length; j++){
		var oldPath = retainers[j].value;	
		var sections = oldPath.split("/");
		var newPath = new String();
		for(i=0; i<sections.length-1; i++)
			if(sections[i]!="")
				newPath += "/" + sections[i];
		if(newPath=="")
			if(getInput(fileParentID)!=null)
				setInput(filenameID,getInput(fileParentID));
			else 
				return false;
		retainers[j].value = newPath;
		retainers[j].form.submit();
		return true;			
	}
	return false;
}
function save(retainerID){
	return setInput(retainerID, "save");
}
function fusedSave(retainerID, fuse){
	setTimeout('save("'+retainerID+'");', fuse);
}
function insert(retainerID, highlightID){
	var operation = "insert";
	if(!isHighlighted(highlightID))
		operation = "append";	
	return setInput(retainerID, operation);	
}

function remove(retainerID, highlightID){
	if(!isHighlighted(highlightID)){
		alert("Nie wybrano obiektu do usunięcia.");
		return false;
	}
	
	if(window.confirm("Usunąć wybrany obiekt?.")){
		var retainers = document.getElementsByName(retainerID);
		return setInput(retainerID, "remove");
	}	
}

function edit(retainerID, highlightID){
	if(!isHighlighted(highlightID)){
		alert("Nie wybrano obiektu do edycji.");
		return false;
	}	
	setInput(retainerID, "edit");
}

function intro(retainerID, xPathID, xPath){
	//xPath = getInput(xPathID) + xPathSuffix;
	setInput(xPathID, xPath, false);
	setInput(retainerID, "edit");
}

function moveUp(retainerID, highlightID){
	if(!isHighlighted(highlightID)){
		alert("Nie wybrano obiektu do przesunięcia.");
		return false;
	}	
	//alert("moving up");
	setInput(retainerID, "move up");
}

function moveDown(retainerID, highlightID){
	if(!isHighlighted(highlightID)){
		alert("Nie wybrano obiektu do przesunięcia.");
		return false;
	}	
	//alert("moving down");
	setInput(retainerID, "move down");
}

/*
function newsMenuAction(sectionValue, form){
	if(form.highlightedInput.value==null || form.highlightedInput.value==""){
		alert("Nie wybrano obiektu do edycji.");
		return false;
	}
	form.sectionInput.value = sectionValue;
	form.submit();			
}*/
