	  function input2typeModify(cellName,cellType,whatAction)
	  {
	    var position,i,j;
		position = input2type.length;
		if (whatAction == 'insert') 
		{
		  input2type[position] = cellName;
		  input2type[position+1] = cellType;
		}
		if (whatAction == 'update')
		{
		  for(i=0;i<input2type.length;i=i+2)
		  {
		    if (input2type[i] == cellName) input2type[i+1] = cellType;
		  }
		}
		if (whatAction == 'delete')
		{
		  pomArray = new Array();
		  pomArray = input2type;
		  input2type = Array();
		  j=0;
		  for (i=0;i<pomArray.length;i=i+2)
		  {
		    if (pomArray[i] != cellName)
			{
			  input2type[j]=pomArray[i];
			  input2type[j+1]=pomArray[i+1];
			  j=j+2;
			}//end of if
		  } //end of for
		} //end of if
	  } //end of function
	  
	  function strReplace(what,replecament,str)
	  {
	    var i;
	    var pomArr = new Array();
		//alert(what+'='+replecament+'='+str);
		pomArr = str.split(what);
		str = pomArr[0];
		for (i=1;i<pomArr.length;i++) str = str + replecament + pomArr[i];
		
		return str;
	  }
	  
	  function checkDate(newDay,newMonth,newYear,noFreeDay,canBeFuturesDate)//den,mesiac,rok
      {
	    var i,pomDate,eMonth;
 
	    if (isNaN(newDay) || isNaN(newMonth) || isNaN(newYear)) return false;
        
		eMonth = newMonth - 1;
        newDate = new Date(newYear,eMonth,newDay);
    
	    if ((newDay != newDate.getDate() || eMonth != newDate.getMonth() || (newYear % 100)!= (newDate.getYear() % 100)))
        { 
		  alert('Incorrect date format '+newDay+'.'+newMonth+'.'+newYear);
	      return false;
        }

    if (!canBeFuturesDate)
    {
      today = new Date();
      if (newDate > today) 
      {
        alert('Future dates cannot be entered. Please correct.');
        return false;
      }  
    }
		
        return true;
       } //end of function checkDate()
	  
	  function checkInput(thisForm)
	  {
	    var i,myValue,myType,myName,pomStr;
	    pomArray = new Array();
	    for (i=0;i<input2type.length;i=i+2)
		{
		  eval ('myValue = thisForm[\''+input2type[i]+'\'].value');
		  myType = input2type[i+1];
		  myName = input2type[i];
	//alert(myValue + ' = '+ myType);
		  if (myType.charAt(1)=='N' && myValue=='') continue;
		  if (myType.charAt(1)!='N' && myValue=='') { eval('thisForm[\''+myName+'\'].focus()');alert('Please fill in all mandatory fields.');return false; }
		  
		  if (myType.charAt(0)=="I") //integer
		  {
		  
		    if ((isNaN(myValue)) || (Math.round(myValue)!=myValue))	
			{
			  alert(myValue+' must be integer number!');
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}
		    for (j=0; j<myValue.length;j=j+1)	
		      if (myValue.charAt(j) < '0' || myValue.charAt(j) > '9')
			{
			  alert(myValue+' must be integer number!');
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}
		  } // end if myType==I
		  
		  
		  		  
		  if (myType.charAt(0) == "R" ) 
		  {
		  
		    var pos;
		    if (myType.charAt(1) == "N") pos=1; else pos=0;
		    
		    if (!myValue.length == 0) 
	            { 
	      		myValue = strReplace(',','',myValue);
	      		myVvalue = strReplace(' ','',myValue);
			if ((isNaN(myValue)) || (myValue.length == 0)) 
				{ alert('Error in '+myName+': Please enter real number only');
				  eval('thisForm[\''+myName+'\'].focus()');
				return false; }
	    	    }
            		
	            	if (myType.charAt(1 + pos) == ';')
        	    	{
        	    		
	        		var pomArr = new Array();
				pomArr = myType.split(";");
				if (pomArr[2]) 
				{
			  	if (!checkRange(thisForm[myName],pomArr[1],pomArr[2])) return false;
				}  
				else if (!checkRange(thisForm[myName],pomArr[1])) return false;
			}
			
		  }
		  
		  if ( myType.charAt(0) == "D" ) 
		  {
		    var pos;
		    if (myType.charAt(1) == "N") pos=1; else pos=0;

		    //return false;
		    //ak je za dateN.. vtedy to musi byt nenulove
		        
  	    	    canBeFuturesDate = 0;
		    if (myType.charAt(1) == "F" || myType.charAt(2) == "F")
		    {
		    	 pos=pos+1;
		    	 canBeFuturesDate = 1;
		    }

			maska = myType.substring(1+pos,myType.length);
			//alert (mask2Value(maska,value));
			//dobre = mask2Value(maska,value);
			//dobre = true;
			if  (! mask2Value(maska,myValue,canBeFuturesDate))
			{
			  // presunute do mask2Value: alert('incorect date format\n '+maska+' to '+value);
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}
			myValue = strReplace('/','.',myValue);
			eval('thisForm[\''+myName+'\'].value=myValue');
			//return false;
	              
		  }
		  
	  
		  
		  if (myType.charAt(0)=="E")
		  {
		    pomArray = myValue.split("@");
			if (pomArray.length < 2 || pomArray[0].length==0 || pomArray[1].length==0)
			{
			  alert(myValue+' is not valid email adress!');
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}
			pomArray = myValue.split(".");
			if (pomArray.length < 2 || pomArray[0].length==0 || pomArray[1].length==0)
			{
			  alert(myValue+' is not valid email adress!');
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}
		  } //end if myType=="E"
		  if (myType.charAt(0)=="P")
		  {
		    //if (myValue.charAt(0)=='+') myValue = myValue.substring(1,myValue.length);
			
			pomStr = strReplace(' ','',myValue);
			pomStr = strReplace('+','',pomStr);
			pomStr = strReplace('-','',pomStr);
			pomStr = strReplace('/','',pomStr);
			if ((isNaN(pomStr)) || (Math.round(pomStr)!=pomStr))
			{
			  alert(myValue+' is not valid phone number!');
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}
		  } // end if myType=="P"
		  if (myType.charAt(0)=="C")
		  {
		    if (!myValue) { return false;}
		    myValue = strReplace(',','.',myValue);
		    pomArray = myValue.split(' ');
			pomStr = "";
			//tento if: ak je na konci nejake necislo DEM,SK, .. tak ho odfajci po najblizsiu medzeru
			if (isNaN(pomArray[pomArray.length-1]))
			     pomStr = myValue.substring(0,myValue.length-pomArray[pomArray.length-1].length);
			if (!pomStr) pomStr = myValue;
			pomStr = strReplace(' ','',pomStr);//medzera
			pomStr = strReplace(' ','',pomStr);//bacha toto nieje medzera ale znak 160					
			
			if (isNaN(pomStr) || (pomStr.indexOf("-") != -1))
			{
			  alert(myValue+' is not valid input');
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}

			pomValueArray = pomStr.split('.');
			if (pomValueArray.length > 1 && (pomValueArray[pomValueArray.length-1].length) > 2)
			{
			  alert(myValue+' has more than 2 numbers in decimal place.');
			  eval('thisForm[\''+myName+'\'].focus()');
			  return false;
			}
			//alert(pomStr+' ');
			eval('thisForm[\''+myName+'\'].value='+pomStr);
		    //alert(myValue);
		  }//end if myType=="C"

		  if (myType.charAt(0)=="S")
		  {
		    // - select			
		      if (eval('thisForm[\''+myName+'\'][thisForm[\''+myName+'\'].selectedIndex].value') == '')
		      {
		        eval('thisForm[\''+myName+'\'].focus()');
                        alert('Please fill in all mandatory fields.');
		        return false;
		      }  
		  } // end if myType=="S"
		} //for
		//alert('true');
	    return true;
	  } // end of function 
	  
	  function checkRange(myNumber, minValue, maxValue)  // kontrola, ci je cislo >=minValue a <= maxValue
{
		myValue = myNumber.value;
//		alert("cislo="+myValue);
		myValue = strReplace(',','',myValue);
		myValue = strReplace(' ','',myValue);//bacha toto nie je medzera ale znak 160

		if (parseFloat(myValue) < parseFloat(minValue))
		{
		  alert("This number can't be smaller than " + minValue + ". Please correct.");
		  myNumber.focus();
		  return false;
		}  
		else if (parseFloat(myValue) > parseFloat(maxValue))
		{
		  alert("This number can't be greater than " + maxValue + ". Please correct.");
		  myNumber.focus();
		  return false;
		}  
		else return true;
}


