	var highlightcolor="c7d5ef"

	
	var ns6=document.getElementById&&!document.all
	var previous=''
	var eventobj
	
	//Regular expression to highlight only form elements
	var intended=/INPUT|TEXTAREA|SELECT|OPTION/
	
	//Function to check whether element clicked is form element
	function checkel(which){
		if (which.style&&intended.test(which.tagName)){
			if (ns6&&eventobj.nodeType==3)
			eventobj=eventobj.parentNode.parentNode
			return true
		}
		else
			return false
	}
	
	//Function to highlight form element
	function highlight(e){
		eventobj=ns6? e.target : event.srcElement
		if (previous!=''){
			if (checkel(previous))
			previous.style.backgroundColor=''
			previous=eventobj
			if (checkel(eventobj))
			eventobj.style.backgroundColor=highlightcolor
		}
		else{
			if (checkel(eventobj))
			eventobj.style.backgroundColor=highlightcolor
			previous=eventobj
		}
	}
//*****************************************************************************************
function validEmail(email) {
	invalidChars = " /:,;"

	if (email == "") {						// cannot be empty
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// there must be one "@" symbol
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// and at least one "." after the "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
		return false
	}
	return true
}

function isNum(passedVal) {					// Is this a number?
	if (passedVal == "") {
		return false
	}
	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i) < "0") {
			return false
		}
		if (passedVal.charAt(i) > "9") {
			return false
		}
	}
	return true
}

function checkaccount()
{
	if (!isNum(document.account.karnet.value) ) {
		alert('Въведете валидни данни в поле Партида!');
		document.account.karnet.select();
		return false;
	}

	if (!isNum(document.account.stranica.value) ) {
		alert('Въведете валидни данни в поле Партида!');
		document.account.stranica.select();
		return false;
	}

	if (document.account.egn.value.length < 10 || !isNum(document.account.egn.value) ) {
		alert('Въведете валидни данни в поле ЕГН!');
		document.account.egn.select();
		return false;
	}

	return true;
}

function checkfirms()
{

	if ( !isNum(document.accountfirms.bulstat.value) ) {
			alert('Въведете валидни данни в поле БУЛСТАТ / ЕГН !');
			document.accountfirms.bulstat.select();
			return false;
		}
	
	if ( !isNum(document.accountfirms.an.value) ) {
			alert('Въведете валидни данни в поле Абонатен № !');
			document.accountfirms.an.select();
			return false;
		}

	return true;
}

