function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=windows-1250');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

//   The following function obtains two variables from your form (email and message) 
//   and builds a string that gets sent to your PHP script.  Change this function to
//   obtain whatever fields you want from your form.

function getquerystring() {
    var form     = document.forms['form1'];
    var komentar = form.komentar.value;
    qstr = 'komentar=' + escape(komentar); 
    return qstr;
}

function domovska() {
	document.body.style.behavior = 'url(#default#homepage)';
	document.body.setHomePage('http://www.webgames.cz');
}



function updatepage(str){
    document.getElementById("result").innerHTML = str;
}

function zobrazSkryj(idecko){
el=document.getElementById(idecko).style;
el.display=(el.display == 'block')?'none':'block';
}

function Skryj(idecko){
el=document.getElementById(idecko).style;
el.display=(el.display == 'block')?'none':'none';
}

function load_element(element, page) {

  document.getElementById(element).innerHTML = '<div style="margin-top: 7px;"><img src="http://www.webgames.cz/_grafika/hra/load.gif" style="width: 16px; height: 16px;"> chvilku strpení ...</div>';

  // definovanie objektu XMLHttpRequest aby pracoval korektne aj v IE
  var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
  var document_element = document.getElementById(element).innerHTML;

  xmlhttp.open('GET', page);
  xmlhttp.onreadystatechange = function() {
      spracuj(xmlhttp);
  };
  xmlhttp.send(document_element);

  function spracuj(xmlhttp) {

    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            document.getElementById(element).innerHTML = xmlhttp.responseText;
        } else {
            document.getElementById(element).innerHTML = 'Error';
        } // end if.. else..
    } // end if..
  } // end function spravuj

} // end function load element

function load_elementdole(element, page) {

  document.getElementById(element).innerHTML = '<div style="margin-top: 7px;"><img src="http://www.webgames.cz/_grafika/hra/load2.gif" style="width: 16px; height: 16px;"> Načítám ...</div>';

  // definovanie objektu XMLHttpRequest aby pracoval korektne aj v IE
  var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
  var document_element = document.getElementById(element).innerHTML;

  xmlhttp.open('GET', page);
  xmlhttp.onreadystatechange = function() {
      spracuj(xmlhttp);
  };
  xmlhttp.send(document_element);

  function spracuj(xmlhttp) {

    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            document.getElementById(element).innerHTML = xmlhttp.responseText;
        } else {
            document.getElementById(element).innerHTML = 'Error';
        } // end if.. else..
    } // end if..
  } // end function spravuj

} // end function load element


function GetRandomNumber(low, high)
{
	return(Math.floor((Math.random() * (high - low + 1)) + low));
}

// Use this to properly write out the HTML for any Flash.
function OtevreniSWF(url, width, height)
{
	// Options here are "window", "opaque", and "transparent"
	var DEFAULT_WINDOW_SETTING = "window";

	// Defaults for optional stuff below
	var quality = "high";
	var id = "flash" + GetRandomNumber(1000000, 9999999);
	var wmode = DEFAULT_WINDOW_SETTING;
	var script_access = "sameDomain";
	var allow_fullscreen = "false";
	var params = null;
	var has_flash = LookForFlashPlugin();

	this.SetQuality = function(new_quality)
	{
		quality = new_quality;
	}

	this.SetID = function(new_id)
	{
		id = new_id;
	}

	this.SetTransparent = function(is_transparent)
	{
		wmode = is_transparent ? "transparent" : DEFAULT_WINDOW_SETTING;
	}
	
	this.SetOpaque = function(is_opaque)
	{
		wmode = is_opaque ? "opaque" : DEFAULT_WINDOW_SETTING;
	}

	this.SetFullScreen = function(fullscreen)
	{
		allow_fullscreen = fullscreen ? "true" : "false";
	}

	this.SetScriptAccess = function(new_script_access)
	{
		script_access = new_script_access;
	}

	this.SetParams = function(new_params)
	{
		params = new_params;
	}

	this.ToString = function()
	{
		var str = "";

		if(has_flash)
		{
			str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" id="' + id + '">';

			str += '<param name="allowScriptAccess" value="' + script_access + '" />';
			str += '<param name="allowFullScreen" value="' + allow_fullscreen + '" />';
			str += '<param name="movie" value="' + url + '" /><param name="quality" value="' + quality + '" />';
			str += '<param name="wmode" value="' + wmode + '" />';

			if(params != null)
			{
				// IE needs this
				str += '<param name="flashvars" value="' + params + '" />';
			}

			str += '<embed src="' + url + '" quality="' + quality + '" ';

			if(params != null)
			{
				// Non-IE browsers need this
				str += 'flashvars="' + params + '" ';
			}

			str += 'wmode="' + wmode + '" width="' + width + '" height="' + height + '" name="' + id + '" allowScriptAccess="' + script_access + '" allowFullScreen="' + allow_fullscreen + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
			str += '</object>';
		}
		else
		{
			str += '<p style="text-align: center; margin-top: 2em; margin-bottom: 2em; padding-top: 3em; padding-bottom: 3em; background: #333333">You don\'t appear to have <a target="_blank" href="http://getflash.ngfiles.com">Flash</a> installed. <a target="_blank" href="http://getflash.ngfiles.com">Click here</a> to get it (it\'s free).</p>';
		}

		return(str);
	}

	this.Print = function()
	{
		document.write(this.ToString());
	}

	function LookForFlashPlugin()
	{
		var flash_versions = 12;

		// Code swiped from http://www.dangrossman.info/2007/01/03/detecting-flash-and-java-with-javascript/
		if (navigator.plugins && navigator.plugins.length) {
			// Netscape style plugin detection
			for (x = 0; x <navigator.plugins.length; x++) {
				if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
					return(true);
				}
			}
		}
		else if (window.ActiveXObject) {
			// ActiveX style plugin detection
			for (x = 2; x <= flash_versions; x++) {
				try {
					oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
					if (oFlash) {
						return(true);
					}
				}
				catch(e) { }
			}
		}
		
		return(false);
	}
}




function sendRequest(n) {

function htmlspecialchars(text) {
    return text.replace(/[<>&"]/g, function (s) {
        switch (s) {
            case '<': return '&lt;';
            case '>': return '&gt;';
            case '&': return '&amp;';
            case '\'': return '&#039;';
            case '"': return '&quot;';
        }
    });
}
function htmlspecialchars2(text) {
    return text.replace(/[<>&"]/g, function (s) {
        switch (s) {
            case '<': return '%3C';
            case '>': return '%3E;';
            case '&': return '%26';
            case '"': return '%22';
            case '\+': return 'tohlejeplus';
        }
    });
}


  var str = $F('name' + n);
  var stroprav2 = htmlspecialchars(str); 
  var stroprav = htmlspecialchars2(stroprav2);
  var req = new Ajax.Request('http://www.webgames.cz/bridge/form/testvloz.php', 
    { method: 'post',
      encoding: 'windows-1250', 
      postBody: 'name='+stroprav+'&kdoto='+ $F('kdoto')+'&coto='+ $F('coto' + n),
      onComplete: showResponse
    });
   function showResponse(req){$('nahoda' + n).innerHTML = req.responseText;}
}




