function rozwin( id ) {
	if(document.getElementById( id ).style.display=='none')
		document.getElementById( id ).style.display='';
	else
		document.getElementById( id ).style.display='none';
}

function pokazpola( id ) {
	if (document.getElementById( id ).style.display=='none')
		document.getElementById( 'nowyautor' ).style.display='';
	else
		document.getElementById( id ).style.display='none';

}

function dodanieform(tekst,id,tresc, nazwa) {
	if (confirm('Czy na pewno dodać '+tresc)== true) {
	var tableRef = opener.document.getElementById( nazwa );
	if(!opener.document.getElementById( nazwa + id )) {
	    var newRow   = tableRef.insertRow(0);
	    newRow.id=nazwa+id;
	    var newCell  = newRow.insertCell(0);
	    newCell.innerHTML=tekst ;
	    var newCell2  = newRow.insertCell(1);
	  newCell2.innerHTML=  "<a href='#' "+'onclick="'+ "if(okienko('Czy na pewno usunać "+tekst+" z tej książki'));deleteRow('"+nazwa+"',this.parentNode.parentNode.rowIndex);"+ '"><img src="/images/usun.jpg" border="0"></a> <input type="hidden" name="'+nazwa+id+'" value="'+id+'" />';
		}
		else
			alert ("W danych już występuje  "+tekst);
	}
	return false;
}


function deleteRow( nazwa , i)
{
	document.getElementById( nazwa ).deleteRow(i)
}

function usunelem( elem ) {
	elem.parentNode.removeChild(elem);

}

function zmienpole( pole , id , nazwa ) {
	if(opener.document.getElementById( pole ))
	opener.document.getElementById( pole ).innerHTML=nazwa;
	if (opener.document.getElementById( pole + "h" ))
	opener.document.getElementById( pole + "h" ).value=id;
	if (opener.document.getElementById( pole + "u" ))
	opener.document.getElementById( pole + "u" ).style.display='';
}

function deletepole( pole ) {
	var polezm = document.getElementById( pole );
	var polezmh = document.getElementById( pole + "h" );
	var polezmu = document.getElementById( pole + "u" );
	polezm.innerHTML='';
	if(document.getElementById( pole + "h" ))
		polezmh.value='';
	if(document.getElementById( pole + "u" ))
	polezmu.style.display='none';
}

function deletepoleop( pole ) {
	var polezm = opener.document.getElementById( pole );
	var polezmh = opener.document.getElementById( pole + "h" );
	var polezmu = opener.document.getElementById( pole + "u" );
	polezm.innerHTML='';
	polezmh.value='';
	polezmu.style.display='none';
}

function dodanieformwsp(tekst,id,tresc, nazwa) {
	var mylist=document.getElementById( 'wsp' );
	wsp=mylist.options[mylist.selectedIndex].text;
	wspid=mylist.options[mylist.selectedIndex].value;
	if (confirm('Czy na pewno dodać '+tekst+' '+wsp+tresc)== true) {
	var tableRef = opener.document.getElementById( nazwa );
	if(!opener.document.getElementById( nazwa + id )) {
	    var newRow   = tableRef.insertRow(0);
	    newRow.id=nazwa+id;
	    var newCell  = newRow.insertCell(0);
	    newCell.innerHTML=tekst + ' ' + wsp;
	   var newCell2  = newRow.insertCell(1);
	  	newCell2.innerHTML= "<a href='#' "+'onclick="'+ "if(okienko('Czy na pewno usunać "+tekst+" z tej książki'));deleteRow('"+nazwa+"',this.parentNode.parentNode.rowIndex);"+ '"><img src="/images/usun.jpg" border="0"></a> <input type="hidden" name="'+nazwa+wspid+'" value="'+id+'" />';
		}
		else
			alert ("W danych już występuje  "+tekst);
	}
	return false;

}

function okienko(tresc) {
	if (confirm(tresc)== true) {
		return true;
	}
	return false;
}
function rodzajwypoz() {
	var mylist=document.getElementById( 'wypo' );
	if (mylist.options[mylist.selectedIndex].value=='1')
		document.getElementById( 'album' ).style.display='';
	else
		document.getElementById( 'album' ).style.display='none';
	if (mylist.options[mylist.selectedIndex].value=='1')
		document.getElementById( 'szkola' ).style.display='';
	else
		document.getElementById( 'szkola' ).style.display='none';

}

function nadajnazwe( lista, id  ) {

var mylist=document.getElementById( lista );
	document.getElementById( id ).name=mylist.options[mylist.selectedIndex].value;
	if (mylist.options[mylist.selectedIndex].value=='klucz' || mylist.options[mylist.selectedIndex].value=='klucz2' || mylist.options[mylist.selectedIndex].value=='klucz3' )
	document.getElementById( id + 'a' ).style.display='';
	else
	document.getElementById( id + 'a' ).style.display='none';
}

