function send_xmlhttprequest(obsluha, method, url, content, headers) {
	var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));

	if (!xmlhttp)
		return false;

	xmlhttp.open(method, url);

	if (obsluha != null)
		xmlhttp.onreadystatechange = function() {
			obsluha(xmlhttp);
		};

	if (headers) {
		for (var key in headers)
			xmlhttp.setRequestHeader(key, headers[key]);
	}

	xmlhttp.send(content);
	return true;
}

function open_popup(dokument, sirka, vyska, scrollbars) {
	so = screen.width;
	vo = screen.height;
	zleva = ((so - sirka) / 2) - 13;
	shora = 120;
	popup_win = window.open(dokument,"popup_okno","width="+sirka+",height="+vyska+",left="+zleva+",top="+shora+",location=0,menubar=0,resizable=1,scrollbars="+scrollbars+",status=0,titlebar=0,toolbar=0");
	popup_win.focus();
}

function Show(id, show) {
  if (show)
    document.getElementById(id).style.visibility='visible';
  else
    document.getElementById(id).style.visibility='hidden';
}

function mute(m) {
    if ((m == "on") || (m == "off"))
        send_xmlhttprequest(null, "GET", "/audio_mute.php?mute=" + m);
}


function reload_confirm_image() {
	var d = new Date();
	var obj = document.getElementById('confirm_data_image_image');

	if (obj)
		obj.src = '/confirm_number.php?new&time=' + d.getTime();
}

function change_confirm_style(second) {
	var obj1 = document.getElementById('confirm_data_image');
	var obj2 = document.getElementById('confirm_data_flash');

	if (second) {
		obj1.style.display = 'none';
		obj2.style.display = 'block';
	} else {
		obj2.style.display = 'none';
		obj1.style.display = 'block';
	}
}

function on_off(_id) {
    var elem = document.getElementById(_id);

    if (elem == null)
        return;

    if (elem.style.display == "none")
        elem.style.display = "block";
    else
        elem.style.display = "none";
}

function anonym_email(formular, profile, language) {
	var email = formular.email.value;

	if (!send_xmlhttprequest(anonym_email_r, 'GET', '/index.php?ma=ajax&sid=aemail&p=' + profile + '&l=' + language + '&e=' + email)) {
		return true;
	}

	return false;
}

function anonym_email_r(xmlhttp) {
	if (xmlhttp.readyState == 4) {
		document.getElementById('dark_bg').style.display = 'block';
		document.getElementById('matwindow').style.display = 'block';
		document.getElementById('matwindow_in').style.display = 'block';
		document.getElementById('matwindow_in').innerHTML = xmlhttp.responseText;

        reg = /^.*MSIE 6.*$/;
        if (reg.test(navigator.appVersion)) {
            var sel = document.body.getElementsByTagName("SELECT");
            for (var i = 0; i < sel.length; i++)
                sel[i].style.visibility = "hidden";
        }
	}
}

function close_matwindow() {
	var obj = document.getElementById('matwindow');
    var obj2 = document.getElementById('matwindow_in');
    var obj3 = document.getElementById('dark_bg');

	if (obj) {
		obj2.innerHTML = '';
		obj.style.display = 'none';
		obj2.style.display = 'none';
	}

	if (obj3)
		obj3.style.display = 'none';

    reg = /^.*MSIE 6.*$/;
    if (reg.test(navigator.appVersion)) {
        var sel = document.body.getElementsByTagName("SELECT");
        for (var i = 0; i < sel.length; i++)
            sel[i].style.visibility = "visible";
    }
}

