// JScript source code

var BigMap;
var Navigation;
var Square;
var SquareA = 50; // width of square's side (in px)
var X0,Y0;
var MapCenterX = 550;
var MapCenterY = 300;
var DeltaX = 33;
var DeltaY = 13;

var stop = true;

function onLoad_html()
{
	isDOM=document.getElementById; //DOM1 browser (MSIE 5+, Netscape 6, Opera 5+)
	isMSIE=document.all && document.all.item; //Microsoft Internet Explorer 4+
	isNetscape4=document.layers; //Netscape 4.*
	isOpera=window.opera; //Opera
	isOpera5=isOpera && isDOM; //Opera 5+
	isMSIE5=isDOM && isMSIE; //MSIE 5+
	isMozilla=isNetscape6=isDOM && !isMSIE && !isOpera; //Mozilla или Netscape 6.*
	
	BigMap = document.getElementById("MapImage");
	X0 = parseInt( (BigMap.style.left).replace(/px/,"") )*(-1);
	Y0 = parseInt( (BigMap.style.top).replace(/px/,"") )*(-1);
	//alert(X0+" , "+Y0);
	
	Navigation = document.getElementById("Navigation");
	Square = document.getElementById("Square");

    tab1 = document.getElementById('MembersColumn'); // Tab which shows member's list
    tab2 = document.getElementById('ServiceColumn'); // Tab which shows service's list
    tab3 = document.getElementById('ProjectColumn'); // Tab which shows project's list
    tab4 = document.getElementById('TypeColumn');   // Tab which shows type's list
    arrow1 = document.getElementById('Marrow');     // Arrows from Tabs
    arrow2 = document.getElementById('Sarrow');
    arrow3 = document.getElementById('Parrow');
    arrow4 = document.getElementById('Tarrow');
    link1 = document.getElementById('MlinkArrow');
    link2 = document.getElementById('SlinkArrow');
    link3 = document.getElementById('PlinkArrow');
    link4 = document.getElementById('TlinkArrow');
    
    setGlowingTabsBy(1,0,0,0);
	
    var mouse = new Array();
	mouse.X = 70;
	mouse.Y = 70;
	changePos(BigMap,MapCenterX-mouse.X*10,MapCenterY-mouse.Y*10);
	changePos(Square,mouse.X+DeltaX-SquareA/2,mouse.Y+DeltaY-SquareA/2);

}


function getXY(e)
{
	var elem = Navigation;
	var mousex;
	var mousey;
	var left = 0;
	var top = 0;
	
	if(isMSIE && !isOpera)
	{
		while (elem)
    	{
			left += elem.offsetLeft;
        	top += elem.offsetTop;
        	elem = elem.offsetParent;
    	}
		
		mousex=event.clientX - left + document.body.scrollLeft - 1;
		mousey=event.clientY - top + document.body.scrollTop - 1;
		//alert(mousex+","+mousey);	
	}
	else if(isOpera)
	{
		while (elem)
    	{
			left += elem.offsetLeft;
        	top += elem.offsetTop;
        	elem = elem.offsetParent;
    	}
		
		mousex=event.clientX - left + document.body.scrollLeft;
		mousey=event.clientY - top + document.body.scrollTop;
		//alert(mousex+","+mousey);	
	}
	else if(isNetscape4 || isMozilla)
	{
		while (elem)
    	{
			left += elem.offsetLeft;
        	top += elem.offsetTop;
        	elem = elem.offsetParent;
        	//alert(elem.offsetTop);
    	}
		mousex = e.pageX - left -1; 
		mousey = e.pageY - top -1;
	}
		mousex = parseInt(mousex)-DeltaX ;
		mousey = parseInt(mousey)-DeltaY ;
		
		//alert(mousex+","+mousey);
		return {"X":mousex, "Y":mousey};
}

function moveMap(e)
{	
	var mouse;
	
	if (!stop) 
	{
		mouse = getXY(e);
		changePos(BigMap,MapCenterX-mouse.X*10,MapCenterY-mouse.Y*10);
		changePos(Square,mouse.X+DeltaX-SquareA/2,mouse.Y+DeltaY-SquareA/2);
	}
}

function changePos(obj, x, y)
{
	obj.style.top = (y)+'px';
	obj.style.left = (x)+'px';
}

function StartMoving(e)
{ 
	stop = false;
	mouse = getXY(e);
	changePos(BigMap,MapCenterX-mouse.X*10,MapCenterY-mouse.Y*10);
	changePos(Square,mouse.X+DeltaX-SquareA/2,mouse.Y+DeltaY-SquareA/2);//alert(Square.style.cursor);
	Square.style.cursor = 'move'; 
}

function StopMoving()
{ 
	if (!stop) { stop = true; }
	Square.style.cursor = '';
}
