function Mobile()
{
  MojaTapeta('222', document.getElementById('profile_photo_image').src.replace('http://www.myphoto.pl/fotki/duze/', ''));
  return false;
}

function HiglightUnread()
{
  var oUnread =document.getElementById('top_unread');
  oUnread.style.visibility = (oUnread.style.visibility == 'visible') ? 'hidden' : 'visible';

}

function HighlightInvitation()
{
 var oIvitation=document.getElementById('top_invitation');
 oIvitation.style.visibility = (oIvitation.style.visibility == 'visible') ? 'hidden' : 'visible';
}

function Higlightall()
{
var oUnread =document.getElementById('top_unread');
    oUnread.style.visibility = (oUnread.style.visibility == 'visible') ? 'hidden' : 'visible';

var oIvitation=document.getElementById('top_invitation');
    oIvitation.style.visibility = (oIvitation.style.visibility == 'visible') ? 'hidden' : 'visible';
}


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 boxaction(sAction)
{
  document.getElementById('action').value = sAction;
  document.getElementById('box').submit();
}

function setNameConfiguration() {

/*	if(document.getElementById('save').checked == true)
	 {

	 var text = prompt("Set the config name( 200 characters max )", "");

		 document.getElementById('conf_name').value = text;
		 document.getElementById('form1').submit();

	}
  else
   {
    document.getElementById('form1').submit();
   } */

    var oIvitation=document.getElementById('conf_name');
 	//oIvitation.style.visibility = (oIvitation.style.visibility == 'visible') ? 'hidden' : 'visible';
 	//oIvitation.style.position = (oIvitation.style.visibility == 'relative') ? 'absolute' : 'relative';
    
    oIvitation.style.display =(oIvitation.style.display == 'none') ? 'inline' : 'none';

}

function destroyConfig(sUrl, iId , oDiv) {

 advAJAX.get({

  			url:  sUrl + "search/deleteconfig/" + iId + "/",
  			timeout: 15000,
  			retry: 1,
  			retryDelay: 1000,

  			onInitialization : function() {
          		 //document.getElementById("errorbox").innerHTML = 'Sending a e-mail to ' + sUser;
    			},

  			onSuccess : function(obj){


      	    oDiv.innerHTML = '';
		    },
  			onError : function(obj) {
  				alert("Zerwamo połączenie!");
  			}
  		});


}

function deleteprofile(sUrl, iId){

	if(window.confirm('Proszę podać powód:')){

		var ajax = getXMLHttpRequest();
		ajax.open('POST', sUrl + 'delete_account/', true );
		ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send('id=' + iId);
		//alert(ajax.responseText);

		window.location.href= sUrl + "logout";

		if(ajax.readyState == 4){
		 window.location.href= sUrl + "logout";
		}

	}



	/* advAJAX.get({

  			url:  sUrl + "delete_account/" + iId + "/",
  			timeout: 15000,
  			retry: 1,
  			retryDelay: 1000,

  			onInitialization : function() {
          		 //document.getElementById("errorbox").innerHTML = 'Sending a e-mail to ' + sUser;
    			},

  			onSuccess : function(obj){

				alert(obj.responseText);

		    },
  			onError : function(obj) {
  				alert("Connection lost!");
  			}
  		}); */

	/*
	naruszenie_trim = naruszenie.replace(/^\s+|\s+$/g, '') ;
	if( naruszenie_trim != '' ){

	alert(naruszenie_trim);
   	// tworzenie obiektu ajax
		var ajax = getXMLHttpRequest();
		ajax.open('POST', sUrl + 'reguls_aberration/', true );

		ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send('id=' + id + '&idFrom=' + id_from + '&comment=' +  naruszenie_trim );
		window.alert('Your report was send to administrator');
	}else{
		window.alert('You do not type the reason !!');
	} */


}



function boxaction2(iIdUser, sAction)
{
  document.getElementById('action').value = sAction;
  document.getElementById('input_' + iIdUser).checked=true;
  document.getElementById('box').submit();
}

