function InitTrigersSearch() {
	setTrigersSearch('how_to_adress', "");
	setTrigersSearch('phone_number', "");
	setTrigersSearch('enter_code', '');
}

function gebi(id) {
	return document.getElementById(id);
}
function setTrigersSearch(param, value) {
	var param2 = param;
	var focused;
	gebi(param).blur();
	if (value !== "" && gebi(param).value == "")
		gebi(param).value = value;
	gebi(param + '_text').style.display = (gebi(param).value == '') ? 'inline'
			: 'none';
	gebi(param + '_text').onclick = function() {
		searchInputText(param + '_text', param, 'in');
	};
	gebi(param).onfocus = function() {
		focused = true;
		searchInputText(param + '_text', param, 'in');
	};
	gebi(param).onblur = function() {
		focused = false;
		searchInputText(param + '_text', param, 'out');
	};
	var param2 = param;
	setInterval(
			function() {
				if (!focused == true)
					gebi(param2 + '_text').style.display = (gebi(param2).value == '') ? 'inline'
							: 'none';
			}, 100);
}
function searchInputText(in_id_text, in_id_input, in_act) {
	if (in_act == 'out') {
		if (in_id_text != null) {
			if (gebi(in_id_text)) {
				setTimeout(
						function() {
							gebi(in_id_text).style.display = (gebi(in_id_input).value == '') ? 'inline'
									: 'none';
						}, 500)
			}
		}
	} else {
		if (in_id_text != null && gebi(in_id_input)) {
			setTimeout(function() {
				gebi(in_id_text).style.display = 'none';
				gebi(in_id_input).focus();
			}, 10)
		}
	}

}

function init_checker0() {
	var user_phone;
	var user_name;
	var code;
	var sel_cons;
	var times;
	setInterval(function() {
		user_phone = $("#phone_number").val();
		user_name = $("#how_to_adress").val();
		times = $("#times").val();
		code = $("#enter_code").val();
		sel_cons = $("#sel_cons").val();
		if ((code.length == 4) && (user_phone.indexOf('_') == -1)
				&& (user_phone !== "") && (user_phone !== "8 (___) ___-____")
				&& user_name !== "" && times !== "0" && sel_cons !== "0") {
			if ($("#submit_re_call").hasClass("submit_disable")) {
				$("#submit_re_call").removeClass("submit_disable");
				$("#submit_re_call").addClass("submit_enable");
				$("#submit_re_call").removeAttr("disabled");
			}
		} else {
			if ($("#submit_re_call").hasClass("submit_enable")) {
				$("#submit_re_call").removeClass("submit_enable");
				$("#submit_re_call").addClass("submit_disable");
				$("#submit_re_call").attr("disabled", "disabled");
			}
		}
	}, 100);
}

function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value)
			+ ((expires) ? "; expires=" + expires.toGMTString() : "")
			+ ((path) ? "; path=" + path : "")
			+ ((domain) ? "; domain=" + domain : "")
			+ ((secure) ? "; secure" : "")
	if ((name + "=" + escape(value)).length <= 4000)
		document.cookie = curCookie
	else if (confirm("Cookie превышает 4KB и будет вырезан !"))
		document.cookie = curCookie
}

function getCookie(name) {
	var prefix = name + "="
	var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1)
		return null
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex
			+ prefix.length)
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length,
			cookieEndIndex))
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=null " + ((path) ? "; path=" + path : "")
				+ ((domain) ? "; domain=" + domain : "")
				+ "; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}
