var check = (document.all == '[object]' || document.all == '[object Collection]');

function start(){
	defWin();
	defHod();
	fsetLayer();
	tentoText.visibility = (check) ? 'visible' : 'show';
    def_doraz();
}

var winWidth = 0;
var winHeight = 0;
var defLeft = 0;
var defTop = 10;
var xtimer = 0;
var vstep = 2;    //  rychlost posuvu
var timer = 5;
var defxrect = 126;             //  sirka ttextoveko pole - resp. prevy orezovy okraj -- stejnou hodnotu musis nastavit i v tabulce kde je umisteny text
var defyrect = 0;
var defheight = 183;            //  vyska textoveho pole ktery bude videt
var ytop = 0;
var xrect = defxrect;
var yrect= defyrect;

function ftext(up_do) {
	if (xtimer != 0) {
		clearTimeout(xtimer);
	}
	difer = (check) ? 80 : 65;
	if ((up_do == '01') && (yrect < (doraz - defheight))){
		ytop    -= vstep;
		yrect	+= vstep;
	} else if((up_do == '10') && ((yrect + vstep + defheight) > defheight)){
		ytop    += vstep;
		yrect	-= vstep;
	}	
	fsetLayer();
	xtimer = setTimeout('ftext(\'' + up_do + '\');', timer);
}

function text_up(){
	ytop = 0;
	yrect = 0;
	fsetLayer();
}

function text_down() {
	ytop = defheight - doraz;
	yrect = doraz - defheight;
	fsetLayer();
}

function fStop() {
	if (xtimer != 0){
		clearTimeout(xtimer);
	}
	xtimer = 0;
}

function def_doraz() {
	doraz = (check) ? document.all.text.offsetHeight : document.nstext.layers[0].clip.height;
}

function defWin(){
	winWidth = (check) ? document.body.clientWidth : window.innerWidth;
	winHeight = (check) ? document.body.clientHeight : window.innerHeight;
}

function defHod(){
//	korekce = (check) ? 0 : 8;  //  vyrovnani pro nn - standardne o neco posunuje oproti ie
	defLeft = 5;              //  odsazeni z leva
	defTop = 112;     //  odsazeni z vrchu
}

function fsetLayer() {
	tentoText = (check) ? document.all.text.style : document.nstext;
	tentoText.left = defLeft + 5;
	textTop = defTop + ytop;
	cl_top = yrect.toString();
    cl_right = xrect.toString();
    cl_left = (xrect - defxrect).toString();
    cl_bot = (yrect + defheight).toString();
	if (check)	{
    	tentoText.top = textTop;
    	tentoText.clip = 'rect(' + cl_top + ' ' + cl_right + ' ' + cl_bot + ' ' + cl_left + ')';
	} else {
		tentoText.top = textTop;
		tentoText.clip.top = cl_top;
		tentoText.clip.right = cl_right;		
		tentoText.clip.bottom = cl_bot;
		tentoText.clip.left = cl_left;
	}
}
