var fbTableCopy = FbTablePlugin.extend({
	initialize: function(tableform, options, lang) {
		this.setOptions(tableform, options);
		this.lang = Object.extend({'selectrow':'Please select a row!'}, lang || {});
		window.addEvent('domready', function() {
			var t = this.tableform.getElement('input[name=tableid]');
			//incase its in a viz
			if($type(t) === false){
				return false;
			}
			this.tableid = t.value;
			this.watchButton();
		}.bind(this));
	},
	
	watchButton:function() {
		var button = this.tableform.getElement('input[name='+this.options.name+']');
		if(!button) {
			return;
		}
		button.addEvent('click', function(event) {
			var e = new Event(event);
			e.stop();
			var ok = false;
			this.tableform.getElements('input[name^=ids]').each(function(c) {
				if(c.checked) {
					ok = true;
				}
			});
			if(!ok) {
				alert('Please select a row!');
				return;
			}
			this.tableform.getElement('input[name=fabrik_tableplugin_name]').value = 'copy';
			this.tableform.getElement('input[name=fabrik_tableplugin_renderOrder]').value = button.name.replace('copy-', '');
			oPackage.submitfabrikTable(this.tableid,'doPlugin');
		}.bind(this));
	}
	});