function toggle(elid)
{
	if(document.getElementById(elid).style.display=='block') {document.getElementById(elid).style.display='none';}
	else {document.getElementById(elid).style.display='block';}
	//alert(id);
	//alert(document.getElementById(id).style.display);
}
function togglediv(elid)
{
	if(document.getElementById(elid).style.display=='block') {document.getElementById(elid).style.display='none';}
	else {document.getElementById(elid).style.display='block';}
}
function appendvalue(id, newvalue)
{
	document.getElementById(id).innerHTML=newvalue+document.getElementById(id).innerHTML;
}
function appendvalue2(id, newvalue)
{
	document.getElementById(id).innerHTML=document.getElementById(id).innerHTML+newvalue;
}

function hidediv(id)
{
	document.getElementById(id).style.display='none';
}

function showdiv(id)
{
	document.getElementById(id).style.display='block';
}

function setvalue(id, newvalue)
{
	document.getElementById(id).innerHTML=newvalue;
}

function setinputvalue(id, newvalue)
{
	document.getElementById(id).value=newvalue;
}



		function removeFriend(id, refreshlocation)
		{
			if(confirm(reallydelete))
			{
				var xmlhttp;
				if(window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
				else if(window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
				xmlhttp.onreadystatechange=function()
				{
					if(xmlhttp.readyState==4)
					{
						if(xmlhttp.responseText[0]=='1')
						{
							if(!refreshlocation)
							{
								friends--;
								if(friends==0) document.getElementById('user'+id).innerHTML=youhavenofriends;
								else document.getElementById('user'+id).style.display='none'; //if(xmlhttp.responseText=="") alert("Error. Please check your internet connection.");
							}
							if(refreshlocation) window.location.reload(true);
						}
						else alert(checkconnection);
					}
//						alert(xmlhttp.responseText);
				}
				xmlhttp.open("GET", '/users.php?option=delete&uid='+id, true);
				xmlhttp.send(null);
			}
		}
		function addFriend(id)
		{
			if(confirm(reallyadd))
			{
				var xmlhttp;
				if(window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
				else if(window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
				xmlhttp.onreadystatechange=function()
				{
					if(xmlhttp.readyState==4)
					{
						if(xmlhttp.responseText[0]=='1')
						{
							window.location.reload(true);
						}
						else if(xmlhttp.responseText[0]=='2') alert(requestalreadysent);
						else if(xmlhttp.responseText[0]=='3') alert(alreadyfriends);
						else if(xmlhttp.responseText[0]=='4') alert(cannotaddyourself);
						else if(xmlhttp.responseText[0]=='5') alert(friendshipalreadyconfirmed);
						else if(xmlhttp.responseText[0]=='6')
						{
							alert(friendshipconfirmed);
							window.location.reload(true);
						}
						else alert(checkconnection);
					}
//						alert(xmlhttp.responseText);
				}
				xmlhttp.open("GET", '/users.php?option=add&uid='+id, true);
				xmlhttp.send(null);
			}
		}

function ajaxrequest(url, target)
{
	var xmlhttp;
	if(window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
	else if(window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			document.getElementById(target).innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

      function getWidth()
      {
              var x = 0;
              if (self.innerHeight)
              {
                      x = self.innerWidth;
              }
              else if (document.documentElement && document.documentElement.clientHeight)
              {
                      x = document.documentElement.clientWidth;
              }
              else if (document.body)
              {
                      x = document.body.clientWidth;
              }
              return x;
      }
       
      function getHeight()
      {
              var y = 0;
              if (self.innerHeight)
              {
                      y = self.innerHeight;
              }
              else if (document.documentElement && document.documentElement.clientHeight)
              {
                      y = document.documentElement.clientHeight;
              }
              else if (document.body)
              {
                      y = document.body.clientHeight;
              }
              return y;
      }

function changestatus(txt)
{
	ajaxrequest('/users.php?setstatus='+txt, 'statustext');
	hidediv('editstatus');
	showdiv('status');
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}





//jQuery.noConflict();

function deletepost(id,type){
jQuery.ajax({
   type: "GET",
   url: "/wall.php",
   data: "id="+id+"&type="+type+"&del",
   success: function(){
   jQuery("#post"+id+"").html("Повідомлення видалено");
   
   }
 });
}

jQuery(document).ready(function(){
jQuery('#wallnew input[type=submit]').click(function(event) {
event.preventDefault();
jQuery.ajax({
  type : 'POST',
  url: '/wall.php',
  data: 'message='+jQuery('textarea[name=message]').val()+
  '&to='+jQuery('input[name=to]').val()+'',
  success: function(data) {
  jQuery('#wallnew').css('display','none');
    jQuery('#wall').prepend(data);
	
  }
});
});

jQuery("#wallnewcom input[type=submit]").click(function(event){
event.preventDefault();
jQuery.ajax({
   type: "POST",
   url: "/wall.php",
   data: "message="+jQuery("#wallnewcom textarea[name=message]").val()+"&comid="+jQuery("#wallnewcom input[name=comid]").val()+"",
   success: function(msg){
   jQuery('#wallnewcom').css('display','none');
    jQuery("#wall").prepend(msg);
   }
 });

});
jQuery(".imgspol span").click(function(){
if (jQuery(this).parent().find("div").css("display")=="none")
{jQuery(this).parent().find("div").show();
jQuery(this).parent().find("span").html("Сховати зображення");
}else{jQuery(this).parent().find("div").hide();
jQuery(this).parent().find("span").html("Показати зображення");
}

});

jQuery("a#single_image").fancybox();

jQuery("#wallnewcomart input[type=submit]").click(function(event){
event.preventDefault();
jQuery.ajax({
   type: "POST",
   url: "/wall.php",
   data: "message="+jQuery("#wallnewcomart textarea[name=message]").val()+"&artid="+jQuery("#wallnewcomart input[name=comid]").val()+"",
   success: function(msg){
   jQuery('#wallnewcomart').css('display','none');
    jQuery("#wall").prepend(msg);
   }
 });

});


jQuery('a.showvideo').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
	'speedOut'		:	200, 
		'overlayShow'	:	true,
		'type' : 'iframe',
		'width' : 480,
		'height' : 320,
		'margin' : 0,
		'padding' : 0
	});
	
jQuery('a#showallfriends').fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
	'speedOut'		:	200, 
		'overlayShow'	:	true,
		'type' : 'iframe',
		'width' : 480,
		'height' : 490
	});
	

});



