function popup(name,url,wwidth,wheight) {
	
	var left = parseInt((screen.width - wwidth) / 2);
	var top = parseInt((screen.height - wheight) / 2);
				
	var win = window.open(url,name + $random(10000,99999),'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=' + wwidth + ',height=' + wheight + ',top=' + top + ',left=' + left + ',screenX=' + left + 'screenY=' + top);
}

window.addEvent('domready', function() {
	
	['addfriend','sendmessage'].each(function(item,index) {
		var option = $(item);
		if (option) {
			option.addEvent('click',function(event) {
				event.stop();
				var url = this.getProperty('href');
				
				
				if (item == 'addfriend') {
					height = 200;	
				} else if (item == 'sendmessage') {
					height = 550;	
				}
								
				popup(item,url,500,height);
			});	
		}
	});
	
	var profile = $('profile');
	if (profile) {
		profile.getElements('li.mediamenuitem').addEvents({
			'click' : function() {
				window.location.href = this.getFirst().get('href');
			},
			'mouseover' : function() {
				this.set('class','mediamenuitemselected');
			},
			'mouseout' : function() {
				this.set('class','mediamenuitem');
			}
		});	
	}

});