function showPanelOfNewGallery(oDiv,sUrl)
{

 var sPanel="<input type=text maxlength=20 size=24 name=galleryName id=galleryNewName>";
 sPanel+=" <div class=\"priv_icon\"><a href=\"javascript:addNewGallery('"+sUrl+"')\"><span>Dodaj</span></a></div>";
 oDiv.innerHTML=sPanel;
}



function addNewGallery(sUrl) {

 //alert(id);

 //alert(sUrl);

 var sText=document.getElementById('galleryNewName').value;
 var aCodeAscii=new Array(sText.length);
 //alert(sText);

 for(var i=0; i<sText.length;i++)
 {
  aCodeAscii[i]=sText.charCodeAt(i);
  //alert(aCodeAscii);
 }


sText=aCodeAscii.toString();


  advAJAX.get({

    url: sUrl + "gallery/action/add/"+sText+"/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,


    onInitialization : function() {
      oLayer = document.getElementById("newGallery");
      sInner = oLayer.innerHTML;
      oLayer.innerHTML = '<span>Tworzenie galerii...</span>';
    },
    onSuccess : function(obj){

       var html = obj.responseText;
       document.getElementById("newGallery").innerHTML = html;
    },
    onError : function(obj) {
      alert("Connection lost!");
    }
  });
}




function showPanelOfNewPhotoInGallery(oDiv,sUrl)
 {
  oDiv.style.visibility="visible";
  oDiv.style.position="relative";
 }


function showPanelOfNewChangeText(oDiv,oObject)
{
 oDiv.style.visibility="visible";
 oDiv.style.position="relative";

  var oInputHidden=document.getElementById('id_gallerySinc');

  oInputHidden.value=oObject.id;

// alert(oInputHidden.value);
}

function showPanelOfNewChangeText23(oDiv,iId)
{
 oDiv.style.visibility="visible";
 oDiv.style.position="relative";

  var oInputHidden=document.getElementById('id_gallerySinc');

  oInputHidden.value = iId;


}

function showPanelOfNewChangeText24(oDiv,iId)
{
 oDiv.style.display = "inline";

  var oInputHidden=document.getElementById('id_gallerySinc');

  oInputHidden.value = iId;


}

/*
function destroyGallery(oDiv,oObject,sAction)
{
 if(confirm("Delete gallery?"))
 {
  var oInputHidden=document.getElementById('id_gallerySinc');

  oInputHidden.value=oObject.id;

  document.getElementById('action').value = sAction;
  document.getElementById('box').submit();
 }

} */

function destroyGallery(iId, sAction)
{
 if(confirm("Delete gallery?"))
 {
  var oInputHidden=document.getElementById('id_gallerySinc');

  oInputHidden.value = iId;

  document.getElementById('action').value = sAction;
  document.getElementById('box').submit();
 }

}


function sendAgainMail(sUser, sUrl) {

      advAJAX.get({

  			url:  sUrl + "login/send_again/" + sUser + "/",
  			timeout: 15000,
  			retry: 1,
  			retryDelay: 1000,

  			onInitialization : function() {
          		 document.getElementById("errorbox").innerHTML = 'Sending a e-mail to ' + sUser;
    			},

  			onSuccess : function(obj){

      	     document.getElementById("errorbox").innerHTML = obj.responseText;
		    },
  			onError : function(obj) {
  				alert("Connection lost!");
  			}
  		});


}


function showPanelOfNewPhotoInGallery2(oDivOpen,oDivClose1)
 {

  oDivClose1.style.visibility="hidden";
  oDivClose1.style.position="absolute";

  oDivOpen.style.visibility="visible";
  oDivOPen.style.position="relative";

 }

function catchValue(oObject)
 {

  var oHiddenInput=document.getElementById('grupa_'+oObject.getAttribute('id'));
  oHiddenInput.value=oObject.options[oObject.selectedIndex].value;

 }

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, sUrl ) {

  var text = prompt("Wpisz podpis ( maks 200 znaków)", "");

  if(text != null)
  {
    if(confirm("Podpis zostanie zmieniony. Czy jesteś pewny?"))
    {
      var text = text.substr(0,200);

      advAJAX.get({

  			url:  sUrl + "movies/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("Connection lost!");
  			}
  		});
    }
  }
}

