

	function smartCheck(form){
	/***********************
		This function checks all inputs, selects and textareas in the given form
		witch will have	isEmpty or isEmail attribute or both.
	***********************/
		if(!is.dom) { /*alert("DOM not implemented!");*/return true;	}

		for (i = 0; i < form.elements.length; i++) {
			curElement = form.elements[i];
			switch (curElement.type.toLowerCase()) {
				case "text":			if(!validateText(curElement))			return false; break;
				case "file":			if(!validateText(curElement))			return false; break;
				case "textarea":		if(!validateText(curElement))			return false; break;
				case "checkbox":		if(!validateRadio(curElement))			return false; break;
				case "radio":			if(!validateRadio(curElement))			return false; break;
				case "select-one":		if(!validateSelect(curElement))			return false; break;
				case "select-multiple":	if(!validateSelectMultiple(curElement))	return false; break;
				case "password":		if(!validateText(curElement))			return false; break;
				default : break;
			}
		}
		return true;
	}/*  smartCheck() end */

	function validateText(obj) {
		/************************
			NOTICE: You can check is field emty, or only validate email syntax. Depending on witch attribute you'll give to the INPUT tag.
		*************************/
		obj.value = remSpaces(obj.value);
		var oVal = obj.getAttribute("isEmpty");
		if(oVal) {
			obj.value = remSpaces(obj.value);
			if(is_empty(obj.value)) {
				alert(oVal);
				obj.select();
				obj.focus();
				return false;
			}
		}
		oVal = obj.getAttribute("isEmail");
		if(oVal) {
			if(!is_empty(obj.value)) {
				if(!is_email(obj.value)) {
					alert(oVal);
					obj.select();
					obj.focus();
					return false;
				}
			}
		}
		return true;
	}

	function validateRadio(obj) {
		obj.value = remSpaces(obj.value);
		var oVal = obj.getAttribute("isEmpty");
		if(oVal) {
			if(!obj.checked) {
				alert(oVal);
				obj.focus();
				return false;
			}
		}
		return true;
	}

	function validateSelect(obj) {
		var oVal = obj.getAttribute("isEmpty");
		if(oVal) {
			if(obj.selectedIndex == -1) {
				alert(oVal);
				obj.focus();
				return false;
			} else if(is_empty(obj.options[obj.selectedIndex].value)) {
				alert(oVal);
				obj.focus();
				return false;
			}
		}
		return true;
	}

	function validateSelectMultiple(obj) {
		var oVal = obj.getAttribute("isEmpty");
		if(oVal) {
			if(obj.selectedIndex == -1) {
				alert(oVal);
				obj.focus();
				return false;
			}
		}
		return true;
	}

	function initSubmit(form) {
		return smartCheck(form);
	}

	function deleteConfirm(msg) { /* analog of the build in confirm() function */
		return confirm(msg);
	}
