function isEmail(string) {
	return string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)+[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1
		&& string != "";
}

function isFloat(string) {
	if (string == "") return false;	
	var n = Number(string);
	return !isNaN(n);
}

function isPositiveFloat(string) {
	if (string == "") return false;	
	var n = Number(string);
	if (isNaN(n)) return false;
	return n >= 0;
}

function isGreateZeroFloat(string) {
	if (string == "") return false;	
	var n = Number(string);
	if (isNaN(n)) return false;
	return n > 0;
}

function isInteger(string) {
	return isFloat(string) && string.indexOf(".") < 0;
}

function isPositiveInteger(string) {
	if (string == "" || string.indexOf(".") >= 0) return false;	
	var n = Number(string);
	if (isNaN(n)) return false;
	return n >= 0;
}

function isGreateZeroInteger(string) {
	if (string == "" || string.indexOf(".") >= 0) return false;	
	var n = Number(string);
	if (isNaN(n)) return false;
	return n > 0;
}

function isDate(string) {
	if (string == "") return false;
	isplit = string.indexOf('/');
	if (isplit == -1) isplit = string.indexOf('.');
	if (isplit == -1 || isplit == string.length) return false;
	sMonth = string.substring(0, isplit);
	monthSplit = isplit + 1;
	isplit = string.indexOf('/', monthSplit);
	if (isplit == -1) isplit = string.indexOf('.', monthSplit);
	if (isplit == -1 ||  (isplit + 1 )  == string.length) return false;
	sDay = string.substring((sMonth.length + 1), isplit);
	isplit = string.indexOf('/', isplit);
	sYear = string.substring(isplit + 1);

	if (!isGreateZeroInteger(sYear)) return false;
	if (!isGreateZeroInteger(sMonth)) return false;
	if (!isGreateZeroInteger(sDay)) return false;

	var day = Number(sDay);
	var month = Number(sMonth);
	var year = Number(sYear);
	
	if (month < 1 || month > 12) return false;
	if (day > 31) return false;
	if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) return false;
	if (month == 2)
		if (year % 4 == 0 || (year % 100 > 0 && year % 1000 == 0)) {
			if (day > 29) return false;
		}
		else {
			if (day > 28) return false;
		}
	
	return true;
}

function datesCompare(string, string2) {
	isplit = string.indexOf('/');
	if (isplit == -1) isplit = string.indexOf('.');
	sMonth = string.substring(0, isplit);
	monthSplit = isplit + 1;
	isplit = string.indexOf('/', monthSplit);
	if (isplit == -1) isplit = string.indexOf('.', monthSplit);
	sDay = string.substring((sMonth.length + 1), isplit);
	isplit = string.indexOf('/', isplit);
	sYear = string.substring(isplit + 1);

	var day = Number(sDay);
	var month = Number(sMonth);
	var year = Number(sYear);
	
	isplit = string2.indexOf('/');
	if (isplit == -1) isplit = string2.indexOf('.');
	sMonth = string2.substring(0, isplit);
	monthSplit = isplit + 1;
	isplit = string2.indexOf('/', monthSplit);
	if (isplit == -1) isplit = string2.indexOf('.', monthSplit);
	sDay = string2.substring((sMonth.length + 1), isplit);
	isplit = string2.indexOf('/', isplit);
	sYear = string2.substring(isplit + 1);

	var day2 = Number(sDay);
	var month2 = Number(sMonth);
	var year2 = Number(sYear);
	
	if (year == year2 && month == month2 && day == day2)
		return 0;
	if ((year > year2) ||
			(year == year2 && month > month2) ||
			(year == year2 && month == month2 && day > day2))
			return -1;
	if ((year < year2) ||
			(year == year2 && month < month2) ||
			(year == year2 && month == month2 && day < day2))
			return 1;
}


function hide_unhide_layer (layer_id) {
	if ( layer_id.style.visibility == "hidden" ) {
		layer_id.style.visibility = "visible";
		layer_id.style.display = "block";
	}
	else {
		layer_id.style.visibility = "hidden";
		layer_id.style.display = "none";
	}
}

function hide_unhide_layer2 (layer_id, state) {
	if ( state == "visible" ) {
		layer_id.style.visibility = "visible";
		layer_id.style.display = "block";
	}
	else {
		layer_id.style.visibility = "hidden";
		layer_id.style.display = "none";
	}
}





function sbm_signup() {
if (document.forms[0].Name.value == "") {
  alert("Please, give your name");
  document.forms[0].Name.focus();
  return false;
}
if (!isEmail(document.forms[0].Email.value)) {
  alert("Email is incorrect");
  document.forms[0].Email.focus();
  return false;
}
return true;
}