/**
 *  ASYSTENT - Asystent strony helpo
 */
 
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function ASYSTENT() {
	this._container = null;	
}
ASYSTENT.prototype.init = function() {
	this.test();
}
ASYSTENT.prototype.test = function(){
	this._container = hmain.vbox('asystent');
	this._container.style('position:absolute;top:0;left:0;background:#d3d3d3;width:100%;height:30px')
	this._container.opacity(40);
	hmain.append();
	this.repos();
}
ASYSTENT.prototype.repos = function(){
	usize = utils.usize();
	s = getScrollXY();
	if(asystent._container){
		asystent._container.pos(0, usize[1]-30 + s[1]);
		setTimeout('asystent.repos()', 10);
	}
}


ASYSTENT.prototype.comet = {
	// CONST
	_request: 	null,
	_uri: 		'/asystent/push/',
	
	init: function() {
		this._request = new pi.comet(); 
		this._request.environment.setUrl(asystent.comet._uri); 
		this._request.event.push = this.push;
		this._request.send();
	},
	
	push: function(Response) {
		if(parseInt(Response) == 100) {
			asystent.comet._request.abort();
			asystent.comet.init();
			Response = 'reconnecting...';			
		}
	}
}
var asystent = new ASYSTENT();