<!--
function ltrim(s) {
	return s.replace( /^\s*/, "" );
}
function rtrim(s) {
	return s.replace( /\s*$/, "" );
}
function trim ( s ) {
	return rtrim(ltrim(s));
}

function is_empty(checkStr) {
  if (trim(checkStr) == "")
     return (true);
}


function check_date(checkStr, with_empty) {
	if (isNaN(with_empty)) with_empty = 0;
	if (trim(checkStr)=="" && with_empty==1) return (true);

	var d,m,y,i,j,s,sloc, str, isdate;
	
	DaysInMonth = new Array();
	DaysInMonth[1] = 31;
	DaysInMonth[2] = 28;
	DaysInMonth[3] = 31;
	DaysInMonth[4] = 30;
	DaysInMonth[5] = 31;
	DaysInMonth[6] = 30;
	DaysInMonth[7] = 31;
	DaysInMonth[8] = 31;
	DaysInMonth[9] = 30;
	DaysInMonth[10] = 31;
	DaysInMonth[11] = 30;
	DaysInMonth[12] = 31;
	
	ymd = new Array();
	
	sym = new Array();
	sym[0] = ".";
	sym[1] = "/";
	
	//check structure of string (must be "*/*/*" or "*.*.*")
	for (j=0;j<2;j++) {
		str = checkStr;
		s = sym[j];
		isdate = true;
		for (i=0;i<3;i++) {
			sloc = str.lastIndexOf(s);
			if (((sloc==-1)&&(i<2)) || ((sloc!=-1)&&(i>1))) isdate = false;
			ymd[i] = str.substring(sloc+1);
			str = str.substring(0, sloc);
		}
		if (isdate==true) break;
	}
	
	if (isdate==false) return (false);


	//check year, month and day numeric 
	var valid = new Date(ymd[0],ymd[1],ymd[2]);

	if (valid=="Invalid Date" || valid=='NaN') return false;
		
	//check year validate
	if ( (ymd[0]<10) || (ymd[0]>9999) ) return false;
	//set 29 days in february if needed
	if ((ymd[0]-1004)%4==0) DaysInMonth[2] = 29; 
	
	//check month validate
	if ( (ymd[1]<0) || (ymd[1]>12) ) return false;
	
	//check day	validate
	if ( (ymd[2]<0) || (ymd[2]>DaysInMonth[ymd[1]]) ) return false;
	
	//OK			
	return true;
}




function check_time(checkStr, with_empty) {
	if (isNaN(with_empty)) { with_empty = 0; }
	
	if (trim(checkStr)=="" && with_empty!=0) return (true);

	var k, ch, str;

	hms = new Array();
	hms[0] = '';
	hms[1] = '';
	hms[2] = '';
	
	k = 0;
	str = trim(checkStr)+':00:00:00';

	for (i=0;  i<str.length;  i++) {
		ch = str.charAt(i);
		if (ch==':') { 
			if (k==2) { break; }
			k = k + 1;
		} else {
			hms[k] = hms[k] + ch;
		}
	}
	
	// check HOURS
	if (! check_int(hms[0], 0)) return(false);
	if (hms[0]<0 || hms[0]>23)  return(false);

	// check MINUTES
	if (! check_int(hms[1], 0)) return(false);
	if (hms[1]<0 || hms[1]>59)  return(false);

	// check SECUNDES
	if (! check_int(hms[2], 0)) return(false);
	if (hms[2]<0 || hms[2]>59)  return(false);

	//OK			
	return (true);
}




function check_int(checkStr, without_0) {
  var checkOK = "0123456789-";

  if (trim(checkStr)=="") {
  	if (without_0==0) {
		return (true);
	} else {
		return (false);
	}
  }

  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);

    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;

    if (j == checkOK.length)
      return (false);
  }  

  var x = new Number(checkStr);
  if (x == 0 && without_0 == "1")
    return (false);

  return (true);
}




function check_money(checkStr, equal_0) {
  var mask = " 0123456789.,";
  var newStr = '';

  if (trim(checkStr) == "")
     return (false);


  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);

    for (j = 0;  j < mask.length;  j++) {
      if (ch == mask.charAt(j))
        	break;
    }

    if (j == mask.length) {
      return (false);
    }

    if (ch == ',') { newStr = newStr + '.'; } else { newStr = newStr + ch; } 
  }  

  var x = new Number(newStr);

  if (!equal_0) {
      if (x < 0.01) return (false);
  }

  return (true);
}






// вывод разности в датах
function put_diff_date() {
	today = new Date();     // Сегодняшняя дата
	festival = new Date();
	festival.setYear(2000); // Устанавливаем год фестиваля
	festival.setMonth(05);  // Устанавливаем месяц фестиваля
	festival.setDate(24);   // Устанавливаем день фестиваля

	// Если фестиваль еще не начался, вычисляем разность
	// между сегодняшней датой и датой фестиваляв милисекундах
	// и выводим на экран.

	if (today.getTime() < festival.getTime()) {
		difference = festival.getTime() - today.getTime();
		difference = Math.floor(difference / (1000 * 60 * 60 * 24));
		k = difference % 10;
		s = "дней";
		if (k==1) s = "день";
		if (k>=2 && k<=4) s = "дня";
	 	document.write('<h3>До фестиваля осталось ' + difference + ' ' + s + '!</h3>');
	}
}

!-->
