TLogowanieSchowek = function()
{   
	var klik=0;
	var param =
	{
		status	:0,
		liczba 	:0,
		schowek_moje_krok	: 1,
		className	:'okno_logowania',
		AJAXsrc		:'/strona_v2/ajax/login/'
	};
	
	for (var i in arguments[0]) if (typeof(arguments[0][i]!= 'function')) param[i]=arguments[0][i];
	this.obj		= _c('div',param);
	           
	this.obj.rysuj = function( dane )
	{ 
		var napis1="Wpisz swój numer telefonu!"; 
		var napis2="Jeśli nie posiadasz jeszcze konta - wprowadź dowolne hasło.\n Jeśli zaś posiadasz wprowadź w pole hasło otrzymane przy rejestracji.";
			
		this.div_a		=	_c('div',{parent:this,className:'naglowek_area'});
		this.login		=	_c('input',{parent:this,name:'login'});
		this.oprawka1 = new TOprawkaInput( {parent:this,inner_obj:this.login,className:'LogowanieInput', title: napis1} );
		
		//this.tipopis	= _c('div',{parent:this,className:'tipopis'});
		//this.tipopis.innerHTML = '<img src="http://oferta.pl/images/01/80p/help.png" width="16" height="16" class="vtip" title="Wpisz swój numer telefonu!">';

		this.haslo		    = _c('input',{parent:this,name:'haslo',type:'password',value:''});
		this.haslo_weryf	= _c('input',{parent:this,name:'haslo_weryf',type:'password',value:''});

		this.oprawka2		= new TOprawkaInput( {parent:this,inner_obj:this.haslo,className:'LogowanieHaslo ', title: napis2} );
		this.oprawka_weryf	= new TOprawkaInput( {parent:this,inner_obj:this.haslo_weryf,className:'LogowanieHaslo'} );
		this.info_sms	= _c('div',{parent:this,className:'informacja_sms'});
		
		this.info_sms.innerHTML = '<p>Uwaga korzystanie ze schowka oznacza akceptację niniejszego <b><a href="/strona_v2/regulamin/schowek/" class="vtip" title="Uwaga jeśli nie posiadasz jeszcze konta. Wystarszy uzupełnić oba zamieszczone z boku pola!">regulaminu.</a></b></p>';
		
		this.oprawka1.setLabel('telefon:');
		this.oprawka2.setLabel('hasło:');
		this.oprawka_weryf.setLabel('potwierdź hasło:');
		this.oprawka_weryf.hide();
		
		if ( this.komunikatPowiadomienie == 1 )
			this.div_a.apC( _cTxt('Zaloguj się aby wysłać powiadomienie') );	
		else
			this.div_a.apC( _cTxt('Zaloguj się aby dodać ogłoszenia do schowka') );	
		
		this.apC( this.div_a );
		this.apC( this.oprawka1 );
	//	this.apC( this.tipopis );
		this.apC( this.oprawka2 );
		this.apC( this.oprawka_weryf );
		this.apC( this.info_sms ); 
 
		//akcja od ikonki
		this.oprawka2.onAkcept = function()	
		{ 
			this.parent.sendValues();			
		}
		
		this.onSetByAjaxEnd = function(){
			if ( this.sprawdz() ) this.handle.ukryj(); 
		}
		
		
		this.sendValues = function(){
			setByAjax( '/strona_v2/ajax/set/', this, {akcept:encodeURI(this.login.value + ':' + this.haslo.value + ':' + this.haslo_weryf.value  )} );
		}
		
		this.oprawka_weryf.onAkcept = function() {	this.parent.sendValues();	klik++;	 }
		this.login.onkeyup 			= function(e){	this.parent.keydownHandler(e,1);	 }
		this.haslo.onkeyup 			= function(e){	this.parent.keydownHandler(e,2);	 }
		this.haslo_weryf.onkeyup 	= function(e){	this.parent.keydownHandler(e,2);	 }
		
		//this.haslo_weryf.onfocus = function(){ console.log('tests'); }
		
		if (dane != undefined)
		{ 
			this.update( dane ); 
		}		
	}
	
 
	this.obj.setHasloWeryf = function(value)
	{try{console.log('akceptacja1')} catch(e){}
		setByAjax( '/strona_v2/ajax/set/', this,{'haslo_weryf' : (this.login.value + ':' + this.haslo.value )} );
		
	}
 
 	this.obj.keydownHandler = function(e, v)
	{
		var evt = e ? e : event;
		var keyCode = evt.keyCode;
		//console.log(keyCode)
		if(keyCode == 27){
			this.handle.ukryj();
		}
		if(keyCode == 13)
		if(v==1)
			this.haslo.focus();
		else if(v==2)
			this.sendValues();
		else return false; 
	}	
 	

	this.obj.showWeryfikacja = function(   )
	{ 
		this.oprawka2.icon.style.display = 'block';
		this.oprawka2.hide();
		this.haslo.hide();
		this.oprawka1.hide();
		this.oprawka_weryf.show();
		//this.haslo_weryf.focus(); 
		 
	}
	this.obj.setHasloWeryfFocus = function()
	{
		this.haslo_weryf.focus();		 
	}
	
	this.obj.hideWeryfikacja = function()
	{
		this.oprawka2.icon.style.display = 'block';
		this.oprawka2.show();
		this.oprawka1.show(); 
	//	this.oprawka_weryf.hide(); 
	}

	this.obj.sprawdz = function(value)
	{
		if( this.status != 1)
		{ 
			this.onGetByAjaxEnd	 = function()
			{
				if (dane['zalogowany'] == '')
				{
					this.handle.pokaz();
					//this.login.focus();
					if( dane['login'] !='' )
					{
						this.haslo_weryf.focus();
					}
					else this.login.focus();
					
					if(klik>=2) { //jesli wpiisano więcej niż 2 razy bledny weryfHaslo to od nowa loguj
						
						this.oprawka2.icon.style.display = 'block';
						this.oprawka2.show();
						this.oprawka1.show(); 
						this.haslo.show();
						this.oprawka_weryf.hide();
					}  
				}
				
			}
			this.getByAjax(); 
		}
		if(this.status == 1)
		{
			if (dane['schowek_ostatni_krok'] != 0) {
				document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/moje";
			}
			else {
				this.handle.ukryj();
				if (value != undefined)	return true;
				document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/inne";
			} 
		}
		return(this.status);
	}
	this.obj.sprawdz2 = function(value)
	{
		if( this.status != 1)
		{ 
			//console.log('status nie: ' + this.status);
			this.onGetByAjaxEnd	 = function()
			{
			//	console.log(dane);
				if (dane['zalogowany'] == '')
				{  
					this.handle.pokaz();
					if( dane['login'] !='' )
					{
						this.haslo_weryf.focus();
					}
					else this.login.focus();
					
					if(klik>=2) { //jesli wpiisano wiecej niy 2 razy bledny weryfHaslo to od nowa loguj
						
						this.oprawka2.icon.style.display = 'block';
						this.oprawka2.show();
						this.oprawka1.show(); 
						this.haslo.show();
						this.oprawka_weryf.hide();
					}  
				}
			}
			this.getByAjax(); 
		}
		if(this.status == 1)
		{
		//	console.log('status: tak' + this.status);
		//	console.log(dane);
			this.handle.ukryj();
			if ( value != undefined ) return true;
			//if(typeof(console)== 'object' ){ console.log(dane); }
			//document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/inne" ; 
		}
		if(this.status == 2)
		{
		//	console.log('status 2: tak' + this.status);
		//	console.log(dane);
			this.handle.ukryj();
			if ( value != undefined ) return true;
			//if(typeof(console)== 'object' ){ console.log(dane); }
			document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/moje" ; 
		}
		return(this.status);
	}	
	
	this.obj.load = function( dane ){  this.update( dane );	 }
	
	this.obj.update = function( dane )
	{
		if (dane == undefined) return false;
		if(this.status != 0) this.handle.ukryj();
		if (dane['zalogowany'] != '')
		{
			this.status = 1;
			//if(typeof(console)== 'object' ){ console.log('jest zalogowany'); }
			//if(typeof(console)== 'object' ){ console.log( this.status ); }
			this.sprawdz(); 			
		}
		else
		{
			this.status = 0;
			this.hideWeryfikacja(); 			
		}
		
		if (dane['login'] != '' && dane['haslo_weryf'])
		{   
			this.showWeryfikacja();
			this.setHasloWeryfFocus(); 
		}
		if( dane['schowek_ostatni_krok'] == 1)
		{
		//	console.log('schowek_ostatni_krok = 1 ');
			this.status = 2;
		}
	}
	this.obj.rysuj();
	return this.obj;
}
	