function editMovieDelete(id, sUrl) {

  if(confirm("Video zostanie usunięte. Czy jesteś pewny?"))
  {
    advAJAX.get({

      url:  sUrl + "movies/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("Sracono połączenie!");
      }
    });
  }
}

function editGalleryDesc(id, sUrl ) {

  var text = prompt("Wpisz podpis ( maks 200 znaków )", "");

  if(text != null)
  {
    if(confirm("Podpis zostanie zmieniony. Czy jesteś pewny?"))
    {
      var text = text.substr(0,200);

      advAJAX.get({

            url:  sUrl + "gallery/action/desc/id/" + id + "/text/" + text + "/",
            timeout: 15000,
            retry: 1,
            retryDelay: 1000,

            onSuccess : function(obj){

            responseMod = obj.responseText.substr(0,5);
            responseText = obj.responseText.substr(5, 10000);

            alert(responseText);

            if(responseMod == '[1]')
              {
                document.getElementById("photo_desc_" + id).innerHTML = text;

              }

            },
            onError : function(obj) {
                alert("Connection lost!");
            }
        });
    }
  }
}

function editGalleryDelete(id,sBaseUrl) {

  if(confirm("Zdjęcie zostanie usunięte. Czy jesteś pewny?"))
  {
    advAJAX.get({

      url: sBaseUrl + "gallery/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("Connection lost!");
      }
    });
  }
}

function deletePhotoFromGallery(iId, iGalleryId){

    //var oinput = document.getElementById("action");  
    
        
     var ajax = getXMLHttpRequest();
   // var oPhotoDiv = document.getElementById('photo_' + iId);
        ajax.open('POST','http://'+ window.location.hostname +'/gallery/view/' + iGalleryId + '/', true );
        
        ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
        ajax.setRequestHeader('X_REQUESTED_WITH', "XMLHttpRequest");
        
        ajax.onreadystatechange = function(){
            
	            if(ajax.readyState == 4){

	               var sResponseText = ajax.responseText.substr(5, 10000);
	               mod = ajax.responseText.substr(0, 5);
	               if(mod.indexOf('[1]') > - 1){
		               document.getElementById('photo_panel_' + iId).innerHTML = '';
	               } else {
	                   alert(sResponseText);
	               }
	             }
        
        }
        
        ajax.send('photo_id=' + iId + '&action=destroyPhoto');
        
}

function changePhotoGalleryDesc(iId, iGalleryId){

     var ajax = getXMLHttpRequest();
     var text = prompt("Podaj podpis zdjęcia", "");
     
     if(text != null && confirm("Tyuł zostanie zmieniony. Czy jesteś pewny?")){
		   
		    ajax.open('POST','http://'+ window.location.hostname +'/gallery/view/' + iGalleryId + '/', true );
		    ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
		    ajax.setRequestHeader('X_REQUESTED_WITH', "XMLHttpRequest");
		    
		    ajax.onreadystatechange = function(){
		        
		         if(ajax.readyState == 4){
		
		           /* var sResponseText = ajax.responseText.substr(5, 10000);
		            mod = ajax.responseText.substr(0, 5);
		            if(mod.indexOf('[1]') > - 1){*/
		                  document.getElementById("photo_desc_" + iId).innerHTML = text;
		            /*} else {
		                alert(sResponseText);
		            } */
		          }
		    
		    }
        
    ajax.send('photo_id=' + iId + '&action=changeTextPhoto&desc=' + text);
        
  }
  
}

