/******************************************************************

     Auto Install javascript functions

Author: 
Date Created: 9/14/00
*******************************************************************/
//(((((((((((((((((((((((( Generic functions ))))))))))))))))))))))))))))))))

	/******************************************************************
   NS_PluggedIn()
   
        Determines if the NS plugin is loaded / installed
   
   Author: 
   Date Created: 9/14/00
   *******************************************************************/
    function NS_PluggedIn()
    {
		var x = 0;
		var numPlugins = navigator.plugins.length;
		var sPlugins = "";
		var bPluggedIn = false;
		
		for (x = 0; x < numPlugins; x++)
		{
			plugin = navigator.plugins[x];
			if (plugin.name.indexOf("VisiCheck") >= 0)
			{
				bPluggedIn = true;
				break;
			}			
		}
		return bPluggedIn;
    }
    
	/******************************************************************
   VerifyPlugin()
   
        Determines if the either the IE control or the NS plugin is loaded / installed
   
   Author: 
   Date Created: 9/14/00
   *******************************************************************/
    function VerifyPlugin()
    {
    
		if (isNS)
			return NS_VerifyPlugin();
		else
			return IE_VerifyPlugin();
    }
    
    function NS_VerifyPlugin()
	{
		return (isNS && NS_PluggedIn());
	}

	/******************************************************************
   function IE_VerifyPlugin()
   
        Returns true if the IE control is initialized
   
   Author: 
   Date Created: 9/14/00
   *******************************************************************/
	 function IE_VerifyPlugin()
	{
		return (isIE && "undefined" != typeof(document.objVerify));
	}
	
	/******************************************************************
   UpdatePlugin(strVersion)
   
        Returns true if the control / plugin needs to be updated
   
   Author: 
   Date Created: 9/14/00
   *******************************************************************/
	function UpdatePlugin(strVersion)
	{	
		//return (document.objVerify.checkCtlVersion(strVersion) != 0)
		if (isIE)
		{
			if (document.objVerify.checkVersion("9.9.9.9") == 1)
			{
			
		
				//They have the old control and they need to upgrade
				bUpdatePlugin = true;
				return bUpdatePlugin;
			}
			else
			{
				bUpdatePlugin = (document.objVerify.checkCtlVersion(strVersion) == 1);
				return bUpdatePlugin;
			}
		}
		else
		{
			//Make sure and load any new plugins
			navigator.plugins.refresh(true);
			if ( navigator.javaEnabled())
			{
			    trigger = netscape.softupdate.Trigger;
			    if ( trigger.UpdateEnabled())
			    {
			        if (navigator.platform == "Win32")
			        {
			            vi = new netscape.softupdate.VersionInfo(NS_maj, NS_min, NS_rev, NS_bld);
			            client_vi = trigger.GetVersionInfo("plugins/com/visitalk.com");
			            
			            bUpdatePlugin = ((client_vi == null) || (client_vi.compareTo(vi) < 0));
			            return bUpdatePlugin;
			            
			            //if ((client_vi == null) || client_vi.compareTo(vi < 0))
						//	return true;
						//else
						//{
						//	return false;
						//}
			        }
			        else
			            alert("This plug-in only runs on Win32 platform.")
			    }
			    else
			        alert("Enable SmartUpdate before running this script.");
			}
			else
			    alert("Enable Java before running this script.");
		
		//	return (document.embeds["NPVerify"].checkVersion(strVersion) == 1)
		}
	}
	
	/******************************************************************
   UpdateConnector(strVersion)
   
        Returns true if the connector needs to be updated
   
   Author: 
   Date Created: 9/14/00
   *******************************************************************/
   function UpdateConnector(strVersion) 
   {
      if (objVerify.checkVersion("9.9.9.9") == 1)
      {
      	//They have old control
      	return (objVerify.checkVersion(strVersion) == 1);
      }
      else
      {
      	//The have the new control
      	return (objVerify.checkConnectorVersion(strVersion) == 1);
      }
   }

	
	
	function IE_Init()
	{
		window.status = "visitalk.com";
		bInitialized = true;
		return bInitialized;
	}
	
	//=-=-=-=-=-=-=-=-DoesKeyExist()=-=-=-=-=-=-=-=-=-
	function DoesKeyExist()
	{
		if (isNS)
			return NS_DoesKeyExist();
		else
			return IE_DoesKeyExist();
	}
	
	function NS_DoesKeyExist()
	{
		if (isNS && document.embeds["NPVerify"].doesKeyExist())
			return true;
		else
			return false
	}
	
	function IE_DoesKeyExist()
	{
		if (isIE && document.objVerify.doesKeyExist)
			return true;
		else
			return false
	}
	
