var agt = navigator.userAgent.toLowerCase();
var is_winNTOS=(agt.indexOf("windows nt") != -1)//added for wg0001224

//adding a comment to change the checksum
//check for vista added to solve the problem that Vista does not allow Firefox to install plugin dll files, 
//if user does not have administrative rights at the Firefox installation location
var isVista = (agt.indexOf("windows nt 6.0") != -1);

is_major = parseInt(navigator.appVersion);
is_minor = parseFloat(navigator.appVersion);
is_ie  = ((agt.indexOf("msie") != -1) && (agt.lastIndexOf(")") == agt.length-1));
is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
is_ie5up = (is_ie && (is_major == 4) && (agt.indexOf("msie 4.0")==-1) );
is_nav = (navigator.appName.indexOf("Netscape") != -1);
is_win = ( (agt.indexOf("win") != -1) || (agt.indexOf("16bit") != -1) );
is_mac = (agt.indexOf("mac")!=-1);
is_macintel = (navigator.platform.toLowerCase().indexOf("macintel") != -1);
is_nav4 = (is_nav && is_major == 4);
is_nav6 = (is_nav && (is_major > 4));
is_safari = (agt.indexOf("safari") > -1);
is_msntv = (agt.indexOf("msntv") > -1);
is_winme = (agt.indexOf("Windows 98; Win 9x 4.90") > -1);
is_win98 = (agt.indexOf("Windows 98") > -1); 
isActiveXCapable = ( is_ie5up && !is_msntv && is_winNTOS && !is_winme && !is_win98);
isDHTMLCapable = (is_nav6 || is_safari);
isMacUpload = (is_mac && is_safari);
isMacIntelUpload = (is_macintel && is_safari);
isFirefox = (agt.indexOf("firefox/1.0") != -1) || (agt.indexOf("firefox/1.5") != -1) || (agt.indexOf("firefox/2.0") != -1) || (agt.indexOf("firefox/3.0") != -1) || (agt.indexOf("firefox/3.5") != -1);
isWindowsFirefox = isFirefox && is_win;
isFirefox3 = agt.indexOf("firefox/3.0") != -1 || agt.indexOf("firefox/3.5") != -1;
isFirefox2 = (agt.indexOf("firefox/1.0") != -1) || (agt.indexOf("firefox/1.5") != -1) || (agt.indexOf("firefox/2.0") != -1);
isChrome = (agt.indexOf ("chrome") != -1) ;
function isMacUploaderInstalled()
{
	if( getMacUploaderVersion() != null )
	{
		return true;
	}
	return false;
}

function getMacUploaderVersion()
{
	var rgx = new RegExp("PhotoCenterPlugin","g");
	for( var i=0; i < navigator.plugins.length; i++ )
	{
		if( navigator.plugins[i].name.search(rgx) > -1 )
		{
			return navigator.plugins[i].name.replace(rgx, "");
		}
	}
	return null;
}

function isMacUploaderCurrent(sVersion)
{
	if( isMacUploaderInstalled() )
	{
		var sServerVersion = sVersion;
		var sInstalledVersion = getMacUploaderVersion();
		if( sInstalledVersion == sServerVersion )
		{
			return true;
		}
		else
		{
			var aServerVersion = sServerVersion.split(".");
			var aInstalledVersion = sInstalledVersion.split(".");
			for( var i=0; i < Math.min(aInstalledVersion.length,aServerVersion.length); i++ )
			{ //go through the entire version string, bit by bit
				var iIVBit = (new Number(aInstalledVersion[i])).valueOf();
				var iSVBit = (new Number(aServerVersion[i])).valueOf();
				if( iIVBit == iSVBit )
				{ //if current bits are identical, move on to the next set
					continue;
				}
				else if( iIVBit > iSVBit )
				{ //rare case: if the current installed bit is greater than the server bit, return true
					return true;
				}
				else
				{ //otherwise the current installed bit is lower than the passed server version; we need an upgrade
					return false;
				}
			}
			//If we exit the loop without a hit that means that the lowest common denomiator for length
			// was identical but one of the plug-ins had more sub-versions to it so lets handle that...
			if( aInstalledVersion.length > aServerVersion.length )
			{ //if we got here then the installed version is a newer sub-version than the server version so it must be newer
				return true;
			}
			else
			{ //otherwise the server version has more sub-versions so the installed version is older
				//alert("server version has more minor versions");
				return false;
			}
		}
	}
	return true; //catch all return: we should never get here but make sure it works for the impossible case anyway
}

function removeInvalidChars(caption)
{
	return caption.replace(/\"/g, "'");
}

if( is_win )
{
    document.writeln('<SCRIPT LANGUAGE="VBSCRIPT">  ');
    document.writeln('  function getActiveXInstallState(currentVersion , controlName)  ');
    document.writeln('      on error resume next  ');
    document.writeln('      getActiveXInstallState = -1 ');
    document.writeln('      Dim AxObject ');
    document.writeln('      Dim isObjectDefined ');
    document.writeln('      set AxObject = CreateObject(controlName)  ');
    document.writeln('      isObjectDefined = IsObject(AxObject)  ');
    document.writeln('      if (err) then  ') ;
    document.writeln('        getActiveXInstallState = 0 ');
    document.writeln('      else  ');
    document.writeln('          if AxObject.getClassID() = currentVersion then ');
    document.writeln('              getActiveXInstallState = 2 ');
    document.writeln('          else  ') ;
    document.writeln('              getActiveXInstallState = 1  ');
    document.writeln('          end if ');
    document.writeln('      end if  ');
    document.writeln('  end function  ');
    document.writeln('</SCRIPT\>  ') ;
}

