function doLoad()
{
	if (document.getElementById('inpOrph').innerHTML.length < 1)
	{
		document.getElementById('ansOrph').innerHTML = 'Вы не выделили текст ошибки. Выделите и нажмите ctrl+enter'; 
		return;
	}
	
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open('POST', 'orph.php', true);
	oXmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	oXmlHttp.onreadystatechange = function () {
		if (oXmlHttp.readyState == 4) {
			if (oXmlHttp.status == 200) 
			{
				document.getElementById('ansOrph').innerHTML = oXmlHttp.responseText;
				doPos('ansOrphCont');
				doShow('ansOrphCont');
				doHide('contOrph');
			}
		}	
	}; oXmlHttp.send('e='+encodeURIComponent(document.getElementById('inpOrph').innerHTML)+'&c='+encodeURIComponent(document.getElementById('commOrph').value)+'&u='+encodeURIComponent(sUrl));
}
function putSel(txt)
{
	if (txt.length < 3)
	{
		document.getElementById('inpOrph').innerHTML = 'Вы не выделили текст ошибки. Выделите и нажмите Ctrl+Enter.';	
	}else{
		document.getElementById('inpOrph').innerHTML = 'В выражении "' + txt + '" замечена ошибка.';
	}
}
function getSel()
{
	var txt = '';
    if (window.getSelection){
        txt = window.getSelection();
    }
    else if (document.getSelection){
        txt = document.getSelection();
    }
    else if (document.selection){
		txt = document.selection.createRange().text;
    }
	return txt;
}
function kH(e)
{
	var pressed=0;
    var we = null;
    if (window.event) we = window.event;
    else if (parent && parent.event) we = parent.event;
    if (we) {
      pressed = we.keyCode==10 || (we.keyCode == 13 && we.ctrlKey);
    } else if (e) {
      pressed = 
        (e.which==10 && e.modifiers==2) ||
        (e.keyCode==0 && e.charCode==106 && e.ctrlKey) ||
        (e.keyCode==13 && e.ctrlKey)
    }
    if (pressed) {
		putSel(getSel());
		doEmptyInp('commOrph');
		doHide('ansOrphCont');
		doPos('contOrph');
		doShow('contOrph');
	}
}
function doHide(divName){
	document.getElementById(divName).style.display = 'none';
}
function doShow(divName){
	document.getElementById(divName).style.display = 'block';
}
function doEmptyInp(inpName){
	document.getElementById(inpName).value = '';
}
function doPos(divName){
	document.getElementById(divName).style.top = document.body.scrollTop + 300 +"px";
}
document.onkeypress = kH;