var xmlHttp = createXmlHttpRequestObject(); 
function createXmlHttpRequestObject() 
{	
  var xmlHttp;
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  if (!xmlHttp)
     alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

var card = 0;
function checkPostcardForm()
	{
	var objF = document.forms['postcardForm'];
	if(card == 0)
		{
		alert("Vyberte jednu z pohlednic.");
		return false;
		}
	if(objF['form_field[usr_name]'].value == "")
		{
		alert("Zadejte vaše jméno.");
		objF['form_field[usr_name]'].focus();
		return false;
		}
	if(objF['form_field[usr_email]'].value == "")
		{
		alert("Zadejte váš e-mail.");
		objF['form_field[usr_email]'].focus();
		return false;
		}
	if(objF['form_field[usr_email]'].value != "")
		{
		var str = objF['form_field[usr_email]'].value;
		var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (!filter.test(str))
			{
			alert("Váš e-mail je v neplatném tvaru.");
			objF['form_field[usr_email]'].focus();
			return false;
			}
		}
	if(objF['form_field[rec_name]'].value == "")
		{
		alert("Zadejte jméno příjemce.");
		objF['form_field[rec_name]'].focus();
		return false;
		}
	if(objF['form_field[rec_email]'].value == "")
		{
		alert("Zadejte e-mail příjemce.");
		objF['form_field[rec_email]'].focus();
		return false;
		}
	if(objF['form_field[rec_email]'].value != "")
		{
		var str = objF['form_field[rec_email]'].value;
		var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (!filter.test(str))
			{
			alert("E-mail příjemce je v neplatném tvaru.");
			objF['form_field[rec_email]'].focus();
			return false;
			}
		}
	if(objF['form_field[usr_message]'].value == "")
		{
		alert("Zadejte zprávu pro příjemce.");
		objF['form_field[usr_message]'].focus();
		return false;
		}
	}
function showCykloMap()
	{
	document.getElementById("map_prew_big").style.width = "908px";
	document.getElementById("map_prew_big").style.height = "638px";
	document.getElementById("map_prew_big").style.visibility = "visible";
	}
function hideCykloMap()
	{
	document.getElementById("map_prew_big").style.width = "0px";
	document.getElementById("map_prew_big").style.height = "0px";
	document.getElementById("map_prew_big").style.visibility = "hidden";
	}
function gameStatus(value)
    {
    window.status = value;
    //alert(value);
    process(value);
    }

function process(statLevel)
{
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
  	//alert(statLevel);
    xmlHttp.open("GET", "js/stats.php?level="+statLevel, true);
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(null);
  }
  else
    // if the connection is busy, try again after one second  
    setTimeout('process(statLevel)', 1000);
}

function handleServerResponse() 
{
  if (xmlHttp.readyState == 4) 
  {
    if (xmlHttp.status == 200) 
    {      
      //myResult = xmlHttp.responseText;
      //document.getElementById("popup_news_form").innerHTML = myResult;
    } 
    else 
    {
      //alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}

function closePromo(){
	document.getElementById("promoBox").style.visibility = "hidden";
	document.getElementById("promoBox").style.width = "0px";
	document.getElementById("promoBox").style.height = "0px";
	}
