function sendRequest(uid,req)
{
	if(req)
	document.getElementById('mcontent').innerHTML ='Sending request...';
	else
	{
		document.getElementById('btn_send').innerHTML ='Sending ...';
		mess_value = document.getElementById('m_val').value;
	}
	httpobject = new newObject();
	httpobject.onreadystatechange=function()
	{
		if(httpobject.readyState==4)
		{
			var respose = httpobject.responseText;
			if(req)
			{
				document.getElementById('mcontent').innerHTML = respose;
				setTimeout("hideArea('message')",1000);
			}
			else
			{
				document.getElementById('res').innerHTML = respose;
				document.getElementById('btn_send').innerHTML = "Send message";
				setTimeout("hideArea('message')",1000);
			}
		}
	}
	if(req)
	httpobject.open("GET","/community/ajax_friends_request.php?uid="+uid,true);
	else	
	httpobject.open("GET","/community/ajax_sending_message.php?uid="+uid+"&m="+mess_value,true);
	httpobject.send(null);
}
function showArea(uname,req)
{
	document.getElementById('message').style.height = '80px';
	document.getElementById('message').innerHTML = 'Loading....';
	changeOpac(100,'message');
	var myWidth = 0;
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	var vscroll = (document.all ? document.documentElement.scrollTop : window.pageYOffset);
	document.getElementById('message').style.left = (((myWidth/2)-250)) + 'px';
	var h = (((myHeight/2)-50));
	document.getElementById('message').style.top = (h + vscroll) +'px';
	document.getElementById('message').style.display = 'block';
	document.getElementById('message').style.height = '50px';
	//form requesting part
	httpobj = new newObject();
	httpobj.onreadystatechange=function()
	{
		if(httpobj.readyState==4)
		{
			var respose = httpobj.responseText;
			document.getElementById('message').innerHTML = respose;
			newHeight('205');
		}
	}
	if(req)
	httpobj.open("GET","/community/ajax_request_form.php?uname="+uname,true);
	else
	httpobj.open("GET","/community/ajax_message.php?uname="+uname,true);
	httpobj.send(null);
}
function hideArea(id)
{
	var hspeed = 5;
	var time = 0;
	for(i = 100; i >= 0; i--) 
	{
		setTimeout("changeOpac(" + i + ",'" + id + "')",(time * hspeed));
		time++;
	}
}
function changeOpac(opacity, id) 
{
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	if(opacity == 0)
		document.getElementById(id).setAttribute('style',"z-index:'-1';");
}
function newHeight(newvalue)
{
	new_height = (parseInt(document.getElementById('message').style.height) + 5);
	if(new_height < newvalue) 
	{
		
		document.getElementById('message').style.height = new_height+'px';
		setTimeout('newHeight('+newvalue+')',50);
	}
}
function newObject()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
		return xmlhttp;
	}
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		return xmlhttp;
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
}
function logIn()
{
	if(confirm("sorry, only members are allowed to send messages and requests. click ok to proceed to login page"))
		window.location ="../login.php";
}

