function ShowOrHideElement(element, przycisk){

 

 if(document.getElementById(element).style.display==''){

// powyżej sprawdzamy czy warstwa jest widoczna

// jeżeli tak, przechodzimy dalej:

document.getElementById(element).style.display = 'none';

// wyżej ustawiony parametr display dla warstwy, na "none"

// dzięki temu warstwa staje się niewidoczna

 

// teraz zmiana nazwy przycisku i linka:

document.getElementById(przycisk).innerHTML='<a href=\"javascript:void(0)\" style=\'cursor:hand\' onclick=\"ShowOrHideElement(\'' + element + '\', \'' + przycisk + '\')\"><img src="http://www.nast.ws/images/info_wiecej.gif" border=\'0\' /></a>';

 }

 else{

// tu akcje, gdy warstwa jest schowana:

document.getElementById(element).style.display = '';

document.getElementById(przycisk).innerHTML='<a href=\"javascript:void(0)\" style=\'cursor:hand\' onclick=\"ShowOrHideElement(\'' + element + '\', \'' + przycisk + '\')\"><img src="http://www.nast.ws/images/info_ukryj.gif" border=\'0\' /></a>';

 }

}



function getData(adres, gdzie) {

advAJAX.get({

url : adres,

onInitialization : function() {

document.getElementById(gdzie).innerHTML = "<center><img src=\"http://www.nast.ws/loader.gif\"></center>";;

},

onSuccess : function(obj) {

document.getElementById(gdzie).innerHTML = obj.responseText;

},

onError : function(obj) {

alert("Error: " + obj.status);

},

onFinalization : function(obj) {

document.getElementById(gdzie).style.visibility = "visible";

}

});

} 

function ShowAdvancedSearchPanel(){

 if(document.getElementById("advancedSearchResults").style.display==''){

document.getElementById("advancedSearchResults").style.display = 'none';

document.getElementById("AdvancedSearchButton").innerHTML='<a href=\"javascript:void(0)\" onclick=\"ShowAdvancedSearchPanel();\"><img src="images/szukaj_zaawansowane.gif" border="0" /></a>';

 }

 else{

document.getElementById("advancedSearchResults").style.display = '';

document.getElementById("AdvancedSearchButton").innerHTML='<a href=\"javascript:void(0)\" onclick=\"ShowAdvancedSearchPanel();\"><img src="images/szukaj_zwin.gif" border="0" /></a>';

 }

}

function ShowTranslationsDetails(id, przycisk){

 if(document.getElementById("trans_details_" + id).style.display==''){

document.getElementById("trans_details_" + id).style.display = 'none';

document.getElementById("trans_details_BTTN_" + id).innerHTML='<a href="javascript:void(0)" onclick="ShowTranslationsDetails(\'' + id + '\', \'' + przycisk + '\');"><font color="#C1C1C1">' + przycisk + '</font></a>';

 }

 else{

document.getElementById("trans_details_" + id).style.display = '';

document.getElementById("trans_details_BTTN_" + id).innerHTML='<a href="javascript:void(0)" onclick="ShowTranslationsDetails(\'' + id + '\', \'' + przycisk + '\');"><font color="#C1C1C1">' + przycisk + '</font></a>';

 }

}

function ShowLastAddedComments(){

 if(document.getElementById("LastAddedCommentsResults").style.display==''){

document.getElementById("LastAddedCommentsResults").style.display = 'none';

document.getElementById("LastAddedCommentsButton").innerHTML='<a href="javascript:void(0)" style="cursor:hand" onclick="ShowLastAddedComments()"><img src="images/koment_pokaz_ostatnie.gif" border="0" /></a>';

 }

 else{

document.getElementById("LastAddedCommentsResults").style.display = '';

document.getElementById("LastAddedCommentsButton").innerHTML='<a href="javascript:void(0)" style="cursor:hand" onclick="ShowLastAddedComments()"><img src="images/koment_ukryj_ostatnie.gif" border="0" /></a>';

 }

}

function ShowAllIMDBinfo(){

 if(document.getElementById("allIMDBinfo").style.display==''){

document.getElementById("allIMDBinfo").style.display = 'none';

document.getElementById("showAllIMDBinfo").innerHTML='<a href="javascript:void(0);" onclick="ShowAllIMDBinfo()"><font color="#FF9900">poka&#380; wszystkie informacje pobrane z IMDB</font></a>';

 }

 else{

document.getElementById("allIMDBinfo").style.display = '';

document.getElementById("showAllIMDBinfo").innerHTML='<a href="javascript:void(0);" onclick="ShowAllIMDBinfo()"><font color="#FF9900">ukryj wszystkie informacje pobrane z IMDB</font></a>';

 }

}

