function imgIndex(index)
{
var url='imgIndex-'+index;
window.open(url,'_self','','')
}
function MojaTapeta(s,l) {

	w=window.open(

		l?'http://www.mojatapeta.com/'+s+'/'+escape(l)

		:'http://www.mojatapeta.com/?s='+s,

		'MT','width=510,height=500,scrollbars=yes');

	return false;

}



function GetImage()

{

  return MojaTapeta('128001', document.getElementById('current_image').value);

}



function light(obj, color1, color2)

{

  if(obj.style.color == color1)

    obj.style.color = color2;

  else

    obj.style.color = color1;

}



function disableme(obj, form)

{

  obj.disabled = true;

  document.getElementById(form).submit();

}



function CheckboxReverse(oObject)

{

  var iObjectElements = oObject.elements.length;

   

  for (iElement = 0; iElement <iObjectElements; iElement++)

  {

    if(oObject.elements[iElement].type == "checkbox" && oObject.elements[iElement].disabled == false)

    {

      if(oObject.elements[iElement].checked == true)

        oObject.elements[iElement].checked = false;

      else

        oObject.elements[iElement].checked = true;

    }

  }

}



function CheckboxCheck(oObject, bMode)

{

  var iObjectElements = oObject.elements.length;

  var bMode = (bMode === true) ? true : false;

   

  for (iElement = 0; iElement <iObjectElements; iElement++)

  {

    if(oObject.elements[iElement].type == "checkbox" && oObject.elements[iElement].disabled == false)

    {

      oObject.elements[iElement].checked = bMode;

    }

  }

}



function editMovieDesc(id) {



  var text = prompt("Podaj podpis filmu (max 40 znaków):", "");



  if(text != null)

  {

    if(confirm("Na pewno chcesz zmienić tytuł?"))

    {

      var text = text.substr(0,40);



      advAJAX.get({



  			url: "/ankieterzy/konto_filmy/action/desc/id/" + id + "/text/" + text + "/",

  			timeout: 15000,

  			retry: 1,

  			retryDelay: 1000,



  			onSuccess : function(obj){



  				responseMod = obj.responseText.substr(0,3);

      		responseText = obj.responseText.substr(3, 10000);



      		alert(responseText);



      		if(responseMod == '[1]')

      			document.getElementById("movie_desc_" + id).innerHTML = text;



  			},

  			onError : function(obj) {

  				alert("Stracono połączenie!");

  			}

  		});

    }

  }

}



function editMovieDelete(id) {



  if(confirm("Na pewno chcesz usunąć film?"))

  {

    advAJAX.get({



      url: "/ankieterzy/konto_filmy/action/delete/id/" + id + "/",

      timeout: 15000,

      retry: 1,

      retryDelay: 1000,



      onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          document.getElementById("movie_panel_" + id).innerHTML = '';



      },

      onError : function(obj) {

        alert("Stracono połączenie!");

      }

    });

  }

}



function editPhotoDesc(id) {



  var text = prompt("Podaj podpis fotografii (max 40 znaków):", "");



  if(text != null)

  {

    if(confirm("Na pewno chcesz zmienić tytuł?"))

    {

      var text = text.substr(0,40);



      advAJAX.get({



  			url: "/ankieterzy/konto_fotki/action/desc/id/" + id + "/text/" + text + "/",

  			timeout: 15000,

  			retry: 1,

  			retryDelay: 1000,



  			onSuccess : function(obj){



  				responseMod = obj.responseText.substr(0,3);

      		responseText = obj.responseText.substr(3, 10000);



      		alert(responseText);



      		if(responseMod == '[1]')

      			document.getElementById("photo_desc_" + id).innerHTML = text;



  			},

  			onError : function(obj) {

  				alert("Stracono połączenie!");

  			}

  		});

    }

  }

}



