	function BWCheck_VL() {  /* Detects version of the client browser */
		var bw = navigator.appName;
		this.bwFull = bw;
		if (bw == "Netscape") this.bw = "ns";
		else if (bw == "Microsoft Internet Explorer") this.bw = "ie";
		else if (bw.toLowerCase() == "opera") this.bw = "op";
		else this.bw = bw;
		this.version = navigator.appVersion
		
		if (this.bw=='ie'){ // Internet Explorer return '4.0 (compatible; MSIE 5.5...'
			var ve = this.version.indexOf("MSIE");
			this.v = parseInt(this.version.substr(ve+4))
		}
		else this.v = parseInt(this.version);

		this.op = (this.bw == "op"); // added by VL
		this.ns = (this.bw == "ns" && this.v >= 4);
		this.ns4 = (this.bw == "ns" && this.v == 4);
		this.ns5 = (this.bw == "ns" && this.v == 5);
		this.ie  = (this.bw == "ie" && this.v >= 4);
		this.ie4 = (this.version.indexOf('MSIE 4') > 0);
		this.ie5 = (this.version.indexOf('MSIE 5') > 0);
		this.ie55 = (this.version.indexOf('MSIE 5.5') > 0); // AT 05.11.00
		this.ie6 = (this.version.indexOf('MSIE 6') > 0); // added by ZM
		this.dom = (document.getElementById) ? true : false;
	}

	is = new BWCheck_VL();


	var SEARCH = false;
	function is_empty(string){
		string = remSpaces(string);
		if(string == "")	{ return true;	}
		expression = /[\w\dàáâãäå¸æçèéêëìíîïðñòóôõö÷øùúûüýþÿàèæëáðøûþ]+/ig;
		if(SEARCH == true) {
			expression = /\w+|\d+|\*+/ig;
		}
		rez = string.match(expression);
		SEARCH = false;
		return (rez == null) ? true : false;
	}


	function is_email(string) {
		if(string == "mano@pastas.lt") { return false; }

		rez = string.match(/.*@pastas.*/ig);
		if(rez != null) { return false; }

		rez = string.match(/^[\w-\.]+@[\w-\.]+\.\w{2,4}$/ig);
		return (rez == null) ? false : true;
	}


	function remSpaces(string) {
		return string.replace(/^\s*/ig,"").replace(/\s*$/ig,"");
	}
	

	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];
			if(curElement.tagName!="FIELDSET")
			switch (curElement.type.toLowerCase()) {
				case "text":			if(!validateText(curElement))			return false; break;
//				case "file":			if(!validateText(curElement))			return false; break;		// uzkomentuota 2007.05.25 - firFox'se neveikia
				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(obj.getAttribute("check") == "1")	// added
		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(obj.getAttribute("check") == "1")	// added
		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(obj.getAttribute("check") == "1")	// added
		if(oVal) {
			if(!obj.checked) {
				alert(oVal);
				obj.focus();
				return false;
			}
		}
		return true;
	}

	function validateSelect(obj) {
		var oVal = obj.getAttribute("isEmpty");
		if(obj.getAttribute("check") == "1")	// added
		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(obj.getAttribute("check") == "1")	// added
		if(oVal) {
			if(obj.selectedIndex == -1) {
				alert(oVal);
				obj.focus();
				return false;
			}
		}
		return true;
	}

	function initSubmit(form) {
		/*_added____begin*/

		if (getElement("subscType") && getElement("subscType").type != "hidden")
		if (form.subscType[0].checked == false && form.subscType[1].checked == false)	{
			alert("Nepaþymëtas mokëtojo tipas: asmuo arba ámonë.")
			return false
		}

		for (i=0; i<form.apmok_budas.length; i++)
		{
			if (form.apmok_budas[i].checked != false)
/*_added____end*/
				return smartCheck(form);
		}
//		if (form.apmok_budas[0].checked == false && form.apmok_budas[1].checked == false && form.apmok_budas[2].checked == false && form.apmok_budas[3].checked == false && form.apmok_budas[4].checked == false && form.apmok_budas[5].checked == false)	{
			alert("Nepaþymetas mokëjimo bûdas.")
			return false
//		}
		
	}

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