function date_toSend(tday){
	var yr = tday.getFullYear();
	var mo = tday.getMonth() + 1;
	var dy = tday.getDate();
	if (mo < 10) mo = "0" + mo;
	if (dy < 10) dy = "0" + dy;
	
	return yr + "-" + mo + "-" + dy;
}
function date_hu(tday){
	var yr = tday.getFullYear();
	var mo = tday.getMonth();
//	var dy = tday.getDate();
//	var tdy = tday.getDay();
//	var txdy = "";
//	switch(tdy)
//	{
//		case 0:
//		txdy = "Vasárnap";
//		break;
//		case 1:
//		txdy = "Hétf?";
//		break;
//		case 2:
//		txdy = "Marti";
//		break;
//		case 3:
//		txdy = "Miercuri";
//		break;
//		case 4:
//		txdy = "Joi";
//		break;
//		case 5:
//		txdy = "Vineri";
//		break;
//		case 6:
//		txdy = "Sambata";
//		break;
//		default:
//		txdy = "";
//
//	}

	var txmo = "";
	switch (mo)
	{
		case 0:
		txmo = "Január";
		break;
		case 1:
		txmo = "Február";
		break;
		case 2:
		txmo = "Március";
		break;
		case 3:
		txmo = "Április";
		break;
		case 4:
		txmo = "Május";
		break;
		case 5:
		txmo = "Június";
		break;
		case 6:
		txmo = "Július";
		break;
		case 7:
		txmo = "Augusztus";
		break;
		case 8:
		txmo = "Szeptember";
		break;
		case 9:
		txmo = "Október";
		break;
		case 10:
		txmo = "November";
		break;
		case 11:
		txmo = "December";
		break;
		default:
		txmo = "";
	}

//	var dysfx = "";
//	var tbit = "";
//	if (dy.toString().length > 1)
//	{
//		tbit = dy.toString().slice(1,2);
//	}
//	else
//	{
//		tbit = dy.toString();
//	}

	return (yr + " " + txmo);
}

function month_hu (tday)
{
	var mo = tday.getMonth();

	var txmo = "";
	switch (mo)
	{
		case 0:
		txmo = "Január";
		break;
		case 1:
		txmo = "Február";
		break;
		case 2:
		txmo = "Március";
		break;
		case 3:
		txmo = "Április";
		break;
		case 4:
		txmo = "Május";
		break;
		case 5:
		txmo = "Június";
		break;
		case 6:
		txmo = "Július";
		break;
		case 7:
		txmo = "Augusztus";
		break;
		case 8:
		txmo = "Szeptember";
		break;
		case 9:
		txmo = "Október";
		break;
		case 10:
		txmo = "November";
		break;
		case 11:
		txmo = "December";
		break;
		default:
		txmo = "";
	}

	return txmo;
}

function trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function validate_completed (value, msg)
{
	value = trim(value);
	if (!is_completed(value)) return msg + '\n';
	else return '';
}

function validate_length (value, min, max, msg_min, msg_max)
{
	value = trim(value);
	if (value.toString().length < min) return msg_min + '\n';
	if (value.toString().length > max) return msg_max + '\n';
	
	return '';
}

function validate_int (value, min, message)
{
	if (trim(value).toString().length < 1) return message + '\n';
	if (!(Number(value) >= min)) return message + '\n';
	if (Math.round(value) != value) return message + '\n';
	return '';
}

function validate_int_minmax (value, min, max, message)
{
	if (trim(value).toString().length < 1) return message + '\n';
	if (!(Number(value) >= min)) return message + '\n';
	if (!(Number(value) <= max)) return message + '\n';
	if (Math.round(value) != value) return message + '\n';
	return '';
}

function is_completed (value)
{
	if (trim(value).toString().length > 0) return true;
	else return false;
}

function validate_extension (value, ext_list, message)
{
	if (!is_completed(value))
		return message + '\n';
	
	var sExt = value.match( /\.[^\.]*$/ ) ;
	sExt = sExt ? sExt[0].toLowerCase() : "." ;

	if (ext_list.indexOf(sExt) < 0) 
		return message + '\n';

	return '';
}