function valForm(e)
	{
		var myFormValidation = new FormValidator(this);
		if(myFormValidation.validateForm(false))
			this.submit();
		discardDefault(e);
	}

function changeSelection(e)
	{
		var inputsForChange = document.getElementsByName("selected_to_action[]");
		for(var i = 0; i < inputsForChange.length; i++)
			inputsForChange[i].checked = (inputsForChange[i].checked) ? false : true;
	}
	
function addFileInput(e)
	{
		element = document.getElementById("morefiles");
		nw = previousS(element);
		next = document.createElement("input");
		next.type = "file";
		next.name = "attach[]";
		next.className = "file_input";
		nw.parentNode.insertBefore(next,nw.nextSibling);
		/*
										nxelem.style.display = (nxelem.style.display == "block") ? "none" : "block";
										discardDefault(e);
									});*/
	}
	
function selMail(e,j)
	{	alert(j);
		var ielem = nextSName(this);
		alert(ielem);
		/*var inputs = document.getElementsByName("selected_to_action[]");
		inputs[j].checked = true;
		nxelem = nextS(this);
		nxelem.style.display = (nxelem.style.display == "block") ? "none" : "block";*/
		discardDefault(e);
	}

/*
* stop client to do default action
* two ways - w3c and ie
* it always returns false because addEvent function should return false
* @param mix Event
* @return bool
*/

function discardDefault(e)
	{
		if(e && e.preventDefault) // w3c way, there is e event object
			e.preventDefault();
		else
			window.event.returnValue = false; // ie way there is global event object in window.event attribute
		return false;
	}
	

	
function nextS(elem)
	{
		do
			{
				elem = elem.nextSibling;
			}	while(elem && (elem.nodeType != 1 || elem.nodeType == 0));
		return elem;
	}
	
function previousS(elem)
	{
		do
			{
				elem = elem.previousSibling;
			}	while(elem && (elem.nodeType != 1 || elem.nodeType == 0));
		return elem;
	}
	


