window.addEvent( 'domready', function(){
	// thanks for htmlweb.ru/other/hidden_ref.php
	mydomain = location.href.replace( /\b(https?|ftp):\/\/(www\.)?([\-A-Z0-9.]+)(\/[\-A-Z0-9+&@#\/%=~_|!:,.;]*)?(\?[\-A-Z0-9+&@#\/%=~_|!:,.;]*)?/im, "$3" ); //Вставить получение домена документа
	$$('a').each( function( l ){
		if( l.hostname.indexOf( mydomain )<0 ){
			l.target = '_blank';
			var ldomain = l.href.replace( /\b(https?|ftp):\/\/([\-A-Z0-9.]+)(\/[\-A-Z0-9+&@#\/%=~_|!:,.;]*)?(\?[\-A-Z0-9+&@#\/%=~_|!:,.;]*)?/im, "$2" );
			if( l.onclick==null ){
				l.onclick = new Function( 'this.href="' + l.href + '";' );
				l.href = 'http://' + ldomain + '/';
			}
		} else if( l.pathname.substring(0,4)=='/go/' ){
			l.target = '_blank';
			l.href = l.pathname.replace( /^\/go\/([\s\S]+)$/im, "http://$1" );
			var ldomain = l.href.replace( /\b(https?|ftp):\/\/([\-A-Z0-9.]+)(\/[\-A-Z0-9+&@#\/%=~_|!:,.;]*)?(\?[\-A-Z0-9+&@#\/%=~_|!:,.;]*)?/im, "$2" );
			if( l.onclick==null ){
				l.onclick = new Function( 'this.href="' + l.href + '";' );
				l.href = 'http://' + ldomain + '/';
			}
		}
	});
});

function toggleCommentForm(){
	if( $('commentform').getStyle( 'display' )=='none' ) {
		$('commentform').setStyle( 'display', 'block' );
		$('commentform').morph({ 'opacity': 1 });
	} else {
		(function(){$('commentform').setStyle( 'display', 'none' );}).delay( 500 );
		$('commentform').morph({ 'opacity': 0 });
	}
}

function checkCommentForm( form ){
	if( form.f_Message.value.trim()=='' ){
		alert( 'Пустые комментарии не приветствуются' );
		form.f_Message.focus();
	}
	return false;
}

