TOkno = function()
{  
/*
 * mozliwosc zdefiniowania wielkosci poopupa aby wycentrowani
 * jego było odpowiednie względem całego okna domyslna wartosc to -> wysokoscOkna:450
 * 
 * okreslenie czy mpopup ma byc przesuwane czy nie  to ->  przesuwajOkno tak
 * 
	this.obj = _c('div',{parent:this});
	//--
	this.obj.setParam( param );
	this.obj.id = 'tokno';
	//this.obj.className = 'xwindow';
	this.obj.className = 'xokienko';
*/
//------

	var param =
	{
		id	: 'tokno',
		className:'xwindow',
		autoclose:false,
		przesuwajOkno:'nie'
	};

	
	for (var i in arguments[0]) if (typeof(arguments[0][i]!= 'function')) param[i]=arguments[0][i];
	this.obj		= _c('div',param);
	
	this.obj.konsola = function(prz,log)
	{
		switch (prz)
		{
			case 'f':
				var przegladarka = /Firefox/g;
				if (przegladarka.test(navigator.userAgent)) {
					console.log('komunikat konsola: '+ log);
				}
				break;
			case 'c':
				var przegladarka = /Chrome/g;
				if (przegladarka.test(navigator.userAgent)){
					console.log(log);
				}
				break;
			case 'ie':
				var przegladarka = /Trident/g;
				if (przegladarka.test(navigator.userAgent)){
					console.log('komunikat konsola: '+ log);
				}
				break;
			case '1':
					console.log('komunikat konsola: '+ log);
				break;
			default :return false; break;
		}
	}
	
	
//	if(this.obj.przesuwajOkno=='tak')
//    {
//		this.obj.zegar = setInterval("odswiezWysokosc()",800);  
//	}
//	
//	if(this.obj.przesuwajOkno=='nie')
//    {
//		clearInterval( this.obj.zegar );
//		this.obj.konsola('c',this.obj);
//		try { clearInterval( this.obj.zegar ); } catch(e) {};
//	} 
	if(this.obj.przesuwajOkno!='tak')
    {
		clearInterval( this.obj.zegar );
		this.obj.konsola('c',this);
		try { clearInterval( this.obj.zegar ); } catch(e) {};
	}
	else { this.obj.zegar = setInterval("odswiezWysokosc()",800);}

	this.obj.rysuj = function( dane )
	{
		//this.ok	= _c('div',{className: 'okienko'});
		this.tytul		= _c('div',{parent:this, id:'okno_tytul', className:'okno_tytul'});
		this.text		= _c('h3',{parent:this,className:'okno_title'});
		this.icon_close = _c('a',{parent:this,title:'zamknij okno',className:'close_ico'});
		this.body		= _c('div',{parent:this, id: 'okno_body', className:'okno_body'});
		this.bottom		= _c('div',{parent:this, id:'okno_bottom', className:'okno_bottom'});
		
		this.icon_close.onclick = function()
		{
			clearInterval( this.parent.zegar );
			this.parent.konsola('c','test');
			this.parent.hide();
			//this.parent.body.removeChild(this.parent.body.firstChild );
		}
//--------------------------------------
//fetchak
/*		
		this.opak 	= _c('div',{className:'stos'});
		var tl	= _c('div',{className:'corner c1'});
		var tr	= _c('div',{className:'corner c2'});
		var bl	= _c('div',{className:'corner c3'});
		var br	= _c('div',{className:'corner c4'});
		var content	= _c('div',{className:'inner'});
		
		this.opak.apC( tl );
		this.opak.apC( tr );
		this.opak.apC( content );
		this.opak.apC( bl );
		this.opak.apC( br );
*/		
//---------------------------------------

		var content	= _c('div',{className:'inner'});
		//this.opak		= _c('div',{className:'xokienko'});
		this.topleft	= _c('div',{className:'xtop-left'});
		this.corner1	= _c('div',{className:'xcorner1'});
		this.corner2	= _c('div',{className:'xcorner2'});
		this.topright	= _c('div',{className:'xtop-right'});
		this.bottomleft	= _c('div',{className:'xbottom-left'});
		this.bottomright	= _c('div',{className:'xbottom-right'});
		this.top		= _c('div',{className:'xtop'});
		this.left		= _c('div',{className:'xleft'});
		this.top		= _c('div',{className:'xtop'});
		this.right		= _c('div',{className:'xright'});
		this.inner		= _c('div',{className:'xinner'});
		this.corner3	= _c('div',{className:'xcorner3'});
		this.cornert4	= _c('div',{className:'xcorner4'});
		this.bottoms		= _c('div',{className:'xbottoms'});
		
	//alert('ssss');
		this.inner.apC( content );
		this.right.apC(this.inner);
		this.left.apC(this.right);
		this.bottomright.apC(this.top);
		this.bottomright.apC(this.left);
		this.topright.apC(this.bottomleft);
		this.bottomright.apC(this.corner3);
		this.bottomright.apC(this.cornert4);
		this.bottomright.apC(this.bottoms);

		this.bottomleft.apC(this.bottomright);
		this.topleft.apC(this.corner1);
		this.topleft.apC(this.corner2);
		this.topleft.apC(this.topright);

		//this.opak.apC(this.topleft);
		this.apC(this.topleft);

//------------------------------------
		
//		this.content.apC( this.tytul);
		
		
		this.tytul.apC( this.text);
		this.tytul.apC( this.icon_close );
//		this.text.apC(_cTxt( 'Logowanie') );
//		this.tytul.apC( this.text );
		content.apC( this.tytul );
		content.apC( this.body );
		content.apC( this.bottom );
		//this.apC(this.opak);
//		this.apC(this.ok);
	}

	this.obj.wstaw = function(o)
	{
		this.body.innerHTML = '';
		o.handle = this;
		this.body.apC( o );
		//this.body.innerHTML = 'blablabla';
	}
	this.obj.add = function( o )
	{
		o.handle = this;
		//this.body.apC( o );
	}

	this.obj.wstaw_tytul = function(o)
	{
//		if(typeof(o) == 'string')
//		{
//			this.text.apC(_cTxt( 'Logowanie') );
//			this.tytul.apC( this.text );
//		}
	}
	this.obj.clear  = function()
	{
//		this.parent.hide();
//		this.body.removeChild(this.parent.body.firstChild );
		this.body.innerHTML = '';
	}
	
	this.obj.zmien_tytul = function(tytul)
	{
		this.text.innerHTML = '';
		this.text.innerHTML = tytul;
	}
		
	this.obj.zmien_polozenie = function()
	{ 
		if(this.wysokoscOkna == undefined) var wysokoscOkna = 450;
		//-- 
		var wspolrzednay	= parseInt((document.body.clientHeight-wysokoscOkna)/2);
		//-- 
		this.style.position	= "absolute";
  	    this.style.top		= wspolrzednay + 'px'; 
	}
		
	this.obj.pokaz =  function()
	{
		if(this.autoclose) this.delay_close();

		_get('strona').appendChild(okno);
		this.show(); 
		this.className = 'xwindow';
		this.zmien_polozenie();
		
//		if(this.przesuwajOkno!='tak')
//	    {
//			clearInterval( this.zegar );
//			this.konsola('c',this);
//			try { clearInterval( this.zegar ); } catch(e) {};
//		}
//		else { this.zegar = setInterval("odswiezWysokosc()",800);this.konsola('c',this);} 
	}
	
	this.obj.setAutoClose = function(){	this.autoclose = true;}
	this.obj.delay_close = function()
	{
		this._delay = setTimeout("_get('"+this.id+"').ukryj()",6000) 
	}

	this.obj.ukryj =  function()
	{
		clearInterval( this.zegar );
		this.hide();
		this.autoclose = false;
	}
	 
	this.obj.test =  function()	{}

	this.obj.rysuj();
	return this.obj;	 
} 



function alertSize() 
{
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }
	  window.alert( 'Width = ' + myWidth );
	  window.alert( 'Height = ' + myHeight );
}


odswiezWysokosc = function()
{
	var o = _get('tokno');
	
	if (o == undefined) 
		return false;
	//console.log(o.przesuwajOkno);	
	//o.konsola('c',o.przesuwajOkno);
	if (o.przesuwajOkno != 'nie') {
		if (typeof(window.innerWidth) == 'number') {
			o.style.top = (window.pageYOffset + (window.innerHeight / 2) - 340) + 'px';
		}
		else 
			if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
				//IE6 standards compliant mode
				var scrOfY = document.documentElement.scrollTop;
				o.style.top = (scrOfY + (document.body.clientHeight / 2) - 340) + 'px';
			}
			else 
				if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
				}
	}
}

  





 
