function isAdresa(string) {
    if (string.search(/^([\w\(-\/])+/) != -1)
        return true;
    else
        return false;
}

function isPSC(string) {
    if (string.search(/^\d+( \d+)?$/) != -1)
        return true;
    else
        return false;
}

function isMesto(string) {
    if (string.search(/^([\w\(-\/\\])+/) != -1)
        return true;
    else
        return false;
}

function isNumber(string) {
    if (string.search(/^\d+$/) != -1)
        return true;
    else
        return false;
}

function isDate(string) {
	var i = string.search(/^(\d{1,2}[,.]{1}\d{1,2}[,.]{1}\d{1,4})$/)
//	alert("i="+i)
    if (i != -1)
	{
		string = string.substr(i)
//		alert("1="+string)
		i = string.search(/[,.]{1}/)
		var den = Number(string.substr(0,i))
//		alert("den"+den)
		if ((den<1) || (den>31))
			return false
		string = string.substr((i+1))
//		alert("2="+string)
		i = string.search(/[,.]{1}/)
		var mesiac = Number(string.substr(0,i))
//		alert("mes="+mesiac)
		if ((mesiac<1) || (mesiac>12))
			return false
		var rok = Number(string.substr((i+1)))
//		alert("rok="+rok)
		switch (mesiac)
		{
			case 2 :
				if (den>29)
					return false
			case 4 :
				if (den==31)
					return false
			case 6 :
				if (den==31)
					return false
			case 9 :
				if (den==31)
					return false
			case 11 :
				if (den==31)
					return false
		}
        return true;
	}
    else
        return false;
}

function isNowDate(string,date) {
	var datum = string
    if (isDate(string))
	{
//		var i = string.search(/^(\d{1,2}[,.]{1}\d{1,2}[,.]{1}\d{2}|\d{4})$/)
		var i = datum.search(/^(\d{1,2}[,.]{1}\d{1,2}[,.]{1}\d{1,4})$/)
		datum = datum.substr(i)
//		alert("1="+datum)
		i = datum.search(/[,.]{1}/)
		var den = Number(datum.substr(0,i))
//		alert("den="+den)
		datum = datum.substr((i+1))
//		alert("1="+datum)
		i = datum.search(/[,.]{1}/)
		var mesiac = Number(datum.substr(0,i))
//		alert("mes="+mesiac)
		var rok = Number(datum.substr((i+1)))
//		alert("rok="+rok)
		if (rok<100)
			rok += 2000

		i = date.search(/[,.]{1}/)
		var denNow = Number(date.substr(0,i))
		date = date.substr((i+1))
		i = date.search(/[,.]{1}/)
		var mesiacNow = Number(date.substr(0,i))
		var rokNow = Number(date.substr((i+1)))
		
		if (rok==rokNow)
		{
			if (mesiac<mesiacNow)
				return false
			else
				if (mesiac==mesiacNow)
				{
					if (den<denNow)
						return false
					else
						return true
				}
				else
					return true
		}
		else
		{
			if (rok==(rokNow+1))
				return true
			else
				return false
		}
	}
    else
        return false;
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+(((\.|-)\w+)*)?\.\w+$/) != -1)
        return true;
    else
        return false;
}

function isProper(string) {
    if (string.search(/^([a-zA-Z0-9.])+/) != -1)
//    if (string.search(/^\w+( \w+)?$/) != -1)
        return true;
    else
        return false;
}

<!-- ------------------------------------------------------ -->
function checkPSC(formElement)
{
    if (isPSC(formElement.value) == false) {
		return false;
    }
	else
		return true
}

function checkEmail(formElement)
{
    if (isEmail(formElement.value) == false) {
        formElement.focus();
		return false;
    }
	else
		return true
}

function checkLogin(formElement)
{
    if (isProper(formElement.value) == false) {
        formElement.focus();
		return false;
    }
	else
		return true
}

function checkPocet(formElement)
{
    if (isNumber(formElement.value) == false) {
        alert("Zadajte prosm korektn poet.");
        formElement.focus();
		return false;
    }
	else
		return true
}

function checkSuma(formElement)
{
    if (isNumber(formElement.value) == false) {
        formElement.focus();
		return false;
    }
	else
		return true
}

function checkDatum(formElement)
{
    if (isDate(formElement.value) == false) {
        formElement.focus();
		return false;
    }
	else
		return true
}

//function checkMoney(fieldName, fieldValue) 
function checkMoney(formElement) 
{
	decallowed = 2;  // how many decimals are allowed?
	
	if (isNaN(formElement.value) || formElement.value == "") {
        formElement.focus();
		return false;
	}
	else {
		if (formElement.value.indexOf('.') == -1) formElement.value += ".";
		dectext = formElement.value.substring(formElement.value.indexOf('.')+1, formElement.value.length);
	
		if (dectext.length > decallowed)
		{
        formElement.focus();
		return false;
	      }
		else {
		return true;
	      }
	   }
}

function howManyChecked(whichForm,whichCheckBoxArray,myMax,myMin,whichQuestion)
/*
  This function takes 5 paramaters:
  whichForm -- the NAME of the form to be validated, a string
  whichCheckBoxArray -- the NAME of the checkbox to be checked, a string
  myMax -- the most you want the user to be able to check, an integer
  myMin -- the least you want the user to be able to check, an integer
  whichQuestion -- a short description of the question, a string
  
  example use:
  howManyChecked('myform','cb_industry',6,1,'Industry');
*/
{
	var _countChecked = 0;
	var err = 0;
	/* iterate through all the elements in the checkbox array */
	for(i=0;i<document[whichForm][whichCheckBoxArray].length;i++)
	{
		/* and check to see if each is checked */
		if(document[whichForm][whichCheckBoxArray][i].checked==true)
			/* if it is, increment a counter */
			{ _countChecked++; }
	}
	/* is the count too high? */
	if(_countChecked > myMax)
		{ alert('Mes vybra max.  '+myMax+' monost k '+whichQuestion+'');
			err = 1;}
	/* of is the count too low */
	else if(_countChecked <= myMin-1)
		{ alert('Mus vybra min. '+myMin+' monost k '+whichQuestion+'');
			err = 1;}
	if (err == 1) { return false; } {return true;}
}
