function wpopup(url,h,w,features,center,n) {
	if (center==1) {
		ytop=Math.floor((screen.height-h)/2);
		ftop = "top="+ytop;
		left=Math.floor((screen.width-w)/2);
		fleft = "left="+left;
	}
	var feat="";
	if (ftop || fleft) {
		feat=ftop+","+fleft+",";
	}
	feat+="height="+h+",width="+w;
	feat+=(features!="")?(","+features):"";
	var win = window.open(url,(!n)?"newwin":n,feat);
	return win
}

function codeKeyPress(evt, Field) {
	var code = 0;
	if (evt.keyCode) code = evt.keyCode;
	else if (evt.which) code = evt.which;
	else if (evt["keyCode"]) code = evt["keyCode"];
	else return false;
	if (code < 32) {
		return true;
	} else if (!document.all && ((code == 45) || (code == 46))) {
		return true;
	}
	var PrevText = Field.value;
	var KeyCode = String.fromCharCode(code);
	var m;
	if (PrevText.length > 0) {
		m = KeyCode.match((/^[abekmhopctxABEKMHOPCTXàâåêìíîðñòõÀÂÅÊÌÍÎÐÑÒÕ]$/));
	} else {
		m = KeyCode.match((/^[BbHhÂâÍí]$/));
	}
	if (m) return true;
	evt.cancelBubble = true;
	evt.returnValue = false;
	return false;
}

function numberKeyPress(evt, Field) {
	var code = 0;
	if (evt.keyCode) code = evt.keyCode;
	else if (evt.which) code = evt.which;
	else if (evt["keyCode"]) code = evt["keyCode"];
	else return false;
	if (code < 32) {
		return true;
	} else if (!document.all && ((code >= 33) && (code <= 40))) {
		return true;
	}
	var AllowedChars = "0123456789";
	var PrevText = Field.value;
	var KeyCode = String.fromCharCode(code);
	if (AllowedChars.indexOf(KeyCode) < 0) {
		evt.cancelBubble = true;
		evt.returnValue = false;
		return false;
	}
	return true;
}

function _(u,s) {
	location.href = 'mailto:'+u+'@'+s
}

function CtrlEnter(e) {
	if (!isMozilla) e = event;
	if ((e.ctrlKey) && ((e.keyCode==10)||(e.keyCode==13))) {
		txt = getSel()
		new Ajax.Updater('_ajax',
						 '/pcgi/send_mistype.pl?text='+encodeURIComponent(txt)+'&page='+location.href,
						 {method: 'get', onSuccess: info})
	}
}

function info() {
	alert('Îïå÷àòêà îòïðàâëåíà!')
}

document.onkeypress=CtrlEnter;

function getSel() {
	var txt = '';
	var foundIn = '';
	if (window.getSelection) {
		txt = window.getSelection();
	} else if (document.getSelection) {
		txt = document.getSelection();
	} else if (document.selection) {
		txt = document.selection.createRange().text;
	} else return;
	return txt;
}

