function sendRequest(action)
{ 
if (action=='ajax_front_page')
{
var my_rand = Math.random();
http.open('get', 'http://www.rockle.com/yap/claim?logout=user_list&rand=' + my_rand);
http.onreadystatechange = handleOnlineResponse;
http.send(null);
}

} 

function add_buddy(username)
{
if (readCookie('username')==null)
{
var message = 'Please login to add this user as a buddy';
alert(message);
return false;
}
else
{
window.open('http://www.rockle.com/yap/addPersonalContactsServlet?destination='+username+'&app=local','buddy_'+username,'location=0','status=0','resizeable=0','width=300','height=300');
}
}


function createRequestObject()
{

var req;

if(window.XMLHttpRequest)
{

// Firefox, Safari, Opera...

req = new XMLHttpRequest();
} 

else if(window.ActiveXObject)
{

// Internet Explorer 5+

req = new ActiveXObject("Microsoft.XMLHTTP");

} else {

// There is an error creating the object,
// just as an old browser is being used.

alert('Problem creating the XMLHttpRequest object');

}

return req;

}




// Make the XMLHttpRequest objects

var http = createRequestObject();

var http_1 = createRequestObject();




function compose_message(link)
{

if (readCookie('username')==null)
{
alert('Please login to access inbox. You need to login to your inbox to send and receive messages...');
return false;
}
else
{
window.open(link,"inbox");
return false;
}

}


function startim(name,app)
{

// if not logged in...show dialog else open im window...

if (readCookie('username')==null)
{

alert('Please login to start chatting');

}
else
{

var username = readCookie('username');
var destination = name;
var url = 'http://www.rockle.com/yap/chat/'+username+'/'+name+'/local';
window.open(url,name);

}

}

function openinbox()
{
if (readCookie('username')==null)
{

alert('Please login to access your inbox');

return false;

}
else
{

window.open('http://www.rockle.com/yap/inbox?app=local','inbox');

return false;

}

}

function readCookie(name) { 
var nameEQ = name + "="; 
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i]; 
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null; 
} 



function handleOnlineResponse()
{ 
if(http.readyState == 4 && http.status == 200)
{
 var response = http.responseText;
if(response)
{ 
document.getElementById("online").innerHTML = response;
}
}
}


window.onload = function() {
document.getElementById('online').innerHTML= '<center><img src="http://www.rockle.com/language/amigo/images/loading.gif"><br><br><font color="777777">Loading user lists...</font></center>';
sendRequest('ajax_front_page');
}

