isDOM=document.getElementById //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
isOpera=isOpera5=window.opera && isDOM //Opera 5+
isOpera6=isOpera && window.print //Opera 6+
isOpera7=isOpera && document.readyState //Opera 7+
isMSIE=document.all && document.all.item && !isOpera //Microsoft Internet Explorer 4+
isMSIE5=isDOM && isMSIE //MSIE 5+
isNetscape4=document.layers //Netscape 4.*
isMozilla=isDOM && navigator.appName=="Netscape" //Mozilla Netscape 6.*

if(isNetscape4) document.captureEvents(Event.MOUSECLICK);

function Tgt(evt) { return evt.target ? evt.target : evt.srcElement; }
function getClickCoords(e)
{
	var coords = new Object();
	coords.x = 0;
	coords.y = 0;
	if(isMSIE || isOpera7)
	{
		coords.x = event.clientX + document.body.scrollLeft;
		coords.y = event.clientY + document.body.scrollTop;
	}
	else if(isOpera)
	{
		coords.x = event.clientX;
		coords.y = event.clientY;
	}
	else if(isNetscape4 || isMozilla)
	{
		coords.x = e.pageX;
		coords.y = e.pageY;
	}
	return coords;
}
/* */
//============================
var browser=""; 
if(document.getElementById)	browser="Mz";	// Mozilla 
if(document.all)	browser="IE";	// Microsoft IE
if(document.layers)	browser="NN";	// Netscape Navigator
if(window.opera)	browser="Op";	// Опера версий 6.0 и 6.5
//==========================================
//Поиск объекта по его идентификатору
function $(id)
{
	var obj;
	switch (browser)
	{
	case "IE":
	case "Op":
		obj = document.all[id];
	    break; 
	case "NN":
		obj = document.layers[id];
	    break; 
	case "Mz":
		obj = document.getElementById(id);
	}
	return obj;
}
//изменение атрибутов тега
function SetPos(o, cleft, ctop)
{
	if(!o) return false;
	switch (browser)
	{
	case "IE": case "Op":
		o.style.left = cleft;
		o.style.top = ctop;
	    break;
	case "Mz":
		o.clientX = cleft;
		o.clientY = ctop;
		break;
	case "NN":
		o.left = cleft;
		o.top = ctop;
	    break; 
	}
}

function getPos(o)
{
	var point = {x:1, y:1};
	if (o == null) return false;
	switch (browser)
	{
	case "Mz":
		while(o.tagName != "BODY")
		{
			point.x += o.offsetLeft;
			point.y += o.offsetTop;
			o = o.parentNode;
		}
	    break; 
	case "Op":
	case "IE":
		while(o.tagName != "BODY")
		{
			point.x += o.offsetLeft;
			point.y += o.offsetTop;
			o = o.parentElement;
		}
	    break; 
	case "NN":
		point.x =  o.pageX;
		point.y =  o.pageX;
	    break; 
	}
	return point;
}

// Смена цвета элемента
function setColor(o, vColor)
{
	switch (browser)
	{
	case "IE":
	case "Mz":
	case "Op":
		o.style.backgroundColor = vColor;
	    break; 
	case "NN":
		o.bgColor = vColor;
	}
}
// Показать элемент
function show(o)
{
	switch (browser)
	{
	case "IE":
	case "Op":
	case "Mz":
		o.style.display = "block";
	    break; 
	case "NN":
		o.visibility = "block";
	}
}
// Спрятать элемент
function hide(o)
{
	switch (browser)
	{
	case "IE":
	case "Op":
	case "Mz":
		o.style.display = "none";
	    break; 
	case "NN":
		o.display = "none";
	}
}

function Magnify(img)
{
	if(img.tagName!="IMG")
		throw new Exception('Not image');
	var bp = $('BigPic');
	if(!bp) return;
	var img = $(bp.getAttribute('image'));
	img.src = "photos/2.jpg";
	point = getClickCoords();
	bp.style.width = img.width + 40;
	bp.style.height = img.height + 40;
	bp.style.top = point.y;
	bp.style.left = point.x;
	bp.style.height = img.height + 40;
	bp.style.top = (document.body.clientHeight - bp.style.height)/2;
	//bp.offsetLeft = (screen.width - bp.style.width)/2;
	//makebug();
	bp.style.display = 'block';
}

function showFloat(o)
{
	var picfrm = $('picform');
	pos = getPos(o);
	show(picfrm);
	SetPos(picfrm, pos.x, pos.y);
	if(console) console.log("link pos: "+pos.x+", "+pos.y+"; form pos="+getPos($('picform')).x+", "+getPos($('picform')).y);
}
