function checkMsgs(txt1,txt2,txt5) 
{
  var obj = document.getElementById("msgs");
  MsgsRequest('checkmsgs.php',obj,txt1,txt2,txt5);
}
function MsgsRequest(url, obj,txt1,txt2,txt5) 
{
   var http_request = false;

   if (window.XMLHttpRequest) 
   { 
       http_request = new XMLHttpRequest();
   } 
   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) return false;
  http_request.onreadystatechange = function() { MsgsCount(http_request,obj,txt1,txt2,txt5); };
  http_request.open('GET',url,true);
  http_request.send(null);
}

function Req(url,target)
{
	var xmlHttp;
	try
  {
  	xmlHttp=new XMLHttpRequest();
  }
	catch (e)
  {
  	try
    {
    	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  	catch (e)
    {
    	try
      {
      	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    	catch (e)
      {
      	ajaxOk=false;
      	return false;
      }
    }
  }
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			//alert(xmlHttp.getAllResponseHeaders());
			document.getElementById(target).innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.Charset = "windows-1250";
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	return true;
}

function MsgsCount(http_request,obj,txt1,txt2,txt5)
{
  if(http_request.readyState==4)
  {
    if(http_request.status==200)
    {
      if(http_request.responseText==0)
      {
       	obj.innerHTML = '';
       	document.title='Undzwei Gaming Portal';
      }
      else
      {
      	if (http_request.responseText==1)
      	{
       		obj.innerHTML = '(<span class="color_orange">' + http_request.responseText + ' ' + txt1 + '</span>)';
        	document.title =  http_request.responseText+' ' + txt1 + ' - Undzwei Gaming Portal';
       	}
       	else if (http_request.responseText>1 && http_request.responseText<5)
       	{
       		obj.innerHTML = '(<span class="color_orange">' + http_request.responseText + ' ' + txt2 + '</span>)';
        	document.title =  http_request.responseText+' ' + txt2 + ' - Undzwei Gaming Portal';
       	}
       	else
       	{
       		obj.innerHTML = '(<span class="color_orange">' + http_request.responseText + ' ' + txt5 + '</span>)';
        	document.title =  http_request.responseText+' ' + txt5 + ' - Undzwei Gaming Portal';
       	}
      }
		  setTimeout('checkMsgs("' + txt1 + '","' + txt2 + '","' + txt5 + '")',60000);
    } 
    else 
    {
      obj.innerHTML = '';
		  setTimeout('checkMsgs("' + txt1 + '","' + txt2 + '","' + txt5 + '")',120000);
    }
  }
}
