function Is() { //browser leválogatás
  agent = navigator.userAgent.toLowerCase();
  this.agent = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  this.ns = ((agent.indexOf('mozilla') != -1) && ((agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1)));
  this.ns4 = (this.ns && (this.major <= 4) && (this.minor < 5));
  this.ns6 = (this.ns && (this.major >= 5));
  this.ie = (agent.indexOf("msie") != -1);
  this.ie4 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5.0") == -1));
  this.ie5 = (this.ie && (this.major == 4) && (agent.indexOf("msie 5") != -1));
  this.ie6 = (this.ie && (this.major == 4) && (agent.indexOf("msie 6") != -1));
  this.iframe = (this.ie || this.ns6) ;
}
var is = new Is();

/*
var bNetscape4plus = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "4");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
*/

function CheckUIElements()
{
	var yMenuFrom, yMenuTo, yOffset=0, timeoutNextCheck,Ytop,YtopReal;
	
	if ( is.ns4 ) {
		yMenuFrom   = document["rightBanner"].top;
		yMenuTo     = top.pageYOffset + top.innerHeight - 95;
	}
	else if ( is.ns6 ) {
//		alert(pageYOffset);
		var dm = document.getElementById("rightBanner");
		yMenuFrom   = dm.style.top;
		yMenuTo     = pageYOffset + innerHeight - 295;
	}
	else if ( is.ie ) {
		Ytop=document.getElementById("rightBanner").style.top;
		YtopReal=Ytop.substr(0,(Ytop.length-2));

		yMenuFrom   = parseInt (rightBanner.style.top, 10);
		
		yMenuTo     = document.body.scrollTop + document.body.clientHeight-document.body.clientHeight-5;
		
		//alert(yMenuFrom+'>>'+document.body.scrollTop+' >>'+document.body.clientHeight);
	}

	timeoutNextCheck = 500;
	//alert(parseInt(document.getElementById("rightBanner").style.top,10)+' >>'+document.getElementById("LayerHeightInTd").offsetHeight);
	

	/*if ( yMenuFrom != yMenuTo) {
		if (YtopReal<document.getElementById("LayerHeightInTd").offsetHeight-340){
			yOffset=yOffset + document.body.scrollTop;
		}
		

		rightBanner.style.top = parseInt (rightBanner.style.top, 10) + yOffset;

		timeoutNextCheck = 110;
	}
	
	setTimeout ("CheckUIElements()", timeoutNextCheck);*/
	
	/*if (Ytop.substr(0,(Ytop.length-2))<document.getElementById("LayerHeightInTd").offsetHeight-340) {
		//alert(document.getElementById("rightBanner").style.top+' >> '+document.getElementById("LayerHeightInTd").offsetHeight);
				
		if (Ytop.substr(0,(Ytop.length-2))<document.getElementById("LayerHeightInTd").offsetHeight-340)
		{
			//alert(document.getElementById("rightBanner").style.top+' >>>'+document.getElementById("LayerHeightInTd").offsetHeight);
			yOffset=yOffset + 100;
		}
		else
			yOffset=yOffset - 100;
		
		rightBanner.style.top = parseInt (rightBanner.style.top, 10) + yOffset;
		
		timeoutNextCheck = 110;
	}

	
	//alert(Ytop.substr(0,(Ytop.length-2)));
	if (Ytop.substr(0,(Ytop.length-2))<document.getElementById("rightBanner").style.top<document.getElementById("LayerHeightInTd").offsetHeight-340)
	{
		setTimeout ("CheckUIElements()", timeoutNextCheck);
	}*/

	//if (YtopReal>document.getElementById("LayerHeightInTd").offsetHeight-340)
	//{
		//document.getElementById("rightBanner").style.top=YtopReal;
	//}

	if (YtopReal>yMenuTo)
	{
		yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom) / 10);
	}

	if (yMenuTo>300 && document.body.clientHeight<800)
	{
		//yMenuTo=yMenuTo-document.body.clientHeight;
		yMenuFrom=yMenuFrom+330;
	}

//&& (YtopReal>-50 && YtopReal<document.getElementById("LayerHeightInTd").offsetHeight-340)
	
	if ( yMenuFrom != yMenuTo) {
		
		if(YtopReal<document.getElementById("LayerHeightInTd").offsetHeight-340)
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom) / 10);
		
		if ( yMenuTo < yMenuFrom )
			yOffset = -yOffset;
		
		if ( is.ns4 )
			document["rightBanner"].top += yOffset;
		else if ( is.ns6 ){
			var dm = document.getElementById("rightBanner");
			dm.style.top = dm.style.top + yOffset;			
		}else if ( is.ie ){
			rightBanner.style.top =  (parseInt (rightBanner.style.top, 10) + yOffset);
			//alert(rightBanner.style.top+'>> '+parseInt (rightBanner.style.top, 10)+' >> '+yOffset+' >> scroll: '+document.body.scrollTop+' >> '+document.body.scrollheight);
		}

		timeoutNextCheck = 110;
	}
	/*else{
		if (document.body.scrollTop>330)
		{
			rightBanner.style.top =parseInt (rightBanner.style.top, 10)-330;
			yMenuTo=yMenuTo-330;
		}
	}*/
	
	setTimeout ("CheckUIElements()", timeoutNextCheck);
	
	
}

function zapp2()
{
var rb = document.getElementById("rightBanner");
if( (rightDisabled != "true") && (rb!="") ){
	var y;
	
	// we're not gonna be loaded in frames
	if ( top.frames.length )
		top.location.href = self.location.href;
		
	// setting initial UI elements positions
	if ( is.ns4 ) {
		document["rightBanner"].top = top.pageYOffset + 50;
		document["rightBanner"].visibility = "visible";
	}
	else if ( is.ns6 ) {
		var dm = document.getElementById("rightBanner");
		dm.style.top = pageYOffset + 430;
		dm.style.visibility = "visible";
	}
	else if ( is.ie ) {
		
		rightBanner.style.top = 0+'px';
		document.getElementById("rightBanner").style.left=0+'px';

		rightBanner.style.visibility = "visible";
	}
	//alert(document.getElementById("LayerHeightInTd").offsetHeight);
	if (document.getElementById("LayerHeightInTd").offsetHeight>340)
	{
		CheckUIElements();
		if ( is.ie )
			setTimeout ( "FlashTitleStepIt(255)", 10 );
	}
	else{
		rightBanner.style.position="relative";
		rightBanner.style.top=0;
		rightBanner.style.left=0;
	}


	return true;
}
}


/* IE only function for flashing the page title onload */
function FlashTitleStepIt( fptItersLeft )
{
	var str;
	str = fptItersLeft.toString(16);
	str = eval ( "\"#" + str + str + str + "\"" );
	
//	divLinkButton.style.color = str;
	
	fptItersLeft--;
	if ( str !=  "#606060" )
		setTimeout ( eval ( "\"FlashTitleStepIt(" + fptItersLeft + ")\"" ), 10 );
}