function editPhotoDesc(id,sBaseUrl) {

  var text = prompt("Podaj podpis do zdjęcia ( maks 200 znaków )", "");

  if(text != null)
  {
    if(confirm("Podpis zostanie zmienony. Czy jesteś pewny?"))
    {
      var text = text.substr(0,200);

      advAJAX.get({

  			url: sBaseUrl + "photos/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,sBaseUrl) {

  if(confirm("Zdjęcie zostanie skasowane. Czy jesteś pewny?"))
  {
    advAJAX.get({

      url: sBaseUrl + "photos/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("Connection lost!");
      }
    });
  }
}

function editPhotoFake(id) {

  if(confirm("Czy jesteś pewny, aby wskazać ten plik jako 'Fake' ?"))
  {
    advAJAX.get({

      url: sBaseUrl + "photos/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("Connection lost!");
      }
    });
  }
}

function editPhotoAvatar(id) {

  if(confirm("Czy jesteś pewny aby to był Twój avatar?"))
  {
    advAJAX.get({

      url: sBaseUrl + "photos/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, sBaseUrl) {

  advAJAX.get({

    url: sBaseUrl + "photos/action/move/id/" + id + "/position/" + position + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onSuccess : function(obj){

      responseMod = obj.responseText.substr(1,3);
      responseText = obj.responseText.substr(4, 10000);

      alert(responseText);

      if(responseMod == '[1]')
        location.href = sBaseUrl + 'photos/';
    },
    onError : function(obj) {
      alert("Stracono połączenie!");
    }
  });
}

function editFavDelete(id,sUrl) {

  if(confirm("Czy jesteś pewny aby usunąć użytkownika z ulubionych?"))
  {
    advAJAX.get({

      url: sUrl+ "favourites/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("profile_panel_" + id).style.display = 'none';

      },
      onError : function(obj) {
        alert("Connection lost");
      }
    });
  }
}

function VotesReset(sUrl) {

  if(confirm("Czy na pewno chcesz skasować glosy?"))
  {
    advAJAX.get({

      url: sUrl + "votes/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("account_resetvotes").innerHTML = '<span>Votes reseted successful</span>';

      },
      onError : function(obj) {
        alert("Connection lost!");
      }
    });
  }
}

function BattleVote(battle, user, enermy) {

  advAJAX.get({

    url: sBaseUrl + "pojedynki/id/" + battle + "/vote/" + user + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
      oVote1 = document.getElementById("battle_vote_" + battle + "_" + user);
      oVote2 = document.getElementById("battle_vote_" + battle + "_" + enermy);

      sVote1 = oVote1.innerHTML;
      sVote2 = oVote2.innerHTML;

      oVote1.className = oVote2.className = 'load';
      oVote1.innerHTML = oVote2.innerHTML = 'Voting...';
    },
    onSuccess : function(obj){

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

      oVote1 = document.getElementById("battle_vote_" + battle + "_" + user);
      oVote2 = document.getElementById("battle_vote_" + battle + "_" + enermy);

      if(responseMod == '[1]')
        oVote1.innerHTML = oVote2.innerHTML = 'Vote submited';
      else
      {
        alert(responseText);
        oVote1.innerHTML = sVote1;
        oVote2.innerHTML = sVote2;
      }

      oVote1.className = oVote2.className = 'vote';
    },
    onError : function(obj) {
      alert("Stracono połączenie!");
    }
  });
}

function ClubJoin(id, join) {

  advAJAX.get({

    url: sBaseUrl + "klub/action/" + ((join) ? 'join' : 'unjoin') + "/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
      oLayer = document.getElementById(((join) ? 'ajax_join' : 'ajax_unjoin'));
      sInner = oLayer.innerHTML;
      oLayer.innerHTML = '<span>' + ((join) ? 'Join club...' : 'Leave club...') + '</span>';
    },
    onSuccess : function(obj){

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

        alert(responseText);

        if(responseMod == '[1]')
          var html = '<span class="completed">' + ((join) ? 'You are join this club' : 'You are leave this club') + '</span>';
        else
          var html = sInner;

       document.getElementById(((join) ? 'ajax_join' : 'ajax_unjoin')).innerHTML = html;
    },
    onError : function(obj) {
      alert("Connection lost!");
    }
  });
}

function ClubDelete(id)
{
  if(confirm('Do you really want to removed this club pernamently?'))
    window.location.href = sBaseUrl + 'kluby/moje/' + id + '/usun/';
}



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("Connection lost!");
	}

	});
}

