is_ie = ((/msie/i.test(window.navigator.userAgent) && !/opera/i.test(window.navigator.userAgent) && !/Mozilla/i.test(window.navigator.userAgent)));
var mouseX = 0, mouseY = 0, contentCount = 0;
var content_ids = [];
function GID(id){ return (is_ie) ? document.all[id] : document.getElementById(id);}
var tooltipContent = '';
var tooltipTextLoading = 'Загрузка...';
var globals = [];
globals['tooltip_pos_updated'] = false;
globals['tooltip_timer_hide'] = -1;
function showTooltip(text, action, header)
{
tooltipContent = text;
tooltipHeader = header;
if(q = GID('divTooltip'))
{
if(q.style != undefined)
{
q.style.left = mouseX;
q.style.top = mouseY;
q.style.display = 'block';
}
GID('divTooltipContent').innerHTML = "
"+tooltipContent+'
';
$(divTooltip).pngFix();
globals['tooltip_pos_updated'] = false;
}
if(action != undefined)
if(action.length)
eval(action);
}
function hideTooltip()
{
if(q = GID('divTooltip'))
{
if(q.style != undefined)
q.style.display = 'none';
}
globals['tooltip_timer_hide'] = -1;
}
function createRequestObject()
{
if (window.XMLHttpRequest) {
try {
return new XMLHttpRequest();
} catch (e){}
} else if (window.ActiveXObject) {
try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch (e){}
try {
return new ActiveXObject('Msxml2.XMLHTTP');
} catch (e){}
}
return null;
}
function loadTooltipFromLink(tooltipId, link, divider /* ='?' */, prefix /* = ''*/, outputId)
{
if(prefix == undefined)
prefix = '';
if(outputId == undefined)
outputId = '';
if(!eval(prefix+"tooltipRequest"+tooltipId+" = createRequestObject();"))
return;
eval(prefix+"tooltipRequest"+tooltipId+".onreadystatechange = function()\
{\
if(!"+prefix+"tooltipRequest"+tooltipId+") return;\
res = '';\
try {\
if ("+prefix+"tooltipRequest"+tooltipId+".readyState == 4){\
if ("+prefix+"tooltipRequest"+tooltipId+".status == 200){\
res = ''+"+prefix+"tooltipRequest"+tooltipId+".responseText;}\
else res = 'Ошибка';}\
} catch(e) { res = 'Ошибка'; }\
if(res.length) {\
tooltipContent = res;\
if(outputId.length && (q = GID(outputId)))\
q.innerHTML = tooltipContent;\
else if(q = GID('divTooltip'))\
q.innerHTML = tooltipContent;\
globals['"+prefix+"tooltipContent"+tooltipId+"'] = tooltipContent;\
globals['"+prefix+"tooltipLoad"+tooltipId+"'] = 1;\
eval(globals['"+prefix+"tooltipAction"+tooltipId+"']);\
} };");
eval(prefix+"tooltipRequest"+tooltipId+".open('GET', link+divider+'random='+Math.random(), true);");
eval(prefix+"tooltipRequest"+tooltipId+".send(null);");
globals[prefix+'tooltipLoad'+tooltipId] = 2;
}//loadTooltipFromLink
function execLink(link, id /* ='' */, onLoadAction /* ='' */)
{
if(id == undefined || !id.length)
id = Math.random();
if(!eval("tooltipRequest"+id+" = createRequestObject();"))
return;
eval("tooltipRequest"+id+".onreadystatechange = function()\
{\
if(!tooltipRequest"+id+") return;\
res = '';\
try {\
if (tooltipRequest"+id+".readyState == 4){\
if (tooltipRequest"+id+".status == 200){\
res = ''+tooltipRequest"+id+".responseText;}\
else res = '';}\
} catch(e) { res = 'Ошибка'; }\
if(res.length) {\
tooltipContent = res;\
globals['tooltipLoad"+id+"'] = 1;\
eval(globals['tooltipAction"+id+"']);\
} };");
eval("tooltipRequest"+id+".open('GET', link+'"+(/\?/i.test(link) ? '&' : '?')+"'+'random='+Math.random(), true);");
eval("tooltipRequest"+id+".send(null);");
globals['tooltipLoad'+id] = 2;
globals['tooltipAction'+id] = (onLoadAction == undefined ? '' : onLoadAction);
}//execLink
//id - в id.innerHTML будет загружен контент (присвоен content или же загружен из link)
function showContent(id, content, link, action)
{
if(!(q = GID(id)))
return;
if(content.length) //set static content
{
q.innerHTML = content;
return;
}
loadTooltipFromLink(contentCount, link, (/\?/i.test(link) ? '&' : '?'), 'c', id);
globals["ctooltipContent"+contentCount] = tooltipTextLoading;
globals["ctooltipAction"+contentCount] = action;
}//showContent
function tooltipShow(num, link, linkadd/* = '?'*/, action/* = ''*/)
{
if(globals["tooltipLoad"+num] == undefined)
globals["tooltipLoad"+num] = 0;
if(globals["tooltipContent"+num] == undefined)
globals["tooltipContent"+num] = "";
if(globals["tooltipHeader"+num] == undefined)
globals["tooltipHeader"+num] = "";
if(globals["tooltipLoad"+num] != 0)
showTooltip(globals["tooltipContent"+num], '', globals["tooltipHeader"+num]);
else
{
showTooltip(tooltipTextLoading);
loadTooltipFromLink(num, link, linkadd);
globals["tooltipContent"+num] = tooltipTextLoading;
globals["tooltipAction"+num] = action;
}
}//tooltipShow
function tooltipUpdatePos()
{
if(!(q = GID('divTooltip')))
return;
if(q.style != undefined && q.style.display != 'block')
{
if(!globals['tooltip_pos_updated'])
{
q.style.left = mouseX;
q.style.top = mouseY;
globals['tooltip_pos_updated'] = true;
}
}
} //tooltipUpdatePos
setInterval("tooltipUpdatePos()", 1);
function onMouseMoveHandler(e)
{
mouseX = (e == undefined ? document.body.scrollLeft + window.event.clientX : e.pageX);
mouseY = (e == undefined ? document.body.scrollTop + window.event.clientY : e.pageY);
} //onMouseMoveHandler
document.onmousemove = onMouseMoveHandler;