function click2get(msg_no) {
 if	(msg_no.style.display=='none')	msg_no.style.display="";
 else								msg_no.style.display='none';
}

function click2show(msg_no) {
 if	(msg_no.style.visibility=='hidden')	msg_no.style.visibility='visible';
 else									msg_no.style.visibility='hidden';
}

function image_resize(img, maxwidth) {
	if (img.width > maxwidth) {
		img.width = maxwidth;
		img.height = Math.round(maxwidth/img.width*img.height);
	}
}

function image_resize_both (img, maxw, maxh) {
	maxw = maxw | 400;
	maxh = maxh | 300;
	if ((img.width > maxw) || (img.height > maxh)) {
		if (img.width/maxw >= img.height/maxh) {
			img.width = maxw;
			img.height = Math.round(maxw/img.width*img.height);
		} else {
			img.height = maxh;
			img.width = Math.round(maxh/img.height*img.width);
		}
	}
}

/**
 * Forum functions
 */
function get_selection() {
	if (document.getSelection) {
		return document.getSelection();
	} else {
		return document.selection.createRange().text;
	}
	return '';
}
function p3(sel, kto, section, topic){
	if (!sel) {
		alert('Для вставки цитаты необходимо выделить нужное мышью.');
	} else {
		if (kto) {
			sel = '[quote="' + kto + '"]' + sel + '[/quote] ';
		} else {
			sel = '[quote]' + sel + '[/quote] ';
		}
		document.mesquote.description.value = sel;
		document.mesquote.section.value = section;
		document.mesquote.topicid.value = topic;
		document.mesquote.submit();
	}
}
function rep(kto, section, topic) {
	if (kto) {
		sel = '[b]' + kto + '[/b]';
	} else {
		sel = '';
	}
	document.mesquote.description.value = sel;
	document.mesquote.section.value = section;
	document.mesquote.topicid.value = topic;
	document.mesquote.submit();
}
function private(sel, kto, kto2){
	sel = get_selection();
	if (sel) {
		if (kto) {
			sel = '[quote="'+kto+'"]' + sel + '[/quote] ';
		} else {
			sel = '[quote]' + sel + '[/quote] ';
		}
	}
	document.mesprivate.address.value = kto2;
	document.mesprivate.description.value = sel;
	document.mesprivate.submit();
}


