// 
// 	ADDklasaIE6compatibility i REMklasaIE6compatibility jest dodana, w celu nadawania innych niz 'active' wartosci
// 		klas (pierwotnie stworzone specjalnie pod IE6)
// 		
// 	ADDklasaIE6compatibility - dodajen nowa klase
// 	
// 	REMklasaIE6compatibility - usuwa klase z innych elementow
// 		
// 






function change_tab(el, ADDklasaIE6compatibility, REMklasaIE6compatibility ) {
	
	
		/* przypisanie wartosci domyslnej*/
		if ( ADDklasaIE6compatibility == undefined ) {
			ADDklasaIE6compatibility = 'active';
		}
		
		if ( REMklasaIE6compatibility == undefined ) {
			REMklasaIE6compatibility = 'active';
		}		
	
		/*var exprTab = '/tab/i';*/
		///var expr1 = '/'+klasaIE6compatibility+'/i';
		
		
			//	wyrazenie regularne usuwajace wszelkie ciagi 
			//	z podciagiem REMklasaIE6compatibility z elementu wywolujacego 
			//	ten skrypt
			
		var expr1 = new RegExp( "\\w{0,}"+REMklasaIE6compatibility+"\\w{0,}" );
	
		if(el.nodeType==1){
			var att = new RegExp( el.getAttribute('name'), "i");
			var parent = el.parentNode;
			var grand = el.parentNode.parentNode;
			var grandChildes = grand.childNodes;
	
			var childes = parent.childNodes;
			for(i=0;i<childes.length;i++){
			if(childes[i].nodeType==1){
				if(childes[i].getAttribute('name')!=null){
				
					/*if(	childes[i].getAttribute('name').match(/tab/i)){*/
					if(	childes[i].getAttribute('name').match( /tab/i )){
						/*childes[i].className = childes[i].className.replace( /active/,"");*/
						childes[i].className = childes[i].className.replace( expr1,"");	
					}
				}
			}
			}
			
			for(i=0;i<grandChildes.length;i++){
				if(grandChildes[i].nodeType==1){
					if(grandChildes[i].getAttribute('name')!=null){
						if(	grandChildes[i].getAttribute('name').match(/content/i)){
							var tempChild = grandChildes[i].childNodes;
							for(k=0;k<tempChild.length;k++){
								if(tempChild[k].nodeType==1){
									
									if(tempChild[k].getAttribute('name')!=null){
										if(	tempChild[k].getAttribute('name').match(/tab/i)){
											/*tempChild[k].className = tempChild[k].className.replace(/active/i,"");	*/
											tempChild[k].className = tempChild[k].className.replace( /active/i ,"");
										}
										if( tempChild[k].getAttribute('name').match(att)){
											tempChild[k].className+= ' active';
										}
									}
								}
							}
						}
					}
				}
			}
			
			 el.className+= ' '+ADDklasaIE6compatibility;
			 
			 
			 
		 }
	}

 


			// jak sama nazwa wskazuje, funkcja sprawdza czy zmienna jest tablca
			
			
			function isArray(obj) {
			   if (obj.constructor.toString().indexOf("Array") == -1)
			      return false;
			   else
			      return true;
			}
	
	
	
	
	
	/*to rozwiazanie w przeciwienstwie do login jest bardziej
	uniwersalne*/
	//	funkcje do obslugi input password
		
		function setElFocus( elId ) {
			document.getElementById( elId ).focus();
			//alert( document.getElementById( elId ).value );
		}
		
		function onDisplayElement( elId ) {
			document.getElementById( elId ).style.display ='none';
		}
		
		//wywolujacy moze byc jako ID badz jako obiekt
		function offDisplayElement( elemObj, elId ) {
		
		
			var el=null;
			if ( (el=document.getElementById( elemObj ))!=null ) {
				elemObj = el;
				///alert( '>'+elemObj.value+'<' );
			}

			if ( elemObj.value == '' ) {
				///////alert( '...>pusty<' );
				document.getElementById( elId ).style.display ='block';
			}
			else {
				/////alert( '>'+elemObj.value+'< >'+elemObj.value.length );
				document.getElementById( elId ).style.display ='none';
			}
		}	
		
	
	
	
	//elementy do obslugi input login
		
		var czyCosWpisano=false;

		
		function onLoginElement( wyw ) {
			if (czyCosWpisano==false)
				wyw.value = '';
		}
		
		function offLoginElement( wyw, text ) {
		
			if ( wyw.value.length==0 ) {
				wyw.value = text;
				czyCosWpisano=false;
			}
			else {
				czyCosWpisano=true;
			}
						
		}
	
	
	//////////////////////////////
	
	
	
	/**
	 *	funkcja przechodzi po wszystkich elementach 'klasa_group', czyli
	 *	jak nadamy ID: Ala0, Ala1 i Ala2, to wspolnma klasa jest 'Ala' 	 
	 *
	 *	przchodzi i usuwa 'active', nastpenie do wskazanego elementu poprzez
	 *	zmienna item ustawia styl 'active'
	 *	
	 *	item przechowuje integery
	 *	 	 
	 *
	 *	klasa_after - dodatkowa klasa nadawana elementom za elementoem aktywnym
	 *		zmienia klasy obkeitow wyznaczonych przez klasa[0]	 
	 *	 	 	 
	 *
	 *	 	 	 
	 **/	 	 	
	
	

	function aaa() {
		alert('ACHTUNG, ACHTUNG');
	}
	
	
	
	
	

	function generalTabsClassChange( item, klasa_group, klasa_after, klasa_before, klasa_firstactive ) {
	
		if (isArray(klasa_group)==true) {
			
			for( i=0;i<klasa_group.length;i++) {
				var dodatkowa_klasa ='';
				if (i==0) {
					dodatkowa_klasa = klasa_after;
				}
				tabsClassChange( item, klasa_group[i], dodatkowa_klasa );
			}
		
		
		} else {
			
			var el;
			var iter=0;
			
			///var expr1 = new RegExp( klasa_after );
			
			var expRem = new RegExp( "\\w{0,}active\\w{0,}" );
			
			//iterowanie po wszystkich elementach grupy
			while( el=document.getElementById( klasa_group+iter ) ) {
			
				if (el.nodeType==3)
					el = el.parentNode;
			
				el.className = el.className.replace( expRem, '');
				///el.className = el.className.replace( expr1, '');
				
				/*	afteractive VOL 1
				if ( (iter > item) && (klasa_after != '') ) {
					el.className = el.className+' '+klasa_after;
				}
				*/
				
				
				iter = iter+1;
				
			}
			var elem = document.getElementById( klasa_group+item );
					
			if ( elem != null) {	
				if (item==0) {
					elem.className = elem.className+' '+klasa_firstactive;
				} else
					elem.className = elem.className+' active';
			}


			/*afteractive VOL2*/
			var elem2 = document.getElementById( klasa_group+(item+1) );
					
			if ( elem2 != null) {	
				elem2.className = elem2.className+' afteractive';
			}
			
			var elem3 = document.getElementById( klasa_group+(item-1) );
					
			if ( elem3 != null) {	
				elem3.className = elem3.className + klasa_before;
			}			
			
		}

	}	
	

	//alias -- kompatybilnosc
	function tabsClassChange( item, klasa_group, klasa_after ) {
		generalTabsClassChange( item, klasa_group, klasa_after, ' beforeactive', 'firstactive');
	}
	
	
	//alias do funkcji tabsClassChange()
	function mainMenuClick( item, klasa ) {
		generalTabsClassChange( item, klasa, '', '', 'active' );
	}
