$(function(){
	var anchors = document.getElementsByTagName('a');
	for (var i=0; i<anchors.length; i++) {
		var a = anchors[i];
		if (a.getAttribute('href') && (a.getAttribute('rel')+'').indexOf('external', 0) !== -1 ) {
			a.target = '_blank';
		}
	}
	if(registred_user === true) {
		$(document).keyboard(['ctrl', '0'], function(){
			var selection = (document.all)? document.selection.createRange().text:((window.getSelection)? window:document).getSelection().toString();
			var page = window.location.href;
			var prompt_text = selection == '' ? 'Please leave comment about page' : 'Please leave comment about selected text:'+"\n"+'"'+selection+'"';
			var comment = prompt('Spelling error report:'+"\n"+prompt_text);
			if(comment !== null) {
				$.ajax({
					url: WEB_ROOT+'note.html',
					data: {text: selection, message: comment, page: page},
					type: 'POST',
					success: function(){
						alert('Comment sent');
					}, error: function(){
						alert('Error sending comment :(');
					}
				});
			}
			
		});
		setTimeout(function(){
			$('.spell-error-tip').fadeOut('slow');
		}, 2000);
	}
});

