﻿var xmlHttpGuard = createXmlHttpRequestObject(); 

function createXmlHttpRequestObjectBCP() //vytvorenie objektu - XmlHttpRequest
{	
  var xmlHttp;
  if(window.ActiveXObject)	//ak je browser Internet Explorer - pouzije sa komponeneta ActiveX
  {
    try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  else	//Mozilla alebo ine prehliadace - pouzije sa JavaScript objekt
  {
    try { xmlHttp = new XMLHttpRequest(); }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  if (!xmlHttp) alert("Error creating the XMLHttpRequest object.");
  else return xmlHttp;
}

function handleServerResponseBCP() //spusti sa automaticky po prijati spravy zo serveru
{       
  if (xmlHttpGuard.readyState == 4) 	//pokracuj ak je transakcia dokoncena
  {
    if (xmlHttpGuard.status == 200) //200 - uspesne ukoncenie tranzakcie
    { 
    //alert(xmlHttp.responseText);
			var guard = document.getElementById('guardian');									
			if ( guard ) {
				guard.innerHTML = xmlHttpGuard.responseText;
								
				var newScript = document.createElement('script');
				newScript.type = "text/javascript";
				newScript.text = "gd.reloadAntiSpam()";
				document.getElementById('script').appendChild (newScript);

			}
    } 
    else alert("There was a problem accessing the server: " + xmlHttp.statusText);
  }
} 