function ProfileFriend(id,sUrl) {

 //alert(id);

  advAJAX.get({

    url: sUrl + "friends/action/add/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,


    onInitialization : function() {
     // oLayer = document.getElementById("ajax_friend");
     // sInner = oLayer.innerHTML;
     // oLayer.innerHTML = '<span>Dodawanie do znajomych...</span>';
    },
    onSuccess : function(obj){

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

        //alert(responseText);

      //  if(responseMod == '[1]')
      //    var html = '<span class="completed">Dodano do znajomych</span>';
      //  else
      //    var html = sInner;

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

       document.getElementById("HiddenDivFamDelete").style.display = 'block';
       document.getElementById("HiddenDivFamAdd").style.display = 'none';
        document.getElementById("HiddenDivFamAdd1").style.display =  'none';
    },
    onError : function(obj) {
      alert("Connection lost");
    }
  });
}


function DeleteProfileFriend(id,sUrl) {

 //alert(id);

  advAJAX.get({

    url: sUrl + "friends/action/delete/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,


    onInitialization : function() {
     // oLayer = document.getElementById("ajax_friend");
     // sInner = oLayer.innerHTML;
     // oLayer.innerHTML = '<span>Dodawanie do znajomych...</span>';
    },
    onSuccess : function(obj){

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

        //alert(responseText);

     //   if(responseMod == '[1]')
     //     var html = '<span class="completed">Dodano do znajomych</span>';
     //   else
     //     var html = sInner;

     //  document.getElementById("ajax_friend").innerHTML = html;
       document.getElementById("HiddenDivFamDelete").style.display = 'none';
       document.getElementById("HiddenDivFamAdd").style.display = 'block';
       document.getElementById("HiddenDivFamAdd1").style.display =  'none';

    },
    onError : function(obj) {
      alert("Connection lost");
    }
  });
}





function ProfileFav(id,sUrl) {

  advAJAX.get({

    url: sUrl + "favourites/action/add/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
      //oLayer = document.getElementById("ajax_fav");
     // sInner = oLayer.innerHTML;
      //oLayer.innerHTML = '<span>Dodawanie do ulubionych...</span>';
    },
    onSuccess : function(obj){

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

        //alert(responseText);

        /*

        if(responseMod == '[1]')
          var html = '<span class="completed">Dodano do ulubionych</span>';
        else
          var html = sInner;

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

       */

       document.getElementById("HiddenDivFavDelete").style.display = 'block';
       document.getElementById("HiddenDivFavAdd").style.display = 'none';


    },
    onError : function(obj) {
      alert("Connection lost!");
    }
  });
}

function DeleteProvilFav(id,sUrl) {

  advAJAX.get({

    url: sUrl + "favourites/action/delete/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
      //oLayer = document.getElementById("ajax_fav");
     // sInner = oLayer.innerHTML;
     // oLayer.innerHTML = '<span>Usuwanie profilu z ulubionych...</span>';
    },
    onSuccess : function(obj){

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

       // alert(responseText);

        /*if(responseMod == '[1]')
          var html = '<span class="completed">Usunieto z ulubionych</span>';
        else
          var html = sInner;*/

       document.getElementById("HiddenDivFavDelete").style.display = 'none';
       document.getElementById("HiddenDivFavAdd").style.display = 'block';

    },
    onError : function(obj) {
      alert("Connection lost!");
    }
  });
}


function ProfileBlackList(id,sUrl) {

  advAJAX.get({

    url: sUrl + "blacklist/action/add/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
    },
    onSuccess : function(obj){

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

       document.getElementById("HiddenDivBLDelete").style.display = 'block';
       document.getElementById("HiddenDivBLAdd").style.display = 'none';
    },
    onError : function(obj) {
      alert("Connection lost!");
    }
  });
}


function DeleteProfilBlackList(id,sUrl) {

  advAJAX.get({

    url: sUrl + "blacklist/action/delete/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
    },
    onSuccess : function(obj){
        responseMod = obj.responseText.substr(0,3);
        responseText = obj.responseText.substr(3, 10000);

       document.getElementById("HiddenDivBLDelete").style.display = 'none';
       document.getElementById("HiddenDivBLAdd").style.display = 'block';
    },
    onError : function(obj) {
      alert("Connection lost!");
    }
  });
}

