window.addEvent('domready', function(){
	try{
		// enable switching syntax
		if ($('select_syntax')){
			$('select_syntax').addEvent('change', function(oEvent){
				var s_location = document.location.pathname, i_revision = false, a_match, a_paste;
				
				a_match = s_location.match(/\/rev\/([0-9]+)(?:\/?)/);
				if (a_match !== null && a_match.length > 0){
					i_revision = a_match[1];
				}
				
				a_paste = s_location.match(/^\/(public|private)\/([0-9a-zA-Z]+)(?:\/?)/);
				location = '/' + a_paste[1] + '/' + a_paste[2] + '/' + (i_revision !== false ? 'rev/' + i_revision + '/' : '') + $(oEvent.target).value + '/';
			});
		}
		
		// fix report button
		if ($('report_link')){
			$('report_link').addEvent('click', function(oEvent){
				oEvent.stop();
				
				(new Request({
					'url': '/report' + this.pathname, 
					'method': 'post',
					'data': $H({
						'paste': this.pathname
					}).toQueryString(),
					'onComplete': function(){
						if ($('report_paste')){
							$('report_paste').setStyle('visibility', 'hidden');
						}
					}
				})).send();
			});
		}
		
		// delete link
		if ($('delete_link')){
			$('delete_link').addEvent('click', function(oEvent){
				return confirm('sure?');
			});
		}
	} catch(o_exeception){ }
});