function editPhotoDelete(id) {



  if(confirm("Na pewno chcesz usunąć fotografię?"))

  {

    advAJAX.get({



      url: "/ankieterzy/konto_fotki/action/delete/id/" + id + "/",

      timeout: 15000,

      retry: 1,

      retryDelay: 1000,



      onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          document.getElementById("photo_panel_" + id).innerHTML = '';



      },

      onError : function(obj) {

        alert("Stracono połączenie!");

      }

    });

  }

}



function editPhotoFake(id) {



  if(confirm("Na pewno dodać fotografię do FAKE?"))

  {

    advAJAX.get({



      url: "/ankieterzy/konto_fotki/action/fake/id/" + id + "/",

      timeout: 15000,

      retry: 1,

      retryDelay: 1000,



      onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          document.getElementById("photo_panel_" + id).innerHTML = '';



      },

      onError : function(obj) {

        alert("Stracono połączenie!");

      }

    });

  }

}



function editPhotoAvatar(id) {



  if(confirm("Na pewno chcesz ustawić tą fotkę jako avatar? Uwaga: poprzedni zostanie zastąpiony."))

  {

    advAJAX.get({



      url: "/ankieterzy/konto_fotki/action/avatar/id/" + id + "/",

      timeout: 15000,

      retry: 1,

      retryDelay: 1000,



      onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);

      },

      onError : function(obj) {

        alert("Stracono połączenie!");

      }

    });

  }

}



function editPhotoSort(position, id) {



  advAJAX.get({



    url: "/ankieterzy/konto_fotki/action/move/id/" + id + "/position/" + position + "/",

    timeout: 15000,

    retry: 1,

    retryDelay: 1000,



    onSuccess : function(obj){



      responseMod = obj.responseText.substr(0,3);

      responseText = obj.responseText.substr(3, 10000);



      alert(responseText);



      if(responseMod == '[1]')

        location.reload();

    },

    onError : function(obj) {

      alert("Stracono połączenie!");

    }

  });

}



function editFavDelete(id) {



  if(confirm("Na pewno chcesz usunąć osobę z ulubionych?"))

  {

    advAJAX.get({



      url: "/ankieterzy/ulubione/action/delete/id/" + id + "/",

      timeout: 15000,

      retry: 1,

      retryDelay: 1000,



      onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          document.getElementById("fav_panel_" + id).innerHTML = '';



      },

      onError : function(obj) {

        alert("Stracono połączenie!");

      }

    });

  }

}



function VotesReset() {



  if(confirm("Czy na pewno chcesz wyzerować swoją średnią? Wyzerowanie nie oznacza możliwości powtórnego głosowania przez te same osoby."))

  {

    advAJAX.get({



      url: "/ankieterzy/stat_glosy/reset/",

      timeout: 15000,

      retry: 1,

      retryDelay: 1000,



      onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          document.getElementById("rating_panel").innerHTML = 'Średnia została wyzerowana.';



      },

      onError : function(obj) {

        alert("Stracono połączenie!");

      }

    });

  }

}



function ProfileSwitchPhoto(url, url2, height, text, pos)

{

  document.getElementById('preview_photo').src = url;

  document.getElementById('current_image').value = url2;

  document.getElementById('preview_text').innerHTML = text;



  showPreview(url, pos, height);

}



function ProfileVote(id, vote) {



  advAJAX.get({



    url: "/ankieterzy/glosuj/id/" + id + "/vote/" + vote + "/",

    timeout: 15000,

    retry: 1,

    retryDelay: 1000,



    onInitialization : function() {

      document.getElementById("voteline").innerHTML = 'Głosowanie...';

    },

    onSuccess : function(obj){



      responseMod = obj.responseText.substr(0,3);

      responseText = obj.responseText.substr(3, 10000);



      document.getElementById("voteline").innerHTML = responseText;

    },

    onError : function(obj) {

      alert("Stracono połączenie!");

    }

  });

}