function wstawdoin(nazwa,id) {
	if (opener.document.getElementById( id ))
		opener.document.getElementById( id ).value =nazwa ;

	window.close();
}
function init() {
	if(document.forms[0])
	for(i=0;i<document.forms[0].length;i++) {
	var pole=document.forms[0].elements[i];
//	alert(pole.type);
	if(pole.type!="hidden" && pole.type!='select-one') {
		pole.focus();
		return;
		}
  }

}
var kolor;
function podsw(elem,kolo,co){
	kolor=kolo;
var oldBgColor = kolo;
	if (oldBgColor == elem.style.backgroundImage) {
		oldBgColor = elem.style.backgroundImage;
//		elem.style.backgroundColor = "#CEE3CE";	//kolor najechango tr
		if(co=='ks')
			elem.style.backgroundImage="url(/images/gradientramkazazn.jpg)"
		else if (co=='cz')
			elem.style.backgroundImage="url(/images/gradientramkazazn1p.jpg)"
		else
			elem.style.backgroundImage="url(/images/gradientramkazazn3p.jpg)"
		}
//	else {
//		elem.style.backgroundColor = oldBgColor;
//		oldBgColor = "";
//		}
}
function odsw(elem) {
	elem.style.backgroundImage = kolor;
}
function openslownik()  {
	window.open('/slowniki/pokaz/' ,'', 'width=400, height=500, toolbars=no, resizable=yes');
}












var xmlhttp;
var divname;
/*************uruchomienie funkcji w tle (wykonuje kod w tle)*/
function get(url)
	{
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=xmlhttpChange
	  xmlhttp.open("GET",url,true)
	  xmlhttp.send(null)
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	    if (xmlhttp)
	    {
	    xmlhttp.onreadystatechange=xmlhttpChange
	    xmlhttp.open("GET",url,true)
	    xmlhttp.send()
	    }
	  }
	}function xmlhttpChange()
  {
  // if xmlhttp shows "loaded"
  if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {

    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
 }
//wstawaia wykonany kod do diva (wstawia np. pod stronkę)****************/
 function insert(url,pdivname)
	{
	divname=pdivname;
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=xmlhttpChange2
	  xmlhttp.open("GET",url,true)
	  xmlhttp.send(null)
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	    if (xmlhttp)
	    {
	    xmlhttp.onreadystatechange=xmlhttpChange2
	    xmlhttp.open("GET",url,true)
	    xmlhttp.send()
	    }
	  }
	}
//(uruchamia skrypt) zmienia zawartość diva w tle*/*****************/
function change(url,pfieldname)
	{
	divname=pfieldname;
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=xmlhttpChange3
	  xmlhttp.open("GET",url,true)
	  xmlhttp.send(null)
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	    if (xmlhttp)
	    {
	    xmlhttp.onreadystatechange=xmlhttpChange3
	    xmlhttp.open("GET",url,true)
	    xmlhttp.send()
	    }
	  }
	}

function xmlhttpChange()
  {
  // if xmlhttp shows "loaded"
  if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {

    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
 }

  function xmlhttpChange2()
  {
  if (xmlhttp.readyState==4)
  {
  if (xmlhttp.status==200)
    {
 	writit(xmlhttp.responseText,divname);
    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
 }

  function xmlhttpChange3()
  {
  // if xmlhttp shows "loaded"
  if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
 	chfield(xmlhttp.responseText,divname);
    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
 }

 /*zmiana tekstu pola*/
 function writit(text,id)
{

if (document.getElementById)
	{
		x = document.getElementById( id );
		x.innerHTML = '';
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
}
////

/****zmiana value pola*/
 function chfield(text,id)
{
if (document.getElementById)
	{
		x = document.getElementById(id);
		x.value = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.value = text;
	}
}


/******pokazywanie pola*/
function show(show,id)
{
	if (document.getElementById)
	{
		x = document.getElementById(id);

	}
	else if (document.all)
	{
		x = document.all[id];
	}
	if (show)
		x.style.display = '';
	else
		x.style.display = 'none';

}
/***************ukrywanie pola*/
 function hide ( id )
 {
 	if (document.getElementById)
	{
		x = document.getElementById( id ) ;
		x.style.display="none";
	}
	else if (document.all)
	{
		x = document.all[id];
		x.style.display="none";
	}
 }



 function listaz(url)
	{
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=xmlhttpChange5
	  xmlhttp.open("GET",url,true)
	  xmlhttp.send(null)
	  }
	// code for IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	    if (xmlhttp)
	    {
	    xmlhttp.onreadystatechange=xmlhttpChange5
	    xmlhttp.open("GET",url,true)
	    xmlhttp.send()
	    }
	  }
	}

function xmlhttpChange5()
  {
  // if xmlhttp shows "loaded"
  if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {

	zmienokres(xmlhttp.responseText);
    }
  else
    {
    alert("Problem retrieving XML data")
    }
  }
 }


function zmienokres(sygnatura) {
var mylist=document.getElementById( 'okres' );


switch(sygnatura)
{
case 'W':
 	mylist.selectedIndex=2
  break
case 'Z':
 	mylist.selectedIndex=2
case 'C':
 	mylist.selectedIndex=1
  break
case 'T':
 	mylist.selectedIndex=1
  break
case 'M':
 	mylist.selectedIndex=1
  break
case 'B':
 	mylist.selectedIndex=1
default:
  mylist.selectedIndex=2

}

}
function voluminy(elem,czas,art) {
	var mylist=elem;
		document.getElementById('nry').style.display='';
	if(art=='yes')
		insert('/czasopisma/voluminysz/rok/'+mylist.options[mylist.selectedIndex].value+'/id/'+czas+'/art/yes','nry');
	else
		insert('/czasopisma/voluminysz/rok/'+mylist.options[mylist.selectedIndex].value+'/id/'+czas,'nry');
	}


