//JavaScript Document




function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=1,menubar=no' );
}


function pokazTekstFormularza(text,id){
    var searchField = document.getElementById(id);
    if(searchField != null)
        searchField.value = text;
}


function autoSzukanie(str,id)
{
if (str.length==0)
  {
  document.getElementById("livesearch").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
    document.getElementById("livesearch").style.border="1px solid #e6e6e6";
	document.getElementById("livesearch").style.background="#f5f5f5";

			function detectEvent(e) {
	var event = e || window.event;							 
				if( event.keyCode == 40 ) {		
					//go down	
					
					document.getElementById("li.results").style.background="#ff0000";
					$('li.results a').css( 'color', 'black' );					
					$('li.results').eq(++currentSelection).css( 'background', 'blue' );
					$('li.results a').eq(currentSelection).css( 'color', 'white' );									
				}
				else if( event.keyCode == 38 ) {	
					//go up		
					
					$('li.results').css( 'background', 'white' );
					$('li.results a').css( 'color', 'black' );					
					$('li.results').eq(--currentSelection).css( 'background', 'blue' );
					$('li.results a').eq(currentSelection).css( 'color', 'white' );			
				}
				else if( event.keyCode == 39 && $('#livesearch').html() ) {	
					var link = $('li.results a').eq(currentSelection).attr('href');
					window.open(link, '_blank');
				}
				else if( event.keyCode == 27 ) {	
					$('#liveSearch').html("");			
				}
				else {
					performSearch();
				}
			};	
	
    }
  }
xmlhttp.open("GET","?a=aj&qk="+str+"&id="+id,true);
xmlhttp.send();
}


function listaWersji(nid, start)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("dhtmlgoodies_a2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","?a=aj&n_id="+nid+"&s="+start,true);
xmlhttp.send();
}



function submitonEnter(evt,str,start,wns,id,dataPubOd,dataPubDo,dataModOd,dataModDo,walid){
var charCode = (evt.which) ? evt.which : event.keyCode
if(charCode == "13"){
szukajDane(str,start,wns,id,dataPubOd,dataPubDo,dataModOd,dataModDo,walid);
}
}



function szukajDane(str,start,wns,id,dataPubOd,dataPubDo,dataModOd,dataModDo,walid)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("wynikiWyszukiwania").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","?a=aj&q="+str+"&start="+start+"&rpp="+wns+"&id="+id+"&dataPubOd="+dataPubOd+"&dataPubDo="+dataPubDo+"&dataModOd="+dataModOd+"&dataModDo="+dataModDo+"&walid="+walid,true);
xmlhttp.send();
}




function pokazStatystyka(ppp,sor,wns)
{
if (ppp.length==0)
  {
  document.getElementById("wynikiStatystyka").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("wynikiStatystyka").innerHTML=xmlhttp.responseText;
	// document.getElementById("ws").innerHTML="?i=s&a=aj&p="+ppp+"&o="+sor+"&rpp="+wns;
    }
  }
xmlhttp.open("GET","?i=s&a=aj&p="+ppp+"&o="+sor+"&rpp="+wns,true);
xmlhttp.send();
}



function pokazHarmonogram(ppp,sor,wns)
{
if (ppp.length==0)
  {
  document.getElementById("wynikiStatystyka").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("wynikiHarmonogram").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","?i=c&a=aj&p="+ppp+"&o="+sor+"&rpp="+wns,true);
xmlhttp.send();
}



function pokazNews(id,st,wns)
{
if (id.length==0)
  {
  document.getElementById("wynikiNews").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("wynikiNews").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","?id="+id+"&a=aj&st="+st+"&rpp="+wns,true);
xmlhttp.send();
}




var dhtmlgoodies_slideSpeed = 10;	
var dhtmlgoodies_timer = 10;	

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
var dhtmlgoodies_slideInProgress = false;
var dhtmlgoodies_expandMultiple = true; 

function showHideContent(e,inputId)
{
	if(dhtmlgoodies_slideInProgress)return;
	dhtmlgoodies_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

	objectIdToSlideDown = false;

	if(!answerDiv.style.display || answerDiv.style.display=='none'){
		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId && !dhtmlgoodies_expandMultiple){
			objectIdToSlideDown = numericId;
			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
		}else{

			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';

			slideContent(numericId,dhtmlgoodies_slideSpeed);
		}
	}else{
		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
		dhtmlgoodies_activeId = false;
	}
}

function slideContent(inputId,direction)
{

	var obj =document.getElementById('dhtmlgoodies_a' + inputId);
	var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
	}else{
		if(height<=1){
			obj.style.display='none';
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);
			}else{
				dhtmlgoodies_slideInProgress = false;
			}
		}else{
			dhtmlgoodies_activeId = inputId;
			dhtmlgoodies_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dhtmlgoodies_question_1' || divs[no].className=='dhtmlgoodies_question_2'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'dhtmlgoodies_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'dhtmlgoodies_a'+divCounter;
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
			contentDiv.className='dhtmlgoodies_answer_content';
			contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}
	}
}