function DeleteProfilBlackList2( id, sUrl, iIdDiv ) {

  advAJAX.get({

    url: sUrl + "blackList/action/delete/id/" + id + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
    },
    onSuccess : function(obj){
        responseMod = obj.responseText.substr(0,3);
        responseText = obj.responseText.substr(3, 10000);

       document.getElementById(iIdDiv).style.display = 'none';

    },
    onError : function(obj) {
      alert("Stracono polaczenie!");
    }
  });
}


/*
function ProfileAdmin(id) {

  advAJAX.get({
   // url: sUrl + "blacklist/action/delete/id/" + id + "/",
   // timeout: 15000,
   // retry: 1,
   // retryDelay: 1000,

    onInitialization : function() {
    //	el = document.getElementById("ajax_admin");
		//	document.getElementById("ajax_admin").innerHTML = '<li id="ajax_admin"><strong>Please wait...</strong></li>';
    },
    onSuccess : function(obj){
        responseMod = obj.responseText.substr(0,3);
        responseText = obj.responseText.substr(3, 10000);

			if( document.getElementById("HiddenNaruszenieDiv").style.visibility == 'hidden' ){
				document.getElementById("HiddenNaruszenieDiv").style.visibility = 'visible';
				document.getElementById("HiddenNaruszenieDiv").style.position = 'relative';
			} else {
				document.getElementById("HiddenNaruszenieDiv").style.visibility = 'hidden';
				document.getElementById("HiddenNaruszenieDiv").style.position = 'absolute';
			}

    },
    onError : function(obj) {
      alert("Stracono polaczenie!");
    }
  });
}
*/

function getXMLHttpRequest(){
	var request = false;
	try{
		request = new XMLHttpRequest();
	}catch( err1 ){
		try{
			request = new ActiveXObject('Msxm12.XMLHTTP');
		}catch(err2){
			try{
				request = new ActiveXObject('Microsoft.XMLHTTP');
			}catch(err3){
				request = false;
			}
		}
	}
	return request;
}

function ProfileAdmin(sUrl, id, id_from){

	var naruszenie=window.prompt('Proszę podać powód:');
	naruszenie_trim = naruszenie.replace(/^\s+|\s+$/g, '') ;
	if( naruszenie_trim != '' ){

	alert(naruszenie_trim);
   	// tworzenie obiektu ajax
		var ajax = getXMLHttpRequest();
		ajax.open('POST', sUrl + 'reguls_aberration/', true );

		ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send('id=' + id + '&idFrom=' + id_from + '&comment=' +  naruszenie_trim );
		window.alert('Twoje zgłoszenie zostało wysłane do administratora');
	}else{
		window.alert('Nie podałeś powodu!!');
	}
}

function ProfileVote(id, vote, url) {
  advAJAX.get({

    url: url + "/votes/id/" + id + "/vote/" + vote + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
      document.getElementById("vote-line").innerHTML = 'Głosowanie...';
    },
    onSuccess : function(obj){

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

      document.getElementById("vote-line").innerHTML = responseText;
    },
    onError : function(obj) {
      alert("Connection lost!");
    }
  });
}

function setStar(url,iIdStar)
{

 advAJAX.get({

    url: url + "/user_pro_color/action/set/" + iIdStar + "/",
    timeout: 15000,
    retry: 1,
    retryDelay: 1000,

    onInitialization : function() {
     // document.getElementById("star").innerHTML = 'setting a star';
    },
    onSuccess : function(obj){

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

      //document.getElementById("star").innerHTML = responseText;
      if(responseMod='[1]') {

        document.getElementById("star").className='stars star-' + iIdStar;
        document.getElementById("name").className='float-left star-' + iIdStar;

       } else {

         alert(responseText);

       }

    },
    onError : function(obj) {
      alert("loose connection...");
    }
  });

}


