	function reloadFriends(iOwner, sAplha){
		window.location = "viewFriends.php?iUser="+iOwner+"&alphabet="+sAplha;
	}
	
	function checkFriendForm() {
		var el;
		var hasErr = false;
		var fild = "";

		if(!isFriendsChecked('compose_form')){
			alert( "please select at least one friend first!" )
			return false;
		}
		
		if(document.compose_form.actionType.value=="message"){ 
			el = document.getElementById("inpSubj");
			if( el.value.length == 0 ) {
				el.style.backgroundColor = "pink";
				el.style.border = "1px solid silver";
				hasErr = true;
				fild += " : Subject";
			} else
				el.style.backgroundColor = "#fff";

			 /*
			el = document.getElementById("inpMessage");
			if( el.value.length == 0 ) {
				el.style.backgroundColor = "pink";
				el.style.border = "1px solid silver";
				hasErr = true;
				fild += " : Message";
			} else
				el.style.backgroundColor = "#fff";
			*/
			
			if (hasErr) {
				alert( "please fill in these fields first!" + fild )
				return false;
			} else {
				return true;
			}
		} 
	}

	function hidShowDivs(id){
		var arrDiv = ['send_message_form', 'send_group_inv_form', 'send_event_inv_form'];

		for(i=0; i<arrDiv.length; i++){
			document.getElementById(arrDiv[i]).style.display = 'none';
		}
		document.getElementById(id).style.display = 'block';
	}

	function setInviteValue(obj,id){ 
		if(obj.checked){
			document.getElementById("invites_"+id).value = id;
			document.getElementById("friends_"+id).value = id;
		}else{
			document.getElementById("invites_"+id).value = 0;  
			document.getElementById("friends_"+id).value = 0;
		}
	}

	function setAllInvites( formName, _pref, doCheck ) {
		_form = document.forms[formName];
		
		if( !_form )
			return false;
		
		for( ind = 0; ind < _form.length; ind ++ ) {
			_elem = _form[ind];

			if( _elem.type != 'checkbox' )
				continue;

			if( _elem.name.substr( 0, _pref.length ) != _pref )
				continue;

			_elem.checked = doCheck;

			setInviteValue(_elem, _elem.id);

		}
	}

	//checks if at least one checkbox is checked
function isFriendsChecked( formName ) {
	_form = document.forms[formName];
	
	if( !_form )
		return false;
	
	for( ind = 0; ind < _form.length; ind ++ ) {
		_elem = _form[ind];

		if( _elem.type != 'checkbox' )
			continue;

		if(_elem.checked)
			return true;
	}
	return false;
}
 
function getTopFriendsData( elemID, url ) 
{
	var elem = document.getElementById( elemID );
	
	if( !elem || !url )
		return false;
	
	var url = url + '&r=' + Math.random();
	
	
	var oXMLHttpReq = createXmlHttpObj();
	
	if( !oXMLHttpReq )
		return false;
	
	elem.innerHTML = '<div class="loading"><img src="'+urlIconLoading+'"></div>';
	
	oXMLHttpReq.open( "GET", url );
	oXMLHttpReq.onreadystatechange = function()
	{
		if ( oXMLHttpReq.readyState == 4 && oXMLHttpReq.status == 200 )
		{
			sNewText = oXMLHttpReq.responseText;
			//elem.innerHTML = sNewText;
			 		
			eval( sNewText );  
		}
	}
	oXMLHttpReq.send( null );
}
