function preRequest() {
                var http_request = false;
                if (window.XMLHttpRequest) { // Mozilla, Safari,...
                    http_request = new XMLHttpRequest();
                    if (http_request.overrideMimeType) {
                        // See note below about this line
                    }
                } else if (window.ActiveXObject) { // IE
                    try {
                        http_request = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch (e) {
                        try {
                            http_request = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (e) {}
                    }
                }
                if (!http_request) {
                  alert('Ошибка при создании XMLHTTP'); return false;
                }
		return http_request;
	    }

function savecom() {
var co="hform";
url = 'http://' +document.domain+ '/contacts.php';
document.getElementById(co).innerHTML='Идёт передача данных.';
alert(document.getElementById(co).innerHTML);
var name1=document.getElementById("name").value;
var phone1=document.getElementById("phone").value;
var mail1=document.getElementById("e-mail").value;
var url2=document.getElementById("url").value;
var text1=document.getElementById("text").value;
var keystring1=document.getElementById("keystring").value;
var fromsite1=document.getElementById("fromsite").value;

var sendur="name="+encodeURIComponent(name1)+"&phone="+encodeURIComponent(phone1)+"&e-mail="+encodeURIComponent(mail1)+"&url="+encodeURIComponent(url2)+"&text="+encodeURIComponent(text1)+"&keystring="+encodeURIComponent(keystring1)+"&fromsite="+encodeURIComponent(fromsite1);
http_request = preRequest();
                http_request.onreadystatechange = function() {
	// 4 - данные готовы для обработки
                if (http_request.readyState == 4) {
                      if (http_request.status == 200) {

document.getElementById(co).innerHTML=http_request.responseText;

                    } else {
                        document.getElementById(co).innerHTML='Ошибка связи';
                    }
            }
}


                http_request.open('POST', url, true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=windows-1251');
                http_request.send(sendur);


}