var jwebTv={
	/********************************************/
	/** PUBLIC **********************************/
	/********************************************/
	mousePause:function(e,o,b){
		e=jweb.event.get();
		if(b){if(jweb.event.isMouseEnter(e,o)){
			o.contentWindow.jwebTv._scrollPause(1);
			}}
		else if(jweb.event.isMouseLeave(e,o)){
			o.contentWindow.jwebTv._scrollStart();
			}
		},
	/********************************************/
	init:function(url,redialTime){
		this._url=url;
		this._redialTime=redialTime;
		this._dialup();
		document.documentElement.style.overflow='hidden';
		window.onresize=function(){jwebTv._winResize()};
		},
	/********************************************/
	/** PRIVATE *********************************/
	/********************************************/
	_url:0,
	_contentHeight:0,
	_dialupTime:0,
	_scrollTop:0,
	_scrollProcessId:0,
	_scrollSpeed:0,
	_winSize:0,
	_redialTime:0,
	/********************************************/
	_winResize:function(){
		var ws=jweb.xy.size(window);
		if((ws.x!=this._winSize.x)&&(ws.y!=this._winSize.y)){
			this._dialup();
			}
		},
	/********************************************/
	_dialup:function(){
		this._winSize=jweb.xy.size(window);
		var url=this._url
			+'&jwebtvx='+this._winSize.x
			+'&jwebtvy='+this._winSize.y
			+'&nocache='+Math.round(Math.random()*123456789);
		jweb.ajax.post(url,this._answer,1);
		setTimeout(function(){jwebTv._dialup()},this._redialTime);
		},
	/********************************************/
	_answer:function(html){
		
		jwebTv._scrollPause(0);
		
		var fs=Math.round(jwebTv._winSize.x/20);
		
		// stupid readspeed calculation
		var charWidthBody=fs*0.5*0.9;
		var charsPerRow=(jwebTv._winSize.x-fs)/charWidthBody;
		var readSpeedPerChar=40;
		var readSpeedPerRow=charsPerRow*readSpeedPerChar;
		var rowsPerPage=jwebTv._winSize.y/(fs*2);
		var readSpeedPerPage=readSpeedPerRow*rowsPerPage;
		
		jwebTv._scrollSpeed=Math.round(readSpeedPerPage/jwebTv._winSize.y);
		
		document.body.style.fontSize=fs+'px';
		document.body.innerHTML=html;
		
		var cntHeight=jweb.xy.size(document.body).y;
		var winHeight=jweb.xy.size(window).y;
		var tmpHeight=cntHeight;
		
		while(tmpHeight<(winHeight+cntHeight)){
			document.body.innerHTML+=html;
			tmpHeight+=cntHeight;
			}
		
		jwebTv._contentHeight=cntHeight;
		jwebTv._scrollStart();
		},
	/********************************************/
	_scrollPause:function(showScrollBars){
		clearInterval(this._scrollProcessId);
		if(showScrollBars){
			document.documentElement.style.overflowY='scroll';
			}
		},
	/********************************************/
	_scrollStart:function(){
		document.documentElement.style.overflowY='hidden';
		this._scrollProcessId=setInterval(function(){jwebTv._scroll()},this._scrollSpeed);
		},
	/********************************************/
	_scroll:function(){
		if((++this._scrollTop)>this._contentHeight){
			this._scrollTop=0;
			}
		window.scrollTo(0,this._scrollTop);
		}
	/********************************************/
	};