var w = '';
$(function(){
	$("a[@rel$=filemanagerPopup]").each(function(){
		$(this).click(function(){
			url = $(this).attr('href');
			
			// Get ModelNamve and RelID from URL
			v = url.split('/');
			c = v.length;
			model = v[c-2];
			relid = v[c-1];
			
			name = 'filemanager' + model + relid;
			options = 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=600,width=766';
			
			if(!w.closed && w.location){w.focus();return false}
			else{w = window.open(url, name, options);w.focus()}
			return false;
		});
	});
});
