function basename (path, suffix) {
	// Returns the filename component of the path  
	// 
	// version: 1004.2314
	// discuss at: http://phpjs.org/functions/basename
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Ash Searle (http://hexmen.com/blog/)
	// +   improved by: Lincoln Ramsay
	// +   improved by: djmix
	// *     example 1: basename('/www/site/home.htm', '.htm');
	// *     returns 1: 'home'
	// *     example 2: basename('ecra.php?p=1');
	// *     returns 2: 'ecra.php?p=1'
	var b = path.replace(/^.*[\/\\]/g, '');
	
	if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
		b = b.substr(0, b.length-suffix.length);
	}
	
	return b;
}

var rvc = {//Realtour View Controller
	initialize: function(options){
		rvc.scanPage();
	},
	scanPage: function(){
		var links = $$("a").filter(function(el) {
			return el.rel && el.rel.test(/^lightbox/i);
		});
		$$(links).mediabox(
			{
				defaultWidth: (window.getWidth() - 125),
				defaultHeight: (window.getHeight() - 80)
			},
			function(el) {
				elrel = el.rel.split(/[\[\]]/);
				elrel = elrel[1];
//				el.title = ' - <span>Powered By: <a href="http://www.realtour.it" title="Realtour" target="_blank">Realtour</a></span>';
				return [el.href, el.title, elrel];
			}, 
			function(el) {
				var rel0 = this.rel.replace(/[[]|]/gi," ");
				var relsize = rel0.split(" ");
				return (this == el) || ((this.rel.length > 8) && el.rel.match(relsize[1]));
			}
		);
	}
};

window.addEvent('domready',function(){
	rvc.initialize();
});

