function mto(name, server, country, get) {
	mai = "mai";
	mai += "lto: " + name;
	mai += "@";
	mai += server;
	mai += ".";
	mai += country;
	window.location = mai + get;
}

function show_text(id, text, time){
  var x = document.getElementById(id);
  x.innerHTML = text; 
  id_ = id;
  window.setTimeout("hidd_text(id_)", time);
}

function hidd_text(id){
  var x = document.getElementById(id);
  x.innerHTML = ''; 
}

function full_open(adress, width, height){
  window.open(adress, "preview", "toolbar=no, location=no, directiones=no, status=no, menubar=no, scrollbars=no, resizable=no, width= " + width + ", height=" + height);
}

var xmlHttp;
xmlHttp = createXmlHttpRequestObject();

//function crate xml request object
//
function createXmlHttpRequestObject() {

    var xmlHttp;

    //noinspection JSUnusedLocalSymbols
    try {
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {

        var XmlHttpVersions;
        XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                "MSXML2.XMLHTTP.5.0",
                "MSXML2.XMLHTTP.4.0",
                "MSXML2.XMLHTTP.3.0",
                "MSXML2.XMLHTTP",
                "Microsoft.XMLHTTP");

        for (var i = 0; i < XmlHttpVersions.length && !xmlHttp; i++) {

            //noinspection JSUnusedLocalSymbols
            try {
                xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
            }
            catch (e) {
                alert(e.toString());
            }

        }

    }
    if (xmlHttp) {
        return xmlHttp;
    }
    else {
        alert("Error creating the XMLHttpRequest object.");
        return false;
    }
}
//
//end function


//function of send and validate input text
//
function calendar(adress, day, month, year, wh) {
  
    if (xmlHttp) {

        try {
            sendParameters = "day=" + day  + "&month=" + month +  "&year=" + year +  "&resp=" + wh;
            xmlHttp.open("POST", adress + "/response.php", true);
            xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xmlHttp.onreadystatechange = handleRequestStateChange;
            xmlHttp.send(sendParameters);
        }
        catch (e) {
            alert("Can't connect to server :\n" + e.toString());
        }

    }
}
//
//end function


//handle request state change
//
function handleRequestStateChange() {

    if (xmlHttp.readyState == 4) {

        if (xmlHttp.status == 200) {

            try {
                serverResponse();
            }
            catch(e) {
                alert("Error reading the response: " + e.toString());
            }

        }
        else {
            alert("There was a problem retrieving the data:\n" + xmlHttp.statusText);
        }

    }

}
//
//end function


//function of validate response
//
function serverResponse() {
  
    var responseText;
    responseText = xmlHttp.responseText;
    var x = document.getElementById("cal_input");
    x.innerHTML = responseText;

}

function calOn(id, color, buff, from, to){
  clearCal(buff);
  var x = document.getElementById(id);
  x.style.background = "#0054e3";
  x.style.color = "#fff";
  
  x = document.getElementById(from);
  var y = document.getElementById(to);
  y.innerHTML = x.innerHTML;
  
  x = document.getElementById(buff);
  x.innerHTML = id + "|" + color;
}

function clearCal(id){
  var x = document.getElementById(id);
  x = x.innerHTML;
  
  if (x != ""){
    x = x.split("|");
    
    var y = document.getElementById(x[0]);
    y.style.color = "#000";
    y.style.background = x[1];
  }
}



function occup(adress, lodge, room, day, month, year, wh) {

    if (xmlHttp) {

        try {
            sendParameters = "adress=" + adress + "&lodge=" + lodge + "&room=" + room + "&day=" + day  + "&month=" + month +  "&year=" + year +  "&resp=" + wh;
            xmlHttp.open("POST", adress + "/response.php", true);
            xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            xmlHttp.onreadystatechange = handleRequestStateChangeOccup;
            xmlHttp.send(sendParameters);
        }
        catch (e) {
            alert("Can't connect to server :\n" + e.toString());
        }

    }
}


function handleRequestStateChangeOccup() {

    if (xmlHttp.readyState == 4) {

        if (xmlHttp.status == 200) {

            try {
                serverResponseOccup();
            }
            catch(e) {
                alert("Error reading the response: " + e.toString());
            }

        }
        else {
            alert("There was a problem retrieving the data:\n" + xmlHttp.statusText);
        }

    }

}

function serverResponseOccup() {

    var responseText;
    responseText = xmlHttp.responseText;
    responseText = responseText.split('|');
    var x = document.getElementById(responseText[0]);
    x.innerHTML = responseText[1];

}

function chnClass(id, state){
  if (state == 'visible'){
    document.getElementById(id).style.visibility = "visible";
  }
  else if (state == 'hidden'){
    document.getElementById(id).style.visibility = "hidden";
  }
}

function chnBackground(id, state, menu){

    if (state == 'hover'){
      document.getElementById(id).className = "ie_" + menu;
    }
    else if (state == 'out'){
      document.getElementById(id).className = "";
    }

}

function show_image(url){
  window.open(url, "image", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no");
}