function row_highlight(_id) {
    this.wr = document.getElementById(_id);
    if (this.wr == null) {
        alert("row_highlight error: bad id");
        return false;
    }

    this.set_events = function (_elem) {
        _elem.onblur = function () {
            this.parentNode.parentNode.className = "";
        }
        _elem.onclick = function () {
            this.parentNode.parentNode.className = "highlight";
        }
    }

    this.inputs = this.wr.getElementsByTagName("INPUT");
    this.selects = this.wr.getElementsByTagName("SELECT");

    for (var i = 0; i < this.inputs.length; i++)
        if (this.inputs[i].type == "text")
            this.set_events(this.inputs[i]);

    for (var i = 0; i < this.selects.length; i++)
        this.set_events(this.selects[i]);
}

function ShowLoading(_el) {
	var bg = SJEL.CE("div");
	var wh = SJEL.GWindowWH();
	var l = document.createElement("img");
	document.body.appendChild(bg);
	document.body.appendChild(l);
	l.onload = function() {
		//alert(_el.href);
		window.location = _el.href;
	}
	l.src = "/images/loader2.gif";
	SJEL.SStyle(bg, {position: "fixed", zIndex: 5999, top: 0, left: 0, width: wh[0], height: wh[1], backgroundColor: "#001946", opacity: 0.7});
	SJEL.SStyle(l, {position: "fixed", zIndex: 6000, top: (wh[1] / 2) - 106, left: (wh[0] / 2) - 16});
	if (SJEL.ie == 6) {
		SJEL.SStyle(bg, {position: "absolute"});
		SJEL.SStyle(l, {position: "absolute"});
	}
}

function MCursor (_dx, _dy) {
	var ref = this;
	this.m = null;
	this.el = null;
	this.dx = _dx||10;
	this.dy = _dy||10;

	this.Show = function(_el) {
		if ((_el != undefined) && (_el != null)) {
			this.m = new SJEL.Mouse();
			this.m.OnMouseMove(OnMouseMove);
			this.el = _el;
			document.body.appendChild(this.el);
			SJEL.SStyle(this.el, {position: "absolute", left: this.m.mx + this.dx + "px", top: this.m.my + this.dy + "px"});
		}
	}

	this.Hide = function(_el) {
		if ((_el != undefined) && (_el != null) && (this.m != null)) {
			if (_el.parentNode == document.body)
				document.body.removeChild(_el);
			this.el = null;
			this.m.Close();
			delete this.m;
			this.m = null;
		}
	}

	function OnMouseMove() {
		if (ref.el != null)
			SJEL.SStyle(ref.el, {left: ref.m.mx + ref.dx + "px", top: ref.m.my + ref.dy + "px"});
	}
}

function LoaderCursor() {
	this.cur = new MCursor(16, 16);
	this.e = SJEL.CE("div");
	this.e.className = "loader";

	this.Create = function() {
		this.cur.Show(this.e);
	}

	this.Destroy = function(_xmlhttp) {
		if (_xmlhttp != undefined) {
			if (_xmlhttp.readyState == 4) {
				this.cur.Hide(this.e);
			}
		} else
			this.cur.Hide(this.e);
	}
}

