
function whichElement(e, elemId, arrayIndex)
{
	var targ
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
	   targ = targ.parentNode;
	var tname
	tname=targ.tagName
// 	try
// 	{ 		// obsługa sroll'a przy artykułach
	targ.blur();
		if((targ.parentNode.parentNode.parentNode.className).match("articles")){
			//poniewaz tabIndex nie dziala w operze i safari zatem trza cos innego wymyslec...
			var tab = targ.parentNode.parentNode.parentNode.getAttribute('tab');
				if(targ.parentNode.parentNode.className.match('active')==null && targ.parentNode.parentNode.className!='no')
						setTimeout( function(){ animator(targ,targ.parentNode.parentNode,0,120,22,120,22,false,false,null,   0, -1, arrayIndex, tab-1) }, 1);
				
		}
			// obsługa menu
		if((targ.parentNode.parentNode.parentNode.className).match("genericHeader")){
			change_tab(targ);
		}

// 	 }
// 	 catch(er)
// 	 {}
}

// funkcje do skrolowania newsow
function close_all(link,box_id,c,g,f,max,min,to,nt,which){	

	c=c+10;
	f=f+c;
	g=g-c;
// przy pierwszym wykonaniu funkcji

	if(!nt){
		box_id.blur();
		nt=true;
if(box_id.className==null)box_id.className=''
		if((box_id.className).match('active')!=null)to=true;
		for(i=0;i<box_id.parentNode.childNodes.length;i++)
		{	
			if(box_id.parentNode.childNodes[i].className==null)box_id.parentNode.childNodes[i].className=''
			if((box_id.parentNode.childNodes[i].className).match('active')!=null){

			which=box_id.parentNode.childNodes[i]
			box_id.parentNode.childNodes[i].className = box_id.parentNode.childNodes[i].className.replace(/active/,"")
			}
			box_id.parentNode.childNodes[i].className=box_id.parentNode.childNodes[i].className+" no";
		}
	}

		which.style.height=g+"px";
		box_id.style.height=f+"px";
	if(f>=100)
		{
// function endning    			
			for(i=0;i<box_id.parentNode.childNodes.length;i++)box_id.parentNode.childNodes[i].className=box_id.parentNode.childNodes[i].className.replace(/no/,"");
			if(!to)box_id.className=box_id.className+" active";
			else box_id.className=box_id.className.replace(/no/,"");	
			which.style.height=min+"px";
			a_array = which.getElementsByTagName('A');
			a_array[0].setAttribute('onclick',"return false;")
			box_id.style.height=max+"px";	
			link.setAttribute('onclick',"")
		}
	else
		{
			setTimeout(function(){close_all(link,box_id,c,g,f,max,min,to,nt,which)},30);
		}
}
	//funckja animujaca przewijanie
	function bringEmBackToLive( elShow, elShowHeightStart, elShowHeightEnd, 
								elHide, elHideHeightStart, elHideHeightEnd, 
								allSteps, currentStep, endingFunction ) {
		if ( currentStep==undefined || currentStep==null )
			currentStep=1;
				min = elHideHeightStart - elHideHeightEnd;
				max = elShowHeightEnd - elShowHeightStart;
					var val1 = (min/allSteps)*(allSteps-currentStep);
					var val2 = (max/allSteps)*currentStep;
					var eee = 2.7183;
					var beg = 0.14;
					var skala= eee-beg;
					var stopien = skala/allSteps;
					stopien *=currentStep;
					var value = (Math.log( stopien+beg )+2)/3;
					var val1 = min*(1-value);
					var val2 = max*value;
					elHide.style.height= val1+elHideHeightEnd+'px';
					elShow.style.height= val2+elShowHeightStart+'px';						
					elShow.style.filter = 'alpha(opacity=' + value*100 + ')';
					elShow.style.MozOpacity= value;
		currentStep++;
		if ( currentStep<= allSteps )
			setTimeout(function(){  bringEmBackToLive( 	elShow, elShowHeightStart, elShowHeightEnd, 
														elHide, elHideHeightStart, elHideHeightEnd, 
														allSteps, currentStep, endingFunction )
										}, 1);
		else {
			if ( endingFunction!=null) {
				
				endingFunction();
			}else{
				elHide.style.height= elHideHeightEnd+'px';
				elShow.style.height= elShowHeightEnd+'px';
			}
		}
	};
