//
// Browser Detection
//
var isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
var NS4 = (document.layers) ? true : false;
var IEmac = ((document.all)&&(isMac)) ? true : false;
var IE4plus = (document.all) ? true : false;
var IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
var IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
var ver4 = (NS4 || IE4plus) ? true : false;

// Generic Layer Object Functions

// Make an object visible
function showObject(obj) 
{
        if (NS4) obj.visibility = "show";
        else if (IE4plus) obj.visibility = "visible";
}

// Hides an object
function hideObject(obj) 
{
        if (NS4) obj.visibility = "hide";
        else if (IE4plus) obj.visibility = "hidden";
}

// Move a layer
function moveTo(obj,xL,yL) 
{
        obj.left = xL;
        obj.top = yL;
}


//
// MouseTip Methods
//

function MouseTip_ShowNew()
{
	this.WriteLayer();
	this.Show();
}

function MouseTip_Hide()
{
	if ( (NS4) || (IE4plus) ) 
	{
		this.snow = 0;
		hideObject(this.over);
	}
}

function MouseTip_Show() 
{
	if ( (NS4) || (IE4plus) ) 
	{
		if (this.snow == 0) 	
		{
			if (this.dir == 2) 
			{ // Center
				moveTo(this.over,this.x+MouseTip.offsetX-(MouseTip.width/2),this.y+MouseTip.offsetY);
			}
			if (this.dir == 1) 
			{ // Right
				moveTo(this.over,this.x+MouseTip.offsetX,this.y+MouseTip.offsetY);
			}
			if (this.dir == 0) 
			{ // Left
				moveTo(this.over,this.x-MouseTip.offsetX-MouseTip.width,this.y+MouseTip.offsetY);
			}
			showObject(this.over);
			this.snow = 1;
		}
	}
}


// Writes to a layer
function MouseTip_WriteLayer() 
{
        if (NS4) 
        {
                var lyr = eval(MouseTip.divPath).document;
                lyr.write(this.txt);
                lyr.close();
        }
        else if (IE4plus) 
			document.all["overDiv"].innerHTML = this.txt;
}

function MouseTip_AddTip(type,tipTitle,tipText)
{
	var tip = new Object();
	tip.type = type;
	tip.title = tipTitle;
	tip.text = tipText;
	MouseTip.tips[MouseTip.tips.length] = tip;
}

function MouseTip_GetTip(type)
{
	var tip = null;
	
	for (i=0; i < MouseTip.tips.length; i++)
	{
		if (MouseTip.tips[i].type==type)
		{
			tip = MouseTip.tips[i];
			break;
		}
	}
	return tip;
}

function MouseTip(type,dir,x,y)
{
	this.x = x;
	this.y = y;
	this.snow = 0;
	this.dir = dir;
	this.over = null;
	
	this.ShowNew = MouseTip_ShowNew;
	this.Hide = MouseTip_Hide;
	this.Show = MouseTip_Show;
	this.WriteLayer = MouseTip_WriteLayer;

	if ( (NS4) || (IE4plus) ) 
	{
		if (NS4) this.over = eval(MouseTip.divPath);
		if (IE4plus) this.over = document.all["overDiv"].style;
	}

	var tip = MouseTip.GetTip(type);
	
	this.txt = '<TABLE WIDTH=' + MouseTip.width + ' BORDER=0 CELLPADDING=' + MouseTip.borderWidth +
		' CELLSPACING=0 BGCOLOR="' + MouseTip.borderColor + '"><TR><TD>' +
		'<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="' + MouseTip.bgColor +
		'"><TR><td>&nbsp;</td><TD nowrap><span class=seznam1-tekst>' +
		tip.text + '</span></TD></TR></TABLE></TD></TR></TABLE><p></p>';
	
}