function AjaxTable (_el) {
	var ref = this;
	var el = SJEL.$$(_el);
	var trs = SJEL.$T(el, "tr");
	this.link = "/index.php?ma=ajax&sid=requisition&id=";
	this.items = new Array();
	this.loaderCur = new LoaderCursor();

	for (var i = 0; i < trs.length; i++) {
		this.items.push(new Itemo(trs[i], i));
	}

	function Itemo(_tr, _id) {
		var r = this;
		this.tr = _tr;
		this.id = _id;
		this.id2 = parseInt(this.tr.id);
		this.loaded = false;
		this.loading = false;
		this.show = false;
		this.itrs = new Array();
		this.a = SJEL.$('a_' + this.id2);
		if (this.a == null)
			return
//		alert(this.a);

//		this.tr.onclick = function() {
		this.a.onclick = function() {
			if (r.loading)
				return false;

			if (!r.loaded) {
				r.loading = true;
				ref.loaderCur.Create();
				if (!send_xmlhttprequest(r.ParseXML, 'GET', ref.link + r.id2)) {
					return false;
				}
			} else
				r.Show();

			return false;
		}

		this.Show = function() {
			for (var ii = 0; ii < this.itrs.length; ii++)
				if (this.show)
					SJEL.RemoveClass(this.itrs[ii], "nodisplay");
				else
					SJEL.AddClass(this.itrs[ii], "nodisplay");

			this.show = !this.show;
		}

		this.ParseXML = function(_xmlhttp) {
			if (_xmlhttp.readyState == 4) {
				var trs = _xmlhttp.responseXML.getElementsByTagName('tr');
				for (var i = 0; i < trs.length; i++) {
					var t = SJEL.CE("tr");
					t.className = "graytr";

					var tds = trs[i].getElementsByTagName('td');
					for (var j = 0; j < tds.length; j++) {
						var td = SJEL.CE("td");
						if (tds[j].getAttribute("colspan") != null) {
							td.setAttribute((SJEL.ie == 6) ? "colSpan" : "colspan", tds[j].getAttribute("colspan"));
						}

						if (tds[j].firstChild != null) {
							if (tds[j].firstChild.nodeType == 3)
								td.innerHTML = tds[j].firstChild.data;
							else if (tds[j].firstChild.nodeType == 1) {
								if (tds[j].firstChild.tagName == "a") {
									var aa = SJEL.CE("a");
									aa.href = tds[j].firstChild.getAttribute("href");
									aa.className = "pdf";
									aa.innerHTML = tds[j].firstChild.childNodes[0].nodeValue;
									td.appendChild(aa);
								}
							}
						}

						t.appendChild(td);
					}

					r.itrs.push(t);
				}

				for (var i = 0; i < r.itrs.length; i++) {
					if (r.id + 1 == ref.items.length)
						r.tr.parentNode.appendChild(r.itrs[i]);
					else
						r.tr.parentNode.insertBefore(r.itrs[i], ref.items[r.id + 1].tr);
				}

				r.loading = false;
				r.loaded = true;

				ref.loaderCur.Destroy(_xmlhttp);
			}
		}
	}
}

//SJEL.OnPageLoad(function(){SJEL.CreateLog();});