function ProfileFriend(id) {



  advAJAX.get({



    url: "/ankieterzy/znajomi/action/add/id/" + id + "/",

    timeout: 15000,

    retry: 1,

    retryDelay: 1000,





    onInitialization : function() {

      document.getElementById("ajax_friend").innerHTML = 'Dodawanie do znajomych...';

    },

    onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          var html = 'Dodano do znajomych';

        else

          var html = '<a href="javascript:ProfileFriend(' + id + ');">Zaproś do znajomych</a>';



       document.getElementById("ajax_friend").innerHTML = html;

    },

    onError : function(obj) {

      alert("Stracono połączenie...!");

    }

  });

}


function GroupJoin(id) {



  advAJAX.get({



    url: "/ankieterzy/grupy/add/id/" + id + "/",

    timeout: 15000,

    retry: 1,

    retryDelay: 1000,



    onInitialization : function() {

      document.getElementById("ajax_fav").innerHTML = 'Dodawanie do grupy...';

    },

    onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          var html = 'Dodano do ulubionych';

        else

          var html = '<a href="javascript:ProfileFav(' + id + ');">Dodaj profil do ulubionych</a>';



       document.getElementById("ajax_fav").innerHTML = html;

    },

    onError : function(obj) {

      alert("Stracono połączenie!");

    }

  });

}


function ProfileFav(id) {



  advAJAX.get({



    url: "/ankieterzy/ulubione/action/add/id/" + id + "/",

    timeout: 15000,

    retry: 1,

    retryDelay: 1000,



    onInitialization : function() {

      document.getElementById("ajax_fav").innerHTML = 'Dodawanie do ulubionych...';

    },

    onSuccess : function(obj){



        responseMod = obj.responseText.substr(0,3);

        responseText = obj.responseText.substr(3, 10000);



        alert(responseText);



        if(responseMod == '[1]')

          var html = 'Dodano do ulubionych';

        else

          var html = '<a href="javascript:ProfileFav(' + id + ');">Dodaj profil do ulubionych</a>';



       document.getElementById("ajax_fav").innerHTML = html;

    },

    onError : function(obj) {

      alert("Stracono połączenie!");

    }

  });

}



function ProfileAdmin(profile) {



  var text = prompt("Podaj powód jaki zostanie przedstawiony administracji:", "");



  if(text != null && text != '')

  {

    if(confirm("Na pewno chcesz wysłać informację do administratora? Fałszywe powiadomienia są łamaniem regulaminu!"))

    {

      advAJAX.get({



        url: "/ankieterzy/naruszenie_zasad/profil/" + profile + "/text/" + text + "/",

        timeout: 15000,

        retry: 1,

        retryDelay: 1000,



        onInitialization : function() {

          document.getElementById("ajax_admin").innerHTML = 'Wysyłanie...';

        },

        onSuccess : function(obj){



            responseMod = obj.responseText.substr(0,3);

            responseText = obj.responseText.substr(3, 10000);



            alert(responseText);



            if(responseMod == '[1]')

              var html = 'Wysłano informację do administratora.';

            else

              var html = '<a href="javascript:ProfileAdmin(\'' + profile + '\');">Zgłoś naruszenie regulaminu</a>';



           document.getElementById("ajax_admin").innerHTML = html;

        },

        onError : function(obj) {

          alert("Stracono połączenie!");

        }

      });

    }

  }

}



function ProfileComment() {



	advAJAX.assign(document.getElementById("ajax_comment"), {



	onSuccess : function(obj) {



		responseMod = obj.responseText.substr(0,3);

		responseText = obj.responseText.substr(3, 10000);



		if(responseMod == '[1]')

    {

			location.reload();

			document.getElementById("ajax_comment_text").disabled = true;

			document.getElementById("ajax_comment_button").disabled = true;

    }

    else

      alert(responseText);



	},

	onError : function(obj)

	{

		alert("Stracono połączenie!");

	}



	});

}


