/**
 * @author CTAC
 */

GBDowload = {
	
	linkPrefix  : 'http://gameboss.ru/getfile.php?url=http://gameboss.ru/download/',
	
	elementSelector : '.gbdownload',
	
	download : function(link) {
		window.open(link, '_blank', 'scrollbars=no,menubar=no,titlebar=no,resizable=no,width=500, height=50');
	},
	
	buildLinks: function(){
		$$(GBDowload.elementSelector).invoke('observe', 'click', function(){
			link = GBDowload.buildLink(this);
			if (link) {
				GBDowload.download(link);
			}
		})
	},
	
	buildLink: function(element){
		element = $(element);
		if (element.readAttribute('fname')) {
			return GBDowload.linkPrefix + element.readAttribute('fname');
		}
		return false;
	}
}

document.observe('dom:loaded', GBDowload.buildLinks);