
var atoRq1 = 0;
clearAltTimeOut31 = function() {
	if (atoRq1 != 0 && atoRq1 != null) clearTimeout(atoRq1);
	atoRq1 = 0;
}

hideAlt31 = function() {
	atoRq1 = setTimeout(function(){closBox21()}, 350);
}

closBox21 = function() {
	if (getObj('tooltip_ext')) {
		var box0 = getObj('tooltip_ext');
		box0.style.display = 'none';
	}
}

_activate_item = function(obj, id, r, rules) {
	var path_to = '/ru/dealer';
	clearAltTimeOut3();
	closBox2();
	clearAltTimeOut31();
	var topY = objY('russia') + mapGeoY[r] - 8;
	var topX = objX('russia') + mapGeoX[r] + 8;
	var box = $('tooltip_ext');
	box.style.top = topY + "px";
	$('city_dealer').innerHTML = '<b>' + mapData[r] + '</b>';
	$('tool_insert_ext').innerHTML = '<div style="text-align:center;"><img alt="" src="/imgs/ballon/loader.gif" width="32" height="32"></div>';
	$('tool_insert_ext').style.display = '';
	box.style.left = topX + "px";
	box.style.display = "block";
	_res_tooltip();
	if (id) {
		var request = 'id=' + id;
		var opt = {
			method: 'post',
			postBody: request,
			onSuccess: function(t) {
				var tmp = t.responseText;
				var rule = tmp.indexOf('dealer_empty');
				if (rule != -1) {
					setTimeout(function() {_text_ext2()}, 1000);
				}
				else {
					$('tool_insert_ext').style.display = '';
					setTimeout(function() {_text_ext(t.responseText)}, 1000);
				}
			},
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}
		}
		new Ajax.Request(path_to, opt);
	}
}

_text_ext = function(text) {
	$('tool_insert_ext').innerHTML = text;
	_res_tooltip();
}
_text_ext2 = function() {
	$('tool_insert_ext').style.display = 'none';
	$('tool_insert_ext').innerHTML = ' ';
}

_res_tooltip = function() {
	if (document.getElementById('mainBar')) {
		var tff = document.getElementById('mainBar').clientHeight;
		document.getElementById('leftBar').style.height = tff + 'px';
		document.getElementById('rightBar').style.height = tff + 'px';
	}
}







/* генерация точек на карте */
function generate() {
	var cityAll = mapID.length;
	var pX = objX('russia') + 3;
	var pY = objY('russia') + 3;
	var html = '';
	for (var i=0;i<cityAll;i++) {
		tmp = mapID[i];
		tmp1 = tmp.replace(/[ad]+/g, "");
		x0 = pX + mapGeoX[tmp];
		y0 = pY + mapGeoY[tmp];
		html += '<div id="'+tmp+'" class="bt" style="position:absolute;border:0;top:' + y0 + 'px;left:' +  x0 + 'px;"><img src="/imgs/magDot2'+(mapType[tmp]?'_'+mapType[tmp]:'')+'.png?v5" width="6" height="6" alt=""/></div>';
	}
	$('cityBox').innerHTML = html;
	(function($) {
			$('a.adlink').click(function(){
				$('#ad'+$(this).attr('id').substr(6,10)).btOn();
			});
			$('.bt').bt({
				closeWhenOthersOpen: true,
				padding: 10,
				width: 200,
				hoverIntentOpts: {
					interval: 300,
					timeout: 3000
				},
				centerPointX: 0.5,
				centerPointY: 0.5,
				spikeLength: 15,
				spikeGirth: 15,
				cornerRadius: 6,
				fill: '#8699a8',
				strokeWidth: 0,
				ajaxPath: ["'/ru/dealer/?id=' + $(this).attr('id').substr(2,10)"],
				ajaxLoading: '',
				ajaxCache: false,
				cssStyles: {
					color: '#FFF',
					fontWeight: 'normal',
					fontSize: '12px'
				},
				showTip: function(box) {
					$(box).fadeIn();
				},
				hideTip: function(box) {
					$(box).fadeOut();
				}
			});
	})(jQuery)	
}







/* генерация точек на карте Москвы */
function generate_moscow() {
	var cityAll = mapID.length;
	var pX = objX('russia') + 3;
	var pY = objY('russia') + 3;
	var html = '';
	for (var i=0;i<cityAll;i++) {
		tmp = mapID[i];
		tmp1 = tmp.replace(/[ad]+/g, "");
		x0 = pX + mapGeoX[tmp];
		y0 = pY + mapGeoY[tmp];
		html += '<div id="'+tmp+'" class="bt" style="position:absolute;border:0;top:' + y0 + 'px;left:' +  x0 + 'px;"><img src="/imgs/magDot2_m1'+(mapType[tmp]?'_'+mapType[tmp]:'')+'.png?v5" width="16" height="16" alt="" /></div>';
	}
	$('cityBox').innerHTML = html;
	(function($) {
			$('a.adlink').click(function(){
				$('#ad'+$(this).attr('id').substr(6,10)).btOn();
			});
			$('.bt').bt({
				closeWhenOthersOpen: true,
				padding: 10,
				width: 200,
				hoverIntentOpts: {
					interval: 300,
					timeout: 3000
				},
				centerPointX: 0.5,
				centerPointY: 0.5,
				spikeLength: 15,
				spikeGirth: 15,
				cornerRadius: 6,
				fill: '#8699a8',
				strokeWidth: 0,
				ajaxPath: ["'/ru/moscow/?id=' + $(this).attr('id').substr(2,10)"],
				ajaxLoading: '',
				ajaxCache: false,
				cssStyles: {
					color: '#FFF',
					fontWeight: 'normal',
					fontSize: '12px'
				},
				showTip: function(box) {
					$(box).fadeIn();
				},
				hideTip: function(box) {
					$(box).fadeOut();
				}
			});
	})(jQuery)	
}

_activate_item_moscow = function(obj, id, r, rules) {
	var path_to = '/ru/moscow';
	clearAltTimeOut3();
	closBox2();
	clearAltTimeOut31();
	var topY = objY('russia') + mapGeoY[r] - 2;
	var topX = objX('russia') + mapGeoX[r] + 16;
	var box = $('tooltip_ext');
	box.style.top = topY + "px";
	$('city_dealer').innerHTML = '<b>' + mapData[r] + '</b>';
	$('tool_insert_ext').innerHTML = '<div style="text-align:center;"><img alt="" src="/imgs/ballon/loader.gif" width="32" height="32"></div>';
	$('tool_insert_ext').style.display = '';
	box.style.left = topX + "px";
	box.style.display = "block";
	_res_tooltip();
	if (id) {
		var request = 'id=' + id;
		var opt = {
			method: 'post',
			postBody: request,
			onSuccess: function(t) {
				var tmp = t.responseText;
				var rule = tmp.indexOf('dealer_empty');
				if (rule != -1) {
					setTimeout(function() {_text_ext2()}, 1000);
				}
				else {
					$('tool_insert_ext').style.display = '';
					setTimeout(function() {_text_ext(t.responseText)}, 1000);
				}
			},
			onFailure: function(t) {
				alert('Error ' + t.status + ' -- ' + t.statusText);
			}
		}
		new Ajax.Request(path_to, opt);
	}
}