function DrawAMC(prodName, ID, height, width, imagepath, CLSID_AMC, cab, ver_AMC, ShowAMCToolbar, ptzgui, useWithCam, camnbr, UseRel, ShowRelCross, ShowSVG, UseMotion, UseAudio, rtspPort, external, installText1, text, installText2, installText3, installText4, mediaRecording, extra, enableAreaZoom) // NOTE: extra = "yes" -> 207, extra = "9999" means centermode (zoom=9999) is activated in 212PTZ, otherwise extra should be "no" or undefined.
{
  var rtspAddress = "rtsp://" + location.hostname

  if (imagepath.indexOf("mpeg4") != -1) {
    var mpeg4 = "yes";
  }
  if (imagepath.indexOf("mjpg") != -1) {
    var mjpg = "yes";
  }
  if (imagepath.indexOf("mpeg2") != -1) {
    var mpeg2 = "yes";
  }
  if (imagepath.indexOf("sdp") != -1) {
    var multicast = "yes";
  }

  document.write('<OBJECT ID="Player" height="' + height + '" width="' + width + '" border="0" CLASSID="CLSID:' + CLSID_AMC + '" CODEBASE="/activex/' + cab + '#version=' + ver_AMC + '" STANDBY="Loading Axis Media Control components...">');
  if(mpeg4 == "yes" && external == "no") {
    document.write('<param name="MediaURL" value="' + rtspAddress + ':' + rtspPort + '' + imagepath + '">');
  } else {
    document.write('<param name="MediaURL" value="' + imagepath + '">');
  }
  if ((mpeg4 == "yes") && (multicast != "yes")) {
    document.write('<param name="MediaType" value="auto-sense">');
  } else if (multicast == "yes") {
    document.write('<param name="MediaType" value="multicast">');
  }
  if (mjpg == "yes") {
    document.write('<param name="MediaType" value="mjpeg-unicast">');
  }
  if (mpeg2 == "yes") {
    document.write('<param name="MediaType" value="mpeg2-unicast">');
  }
  if (extra == "yes") {  // 207
    document.write('<param name="Volume" value="70">');
  }
  document.write('<param name="ShowStatusBar"');
  if (ShowAMCToolbar == "yes") {
    document.write('value="1">');
  } else {
    document.write('value="0">');
  }
  document.write('<param name="ShowToolbar"');
  if (ShowAMCToolbar == "yes") {
    document.write('value="1">');
  } else {
    document.write('value="0">');
  }

  if (UseAudio == "yes") {
    document.write('<param name="AutoStart" value="0">');
  } else {
    document.write('<param name="AutoStart" value="1">');
  }

  if (UseMotion == "yes") {
    document.write('<param name="StretchToFit" value="0">');
  } else {
    document.write('<param name="StretchToFit" value="1">');
  }

  if ((ptzgui == "yes") && (useWithCam == "yes")) {
    document.write('<param name="PTZControlURL" value="/axis-cgi/com/ptz.cgi?camera=' + camnbr);
    extra += ""
    if (extra == "9999")
      document.write('&zoom=9999')
      document.write('">');
   }

//  document.write('<br><b>' + ID + '</b>&nbsp;' + installText1 + '&nbsp;' + text + '&nbsp;' + installText2 + '&nbsp;' + installText3 + '<br>' + ID + '&nbsp;' + installText4);
  document.write('<br><br></OBJECT>');

  if (document.Player.ShowToolbar) { // This line is essential when installing AMC or else volume and mute buttons will show until reload
    if (ShowAMCToolbar == "yes") {
      if (extra == "yes") { // = 207
        document.Player.ToolbarConfiguration = "+play,+snapshot,+fullscreen,+mute,+volume";
      } else if (mpeg4 == "yes" && mediaRecording != 0) {
        document.Player.ToolbarConfiguration = "+play,+snapshot,+rec,+fullscreen";
        document.Player.EnableRecording = mediaRecording;
      } else {
        document.Player.ToolbarConfiguration = "+play,+snapshot,+fullscreen";
      }
    }
  }

  if (UseMotion == "yes") {
    document.Player.UIMode = "MDConfig";
    document.Player.MotionConfigURL = "/axis-cgi/operator/param.cgi?ImageSource=" + [camnbr - 1]
    document.Player.MotionDataURL = "/axis-cgi/motion/motiondata.cgi";
  }

  if (ShowSVG == "yes") {
    document.Player.SvgDataURL = "/axis-cgi/iv/stream.cgi?channel=9";
  }

  document.Player.EnableContextMenu = "1";
    if ((enableAreaZoom == "yes") && (useWithCam == "yes")) {
      document.Player.EnableJoystick = "True";
      document.Player.EnableAreaZoom = "True";
   }
}