function mask2Value(mask,dateStr,canBeFuturesDate)
{
  var pomStr,pomInt,maskI,dateStrK,i,k,aaa,eMonthDobre,newMonth,newDay,newYear,newHour,newMinute,newSecond;
  eMonth = new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');
  k = 0;newYear=2000;newMonth=1;newDay=1;newHour=0;newMinute=0;newSecond=0;
  //alert(mask+'-'+dateStr);
    for (i=0;i<mask.length;i++)
    {
       maskI = mask.charAt(i);
       dateStrK = dateStr.charAt(i+k);
       if ((maskI == 'M') || (maskI == 'D') || (maskI == 'Y') || (maskI == 'h') ||(maskI == 'm') || (maskI == 's') || (maskI == 'N'))
       {
        pomStr = "";
        while ((dateStrK >='0') && (dateStrK <='9'))
        {
           pomStr += dateStrK;
           k++; //posun oproti maske
           if ((i+k) < dateStr.length) dateStrK = dateStr.charAt(i+k); //posledny znak aby nepretiekol
           else dateStrK = 'x';
		  // if (dateStr.length != i+k && ) return false; //hlusina
        }
		//alert(dateStrK);
		//alert(pomStr);
		if (maskI == 'N')
		{
		  aaa = dateStr.charAt(i+k)+dateStr.charAt(i+k+1)+dateStr.charAt(i+k+2);
		  k++;k++;k++;
		  eMonthDobre = 0;
		  for (jj=0;jj<eMonth.length;jj++)
		     if (eMonth[jj] == aaa) eMonthDobre = 1;	   
		  if (! eMonthDobre) { alert('Date format must be '+mask+'. Please correct.'); return false;}
		}

        k--; //lebo vzdy vojde do while aspon raz
		pomInt = pomStr;
        switch (maskI) //priradenie masky a hodnoty
        {
           case 'M':newMonth=pomInt;
                    break;
           case 'D':newDay=pomInt;
                    break;
           case 'Y':newYear=pomInt;
			           //if (document.layers) newYear -= 1900;
                    break;
           case 'h':newHour=pomInt;
        	        break;
           case 'm':newMinute=pomInt;
                    break;
           case 's':newSecond=pomInt;
                    break;
        }//end switch
		//alert(maskI+'-'+pomInt);
	  } //nasiel masku
	  else 
	  { 
	    
	    if (maskI != dateStrK & dateStrK != "/") 
	    {
	      alert('Date format must be '+mask+'. Please correct.');
	      return false; 
	    }  
	  }
	  //alert(maskI+'-'+dateStrK);
	}// for cylus ktory prechadza celu string masky
	//alert(newDay+' '+newMonth+' '+newYear);
	 //alert(i+'-'+k);
	 if (dateStr.length != i+k )
	 {
	   alert('Date format must be '+mask+'. Please correct.');
	   return false; //hlusina
	 }  
         
         if (newYear.length < 4) 
         {
           alert('Year must have 4 numbers. Please correct.');
           return false; // Lubo: rok aspon 4 cislice: 
         }  
	return checkDate(newDay,newMonth,newYear,mask,canBeFuturesDate);
} //end function

