hide_id = null;
hide_allowed = true;
function showSearch() { 
	document.getElementById('search_popup').style.visibility = 'visible';
	startHideSearch(false);
}
function stopHideSearch(full) {
	if (full) hide_allowed = false;
	clearTimeout(hide_id);
}
function startHideSearch(full) {
	if (full) hide_allowed = true;
	hide_id = setTimeout("hideSearch()", 1000);
}
function hideSearch() {
		if (!hide_allowed) return;
		document.getElementById('search_popup').style.visibility = 'hidden';
}



function forumShowPost(cur_id) {
	if (document.getElementById("short_"+cur_id).style.display=='none') {
		document.getElementById("short_"+cur_id).style.display='';
		document.getElementById("full_"+cur_id).style.display='none';
		return;
	}
	document.getElementById("short_"+cur_id).style.display='none';
	document.getElementById("full_"+cur_id).style.display='';
}

function getWindowWidth() {
	if (document.all) return document.body.clientWidth; 
	if (document.layers) return innerWidth; 
	return document.body.clientWidth;
}
function setSize() {
	if (getWindowWidth()<1200)
		document.getElementById("my_field").style.height = 570*0.75;
	if (getWindowWidth()>1200)
		document.getElementById("my_field").style.height = 570;
}


prev = 0;
old_class = "";
function priceShowSub(id) {
	if (prev) {
		document.getElementById("field_"+prev).className = old_class;
		document.getElementById("field_"+id).blur();
		document.getElementById("desc_"+prev).style.display = 'none';
	}
	if (prev!=id) {
		old_class = document.getElementById("field_"+id).className;
		document.getElementById("field_"+id).className = "catalogue_selected";
		document.getElementById("field_"+id).blur();
		document.getElementById("desc_"+id).style.display = '';
		prev = id;
	} else prev = 0;
}
function priceShowBigImg(name,w,h) {
	wind = window.open("", "wind", "width="+w+" height="+h+"");
	my_doc = "<body marginwidth='0' marginheight='0' topmargin='0' leftmargin='0'>"
	my_doc +="<a href='javascript:window.close()'><img border='0' src='"+name+"' width='"+w+"' height='"+h+"' /></a></body>";
	wind.document.write(my_doc);
}

discount = 0.0;
function priceSubmitBasket(str, is_confirm) {
	if (is_confirm && !window.confirm("Вы уверены в правильности отправляемого заказа?")) return;
	document.getElementById("price_form").action = "index.php?"+str;
	document.getElementById("price_form").submit();
}
function priceSetDiscount(val) {
	doscount = val;
}

function priceUpdateSumm() {
	cur_summ = 0.0;
	for (var i=1;;++i) {
		obj = document.getElementById('id_'+i);
		each = document.getElementById('each_'+i);
		price = document.getElementById('price_'+i);
		if (!obj || !price || !each) {
			cur_summ = Math.ceil(cur_summ*1000)/1000;
			document.getElementById('summ').value = cur_summ;
			return;
		}
		if (obj.value*1 != obj.value) obj.value = 0;
		if (discount>1) discount = 0;
		each.value = Math.ceil( (1-discount)* obj.value * price.value * 1000) /1000;
		cur_summ += 1*each.value;
	}
}
function priceClearBasket(str) {
	if (!window.confirm("Вы уверены, что хотите очистить корзину?")) return;
	for (var i=1;;++i) {
		obj = document.getElementById('id_'+i);
		if (!obj)  {priceSubmitBasket(str, false); return;}
		obj.value = 0;
	}
}
function registerUpdateAdv() {
	if (document.getElementById('adv').value=='0')
		document.getElementById('adv_my').style.display='';
	else document.getElementById('adv_my').style.display='none';
}