function ChangeProgress_translations(id, nr, proc, imdb, kategoria)
{
if (nr == 1) { document.getElementById('transprogress_' + id).innerHTML = '<input type="text" name="progress_' + id + '" id="progress_' + id + '" value="' + proc + '" maxlength="3" style="width: 50px;" />&nbsp;<a href="javascript:UpdateProgress(\'' + id + '\', \'' + imdb + '\', \'' + kategoria + '\')"><img src="images/transtlations_accept.png" border="0" style="vertical-align: middle;"></a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="ChangeProgress_translations(' + id + ', \'2\', ' + proc + ', ' + imdb + ', ' + kategoria + ')"><img src="images/transtlations_back.png" border="0" style="vertical-align: middle;"></a>'; }
else if (nr == 2) { 
	if (proc < 26) { var grafa = 'percentImage_back4.png'; }
	if (proc >= 26 && proc < 51) { grafa = 'percentImage_back3.png'; }
	if (proc >= 51 && proc < 76) { grafa = 'percentImage_back2.png'; }
	if (proc >= 76 && proc <= 100) { grafa = 'percentImage_back1.png'; }
	
	var dzialanie = (120 * proc)/100;
	var zaokraglij = dzialanie.toFixed(1);
	var rozmiar = 120-zaokraglij; 
	
	var pasek = '<img title="' + proc + '" id="element_' + id + '_percentImage" src="images/percentImage.png" alt="' + proc + '" style="margin: 0pt; padding: 0pt; width: 120px; height: 12px; background-position: -' + rozmiar + 'px 50%; background-image: url(images/' + grafa + ');">';
document.getElementById('transprogress_' + id).innerHTML = '<a href="javascript:void(0)" onclick="ChangeProgress_translations(' + id + ', \'1\', ' + proc + ', ' + imdb + ', ' + kategoria + ')" style="cursor: hand;">' + pasek + '</a>'; }
}

function UpdateProgress(gdzie, imdb, kategoria) {

var postep = document.getElementById('progress_' + gdzie).value;

if (postep > 100 || postep < 0) { alert("Wpisz liczbę z przediziału 0-100"); }

else if (postep == 100) {

var komunikat = confirm('Gratulujemy ukończenia prac nad tłumaczeniem!\n\nKliknij OK, aby dokończyć ten proces i dodać tłumaczenie do bazy serwisu.');

if (komunikat) {
location.href = "http://www.nast.ws/addsubs.php?action=1&mid=" + imdb + "&type=" + kategoria + "&transID=" + gdzie;
}

}

else  {

location.href = "http://www.nast.ws/translations.php?action=1&id=" + gdzie + "&progress=" + postep;

}

} 

function DelTranslationDesc() {
location.href = "http://www.nast.ws/translations.php?action=5&id=" + id + "&co=remove";
}

function SearchIMDB_Enter(e) {
var charinput=e.charCode||e.keyCode||e.which;

if (charinput===13){
SearchIMDB();
}
}

function SearchIMDB() {

var zapytanie = document.getElementById('imdb_name').value;
var typ = document.getElementById('type_of_movie').value;

if (zapytanie != 0) {  
location.href = "http://www.nast.ws/addsubs_imdbsearch.php?type=" + typ + "&q=" + zapytanie;
return false;
}

else  {
alert("Musisz wpisac tytuł");
return false;
}

} 

function ChceckValue(id, kontener) {
var wartosc = document.getElementById(id).value;

if (wartosc != '') {
document.getElementById(kontener).innerHTML= "<img src=\"http://www.nast.ws/images/dodaj_napisy_chcecked.png\" border=\"0\" style=\"vertical-align: middle;\">";
}
else {
document.getElementById(kontener).innerHTML= "<font color=\"#CC0000\">Musisz wype&#322;ni&#263; to pole!</font>";
}
}

function updateIMDB(id) {
var zmienna = document.getElementById('updateIMDB').value;

if (zmienna != '') {
var tablica = zmienna.split("/tt");
var adres = str_replace('/', '', tablica[1]);
document.getElementById("updateIMDB_dock").style.display = '';
getData('http://www.nast.ws/editsubs_data.php?action=1&id=' + id + '&mid=' + adres, 'updateIMDB_results');
}
else {
alert('BŁĄD - Wypełnij pole "Link do IMDB.com"');
}
}


function str_replace (search, replace, subject)
{
var result = "";
var oldi = 0;
for (i = subject.indexOf (search); i > -1; i = subject.indexOf (search, i))
{
result += subject.substring (oldi, i);
result += replace;
i += search.length;
oldi = i;
}
return result + subject.substring (oldi, subject.length);
}

function ShowOrHideDiv(kontener, button, przed, po){

 if(document.getElementById(kontener).style.display==''){

document.getElementById(kontener).style.display = 'none';

document.getElementById(button).innerHTML='<a href="javascript:void(0);" onclick="ShowOrHideDiv(\'' +kontener + '\', \'' + button + '\', \'' + przed + '\', \'' + po + '\')"><font color="#FF9900">' + przed + '</font></a>';

 }

 else{

document.getElementById(kontener).style.display = '';

document.getElementById(button).innerHTML='<a href="javascript:void(0);" onclick="ShowOrHideDiv(\'' +kontener + '\', \'' + button + '\', \'' + przed + '\', \'' + po + '\')"><font color="#FF9900">' + po + '</font></a>';

 }

}