//zzz - aktualny krok
//iterNum - ilosc wszystkich krokow
//nrElement - numer elementu (w kolejnosci ladowania na stronie)
//tab - numer kategorii
//arrayIndex - numer boxa
function animator(link, box_id,  c,g,f,max,min,  to,nt,which,    zzz, nrElement, arrayIndex, tab ){	
	// przy pierwszym wykonaniu funkcji
	if(!nt){
		c=0;
		g=0;
		nt=true;
		zzz=0;
		nrElement=-1;
		if(box_id.className==null)
			box_id.className='';
		
		if((box_id.className).match('active')!=null)
			to=true;
		
		for(i=0;i<box_id.parentNode.childNodes.length;i++)
		{	
			if(box_id.parentNode.childNodes[i].className==null)
				box_id.parentNode.childNodes[i].className='';
				
			if((box_id.parentNode.childNodes[i].className).match('active')!=null){
				which=box_id.parentNode.childNodes[i];
				box_id.parentNode.childNodes[i].className = box_id.parentNode.childNodes[i].className.replace(/active/,"");
			}
			box_id.parentNode.childNodes[i].className=box_id.parentNode.childNodes[i].className+" no";
			if ( box_id.parentNode.childNodes[i] === box_id )
				nrElement = i;
		}
		box_id.blur();
	}
	function ending( link, box_id, which, arrayIndex, tab, nrElement  ) {
			newsBoxSizeArray[arrayIndex][tab]["old"]=newsBoxSizeArray[arrayIndex][tab][ nrElement ];
			for(i=0;i<box_id.parentNode.childNodes.length;i++)
				box_id.parentNode.childNodes[i].className=box_id.parentNode.childNodes[i].className.replace(/no/,"");
				
			if(!to)box_id.className=box_id.className+" active";
			else box_id.className=box_id.className.replace(/no/,"");
			a_array = which.getElementsByTagName('A');
			a_array[0].setAttribute('onclick',"return false;");
			link.setAttribute('onclick',"");
			box_id.style.backgroundColor = "transparent";
			box_id.blur();
	}
	var konczWascWstyduOszczedz = function(){ ending(link, box_id, which, arrayIndex, tab, nrElement)  };
		bringEmBackToLive( 	box_id, 22, newsBoxSizeArray[arrayIndex][tab][ nrElement ],
							which, newsBoxSizeArray[arrayIndex][tab]["old"], 22, 
							12, null, konczWascWstyduOszczedz );
}
//zzz - aktualny krok
//iterNum - ilosc wszystkich krokow
//nrElement - numer elementu (w kolejnosci ladowania na stronie)
//tab - numer kategorii
//arrayIndex - numer boxa
function animatorOLD(link, box_id,  c,g,f,max,min,  to,nt,which,    zzz, nrElement, arrayIndex, tab ){
	if(!nt){
		c=0;
		g=0;
		nt=true;
		zzz=0;
		nrElement=-1;
		if(box_id.className==null) box_id.className='';
		if((box_id.className).match('active')!=null) to=true;
		for(i=0;i<box_id.parentNode.childNodes.length;i++)
		{
			if(box_id.parentNode.childNodes[i].className==null)
				box_id.parentNode.childNodes[i].className='';
			if((box_id.parentNode.childNodes[i].className).match('active')!=null){
				which=box_id.parentNode.childNodes[i];
				box_id.parentNode.childNodes[i].className = box_id.parentNode.childNodes[i].className.replace(/active/,"");
			}
			box_id.parentNode.childNodes[i].className=box_id.parentNode.childNodes[i].className+" no";
			if ( box_id.parentNode.childNodes[i] === box_id )
				nrElement = i;
		}
		box_id.blur();
	}
			var iterNum = 12;
			if ( nrElement >=0 ) {
				min = newsBoxSizeArray[arrayIndex][tab]["old"]-22;
				max = newsBoxSizeArray[arrayIndex][tab][ nrElement ]-22;
					var val1 = (min/iterNum)*(iterNum-zzz);
					var val2 = (max/iterNum)*zzz;
					var eee = 2.7183;
					var beg = 0.14;
					var skala= eee-beg;
					var stopien = skala/iterNum;
					stopien *=zzz;
					var value = (Math.log( stopien+beg )+2)/3;
					var val1 = min*(1-value);
					var val2 = max*value;
					c=val1+22;
					g=val2+22;
					var diff= val2-g;
					which.style.height= val1+22+'px';
					box_id.style.height= val2+22+'px';
					box_id.style.filter = 'alpha(opacity=' + value*100 + ')';
					box_id.style.MozOpacity= value;
			}
		zzz++;
		// function endning 
		if(zzz>iterNum) {
			newsBoxSizeArray[arrayIndex][tab]["old"]=newsBoxSizeArray[arrayIndex][tab][ nrElement ];
			for(i=0;i<box_id.parentNode.childNodes.length;i++)
			box_id.parentNode.childNodes[i].className=box_id.parentNode.childNodes[i].className.replace(/no/,"");
			if(!to)box_id.className=box_id.className+" active";
			else box_id.className=box_id.className.replace(/no/,"");
			a_array = which.getElementsByTagName('A');
			a_array[0].setAttribute('onclick',"return false;");
			link.setAttribute('onclick',"");
			box_id.style.backgroundColor = "transparent";
		box_id.blur();
	}else{
			setTimeout(function(){animator(link,box_id,c,g,f,max,min,to,nt,which,    zzz, nrElement, arrayIndex, tab )}, 1);
		}
}
function minimalizeLoginPanel( tryb ) {
	var el = document.getElementById('loginPanelForJS');
	if (!el ) {
		alert('Nie znaleziono elementu (funkcja: minimalizeLoginPanel)');
	}
	else {
	    if( tryb!=undefined){
	        if ( el.className.match('active')==null && tryb.match('active')!=null) {
            	el.className += ' ' + tryb;
			}else if( el.className.match('active')!=null && tryb.match('active')==null) {
                el.className = el.className.replace('active', '');
			}
		}else{
			var currentDate = new Date();
			if ( el.className.match('active')!=null ) {
				el.className = el.className.replace('active', '');
   				setCookie('loginPanel', '', new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth()+1)), "/", ".inet.mediarun.pl");
			} else {
				el.className = el.className+' active'
				setCookie('loginPanel', 'active', new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth()+1)), "/", ".inet.mediarun.pl");
			}
		}
	}
	
}
function setLoginPanel(){
	var cookie = getCookie('loginPanel');
	if(cookie){
		minimalizeLoginPanel(cookie);
	}
}
	function setCSSClass( id, klasa ){
		var el = document.getElementById( id );
		el.className = klasa;
	}
			// 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;
	}
	/**
	 *	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]	 
	 *	 	 	 
	 *
	 *	 	 	 
	 **/	 	 	
	var onOffNewsOfTheDayItemsDisplayArray = new Array();
	function onDisplayedNewsOnTheDayBox( item, klasa_group, firstLastActive, beforeAfterActive ) {
		onOffNewsOfTheDayItemsDisplayArray[item]=1;
		setTimeout(function(){
							ifActionDisplayedNewsOnTheDayBox( item, klasa_group, firstLastActive, beforeAfterActive)
					}, 100 );
	}
	
	function offDisplayedNewsOnTheDayBox( item ){
		onOffNewsOfTheDayItemsDisplayArray[item]=0;
	}
	function ifActionDisplayedNewsOnTheDayBox( item, klasa_group, firstLastActive, beforeAfterActive) {
		if (onOffNewsOfTheDayItemsDisplayArray[item]==1) {
			tabsClassChange( item, klasa_group, firstLastActive, beforeAfterActive );
		} else {
		}
	}
	function starsShining( groupID, count, overalCount, fromClass, toClass, afterClass ){
		for( starsIterator=1;starsIterator<=overalCount; starsIterator++){
			var setActiveClass= afterClass;
			if ( starsIterator<=count) {
				setActiveClass = toClass;
			}
			var elem = document.getElementById( groupID+starsIterator );
			elem.className = setActiveClass;
		}
	
	}
	function hover( evnt, targetClass ) {
		var elem = evnt.target;
		if (evnt.srcElement) 
			elem = evnt.srcElement;
		var classElem = elem.className;
		if ( evnt.type=='mouseover' ) {
			var regE = new RegExp( targetClass+"\\w{0,}" );
			if( classElem.match('hover') == null ) {
				elem.className = classElem.replace( targetClass ,targetClass+'-hover' );
			}
		} else {
			if ( evnt.type=='mouseout' ) {
				//alert( 'out: '+evnt.target );
				//alert('out');
				
				if( classElem.match('hover') != null ) {
					elem.className = classElem.replace( targetClass+'-hover', targetClass );
				}
			}	
		}
		
	}
		function setElFocus( elId ) {
			document.getElementById( elId ).focus();
		}
		function onDisplayElement( elId ) {
			document.getElementById( elId ).style.display ='none';
		}
		//wywolujacy moze byc jako ID badz jako obiekt
		function offDisplayElement( elemObj, labelId ) {
			var el=null;
			if ( (el=document.getElementById( elemObj ))!=null ) {
				elemObj = el;
			}
			var retVal = 0;			

			if ( elemObj.value == '' ) {
				document.getElementById( labelId ).style.display ='block';
				retVal = 0;
			}
			else {
				document.getElementById( labelId ).style.display ='none';
				retVal = 1;
			}
			return retVal;
		}
		//funkcja usuwa boxedLabel-e z pol hasla i loginu wartosci wprowadzanych
		//przez managery przegladarek...
		var theFirstOnLoadTrigger =0;
		function checkForInputBrowserManager( oldEvent, checkingElementsID, labelsSurfix ){
			var returnVal =0;
			for( checkIter=0; checkIter<checkingElementsID.length; checkIter++ ) {
				var inputId = checkingElementsID[checkIter];
				returnVal = offDisplayElement( inputId, inputId+labelsSurfix );
			}
			if ( !theFirstOnLoadTrigger ) {
				theFirstOnLoadTrigger=1;
				if ( oldEvent != undefined) {
					oldEvent();
				}
			}	
			theFirstOnLoadTrigger++;	
			if ( returnVal==0 ){
				setTimeout(  function(){ checkForInputBrowserManager( oldEvent, checkingElementsID, labelsSurfix ) }, 1000  );
			} else {
				///alert( theFirstOnLoadTrigger );
				if ( oldEvent != undefined) {
					document.onload = oldEvent();
				}
			}
		}
		function fontSizeChange( tagId, prefixCSSClass, modifier ) {
			if ( isArray(tagId) ){
				for( i=0;i<tagId.length;i++) {
					fontSizeChange( tagId[i], prefixCSSClass, modifier )
				}
			}else {
				var elem = document.getElementById( tagId );
				if (elem!=null) {
					var regEx = new RegExp( prefixCSSClass+"\\d{1,}" );
					var klasa = elem.className.match(regEx);
					klasa = klasa[0];
					klasa = klasa.match( /\d{1,}/ );
					klasa = parseInt(klasa);
					if ( (klasa>0 || modifier>0) && (klasa <6 || modifier<0))					
						klasa += parseInt(modifier);
					if ( modifier==0 )
						klasa = 3;
					elem.className = elem.className.replace( regEx, prefixCSSClass+klasa );
				}
			}
		}