function GetVerifiedURL2(sURL, bSecure)
{
	var sLoc = "";
	//Appends verified flag to url.
	if (bSecure)
		sLoc = 'https://' + sURL + '&SoftwareVerified=' + VerifyInstall();
	else
		sLoc = 'http://' + sURL + '&SoftwareVerified=' + VerifyInstall();
		
	document.location.href = sLoc;
}
	
function GetVerifiedURL(sURL)
{
	//Appends verified flag to url.
	var i =  VerifyInstall();
	if (i == "1") document.location = 'https://' + sURL + '&SoftwareVerified=' + i;
}
		
function GoToInstall()
{
	document.location.replace(location.host + "/CommSite/Support/NoSoftware.asp");
}

function CloseMe()
{
	window.close();
}

function ReDirectParent(sURL)
{
	creator.location=sURL;
	CloseMe();
}

function OpenWindow(sURL, iAction)
{
	var winHeight = 600;
	var winWidth = 700;
	var leftX = ((screen.width / 2) - (winWidth / 2)) ;
	var topY = ((screen.height / 2) - (winHeight / 2));

	var sLoc = ",width=" + winWidth + ",height=" + winHeight;		
	sLoc = sLoc + ",screenX=" +  leftX  + ",screenY=" + topY + ",left=" + leftX + ",top=" +  topY;
	
	//Append calling page URL so we can take the user back where they were if we need to
	sURL = sURL + strCaller;
	
	//1 = redirect, 2 = replace, 3 = open new
	switch (iAction) {
		case 1:
			document.location = sURL;
			break;
		case 2:
			document.location.replace(sURL);
			break;
		default:
		  window.open(sURL,"","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=yes" + sLoc);
	}
}

function GetQueryString() 
{
	var	StartInd=0;
	var	SourceURL	= document.location;
	var	EndInd=0;
	var lwrSourceURL;
	
	document.write("SourceURL: " + SourceURL);
	
	lwrSourceURL	= SourceURL.toLowerCase();
	StartInd = SourceURL.indexOf("?");
	if (StartInd == -1) return "";
	EndInd = SourceURL.length - StartInd;

	return unescape(SourceURL.substr(StartInd, EndInd));
}

function GetParamVal(Param) 
{
	var	StartInd=0;
	var	SourceURL	= document.location;
	var	ParamLen = Param.length + 1;
	var	EndInd=0;
	var lwrSourceURL;
	
	Param = Param.toLowerCase();
	lwrSourceURL = SourceURL.toLowerCase();
	StartInd = lwrSourceURL.indexOf(Param + "=");
	if (StartInd == -1) return "";
	EndInd = lwrSourceURL.indexOf("&", StartInd + 1);
	if (EndInd == -1) EndInd = lwrSourceURL.length - (StartInd + ParamLen);
	else EndInd = EndInd - (StartInd + ParamLen);
	
	return unescape(SourceURL.substr(StartInd + ParamLen, EndInd));
}

function GetQueryString_old() 
{
	var	StartInd=0;
	var	SourceURL	= document.location;
	var	EndInd=0;
	var lwrSourceURL;
	
	lwrSourceURL	= SourceURL.toLowerCase();
	StartInd = lwrSourceURL.indexOf("?");
	if (StartInd == -1) return "";
	EndInd = lwrSourceURL.length - StartInd;

	return unescape(SourceURL.substr(StartInd, EndInd));
}

function GetParamVal_old(Param) 
{
	var	StartInd=0;
	var	SourceURL	= document.location;
	var	ParamLen = Param.length	+ 1;
	var	EndInd=0;
	var lwrSourceURL;
	
	Param =	Param.toLowerCase();
	lwrSourceURL	= SourceURL.toLowerCase();
	StartInd = lwrSourceURL.indexOf(Param + "=");
	if (StartInd ==	-1) return "";
	EndInd = lwrSourceURL.indexOf("&", StartInd + 1);
	if (EndInd == -1) EndInd = lwrSourceURL.length - (StartInd + ParamLen);
	else EndInd = EndInd - (StartInd + ParamLen);
	
	return unescape(SourceURL.substr(StartInd + ParamLen, EndInd));
}