function topMenuOn(el,flag) {
	if (flag==1) el.style.backgroundImage = "url(images/top_menu_onback.jpg)";
	else  el.style.backgroundImage = "";
}
function in_massiv(looking_for, list){
    for(i in list){
        if(looking_for == list[i]){
            return true;
        }
    }
    return false;
}
var pathname = location.pathname;
var myDomain = '/';
// Установка параметра expire на год вперед.
var largeExpDate = new Date ();
largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000));
//	Версия браузера
var br = navigator.userAgent.toLowerCase();

// 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 действительно
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 OpenHide(id, plus){
	var obj = document.getElementById(id);
	var plus_obj = document.getElementById(plus);
	if (obj.style.display == "none") {
		obj.style.display = "block";
		plus_obj.className  = "menu_minus";
	}
	else {
		obj.style.display = "none";
		plus_obj.className = "menu_plus";
	}

}
function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for ( i = 0; i < gy.length; i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) return ft[1];
	}
}
function add_basket (id_goods,id_user,postpone) {
	// добавляем в cookie
	if(id_user == 'no') {
		var name_prefix=(postpone>0)?'gp_':'gb_';
		var name_cook_p = name_prefix + id_goods;
		var amount =parseInt($.cookie(name_cook_p));
		if(amount==0 || isNaN(amount) == true){
			$.cookie(name_cook_p,1)
		} else {
			$.cookie(name_cook_p,amount+1)
		}
	}	
	var xmas = new Date();
	var abc = xmas.getMilliseconds();
	if (document.getElementById('info_goods') != null) document.getElementById('info_goods').innerHTML = 'Минутку';
	$("#example").dialog('open');
	$.get("scripts/add_basket.php", { goods: id_goods, id_user: id_user, postpone: postpone, abc: abc }, function(data){
		if (document.getElementById('info_goods') != null) document.getElementById('info_goods').innerHTML = data;
		setTimeout (
		function() {
			$("#example").dialog('close');
		},
		2000
		);
	});
}
