// JavaScript Document


function popitup(url) {
	newwindow=window.open(url,'name','height=250,width=250');
	if (window.focus) {newwindow.focus()}
	return false;
}


   function loadContent() {
	   document.getElementById('showloader').style.display = 'none';
	   document.getElementById('showinfo').style.display = 'block';
   }

   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { 
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) {
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            document.getElementById('showinfo').innerHTML = result;
			document.onload = loadContent();
         } else {
            alert('Klaida siunčiant HTTP užklausą.');
         }
      }
   }
   
   function stepTwo1(obj) {
      var poststr = "customer=" + encodeURI( document.getElementById('customer1').value );
      makePOSTRequest('/hb/src/steptwo.php', poststr);
	  document.getElementById('showloader').style.display = 'block';
	  document.getElementById('showinfo').style.display = 'none';
   }

   function stepTwo2(obj) {
      var poststr = "customer=" + encodeURI( document.getElementById('customer2').value );
      makePOSTRequest('/hb/src/steptwo.php', poststr);
   }
   
      function stepThree1(obj) {
      var poststr =	"street=" + encodeURI( document.getElementById('street').value ) +
					"&personcode=" + encodeURI( document.getElementById('personcode').value ) +
					"&city=" + encodeURI( document.getElementById('city').value ) +
					"&vardas=" + encodeURI( document.getElementById('vardas').value ) +
					"&email=" + encodeURI( document.getElementById('email').value ) +
					"&postcode=" + encodeURI( document.getElementById('postcode').value ) +
					"&telephone=" + encodeURI( document.getElementById('telephone').value );
      makePOSTRequest('/hb/src/stepthree.php', poststr);
	  document.getElementById('showloader').style.display = 'block';
	  document.getElementById('showinfo').style.display = 'none';
   }
   
   
      function stepThree2(obj) {
      var poststr =	"company=" + encodeURI( document.getElementById('company').value ) +
					"&companycode=" + encodeURI( document.getElementById('companycode').value ) +
					"&vatcode=" + encodeURI( document.getElementById('vatcode').value ) +
	  				"&vardas=" + encodeURI( document.getElementById('vardas').value ) +
					"&street=" + encodeURI( document.getElementById('street').value ) +
					"&city=" + encodeURI( document.getElementById('city').value ) +
					"&fax=" + encodeURI( document.getElementById('fax').value ) +
					"&email=" + encodeURI( document.getElementById('email').value ) +
					"&postcode=" + encodeURI( document.getElementById('postcode').value ) +
					"&telephone=" + encodeURI( document.getElementById('telephone').value );
      makePOSTRequest('/hb/src/stepfour.php', poststr);
	  document.getElementById('showloader').style.display = 'block';
	  document.getElementById('showinfo').style.display = 'none';
   }


