d = document;
w = window;

loadTip("", false);
installTip();

function installTip()
{
if (d.layers) return;
writeTip('tipDiv');

if (d.addEventListener)
{
d.addEventListener("mousemove", mouseMove, false);
d.addEventListener("mouseover", mouseOverOut, false);
d.addEventListener("mouseout", mouseOverOut, false);
}
else
{
d.onmousemove = mouseMove;
d.onmouseout = mouseOverOut;
d.onmouseover = mouseOverOut;
}
}

function mouseMove(e)
{
if (w.tip)
{
tip.mouseMove(e); 
}
}

function mouseOverOut(e)
{
if (!w.tip) return;
if (typeof(e) == "undefined")
e = event;

var obj = e.srcElement? e.srcElement : e.target;
if ((obj.tagName.toLowerCase() == "img" || obj.tagName.toLowerCase() == "span") && obj.parentNode.tagName.toLowerCase() == "a")
obj = obj.parentNode;

if (obj.tagName && obj.tagName.toLowerCase() == "a" && !obj.notip)
{
if (e.type == "mouseover" && obj.title)
{
tip.show(obj.title);
backupTitle = obj.title;
obj.title = '';
}
else if (e.type == "mouseout" && obj.title == ''
&& typeof(backupTitle) != "undefined" && backupTitle != '')
{
tip.hide();
obj.title = backupTitle;
backupTitle = '';
}
}
}

function writeTip(divName)
{
d.write( '<div id="' + divName + '" style="position: absolute; visibility: hidden; top: 0px; left: 0px; ' );
d.write( 'filter: alpha(opacity=100); -moz-opacity: 0; z-index: 37"><div id="tipText"></div></div>' );
}

function uberToolTip(html, upperOffset)
{
this.html = html;
this.upperOffset = upperOffset;
this.id = "tipDiv";
this.textId = "tipText";
this.mouseX = 0;
this.mouseY = 0;
this.doit = false;
this.obj = null;
this.textObj = null;
this.fader = null;
this.max = 100;

this.getMouseX = function()
{
var coords = this.getScrollCoords();
return this.mouseX + (d.all? coords[0] : 0);
}

this.getMouseY = function()
{
var coords = this.getScrollCoords();
return this.mouseY + (d.all? coords[1] : 0);
}

this.show = function(id)
{
html = this.html;

if (id.indexOf('$') != -1)
{
	id = id.substring(1);
	html = "<center><font face=verdana size=1>Bu içerik <B>üyelerimize özeldir</B>.<BR><BR>Üyelik sistemi ile göndermek için tıklayınız";
}

html = html.replace('XXXXXX',id);
html = html.replace('_',' ');

if (w.opera) return;
this.doit = true;
if (this.fader)
{
this.fader.setTrans(0);
this.fader.fadeIn();
}
this.update();
wdivo(this.textObj, html);
sdivo(this.obj);
}

this.update = function()
{
var left = 0;

if (this.getMouseX()-100 > 0)
left = this.getMouseX() + -100;
else
left = 0;

var top = 0;

if (this.upperOffset)
{
if (this.getMouseY() - 75 >0)
top = this.getMouseY() + (d.all? -75: 0);
else
top = this.getMouseY() + (d.all? +20: 0);
}
else
{
top = this.getMouseY() + (d.all? +20: 0);
}

var w = this.getWinCoords();
var s = this.getScrollCoords();
var winb = w[1] + s[1];
var winr = w[0] + s[0];

top = (top - s[1]);

if (this.upperOffset)
{
if ((winb - top) > 400)
top = top + 95;
}
else
{
if ((winb - top) < 63)
top = top - 95;
}

if (left + parseInt(this.obj.offsetWidth) > winr - 10)
{
left = winr - this.obj.offsetWidth - 10;
}

if (this.getMouseX()>185)
left = 85;


this.obj.style.left = left + "px";
this.obj.style.top = top + "px";
}

this.getWinCoords = function()
{
var wx, hx;
if (w.innerHeight)
{
wx = w.innerWidth;
hx = w.innerHeight;
}
else if (d.documentElement && d.documentElement.clientHeight != 0)
{
wx = d.documentElement.clientWidth;
hx = d.documentElement.clientHeight;
}
else if (d.body && d.body.clientHeight)
{
wx = d.body.clientWidth;
hx = d.body.clientHeight;
}

return [wx, hx];
}

this.getScrollCoords = function()
{
var x = 0, y = 0;
if (typeof(w.pageYOffset) == "number")
{
y = w.pageYOffset;
x = w.pageXOffset;
}
else if (d.documentElement && d.documentElement.clientWidth != 0)
{
y = d.documentElement.scrollTop;
x = d.documentElement.scrollLeft;
}
else if (d.body && typeof(d.body.scrollLeft) != "undefined")
{
y = d.body.scrollTop;
x = d.body.scrollLeft;
}
return [x, y];
}

this.hide = function()
{
if (w.opera) return;
hdivo(this.obj);
this.doit = false;
if (this.fader) this.fader.setTrans(0);
this.obj.style.left = this.obj.style.top = 0;
wdivo(this.textObj, "");
}

this.init = function()
{
if (d.layers || w.opera) return;
this.obj = d.getElementById(this.id);
this.textObj = d.getElementById(this.textId);
if (!this.obj)
{
return;
}
this.loaded = true;
}

this.mouseMove = function(e)
{
var x, y;
if (w.event)
{
x = event.clientX + d.body.scrollLeft;
y = event.clientY + d.body.scrollTop;
}
else
{
x = e.pageX;
y = e.pageY + 10;
}
this.mouseX = x;
this.mouseY = y;
if (this.obj && this.doit) this.update();
}

return this;
}

if (!d.getElementById && d.all)
{
d.getElementById = function(id) { return d.all[id] }
}
function sdivo(l) { l.style.visibility = "visible"; }
function hdivo(l) { l.style.visibility = "hidden"; }
function wdivo(l, html) {
if (typeof(l.innerHTML) != "undefined")
{
html = html.replace(/&/,"&amp;");
l.innerHTML = html;
}
}

function loadTip(html,upperOffset)
{
tip = new uberToolTip(html, upperOffset);
tip.init();
}
