function rep(){
//	alert('Сегодня, 25 декабря, в разделе "Новости" ведутся технические работы...');
//аАеЕмМНоОрРсСТухХ	
	var bod=document.getElementById('body').innerHTML;
	bod=bod.replace(/а/g, "a");
	bod=bod.replace(/А/g, "A");
	bod=bod.replace(/е/g, "e");
	bod=bod.replace(/Е/g, "E");
	bod=bod.replace(/М/g, "M");
	bod=bod.replace(/Н/g, "H");
	bod=bod.replace(/о/g, "o");
	bod=bod.replace(/О/g, "O");
	bod=bod.replace(/р/g, "p");
	bod=bod.replace(/Р/g, "P");
	bod=bod.replace(/с/g, "c");
	bod=bod.replace(/С/g, "C");
	bod=bod.replace(/Т/g, "T");
	bod=bod.replace(/у/g, "y");
	bod=bod.replace(/х/g, "x");
	bod=bod.replace(/Х/g, "X");
//	alert(bod);
 document.getElementById('body').innerHTML=bod;
}

function keyAction(e)
{
    if ( e.shiftKey || e.altKey || !e.ctrlKey) return;
    var Key = e.keyCode;
    if (Key == 0) Key = e.charCode;
    if (!gecko && Key>64 && Key<91) Key += 32;
    var text;
    if (Key==13)
    {        
       if (document.selection) {
            txt=document.selection.createRange().text;
       } else {
            txt=window.getSelection()
       }
       if (txt!="") {
          if (confirm("Вы действильно хотите послать нам "+txt+" ?"))
               process ();
       }
//        e.preventDefault ?
//            e.preventDefault() :
            e.returnValue = false;
    }
   return false;
}

function keyPressInit()
{
    clok();
    if (document.addEventListener)
    {
        document.addEventListener("keypress",
                function(e){keyAction(e)},true);
        if (window.opera) return;
        gecko = true;
    }
    else if (document.attachEvent)
        document.attachEvent("onkeydown", keyAction);
}

var gecko, txt;
txt="";
window.onload = keyPressInit;

var xmlHttp = createXmlHttpRequestObject();
//document.write('WORK');

function createXmlHttpRequestObject()
{
var xmlHttp;

if (window.ActiveXObject)
{
  try
  {
     xmlHttp= new ActiveXObject ("Microsoft.XMLHTTP");
  }
  catch (e)
  {
     xmlHttp = false;
  }
}
else
{
   try
   {
      xmlHttp= new XMLHttpRequest();
   }
   catch (e)
   {
     xmlHttp = false;
  }
}

if (!xmlHttp)
   alert ("Error creating the XmlHttpRequest object.");
else
   return xmlHttp;
} 

function process ()
{
   if (xmlHttp.readyState ==4 || xmlHttp.readyState ==0)
   {
      txt = encodeURIComponent (txt);
      xmlHttp.open("GET","quickstart2.php?txt="+txt,true);
      xmlHttp.onreadystatechange = handleServerResponse;
      xmlHttp.send(null);
   }
   else
      setTimeout ('process()', 1000);
}

function handleServerResponse()
{
   if (xmlHttp.readyState == 4)
   {
      if (xmlHttp.status == 200)
      {
//         xmlResponse = xmlHttp.responseXML;
//         xmlDocumentElement = xmlResponse.documentElement;
         var response = xmlHttp.responseText;
//         helloMessage=xmlHttp.responseXML.getElementsByTagName('response')[0].firstChild.data;
         helloMessage=response;
//         document.getElementById("divMessage").innerHTML='<i>' + helloMessage + '</i>';
//         setTimeout('process()',1000);
         alert ("Ваш текст отправлен на рассмотрение");
      }
      else
      {
         alert("Problem with server: "+xmlHttp.statusText);
      }
   }
}         