function video(imagepath)
{
  var resolution = 0
  var width = 0
  var height = 0

  if (imagepath.indexOf("resolution=") != -1) {
    var resStart = imagepath.indexOf("resolution=")
    var resStop = imagepath.indexOf("&", resStart)
    if (resStop == -1) resStop = imagepath.length
    resolution = imagepath.substring(resStart + 11, resStop);
    width = parseInt(resolution.substring(0, resolution.indexOf('x')));
    height = parseInt(resolution.slice((resolution.indexOf('x') + 1)));
  } else if (imagepath.indexOf("mpeg4") != -1) {
    width = 640;
    height = 480;
    resolution = width + 'x' + height;
  } else {
    width = 640;
    height = 480;
    resolution = width + 'x' + height;
  }

//  if ((imagepath.indexOf("rotation=90") != -1) || (imagepath.indexOf("rotation=270") != -1)) {
//    var aTempWidth = width;
//    width = height;
//    height = aTempWidth;
//    resolution = width + 'x' + height;
//  }

  if ('1' != '1') {
    width = width * 1
    height = height * 1
  }
  var width_height = 'width="' + width + '" height="' + height + '"';
  var use_activex = 0;
  var use_java = 0;
  var use_spush = 0;
  var use_flash = 0;
  var use_still = 0;
  var viewer = "still";
  var use_quicktime = 0;

  if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
    viewer = "activex";
  } else {
    viewer = "spush";
  }

  if (viewer.indexOf("activex") != -1) {
    use_activex = 1;
  }
  if (viewer.indexOf("spush") != -1) {
    use_spush = 1;
  }
  if (viewer.indexOf("flash") != -1) {
    use_flash = 1;
  }
  if (viewer.indexOf("quicktime") != -1) {
    use_quicktime = 1;
  }
  if (imagepath.indexOf("mpeg4") != -1) {
    if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
        use_quicktime = 0;
        use_activex = 1;
    } else {
      use_quicktime = 1;
      use_spush = 0;
      use_still = 0;
    }
  } else {
    if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
        use_quicktime = 0;
        use_activex = 1;
    } else {
      use_quicktime = 0;
      use_spush = 1;
      use_still = 0;
    }
  }
  if (viewer.indexOf("java") != -1) {
    if (imagepath.indexOf("mpeg4") == -1) {
      use_java = 1;
      use_activex = 0;
      use_spush = 0;
      use_flash = 0;
      use_still = 0;
      use_quicktime = 0;
    }
  }
  if ((viewer.indexOf("still") != -1) || !(use_activex || use_spush || use_flash || use_java || use_quicktime)) {
    if (imagepath.indexOf("mpeg4") == -1) {
      use_still = 1;
      use_quicktime = 0;
      use_spush = 0;
      use_activex = 0;
    } else {
      if ((navigator.appName == "Microsoft Internet Explorer") && (navigator.platform != "MacPPC") && (navigator.platform != "Mac68k")) {
        use_activex = 1;
      } else {
        use_quicktime = 1;
      }
    }
  }
  var agent = navigator.userAgent.toLowerCase();
  if (agent.indexOf("applewebkit/") != -1) {
    var pos = agent.indexOf("applewebkit/") + 12
    var webKitVersion = parseInt(agent.substring(pos, agent.indexOf(" ", pos)))
    if ((use_spush) && (webKitVersion < 416)) {
      use_java = 1;
      use_spush = 0;
    }
  }
  if (use_activex) {
    height = height + 54
    var notAuthorizedText = "The installation of the MPEG-4 Decoder has been disabled. Contact the Administrator of this AXIS 211 Network Camera.";
    var authorizedText = "Click here to install or upgrade the MPEG-4 Decoder.";
    var installDecoderText1 = "<b>MPEG-4 Decoder</b>, which enables streaming video in Microsoft Internet Explorer, has not been installed or could not be registered on this computer.";
    var installDecoderText2 = "To <a href=\"javascript:launch('/incl/license.shtml')\">install or upgrade</a> the MPEG-4 Decoder, you must have Administration rights on this computer and you must answer Yes <br>when asked if you wish to allow the installation. AXIS 211 Network Camera can also be configured to show still images.";
    var notAuthorizedAacText = "The installation of the AAC Decoder has been disabled. Contact the Administrator of this AXIS 211 Network Camera.";
    var authorizedAacText = "Click here to install or upgrade the AAC Decoder.";
    var installAacDecoderText1 = "<b>AAC Decoder</b>, which enables streaming AAC audio in Microsoft Internet Explorer, has not been installed or could not be registered on this computer.";
    var installAacDecoderText2 = "To <a href=\"javascript:launch('/incl/aac_license.shtml')\">install or upgrade</a> the AAC Decoder, you must have Administration rights on this computer and you must answer Yes <br>when asked if you wish to allow the installation.";

    var installText1 = "which enables streaming";
    var videoText = "video";
    var audioText = "audio";
    var installText2 = "in Microsoft Internet Explorer, has not been installed or could not be registered on this computer.";
    var installText3 = "To install or upgrade the";
    var installText4 = ", you must have Administration rights on this computer and you must answer Yes <br>when asked if you wish to allow the installation. AXIS 211 Network Camera can also be configured to show still images.";
    
    var installText1 = '';
    var installText2 = '';
    var installText3 = '';
    var installText4 = '';
    var videoText = "";        
    DrawAMC("AXIS 211", "AXIS Media Control", height, width, imagepath, "DE625294-70E6-45ED-B895-CFFA13AEB044", "AMC.cab", "4,1,4,0", "yes", "", "", "1", "", "", "", "no", "no", "554", "no", installText1, videoText, installText2, installText3, installText4, "0", "", "");
    if (imagepath.indexOf("mpeg4") != -1) {
      InstallDecoder("AXIS 211", "MPEG-4 Decoder", "c32fe9f1-a857-48b0-b7bf-065b5792f28d", "NotFound.cab", "1,1,0,12", "yes", notAuthorizedText, authorizedText, installDecoderText1, installDecoderText2);
      InstallFilter("AXIS 211", "MPEG RTP Reader", "67B1A88A-B5D2-48B1-BF93-EB74D6FCB077", "1,6,3,0", "AMC.cab", installText1, videoText, installText2, installText3, installText4);
      InstallFilter("AXIS 211", "Image Notify Component", "0173EEF5-1FDE-479C-9F24-34C3CB0B3243", "1,2,1,0", "AMC.cab", installText1, videoText, installText2, installText3, installText4);
    }

    document.write("<br>");
  }

  if (use_spush) {


//    var ttt =  '<img id="stream" src="' + imagepath + '" ' + width_height + '' + view_NoImageTxt + '" />';
//    var videodiv = document.getElementById('video');
//
//    if( videodiv )
//        videodiv.innerHTML() = ttt;

    document.write('<table cellspacing=0 cellpadding=0 border=0><tr><td colspan=3 align="center">');
      var output = '<img id="stream" SRC="' + imagepath + '" ' + width_height;
//      var view_NoImageTxt = "If no image is displayed, there might be too many viewers, or the browser configuration may have to be changed. See help for detailed instructions on how to do this.";
      var view_NoImageTxt = '';
      output += ' border=0 ALT="' + view_NoImageTxt + '" />';
    output += '<br />';
    document.write(output);
    document.write('</td></tr>');
    document.write('</table>');

     var fullImagePath = document.stream.src

//     var fullImagePath = "http://remote.rayservice.com:8081/mjpg/video.mjpg";

    var stillImagePath = "/jpg/image.jpg"
    if (imagepath.indexOf("/axis-cgi/mjpg/video.cgi") != -1) {
      var searchStr = "/axis-cgi/mjpg/video.cgi"
      var replaceStr = "/jpg/image.jpg"
      var re = new RegExp(searchStr , "g")

       stillImagePath = imagepath.replace(re, replaceStr)

    }


//     document.write('<tr><td colspan=3 align="center" nowrap class="usedBoxStyle">');
//     document.write('<table cellspacing=2 cellpadding=2 border=0 width="100%">');
//     document.write('<tr height="32" id="videoItems" class="shownItems">');
    //document.write("<td align=\"right\" width=\"40\"><a href=\"javascript:void(0)\" onClick=\"stopStartStream('" + stillImagePath + "')\"><img src=\"/pics/stop_button_27x27px.gif\" width=\"27\" height=\"27\" alt=\"Stop stream\" title=\"Stop stream\" border=\"0\"></a></td>");
    //document.write("<td width=\"27\"><a href=\"javascript:void(0)\" onClick=\"stopStartStream('" + fullImagePath + "')\"><img src=\"/pics/play_button_27x27px.gif\" width=\"27\" height=\"27\" alt=\"Start stream\" title=\"Start stream\" border=\"0\"></a></td>");
//     document.write("<td>&nbsp;</td></tr>");
//     document.write('</table></td></tr></table>');

  }

  if (use_quicktime) {
    document.write("QuickTime does not support the current MPEG-4 setting.<br>Go to Setup->Video&Image->Advanced->MPEG-4 and set Video object type to 'Simple' for QuickTime to work.");
  }

  if (use_flash) {
    var view_NeedFlashPluginTxt = "You need a Shockwave Flash plugin, get it from:"
    document.write('<EMBED src="/axis-cgi/mjpg/video.swf?resolution=' + resolution +'&camera=1" ' +
    'quality=high bgcolor=#000000 ' + width_height +
    ' TYPE="application/x-shockwave-flash" swLiveConnect=TRUE' +
    ' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">' +
    '</EMBED>' +
    '<NOEMBED>' + view_NeedFlashPluginTxt +
    '<a href="http://www.macromedia.com/shockwave/download/">Macromedia</a>.' +
    '</NOEMBED><br>');
  }

  if (use_java) {
    var playerWidth = 640
    var playerHeight = 480 + 105
    if (playerWidth < 300)
      playerWidth = 300

    if (imagepath.indexOf("http") != -1) {
      var addrEnd = imagepath.indexOf("/", 8)
      var addr = imagepath.substring(0, addrEnd)
    } else {
      var addr = ""
    }

    document.write('<APPLET archive="ama.jar" codeBase="/java/ama" code="ama.MediaApplet" width="' + playerWidth + '" height="' + playerHeight + '">');
    document.write('<PARAM NAME="code" VALUE="ama.MediaApplet">');
    document.write('<PARAM NAME="archive" VALUE="ama.jar">');
    document.write('<PARAM NAME="codebase" VALUE="/java/ama">');
    document.write('<PARAM NAME="ama_cgi-path" VALUE="axis-cgi">');
    document.write('<PARAM NAME="cache_archive" VALUE="ama.jar">');
    document.write('<PARAM NAME="cache_version" VALUE="1.0.0.0">');
    document.write('<PARAM NAME="ama_plugins" VALUE="">');
    document.write('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
    document.write('<PARAM NAME="ama_url" VALUE="' + addr +
    '/axis-cgi/mjpg/video.cgi?camera=1&resolution=640x480">');
    document.write("Your browser does not support Java")
    document.write("</APPLET><br>");
  }

  if (use_still) {
    var picturepath = imagepath.replace(/video/, "image")
    picturepath = picturepath.replace(/mjpg/g, "jpg")
    picturepath = picturepath.replace(/rtsp/, "http")
    picturepath = picturepath.replace(/mpeg4/g, "jpg")
    picturepath = picturepath.replace(/media.amp/g, "image.jpg")

    document.write('<img SRC="' + picturepath + '" border=0 ' + width_height +'><br>');
  }
}

  function weather_data() {
      if (!send_xmlhttprequest(weather_data_r, 'GET', '/index.php?ma=ajax&sid=weather'))
	return false;

      return true;
  }

  function weather_data_r( xmlhttp ) {
	if (xmlhttp.readyState == 4) {
		var odpovedi = xmlhttp.responseXML.getElementsByTagName('weather')[0].childNodes;

		for (var i = 0; i < odpovedi.length; i++) {
			if (odpovedi[i].childNodes.length > 0) {
				var obj = document.getElementById(odpovedi[i].nodeName);

				if (obj) {
					if (odpovedi[i].nodeName == 'date')
						obj.innerHTML = odpovedi[i].childNodes[0].data;
					else
						obj.innerHTML = odpovedi[i].childNodes[0].data.replace('.', ',');
				}
			}
		}
	}
}