function openThisFuckingWindow()
{
    /*if (window.netscape) {
     alert("dasa");

        netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');

      } */


   if (document.all) {// windows

        alert(fso);

   }


   else
   {
	 window.document.getElementById("uploadfile").select();
     window.document.getElementById("submitfile").click();

   // alert("dad");
   }




   //  document.getElementById("uploadfile").click();

   //  var sValue = document.getElementById("uploadfile").value;
	//      sValue = sValue.replace(/^\s+|\s+$/g, '');



	//   if(sValue!='')
	   //   {
	     //  document.getElementById("addphoto").submit();
	   //   }

    // document.getElementById("addphoto").submit();

 }


 function sendNewFlashMovie()
 {
 	var text = prompt("Podaj link do filmu:", "");

 	 	if (text)
 	 	 {
			 document.getElementById("url").value=text;
 	 	 	 document.getElementById("addmovie").submit()

 	 	  } else {

 	 		  return false;

 	 	  }

 }

function deleteSelect(oSelect, iAllowed)
{
	var aIndexes = new Array;

	  for (var i = oSelect.options.length-1; i >= 0 ; i --) {
		if(oSelect.options[i].value != iAllowed) {
			oSelect.remove(i);
		}
	  }
}


//upload file create
var W3CDOM = (document.createElement && document.getElementsByTagName);
function initFileUploads() {
    if (!W3CDOM) return;
    var fakeFileUpload = document.createElement('div');
    fakeFileUpload.className = 'fakefile';
    
    var oInput = document.createElement('input');
    oInput.style.visibility ='hidden';
    oInput.style.position ='absolute';
    oInput.style.width ='100px';
    fakeFileUpload.appendChild(oInput);
    
    var image = document.createElement('img');
    image.src='/www/layout/formulars/button-login.png';
    fakeFileUpload.appendChild(image);
    var x = document.getElementsByTagName('input');
    for (var i=0;i<x.length;i++) { 
        if (x[i].type != 'file') continue; 
        if (x[i].parentNode.className != 'fileinputs') continue;
        x[i].className = 'file hidden';
        var clone = fakeFileUpload.cloneNode(true);
        x[i].parentNode.appendChild(clone);
        x[i].relatedElement = clone.getElementsByTagName('input')[0];
        //x[i].setAttribute('name', 'uploadfile');
        x[i].onchange = x[i].onmouseout = function () {
            this.relatedElement.value = this.value;
        }
    }
    
     fakeFileUpload.onclick = function () {
               realField.click()
     }
 }

function showAccountPhotos(sType){
    
   var iParseInt = parseInt(document.getElementById('photos_counter').value);
   
   for(var i = 0; i < iParseInt; i++){
   
       var oDiv = document.getElementById('panel_' + i);
       var isProf = parseInt(oDiv.getAttribute('prof')); 
        
       if(sType == 'all'){
        //show all
         oDiv.style.display="inline"; 
         
       }else if(sType == 'plain'){
            //show plain    
            if(isProf){
                oDiv.style.display="none";
            } else {
                oDiv.style.display="inline";
           }
           
       }else if(sType == 'int'){
            //show plain    
            if(isProf < 2){
                oDiv.style.display="none";
            } else {
                oDiv.style.display="inline";
           }
           
       } else {
            
            //show proffesional    
           if(isProf == 1){
                oDiv.style.display="inline";
            } else {
                oDiv.style.display="none";
           }
       
       }
   }

} 

function setMaxLength() {
    var x = document.getElementById('sukces');
    var counter = document.getElementById('counter');
    
    var x2 = document.getElementById('wtopa');
    var counter2 = document.getElementById('counter2');
    
    var x3 = document.getElementById('marzenie');
    var counter3 = document.getElementById('counter3');
    
    
    counter.innerHTML = '0/'+x.getAttribute('maxlength');
    x.onkeyup = x.onchange = checkMaxLength;
    x.onkeyup();
   
    counter2.innerHTML = '0/'+x2.getAttribute('maxlength');
    x2.onkeyup = x2.onchange = checkMaxLength;
    x2.onkeyup();
   
    counter3.innerHTML = '0/'+x3.getAttribute('maxlength');
    x3.onkeyup = x3.onchange = checkMaxLength;
    x3.onkeyup();
    
    
}