MouseTip.current = null;
MouseTip.tips = new Array();
MouseTip.bgColor = "#ffffff";
MouseTip.borderColor = "#000000";
MouseTip.width = 150;
MouseTip.borderWidth = 1;
MouseTip.offsetX = 10;
MouseTip.offsetY = 10;
MouseTip.divPath = "document.overDiv";

MouseTip.AddTip = MouseTip_AddTip;
MouseTip.GetTip = MouseTip_GetTip;


function ShowMouseTip(obj,e,type,level)
{
	chngCrs(1,level);//added by COMLAND\iurii

	if((NS4)||(IE4plus))
	{
		var x = 0;
		var y = 0;
		if (NS4)
			{x=e.pageX; y=e.pageY;}
	  	if (IE4plus)
			{x=e.clientX+document.body.scrollLeft-310;y=e.clientY+document.body.scrollTop;}
		MouseTip.current = new MouseTip(type,1,x,y);
		MouseTip.current.ShowNew();
	}
}

function HideMouseTip(level)
{
	chngCrs(0,level);	//added by COMLAND\iurii
	
	if ( (NS4) || (IE4plus) ) 
	{
		if (MouseTip.current)
			MouseTip.current.Hide();
	}
}

function init()
{
	if (document.layers)
	{
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = function(e){
			if(e.target!=document)
			{
				document.routeEvent(e);
			}
			else
			{
				status='';
			}
		};
		document["pic1"].captureEvents(Event.MOUSEDOWN);
		document["pic1"].onmousedown = showXY;
	}
	else
	{
		document.onmousedown = showXY;
	}
}

function showXY(e,container)
{
	if(document.all)
	{
		e = window.event;
		if(e.srcElement.parentElement == container)
		{
			status = " LEFT: " + e.offsetX + " TOP: " + e.offsetY;
			jsygk = (showXY_h - e.offsetY) * showXY_piece_y + showXY_map_bottom_0;
			jsxgk = e.offsetX * showXY_piece_x + showXY_map_left_0;
			document.map_cat.ygk.value = jsygk;
			document.map_cat.xgk.value = jsxgk;
			if(5>showXY_level) showXY_level = showXY_level + 1;
 			document.map_cat.level.value = showXY_level;
			//location = '?ygk=' + jsygk + '&xgk=' + jsxgk + '&level=' + showXY_level + '&cat=' + showXY_cat;
			document.map_cat.action = document.map_cat.action + "#mapsrchrezults";
			//alert(document.map_cat.action);
			document.map_cat.submit();
		}
		else
		{
			status = "";
		}
	}
	else
	if(document.layers)
	{
		if(e.target.name == this.id)
		{
			status = " LEFT: " + (e.layerX - e.target.x) + " TOP: " + (e.layerY - e.target.y);
			jsygk = (showXY_h - (e.layerY - e.target.y)) * showXY_piece_y + showXY_map_bottom_0;
			jsxgk = (e.layerX - e.target.x) * showXY_piece_x + showXY_map_left_0;
 			document.map_cat.ygk.value = jsygk;
 			document.map_cat.xgk.value = jsxgk;
 			document.map_cat.level.value = showXY_level;
 			//document.map_cat.cat.value = showXY_cat;
			//window.location.href = '?ygk=' + jsygk + '&xgk=' + jsxgk + '&level=' + showXY_level + '&cat=' + showXY_cat;
			document.map_cat.action = document.map_cat.action + "#mapsrchrezults";
			//alert(document.map_cat.action);
 			document.map_cat.submit();
		}
	}
	return false
}

// > added by COMLAND\iurii
//change cursor type of MAP image
function chngCrs(f)
{
	var oImg = document.getElementById("pic1");
	if(!oImg)
	{
//alert('obj not found');
		return;
	}
	var zoomCursor = "move";
	if(4 < showXY_level) zoomCursor = "default";
//window.status = oImg.style.cursor;
	if (1==f)
		oImg.style.cursor = "hand";
	else
		oImg.style.cursor = zoomCursor;
}
// < added by COMLAND\iurii