function ShowAddSubsReleaseHelp(){

 if(document.getElementById("release_help").style.display==''){

document.getElementById("release_help").style.display = 'none';

 }

 else{

document.getElementById("release_help").style.display = '';

 }

}

function PagerMenu(ile, ktora, aid, sort)
{
var wynik;
var i=1;
for (i=1;i<=ile;i++) {
if(ktora == i) { var zaznacz = ' selected="selected"'; } else { zaznacz = ''; }
wynik += '<option VALUE="lastsubs.php?page=' + i + '&sort=' + sort + '&&aid=' + aid + '" ' + zaznacz + '>' + i + '</option>';
}
document.getElementById('page_menu').innerHTML = '<select onchange="self.location.href = this.value">' + wynik + '</select>'; 
}


function ShowallSCREENS(){

 if(document.getElementById("allSCREENS").style.display==''){

document.getElementById("allSCREENS").style.display = 'none';

document.getElementById("showallSCREENS").innerHTML='<a href="javascript:void(0);" onclick="ShowallSCREENS()"><font color="#FF9900">Akceptuje regulamin</font></a>';

 }

 else{

document.getElementById("allSCREENS").style.display = '';

document.getElementById("showallSCREENS").innerHTML='<a href="javascript:void(0);" onclick="ShowallSCREENS()"><font color="#FF9900">Ukryj wszystkie screeny</font></a>';

 }

}


function ShowAllstats(){

 if(document.getElementById("allSTATS").style.display==''){

document.getElementById("allSTATS").style.display = 'none';

document.getElementById("ShowAllstats").innerHTML='<a href="javascript:void(0);" onclick="ShowAllstats()"><font color="#FF9900"><b>Pokaz statystyki</b></font></a>';

 }

 else{

document.getElementById("allSTATS").style.display = '';

document.getElementById("ShowAllstats").innerHTML='<a href="javascript:void(0);" onclick="ShowAllstats()"><font color="#FF9900"><b>Ukryj statystyki</font></b></a>';

 }

}



function ShowallSUBdata(){

 if(document.getElementById("allSUBdata").style.display==''){

document.getElementById("allSUBdata").style.display = 'none';

document.getElementById("ShowallSUBdata").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdata()"><font color="#c1c1c1"><small>Pokaz liste dodanych napisów</small></font></a>';

 }

 else{

document.getElementById("allSUBdata").style.display = '';

document.getElementById("ShowallSUBdata").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdata()"><font color="#c1c1c1"><small>Ukryj liste dodanych napisów</small></font></a>';

 }

}



function ShowallSUBdatatrans(){

 if(document.getElementById("allSUBdatatrans").style.display==''){

document.getElementById("allSUBdatatrans").style.display = 'none';

document.getElementById("ShowallSUBdatatrans").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdatatrans()"><font color="#c1c1c1"><small>Pokaz liste przetlumaczonych napisów</small></font></a>';

 }

 else{

document.getElementById("allSUBdatatrans").style.display = '';

document.getElementById("ShowallSUBdatatrans").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdatatrans()"><font color="#c1c1c1"><small>Ukryj liste przetlumaczonych napisów</small></font></a>';

 }

}



function ShowallSUBdatasynch(){

 if(document.getElementById("allSUBdatasynch").style.display==''){

document.getElementById("allSUBdatasynch").style.display = 'none';

document.getElementById("ShowallSUBdatasynch").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdatasynch()"><font color="#c1c1c1"><small>Pokaz liste synchronizowanych napisów</small></font></a>';

 }

 else{

document.getElementById("allSUBdatasynch").style.display = '';

document.getElementById("ShowallSUBdatasynch").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdatasynch()"><font color="#c1c1c1"><small>Ukryj liste synchronizowanych napisów</small></font></a>';

 }

}



function ShowallSUBdatakor(){

 if(document.getElementById("allSUBdatakor").style.display==''){

document.getElementById("allSUBdatakor").style.display = 'none';

document.getElementById("ShowallSUBdatakor").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdatakor()"><font color="#c1c1c1"><small>Pokaz liste korekconych napisów</small></font></a>';

 }

 else{

document.getElementById("allSUBdatakor").style.display = '';

document.getElementById("ShowallSUBdatakor").innerHTML='<a href="javascript:void(0);" onclick="ShowallSUBdatakor()"><font color="#c1c1c1"><small>Ukryj liste korekconych napisów</small></font></a>';

 }

}



function Showallprocomments(){

 if(document.getElementById("allprocomments").style.display==''){

document.getElementById("allprocomments").style.display = 'none';

document.getElementById("Showallprocomments").innerHTML='<a href="javascript:void(0);" onclick="Showallprocomments()"><font color="#c1c1c1"><small>Pokaz wystawione komentarze</small></font></a>';

 }

 else{

document.getElementById("allprocomments").style.display = '';

document.getElementById("Showallprocomments").innerHTML='<a href="javascript:void(0);" onclick="Showallprocomments()"><font color="#c1c1c1"><small>Ukryj Liste wystawionych komentarzy</small></font></a>';

 }

}