var listener = function(type,first,locFromApp)
{
	if(!$('listener_id'))return false;

	loc = document.location.href.substring(document.location.href.indexOf(document.location.hostname)+document.location.hostname.length,document.location.href.length);
	if(locFromApp)loc = locFromApp;

	var lid = $('listener_id').get('value');
	new Request.HTML({url: baseUrl+"listener/"+type+"/"}).send("lid="+lid+"&loc="+loc).addEvents({'onSuccess': function(responseTree, responseElements, responseHTML, responseJavaScript){
		if(responseHTML)
		{
			if(first)
			{
				Sexy.error('<h1>'+lang.attention+'</h1><p>'+responseHTML+'</p>', {onComplete: function() { 
					growlMessage({title: 'Attention',text: responseHTML, duration: 10});
				}});
			}

			else growlMessage({title: 'Attention',text: responseHTML, duration: 10});
		}	
	}});
};

window.addEvent('domready', function() {
	setInterval('listener("set")',30000);
	listener("set",true);
});


window.addEvent('beforeunload', function() {
	listener("remove",false);
});