function checkMaxLength(iId) {
    var maxLength = this.getAttribute('maxlength');
    var currentLength = this.value.length;
    //var sTemp = currentLength;
    
    if(this.getAttribute('counter_nr') == 1){
        var counter = document.getElementById('counter');
    } else if (this.getAttribute('counter_nr') == 2){
        var counter = document.getElementById('counter2');
    } else {
        var counter = document.getElementById('counter3');
    }
    
    if (currentLength <= maxLength){
    
        counter.innerHTML =(maxLength - currentLength) + '/' + maxLength;
        
    } else {
       // this.relatedElement.className = '';
       this.value = this.value.substr(0, maxLength);
    }    
    
    // not innerHTML
}


function JTlenOpen() { window.open("http://jt.tlen.pl/jtlen.html","JTlen","width=240,height=500,titlebar=no,menubar=no,location=no,toolbar=no,scrollbars=no,status=no,resizable=yes,left="+(screen.availWidth-250)+",top="+(screen.availHeight-530)); }


var activex = ((navigator.userAgent.indexOf('Win')  != -1) && (navigator.userAgent.indexOf('MSIE') != -1) && (parseInt(navigator.appVersion) >= 4 ));
var CantDetect = ((navigator.userAgent.indexOf('Safari')  != -1) || (navigator.userAgent.indexOf('Opera')  != -1));

function oopsPopup() {
    if((navigator.language && navigator.language.indexOf("ja") != -1) || (navigator.systemLanguage && navigator.systemLanguage.indexOf("ja") != -1) || (navigator.userLanguage && navigator.userLanguage.indexOf("ja") != -1)) {
        var URLtoOpen = "communicators_oops.php";
    } else {
        var URLtoOpen = "communicators_oops.php";
    }
    var windowName = "oops";
    var popW = 540, popH = 305;
    var scrollB = 'no';
    w = screen.availWidth;
    h = screen.availHeight;
    var leftPos = (w-popW)/2, topPos = (h-popH)/2;
    oopswindow = window.open(URLtoOpen, windowName,'width=' + popW + ',height=' + popH + ',scrollbars=' + scrollB + ',screenx=' +leftPos +',screeny=' +topPos +',top=' +topPos +',left=' +leftPos);
    return false;
}

if(typeof(detected) == "undefined" && activex) {
    document.write(
        ['<script language="VBscript">',
        'Function isSkypeInstalled()',
        'on error resume next',
        'Set oSkype = CreateObject("Skype.Detection")',
        'isSkypeInstalled = IsObject(oSkype)',
        'Set oSkype = nothing',
        'End Function',
        '</script>'].join("\n")
    );
}

function skypeCheck() {
    if(CantDetect) {
        return true;
    } else if(!activex) {
        var skypeMime = navigator.mimeTypes["application/x-skype"];
        detected = true;
        if(typeof(skypeMime) == "object") {
            return true;
        } else {
            return oopsPopup();
        }
    } else {
        if(isSkypeInstalled()) {
            detected = true;
            return true;
        }
    }
    
    detected = true;
    return oopsPopup();
}

function loadDetection() {
    if(document.getElementById && document.getElementsByTagName) {
        if (window.addEventListener) window.addEventListener('load', addDetection, false);
        else if (window.attachEvent) window.attachEvent('onload', addDetection);
    }
}

function addDetection() {
    var pageLinks = document.getElementsByTagName("a");
    for (var i=0; i < pageLinks.length; i++) {
        if(pageLinks[i].childNodes[0] && pageLinks[i].childNodes[0].src) {
            if((pageLinks[i].childNodes[0].src.indexOf('download.skype.com\/share\/skypebuttons') != -1 || pageLinks[i].childNodes[0].src.indexOf('mystatus.skype.com') != -1) && (typeof(pageLinks[i].onclick) == "undefined" || pageLinks[i].onclick == null)) {
                pageLinks[i].onclick = function sChk() { return skypeCheck(); }
            }
        }
    }
}

loadDetection();
 