	var messages = Array(1);
	messages[0] = 'IP Address is not defined.';
	messages[1] = 'We cannot execute VoIP TEST.<br>Download and intall SUN Java plugin.<br><a href="http://www.java.com/pl/download/manual.jsp?locale=pl&host=www.java.com:80" target="_blank"><font color="#ffffff">Click here</font></a>';
	messages[2] = 'VoIP TEST available ony for: IE, Firefox, Opera.';
	
	var comm_download = Array(1);
	var comm_upload = Array(1);
	var comm_jitter = Array(1);
	var comm_latency = Array(1);
	var comm_loss = Array(1);
	
	comm_download[1] = 'Your download speed is not enough to make VoIP calls. You may hear distortion and voice breaks. Webpages browsing could be very slow.';
	comm_download[2] = 'Your download speed is enough to make VoIP calls and for basic webpages browsing. But on youtube or similar pages you could see buffering lags.';
	comm_download[3] = 'Your download speed is good enough to make VoIP calls and for fast webpages browsing. You should not have problems with youtube and similar pages.';
	
	comm_upload[1] = 'Your upload speed is not enough to make VoIP calls. You may hear distortion and voice breaks. You may have a problems in sending emails with large attachments.';
	comm_upload[2] = 'Your upload speed is enough to make VoIP calls. But you could have problems in sending emails with large attachments.';
	comm_upload[3] = 'Your upload speed is good enough to make VoIP calls. You could not have problem witch sending emails.';
	
	comm_jitter[1] = 'Your jitter is good enough to make VoIP calls. Sound should be clean and without breaks.';
	comm_jitter[2] = 'Your jitter is enough to make VoIP calls. Sometimes you could hear breaks and some distortions.';
	comm_jitter[3] = 'Your jitter is to high to make VoIP calls. Sound may be broken and distorted.';

	comm_loss[1] = 'Your packet loss is good enough to make VoIP calls. You should hear clean sound.';
	comm_loss[2] = 'Your packet loss is enough to make VoIP calls. Sometimes you could hear breaks.';
	comm_loss[3] = 'Your packet loss is to high to make VoIP calls. Sound could be broken and distorted.';

	comm_latency[1] = 'Your latency is good enough to make VoIP calls. Sound should be not dealyed. You could play network games like Warcraft without lags.';
	comm_latency[2] = 'Your latency is enough to make VoIP calls. Sometimes you could notice some delays. Online games like Warcraft should run quite good.';
	comm_latency[3] = 'Your latency is to high to make VoIP calls. Sound would be delayed. You could see a lot of lags in online games like Warcraft.';
	
	var mFlash = null;
		
	var voipServerIP = null;
	var voipPort = null;
	var pomiar = null;
	
	function setID(id, down, up, jit, loss, server, ping, ip, data) {
		var down_id = 0; var up_id = 0; var jitter_id = 0; var loss_id = 0; var latency_id = 0;
		if ( down<128 ) { down_id=1; } else if ( down < 512 ) { down_id=2; } else { down_id=3; }
		if ( up<128 ) { up_id=1; } else if ( up < 512 ) { up_id=2; } else { up_id=3; }
		if ( jit<5 ) { jitter_id=1; } else if ( jit < 20 ) { jitter_id=2; } else { jitter_id=3; }
		if ( loss<5 ) { loss_id=1; } else if ( loss < 10 ) { loss_id=2; } else { loss_id=3; }
		if ( ping<20 ) { latency_id=1; } else if ( ping < 80 ) { latency_id=2; } else { latency_id=3; }
		
		pomiar = document.getElementById('pomiar');
		pomiar.innerHTML = '<br><center><b>Если хочешь поделиться с другими своими результатами на форуме или интернет-странице, скопируй и вставь следующую ссылку!</b><br><br>интернет-страница<br><textarea style="color: white; background-color: black; margin-top: 5px; margin-bottom: 5px; padding: 3px 3px 3px 3px; border: 1px solid white; font-size: 10px; overflow: hidden; width: 470px; height: 26px;" readonly="readonly"><a href="http://www.testskorosti.ru/"><img style="border: 0px;" src="http://www.testskorosti.ru/results/'+id+'.jpg" alt="speed test" /></a></textarea><br>форум<br><textarea style="margin-top: 5px; margin-bottom: 5px; padding: 3px 3px 3px 3px; border: 1px solid white; color: white; background-color: black; font-size: 10px; overflow: hidden; width: 570px; height: 13px;" readonly="readonly">[URL=http://www.testskorosti.ru][IMG]http://www.testskorosti.ru/results/'+id+'.jpg[/IMG][/URL]</textarea><br><br><img src="results/'+id+'.jpg" alt="voiptest result"></center><br>';
	}
	
	function callGetServerIP( url, port )
	{ 
		voipServerIP = getDomeinFromURL(url);
		voipPort = port;
		
		if(isJavaInstalled())
		{
			if (!safari) {
				app = document.getElementById('applet');
				app.innerHTML = appletObject(voipServerIP, voipPort, url);
				//$('applet').update(appletObject(voipServerIP, voipPort, url));
			}
			else
				callSetAppletError(messages[2]);
		}
		else {
			callSetAppletError(messages[1]);
		}
	}
	
	function getURLParam(){
	
		var strReturn = "";
		var strHref = document.URL;
		if ( strHref.indexOf("#") > -1 ){
			var strQueryString = strHref.substr(strHref.indexOf("#"));
			var sQ = strQueryString.split('/');
			strReturn = sQ[1];
		}
		
		return unescape(strReturn);
		
	}

	function callSetVoIPResult(jitter, loss) {
			wnd = getMovie("web");
			wnd.callSetVoIPResult(parseFloat(jitter), parseFloat(loss));
	}
	
	function callSetAppletError(message) {
			m = new String(message);
			getMovie("web").callSetAppletError(m.toString());
	}
	

	function getMovie(movieName) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
	        return window[movieName]
	    }
	    else {
	        return document[movieName]
	    }
	}	
	
	var detect = navigator.userAgent.toLowerCase();
	var windowsIE = (checkPlatform("msie") && checkPlatform("win"));
	
	var safari = (checkPlatform("safari"));
	
	function checkPlatform(string)
	{
			place = detect.indexOf(string) + 1;
			thestring = string;
			return place;
	}
	
	function isJavaInstalled()
	{
		var javaVersion = null;
		
		try 
		{
			javaVersion = navigator.javaEnabled();
		}
		catch (e) 
		{
			javaVersion = null;
		}
		
		if( javaVersion == null ) 
		{
			return false;
		}
		
		return true;
	}
	
	
	function appletObject(ip, port, codebase){
		content = '';	
		content = '<applet id="voip" name="voip" code="VoIP.class" width="1" height="1" codebase="' + codebase +'" MAYSCRIPT>';
		content += '<param name="width" 	value="200">';
		content += '<param name="height" 	value="300">';
		content += '<param name="debug" 	value="0">';
		content += '<param name="ip" 	value="'+ ip +'">';
		content += '<param name="port" 	value="' + port + '">';
		content += '<param name="lang" 	value="en">';
		content += '</applet>';
		
		return content;
	}
	
	function getDomeinFromURL(url){
		var sQ = url.split('/');
		
		return sQ[2] != '' ? sQ[2] : false;
	}
	
	// Event.observe(window, 'load', detectJava, false);
