
var w,h,x,y,cx,cy,cw,ch,hw,hh,hx,hy,p;

function init()
{
	init_window();
	//debug();
	vlastiveda_engine();
}

function init_window()
{
	set_win_params();
	
	// container
	cx = 0;
	cy = 0;
	cw = 920;
	ch = 330;
	
	// text holder
	hx=0;
	hy=0;
	hw=920;
	hh=1000;
	
	// params
	p = new Object();
	p.cy_rel=100; // relative container
	p.cx_rel=100;
	
	p.y_rel=0; // relative navi
	p.x_rel=20;
	
	p.hy_off=0; // holder offset
}

function set_win_params()
{
	if(browser.isIE) {w=document.body.clientWidth;h=document.body.clientHeight;}
	if(browser.isNS) {w=window.innerWidth;h=window.innerHeight;}
}


// #######################3

function debug()
{
	dwrite('dw',w);
	dwrite('dh',h);
	dwrite('dx',x);
	dwrite('dy',y);
	
	dwrite('dcx',cx);
	dwrite('dcy',cy);
	
	dwrite('dhx',hx);
	dwrite('dhy',hy);

	dwrite('dhh',hh);
	dwrite('dhw',hw);

	
}


function dwrite(id,str)
{
	var el = document.getElementById(id);
	el.value=str;
}

// #######################3

function vlastiveda_engine()
{
	vlastiveda_navi();
}

function vlastiveda_navi()
{
	// position of navi
	var pos = get_navi_pos();
	x=pos[0];
	y=pos[1];
	
	// set
	vlastiveda_move();
}

function vlastiveda_move()
{
	var elc = document.getElementById('container');
	var elh = document.getElementById('holder');
	
	// container
	//cx = (w-x-p.x_rel)/(w-p.x_rel*2)*(w-cw-p.cx_rel)+p.cx_rel/2;
	//cy = (h-y-p.y_rel)/(h-p.y_rel*2)*(h-ch-p.cy_rel)+p.cy_rel/2;

	// text holder	
	hy = -(y/h*hh)+p.hy_off;
	
	// aet all
	//elc.style.left = String(parseInt(cx))+'px';
	//elc.style.top = String(parseInt(cy))+'px';
	
	elh.style.top = String(parseInt(hy))+'px';
	
	//debug();
}

function vlastiveda_exit()
{
	var xpos = get_pos('navi');
	var cpos = get_pos('container');
	/*
	if(Math.abs(xpos[0]-cpos[0])<15 && Math.abs(xpos[1]-cpos[1])<15)
		//history.back();
		window.location.href='http://';
	*/
}



function get_navi_pos()
{
	return get_pos('navi');
}

function get_pos(id)
{
	var el = document.getElementById(id);
	var pos= Array(el.style.left,el.style.top);
	var x=String(pos[0]);
	var y=String(pos[1]);
	x=x.substr(0,x.length-2);
	y=y.substr(0,y.length-2);
	return Array(x,y);
}

function get_size(id)
{
	var el = document.getElementById(id);
	var pos= Array(el.style.width,el.style.height);
	var x=String(pos[0]);
	var y=String(pos[1]);
	x=x.substr(0,x.length-2);
	y=y.substr(0,y.length-2);
	return Array(x,y);
}
