pathname = location.pathname;
myDomain = '/';
// Установка параметра expire на год вперед.
var largeExpDate = new Date ();
largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000));

// name - имя cookie
// value - значение cookie
// [expires] - дата окончания действия cookie (по умолчанию - до конца сессии)
// [path] - путь, для которого cookie действительно (по умолчанию - документ, в котором значение было установлено)
// [domain] - домен, для которого cookie действительно (по умолчанию - домен, в котором значение было установлено)
// [secure] - логическое значение, показывающее требуется ли защищенная передача значения cookie
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 (!caution || (name + "=" + escape(value)).length <= 4000)
	document.cookie = curCookie
	//else
	//if (confirm("Cookie превышает 4KB и будет вырезан !"))
	//document.cookie = curCookie
}

// name - имя считываемого cookie
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))
}

// name - имя cookie
// [path] - путь, для которого cookie действительно
// [domain] - домен, для которого cookie действительно
// "; expires=Thu, 01-Jan-70 00:00:01 GMT"
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT"
	}
}
//	Функция подключающая или отключающая блоки
function display_on_off(id_display){
	if (document.getElementById(id_display) != null) {
		if(document.getElementById(id_display).style.display=='none'){
			document.getElementById(id_display).style.visibility='visible';
			document.getElementById(id_display).style.display='block';
		} else {
			document.getElementById(id_display).style.visibility='hidden';
			document.getElementById(id_display).style.display='none';
		}
	}
}

function SendFormSearch() {
	if (document.getElementById('search_id')!= null ){
		if(document.getElementById('search_id').value.length<3) {
			alert ('Для поиска необходимо ввести три и более символов');
		} else document.getElementById('search').submit();
	}
}

function newWindowMap(id_goods, nummap, id_region, name_region, price, ts, tn) {
	url_view='map/map.php?goods=' + id_goods + 
		'&nummap=' + nummap + 
		'&region=' + id_region + 
		'&nameregion=' + name_region + 
		'&price=' + price + 
		'&ts=' + ts +
		'&tn=' + tn
		;
	var newWindowMap;
	newWindowMap=window.open (url_view,'opennewWindowMap',"resizable=yes,scrollbars=yes,width=830,height=870");
}

function openMENU(menu) {
	var br = navigator.userAgent.toLowerCase();
	if (document.getElementById(menu).style.display=="none") {
		setCookie('menu_'+menu,1);
		document.getElementById(menu).style.display="block";
	} else {
		setCookie('menu_'+menu,0);
		document.getElementById(menu).style.display="none";
	}
	document.body.focus();
}
