function news_switch(n)
{
 if (document.getElementById(n).className=="block active") document.getElementById(n).className="block";
  else document.getElementById(n).className="block active";
}


function getXmlHttp()
{
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined')  xmlhttp = new XMLHttpRequest();
  return xmlhttp;
}


function postmail()
{

   var params="";


   params=params+"&t1=" + encodeURIComponent(document.getElementById("T1").value);
//   params=params+"&t2=" + encodeURIComponent(document.getElementById("T2").value);
//   params=params+"&t3=" + encodeURIComponent(document.getElementById("T3").value);
   params=params+"&t4=" + encodeURIComponent(document.getElementById("T4").value);
   params=params+"&t5=" + encodeURIComponent(document.getElementById("T5").value);
   params=params+"&t6=" + encodeURIComponent(document.getElementById("T6").value);
   params=params+"&t7=" + encodeURIComponent(document.getElementById("T7").value);
   params=params+"&t8=" + encodeURIComponent(document.getElementById("T8").value);
   params=params+"&t9=" + encodeURIComponent(document.getElementById("T9").value);
   params=params+"&t10=" + encodeURIComponent(document.getElementById("T10").value);
   params=params+"&t11=" + encodeURIComponent(document.getElementById("T11").value);
   params=params+"&t12=" + encodeURIComponent(document.getElementById("T12").value);
   params=params+"&t13=" + encodeURIComponent(document.getElementById("T13").value);
   params=params+"&t14=" + encodeURIComponent(document.getElementById("T14").value);
   params=params+"&t15=" + encodeURIComponent(document.getElementById("T15").value);
   params=params+"&t16=" + encodeURIComponent(document.getElementById("T16").value);
   params=params+"&t17=" + encodeURIComponent(document.getElementById("T17").value);
//   params=params+"&t18=" + encodeURIComponent(document.getElementById("T18").value);
//   params=params+"&t19=" + encodeURIComponent(document.getElementById("T19").value);
   params=params+"&t20=" + encodeURIComponent(document.getElementById("T20").value);
   params=params+"&t21=" + encodeURIComponent(document.getElementById("T21").value);
   params=params+"&t50=" + encodeURIComponent(document.getElementById("T50").value);
   if (document.getElementById("T22").checked) params=params+"&t22=1"; else params=params+"&t22=0";
   params=params+"&t23=" + encodeURIComponent(document.getElementById("T23").value);


    
   var xmlhttp = getXmlHttp();

   xmlhttp.open("POST", "/ru/send/"+Math.random(), true);
   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   xmlhttp.send(params);
   
   xmlhttp.onreadystatechange = function() 
    {
     if (xmlhttp.readyState==4 && xmlhttp.status==200 && xmlhttp.responseText)
      {
        if (xmlhttp.responseText=="1") alert("Необходимо заполнить поля, отмеченные звездочкой");
        if (xmlhttp.responseText=="2") alert("Необходимо согласиться с правилами поведения в Хостеле");
        if (xmlhttp.responseText!="1" && xmlhttp.responseText!="2") document.getElementById("form").innerHTML='<p>Благодарим Вас за обращение в GRAFFITI HOSTEL! Вами сделан запрос на бронирование. Заказанные Вами услуги не забронированы до подтверждения хостелом. Наш менеджер ответит на Ваш запрос в течение 24 часов.</p>';



      };
    };


};
function postmail_e()
{

   var params="";

   if (document.getElementById("T22").checked=="false") {  
    alert("You must fill all required fields   ");
    return false;
   }


   params=params+"&t1=" + encodeURIComponent(document.getElementById("T1").value);
//   params=params+"&t2=" + encodeURIComponent(document.getElementById("T2").value);
//   params=params+"&t3=" + encodeURIComponent(document.getElementById("T3").value);
   params=params+"&t4=" + encodeURIComponent(document.getElementById("T4").value);
   params=params+"&t5=" + encodeURIComponent(document.getElementById("T5").value);
   params=params+"&t6=" + encodeURIComponent(document.getElementById("T6").value);
   params=params+"&t7=" + encodeURIComponent(document.getElementById("T7").value);
   params=params+"&t8=" + encodeURIComponent(document.getElementById("T8").value);
   params=params+"&t9=" + encodeURIComponent(document.getElementById("T9").value);
   params=params+"&t10=" + encodeURIComponent(document.getElementById("T10").value);
   params=params+"&t11=" + encodeURIComponent(document.getElementById("T11").value);
   params=params+"&t12=" + encodeURIComponent(document.getElementById("T12").value);
   params=params+"&t13=" + encodeURIComponent(document.getElementById("T13").value);
   params=params+"&t14=" + encodeURIComponent(document.getElementById("T14").value);
   params=params+"&t15=" + encodeURIComponent(document.getElementById("T15").value);
   params=params+"&t16=" + encodeURIComponent(document.getElementById("T16").value);
   params=params+"&t17=" + encodeURIComponent(document.getElementById("T17").value);
//   params=params+"&t18=" + encodeURIComponent(document.getElementById("T18").value);
//   params=params+"&t19=" + encodeURIComponent(document.getElementById("T19").value);
   params=params+"&t20=" + encodeURIComponent(document.getElementById("T20").value);
   params=params+"&t21=" + encodeURIComponent(document.getElementById("T21").value);
    params=params+"&t50=" + encodeURIComponent(document.getElementById("T50").value);
   if (document.getElementById("T22").checked) params=params+"&t22=1"; else params=params+"&t22=0";
   params=params+"&t23=" + encodeURIComponent(document.getElementById("T23").value);


    
   var xmlhttp = getXmlHttp();

   xmlhttp.open("POST", "/ru/send/"+Math.random(), true);
   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   xmlhttp.send(params);
   
   xmlhttp.onreadystatechange = function() 
    {
     if (xmlhttp.readyState==4 && xmlhttp.status==200 && xmlhttp.responseText)
      {
       if (xmlhttp.responseText=="1") alert("You must fill all required fields   ");
       if (xmlhttp.responseText=="2") alert("You must agree to the Rules");
       if (xmlhttp.responseText!="1" && xmlhttp.responseText!="2") document.getElementById("form").innerHTML='<p>Thank you for your inquiry to GRAFFITI HOSTEL. You have made a reservation request. Your reservation is not confirmed unless you receive our confirmation letter. Our reservation manager will contact you within 24 hours.</p>';
      };
    };


};

function fsw(n)
{
 if (document.getElementById(n).className=="active")
  {
   document.getElementById(n).className="pass";
   document.getElementById("T23").value="0";
  }
  else 
  {
   document.getElementById(n).className="active";
   document.getElementById("T23").value="1";
  }
}






