TMT_Util = {}

TMT_Util.getStyle = function(id, property)
{
	var obj = document.getElementById(id);
	var value = obj.currentStyle ? obj.currentStyle[property] : null;
	return (obj.style[property] || value);
}

TMT_Util.setStyle = function(id, property, value)
{
	document.getElementById(id).style[property] = value;
}

TMT_Util.changeOpac = function(opacity, id)
{
	var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

TMT_Util.isNum = function(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {return false;} else {return true;}
}

TMT_Util.checkFlash = function()
{
	if (navigator.plugins && navigator.plugins.length)
	{
		if ((navigator.plugins["Shockwave Flash"]) || (navigator.plugins["Shockwave Flash 2.0"])) {return true;}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin) return true;
	}
	else
	{
		for(var i=7; i>0; i--)
		{
			try
			{
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
				return true;
			} catch(e) {}
		}
	}
}

TMT_Util.posX = function(obj)
{
    var curleft = 0;
    
    if(obj.offsetParent)
    {
        while(true) 
		{
			curleft += obj.offsetLeft;
			if(!obj.offsetParent) {break;} else {obj = obj.offsetParent;}
		}
    } else if(obj.x) {curleft += obj.x;}
	
    return curleft;
}

TMT_Util.posY = function(obj)
{
	var curtop = 0;
	
	if(obj.offsetParent)
	{
		while(true)
		{
			curtop += obj.offsetTop;
			if(!obj.offsetParent) {break;} else {obj = obj.offsetParent;}
		}
	}
	else if(obj.y) {curtop += obj.y;}
	
	return curtop;
}

TMT_Util.isArray = function(obj) 
{
   return (obj.constructor.toString().indexOf("Array") == -1) ? false : true;
}

TMT_Util.imgPreload = function(images, callBack, start)
{
	if (!start) {var start = 0;}
	if (!callBack) {var callBack = void(null);}
	var img = new Image();
	
	if (TMT_Util.isArray(images))
	{
		if (start<images.lenght) {img.onload = TMT_Util.imgPreload(start+1, images, callBack)} else {img.onload = callBack;}
		img.src = images[start];
		
	} else 
	{
		img.onload = callBack;
		img.src = images;
	}
}

TMT_Util.getMouse = function(e)
{
	var obj = new Object();
	obj.x = 0;
	obj.y = 0;
  	if (document.all) 
  	{
    	obj.x = event.clientX + document.body.scrollLeft
    	obj.y = event.clientY + document.body.scrollTop
  	} else 
  	{
    	obj.x = e.pageX
    	obj.y = e.pageY
  	}  
  	if (obj.x < 0){obj.x = 0}
  	if (obj.y < 0){obj.y = 0}  
  	
  	TMT_Util.mouse = obj;
  	
	return true;
}


TMT_Util.initialize = function()
{
	TMT_Util.mouse = new Object();
	if (!document.all) document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = TMT_Util.getMouse;
}

TMT_Util.initialize();

Dymek = {}

Dymek.odmyszki_wgore = 5;
Dymek.odmyszki_wlewo = 5;
Dymek.opac = 100; //widocznosc w procentach, nieprzezroczystosc?

Dymek.hint = function()
{
	if (arguments.length==0)
	{
		Dymek.setStyle('TMT_hint', 'display', 'none');
		return;
	}
	
	if (document.getElementById('TMT_hint') === null) 
	{	
		node = document.createElement('div');
		node.setAttribute("id","TMT_hint");
		node.setAttribute("style","display:none; position:absolute;");
		document.body.appendChild(node);
	}
	
	content = '<table cellspacing="0" cellpadding="0">';
	content += '<tr><td class="hint_tl">&nbsp;</td><td class="hint_tm">&nbsp;</td><td class="hint_tr">&nbsp;</td></tr>';
	content += '<tr><td class="hint_ml">&nbsp;</td><td class="hint_mm">'+arguments[0]+'</td><td class="hint_mr">&nbsp;</td></tr>';
	content += '<tr><td class="hint_bl">&nbsp;</td><td class="hint_bm">&nbsp;</td><td class="hint_br">&nbsp;</td></tr>';
	document.getElementById('TMT_hint').innerHTML = content;

	if (Dymek.getStyle('TMT_hint', 'display') != 'block') 
	{
		Dymek.setStyle('TMT_hint', 'display', 'block');
		Dymek.changeOpac(Dymek.opac, 'TMT_hint');
	}
	
	Dymek.setStyle('TMT_hint', 'top', (TMT_Util.mouse.y-(document.getElementById('TMT_hint').offsetHeight)-Dymek.odmyszki_wgore)+'px');
	Dymek.setStyle('TMT_hint', 'left', (TMT_Util.mouse.x+Dymek.odmyszki_wlewo)+'px');
}

Dymek.getStyle = function(id, property)
{
	var obj = document.getElementById(id);
	var value = obj.currentStyle ? obj.currentStyle[property] : null;
	return (obj.style[property] || value);
}

Dymek.setStyle = function(id, property, value)
{
	document.getElementById(id).style[property] = value;
}

Dymek.changeOpac = function(opacity, id)
{
	var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}