/**
 * This method calls the webservice to check whether the selected managed stream
 * has a workflow of broadcasting, and if it is registered, then create an 
 * activity record and wait until coast is clear
 */
function getChatOperators() {
	$.ajax(
		{
			type: 'GET',
			url: 'ws/lookupChatOperators.jsp',
			dataType: 'xml',
			timeout: 10000,
			success: function(xml) {
						// Check whether an error has occured looking up the token status
						var statusOfResponse = $(xml).find('response').attr('status');					
						if (statusOfResponse == "response") {
							// No error has start processing the girls...
							var $number_girls = 0;
							// Find each node which represents a girl
							$(xml).find('chatoperator').each(function(){
                        		$number_girls = $number_girls + 1;
	                       		if ($number_girls <= 5 ) {
	                        		// get the data and update the elements in the dom		
	                        		var $id_text = $(this).attr('id');
	                         		var $server_text = $(this).attr('server');
	                         		var $name_text = $(this).find('name').text();
	                         		var $img_url_text = $(this).find('image').text();                         		
	                         		var $status_text = $(this).find('status').text();	                         		
									$("#img_"+$number_girls).attr("src", $img_url_text);
									$("#link_"+$number_girls).attr("href", 'http://elitetvcams.com/chat.jsp?SUID='+$id_text+'&env='+$server_text);
									$("#name_"+$number_girls).text($name_text);
									if ($status_text == 'available') {
										$("#status_"+$number_girls).attr("src", "images/online.gif");	
									} else if ($status_text == 'busy') {
										$("#status_"+$number_girls).attr("src", "images/online.gif");										
									} else if ($status_text == 'offline') {
										$("#status_"+$number_girls).attr("src", "images/busy.gif");										
									}														
	                       		}							
							});							
							setTimeout("getChatOperators()", 15000);	//Javascript's delay timer for 5000 miliseconds
						} else {
							// Simply try again later
							setTimeout("getChatOperators()", 15000);	//Javascript's delay timer for 5000 miliseconds
						}
					},
			error: function() {
				setTimeout("getChatOperators()", 5000);	//Javascript's delay timer for 5000 miliseconds
			}
		}
	);	
}
