// JavaScript Document by k206i


// Menu MOVE VERT
var scroll_bar = document.getElementById("scroll_bar");
var main_div = document.getElementById("main_div");
var move_div = document.getElementById("move_div");
var posY;
var pos0;
var nextPos = 0; //20
var koef;
var move_int;

var gscroll_bar = document.getElementById("gscroll_bar");
var gmain_div = document.getElementById("gmain_div");
var gmove_div = document.getElementById("gmove_div");
var gposX;
var gpos0;
var gnextPos = 0; //20
var gkoef;
var gmove_int;


function move_scroll()
{
	clearInterval(move_int);
	pos0 = posY - nextPos;
	koef = (main_div.offsetHeight - move_div.offsetHeight)/(main_div.offsetHeight - 25 - scroll_bar.offsetHeight);
	move_int = setInterval("move_func()", 10);
}
function move_func()
{	
//alert((posY - pos0) +'px');
	scroll_bar.style.top = (posY - pos0) +'px';
	move_div.style.top = (posY - pos0)*koef  + 0 + 'px';
	nextPos = posY - pos0;
		
	if (scroll_bar.offsetTop < (main_div.offsetTop)) 
	{
		clearInterval(move_int);
		scroll_bar.style.top = 0  + 'px'; // bilo 20
		move_div.style.top = 0  + 'px';
		nextPos = 0; //20
	}
	if ((scroll_bar.offsetTop + scroll_bar.offsetHeight) > (main_div.offsetTop + main_div.offsetHeight - 20)) 
	{
		clearInterval(move_int);
		scroll_bar.style.top = (main_div.offsetHeight  - scroll_bar.offsetHeight - 20) + 'px';
		nextPos = main_div.offsetHeight  - scroll_bar.offsetHeight - 20;
	}
}








function objectPosition(e)
{
  posY=e.clientY;
  gposX=e.clientX;
}

function objectPositionNew()
{	clearInterval(move_int);
	clearInterval(gmove_int);
}


// Menu MOVE GORIZONT

function gmove_scroll()
{
	clearInterval(gmove_int);
	gpos0 = gposX - gnextPos;
	gkoef = (gmain_div.offsetWidth - gmove_div.offsetWidth)/(gmain_div.offsetWidth - 25 - gscroll_bar.offsetWidth);
	gmove_int = setInterval("gmove_func()", 10);
}
function gmove_func()
{	
//alert((gposX - gpos0) +'px');
	gscroll_bar.style.left = (gposX - gpos0) +'px';

//alert((gmain_div.offsetWidth - gmove_div.offsetWidth));
	gmove_div.style.left = (gposX - gpos0)*gkoef  + 0 + 'px';
	gnextPos = gposX - gpos0;
		
	if (gscroll_bar.offsetLeft < (gmain_div.offsetLeft)) 
	{
		clearInterval(gmove_int);
		gscroll_bar.style.left = 0  + 'px'; // bilo 20
		gmove_div.style.left = 0  + 'px';
		gnextPos = 0; //20
	}
	if ((gscroll_bar.offsetLeft + gscroll_bar.offsetWidth) > (gmain_div.offsetLeft + gmain_div.offsetWidth - 20)) 
	{
		clearInterval(gmove_int);
		gscroll_bar.style.left = (gmain_div.offsetWidth  - gscroll_bar.offsetWidth - 20) + 'px';
		gnextPos = gmain_div.offsetWidth  - gscroll_bar.offsetWidth - 20;
	}
}

function photo( path, alt, width, height )
{        
		var body;
        
        if (document.all)
        { 
                body = '<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White" onblur="self.window.close();" onresize="self.window.location.reload();">';
        } 
        else 
        {
                body = '<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="White" onblur="self.window.close();">';
        }
                
        var win_op = window.open('','show', 'resizable=yes,width='+width+',height='+height+',screenX=200,screenY=200,left=100,top=100');
        
        win_op.document.open();
        win_op.document.writeln('<html>');
        win_op.document.writeln('<head>');
        win_op.document.writeln('<title>' + alt + '</title>');
        win_op.document.writeln('</head>');
        win_op.document.writeln(body);
        win_op.document.writeln('<center><img name="image" src='+ path + ' border=0 alt="' + alt + '"></center>');
        win_op.document.writeln('</body>');
        win_op.document.writeln('</html>');                
        win_op.document.close();
}