TLogowanieSchowekNew = function()
{
	var klik=0;
	var param =
	{
		status	:0,
		liczba 	:0,
		schowek_moje_krok	: 1,
		className	:'okno_logowania',
		AJAXsrc		:'/strona_v2/ajax/login_schowek/'
	};
	
	for (var i in arguments[0]) if (typeof(arguments[0][i]!= 'function')) param[i]=arguments[0][i];
	this.obj		= _c('div',param);
	           
	this.obj.rysuj = function( dane )
	{ 
		var napis1="Wpisz swój numer telefonu!"; 
		var napis2="Jeśli nie posiadasz jeszcze konta - wprowadź dowolne hasło.\n Jeśli zaś posiadasz wprowadź w pole hasło otrzymane przy rejestracji.";
			
		this.div_a		=_c('div',{parent:this,className:'naglowek_area'});
		this.login		= _c('input',{parent:this,name:'login'});
		this.oprawka1 = new TOprawkaInput( {parent:this,inner_obj:this.login,className:'LogowanieInput', title: napis1} );
		
		//this.tipopis	= _c('div',{parent:this,className:'tipopis'});
		//this.tipopis.innerHTML = '<img src="http://oferta.pl/images/01/80p/help.png" width="16" height="16" class="vtip" title="Wpisz swój numer telefonu!">';

		this.haslo		    = _c('input',{parent:this,name:'haslo',type:'password',value:''});
		this.haslo_weryf	= _c('input',{parent:this,name:'haslo_weryf',type:'password',value:''});

		this.oprawka2		= new TOprawkaInput( {parent:this,inner_obj:this.haslo,className:'LogowanieHaslo ', title: napis2} );
		this.oprawka_weryf	= new TOprawkaInput( {parent:this,inner_obj:this.haslo_weryf,className:'LogowanieHaslo'} );
		this.info_sms	= _c('div',{parent:this,className:'informacja_sms'});
		
		this.info_sms.innerHTML = '<p>Uwaga korzystanie ze schowka oznacza akceptację niniejszego <b><a href="/strona_v2/regulamin/schowek/" class="vtip" title="Uwaga jeśli nie posiadasz jeszcze konta. Wystarszy uzupełnić oba zamieszczone z boku pola!">regulaminu.</a></b></p>';
		
		this.oprawka1.setLabel('telefon:');
		this.oprawka2.setLabel('hasło:');
		this.oprawka_weryf.setLabel('potwierdź hasło:');
		this.oprawka_weryf.hide();
		
		if ( this.komunikatPowiadomienie == 1 )
			this.div_a.apC( _cTxt('Zaloguj się aby wysłać powiadomienie') );	
		else
			this.div_a.apC( _cTxt('Zaloguj się aby dodać ogłoszenia do schowka') );	
		
		this.apC( this.div_a );
		this.apC( this.oprawka1 );
	//	this.apC( this.tipopis );
		this.apC( this.oprawka2 );
		this.apC( this.oprawka_weryf );
		this.apC( this.info_sms ); 
 
		//akcja od ikonki
		this.oprawka2.onAkcept = function()	{	this.parent.sendValues();	}
		this.onSetByAjaxEnd = function()	{	if ( this.sprawdz() ) this.handle.ukryj();	}
		
		
		this.sendValues = function(){
			setByAjax( '/strona_v2/ajax/set/', this, {akcept:encodeURI(this.login.value + ':' + this.haslo.value + ':' + this.haslo_weryf.value  )} );
		}
		
		this.oprawka_weryf.onAkcept = function() {	this.parent.sendValues();	klik++;	 try{console.log('po');} catch(e){}}
		this.login.onkeyup 			= function(e){	this.parent.keydownHandler(e,1);	 }
		this.haslo.onkeyup 			= function(e){	this.parent.keydownHandler(e,2);	 }
		this.haslo_weryf.onkeyup 	= function(e){	this.parent.keydownHandler(e,2);	 }
		
		//this.haslo_weryf.onfocus = function(){ console.log('tests'); }
		
		if (dane != undefined){	this.update( dane ); }		
	}
 
	this.obj.setHasloWeryf = function(value)
	{
		setByAjax( '/strona_v2/ajax/set/', this,{'haslo_weryf' : (this.login.value + ':' + this.haslo.value )} );
	}
 
 	this.obj.keydownHandler = function(e, v)
	{
		var evt = e ? e : event;
		var keyCode = evt.keyCode;
		//console.log(keyCode)
		if(keyCode == 27){
			this.handle.ukryj();
		}
		if(keyCode == 13)
		if(v==1)
			this.haslo.focus();
		else if(v==2)
			this.sendValues();
		else return false; 
	}	
 	

	this.obj.showWeryfikacja = function(   )
	{ 
		this.oprawka2.icon.style.display = 'block';
		this.oprawka2.hide();
		this.haslo.hide();
		this.oprawka1.hide();
		this.oprawka_weryf.show();
		//this.haslo_weryf.focus(); 
		 
	}
	this.obj.setHasloWeryfFocus = function()
	{
		this.haslo_weryf.focus();		 
	}
	
	this.obj.hideWeryfikacja = function()
	{
		this.oprawka2.icon.style.display = 'block';
		this.oprawka2.show();
		this.oprawka1.show(); 
	//	this.oprawka_weryf.hide(); 
	}

	this.obj.sprawdz = function(value)
	{
	//	console.log(value);
	//	console.log(dane);
		if( this.status != 1)
		{ 
			this.onGetByAjaxEnd	 = function()
			{
				if (dane['zalogowany'] == '')
				{
					console.log(dane);
					//this.handle.pokaz();
					//this.login.focus();
					if( dane['login'] !='' )
					{
						this.haslo_weryf.focus();
					}
					else this.login.focus();
					
					if(klik>2) { //jesli wpiisano wiecej niy 2 razy bledny weryfHaslo to od nowa loguj
						
						this.oprawka2.icon.style.display = 'block';
						this.oprawka2.show();
						this.oprawka1.show(); 
						this.haslo.show();
						this.oprawka_weryf.hide();
					}  
				}
				
			}
			this.getByAjax(); 
		}
		if(this.status == 1)
		{
			if (dane['schowek_ostatni_krok'] != 0) {
				document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/moje";
			}
			else {
				this.handle.ukryj();
				if (value != undefined)	return true;
				document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/inne";
			} 
		}
		return(this.status);
	}

//	this.obj.setZapisz = function()
//	{
//		setByAjax( '/strona_v2/ajax/set/', this,{'setDodajDoSchowkaAnonim' : ('') } ); //zapisuje do bazy wsyatkie ogloszenia anonima
//	}
//	this.obj.onSetByAjaxEnd	 = function()
//	{
//		if(this.status != 0)
//			this.sprawdz();
//		console.log('onSETByAjaxEnd');
//	}

	this.obj.onGetByAjaxEnd	 = function()
	{
		if (dane['zalogowany'] == '')
		{  
			if( dane['login'] !='' ){	this.haslo_weryf.focus();	}
			else this.login.focus();
			
			//jesli wpiisano wiecej niy 3 razy bledny weryfHaslo to od nowa loguj
			if(klik>2) 
			{ 
				this.oprawka2.icon.style.display = 'block';
				this.oprawka2.show();
				this.oprawka1.show(); 
				this.haslo.show();
				this.oprawka_weryf.hide();
			}  
		}
		
		if(this.status != 0)
			this.sprawdz();
			
		//console.log('ongetByAjaxEnd');
	}
	
//	this.obj.sprawdz = function()
//	{
//		//console.log('status'+ this.status);
//		switch (this.status)
//		{
//			case 0:
//					this.getByAjax();		
//					//alert(this.status);
//					this.onGetByAjaxEnd();
//				break;
//			case 1:
//				//alert('przekierowanie na schowek anonim');
//				console.log('przekierowanie na schowek moje');
//				this.handle.ukryj();
//				//if ( value != undefined ) return true;
//				//if(typeof(console)== 'object' ){ console.log(dane); }
//				//document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/moje" ;
//				break;
//			case 2:
//				alert('przekierowanie na schowek anonim');
//				if(dane['schowek_anonim'] > 0 ) alert('aaaaaaaaaas');
//				console.log(dane['schowek_anonim']);
//				console.log('przekierowanie na schowek anonim');
//				this.handle.ukryj();
//				//if ( value != undefined ) return true;
//				//if(typeof(console)== 'object' ){ console.log(dane); }
//				//document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/anonimOgl" ;
//				break;
//			case 3:
//				console.log(dane);
//				console.log('przekierowanie na schowek inne');	
//				alert('przekierowanie na schowek inne');			
//				this.handle.ukryj();
//				//if ( value != undefined ) return true;
//				//if(typeof(console)== 'object' ){ console.log(dane); }
//				//document.location = location.protocol + '//' + location.hostname + "/strona_v2/schowek/inne" ;
//				break;
//		}
//		return this.status;
//	}	
	
	this.obj.load 		= function( dane ){  this.update( dane );	 }
	this.obj.setStatus 	= function(	value ){	this.status = value;	}
	
	this.obj.update = function( dane )
	{
		if (dane == undefined) return false;
		if(this.status != 0) this.handle.ukryj();
		//console.log(dane);
		
		if (dane['zalogowany_gazeta'] != '' && dane['zalogowany'] != '') // zalogowany gazeta i zalogowany do schowka
		{
			this.status = 3;
		}
				
		if (dane['zalogowany_gazeta'] != undefined)
		if (dane['zalogowany_gazeta'] != '' && dane['zalogowany'] == '') // zalogowany gazeta i niezalogowany do schowka
		{
			if(dane['schowek_anonim'] > 0)
				this.status = 2; 
		}
		
		
//		else
//		{
//			this.status = 0;
//			this.hideWeryfikacja(); 			
//		}
		
//		if (dane['login'] != '' && dane['haslo_weryf'])
//		{   
//			this.showWeryfikacja();
//			this.setHasloWeryfFocus(); 
//		}
		//this.sprawdz();
	}
	this.obj.rysuj();
	return this.obj;
	
} //-- end logowanie_schowek_new
		
	


