﻿	function ShowSnippet(x) 
	{ 
		document.getElementById(x).style.display = "block";
	}
	
	function HideSnippet(x) 
	{
		document.getElementById(x).style.display = "none" 
	}
	

	function IsVista()
	{
		var OSName="Unknown OS";
		if (navigator.appVersion.indexOf("Windows NT 6")>0) OSName = "Vista";

		if(OSName == 'Vista')
		{
			return true;
		}
		
		return false;
				
	}
		
	function LoadWait(n)
	{
		  var serverX = document.getElementById("ServerX");
		  
		  try
		  {
		  
			  if (!typeof(serverX)=="object")
				{
					HideSnippet("Snippet_ActiveX_Download");
					ShowSnippet("Snippet_NoActiveX");
					return true;
				} 

			  	if (serverX.Port==5900)
			  	{
			  		VNCInstalled();
			  		return true;
			  	}  	
		
		  } catch(e) {
		  	//alert('failed');
		  }
		  
		if ( ++n > 60 ) 
		{
			HideSnippet("Snippet_ActiveX_Download");	
			ShowSnippet("Snippet_TimeOut");
			window.status = "Loading failed.";
			return false;
		} else {
			return setTimeout("LoadWait("+n+")", 1000);
		}	  	
	}
	
	function pageLoaded()
		{
		if ( document.body.insertAdjacentHTML )
		{
			HideSnippet("ProcessDefault");
			HideSnippet("Header");
			ShowSnippet("Snippet_ActiveX_Download");	
			setTimeout("LoadWait(0)", 100);
		}
	}

	function VNCInstalled()
		{
			
		  	HideSnippet("Snippet_ActiveX_Download");
		  	ShowSnippet("VNC_Controls");
		  	//ShowSnippet("ActiveX_Download_Complete");
		  	ShowSnippet("Header");
		  	ApplyOnPageLoad();
		  	
	  		if(IsVista())
		  	 { 
		  	 	ShowSnippet("Snippet_DetectVista"); 
		  	 }
	}

//window["onl"+"oad"] = Loader;

