// Determine browser we're working in
var isNav4 = false;
var isIE4 = false;
var isWinIE = false;
var isWin32 = false;
var isMac = false;
var isMacPPC = false;
var insideWindowWidth;
var range = " ";
var styleObj = " ";
var bInit = false;

var documentBase = window.location.href; //document.URL;
var hackIndex = documentBase.indexOf( "?" );
if ( -1 != hackIndex )
	documentBase = documentBase.substring( 0, hackIndex );
documentBase = documentBase.substring( 0, documentBase.lastIndexOf("/")+1 );

// Ultimate client-side JavaScript client sniff.
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute.
// Revised 17 May 99 to add is_nav5up and is_ie5up (see below).
// Revised 20 Dec 00 to add is_gecko and change is_nav5up to is_nav6up
//                      also added support for IE5.5 Opera4&5 HotJava3 AOLTV

// Everything you always wanted to know about your JavaScript client
// but were afraid to ask. Creates "is_" variables indicating:
// (1) browser vendor:
//     is_nav, is_ie, is_opera, is_hotjava
// (2) browser version number:
//     is_major (integer indicating major version number: 2, 3, 4 ...)
//     is_minor (float   indicating full  version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
//     is_nav2, is_nav3, is_nav4, is_nav4up, is_nav6,is_nav6up,is_gecko, is_ie3,
//         is_ie4, is_ie5, is_ie5up, is_ie4up, is_ie5_5, is_ie5_5up, is_hotjava3,is_hotjava3up,
//         is_opera4, is_opera5, is_opera5up
// (4) JavaScript version number:
//     is_js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
//     is_win, is_win16, is_win32, is_win31, is_win95, is_winnt, is_win98
//     is_os2
//     is_mac, is_mac68k, is_macppc
//     is_unix
//        is_sun, is_sun4, is_sun5, is_suni86
//        is_irix, is_irix5, is_irix6
//        is_hpux, is_hpux9, is_hpux10
//        is_aix, is_aix1, is_aix2, is_aix3, is_aix4
//        is_linux, is_sco, is_unixware, is_mpras, is_reliant
//        is_dec, is_sinix, is_freebsd, is_bsd
//     is_vms
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when new versions of browsers are released, so
// in conditional code forks, use is_ie5up ("IE 5.0 or greater") 
// is_opera5up ("Opera 5.0 or greater") instead of is_ie5 or is_opera5
// to check version in code which you want to work on future
// versions.

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
// If you want to allow spoofing, take out the tests for opera and webtv.
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                      (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);

var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) && (agt.indexOf("msie 6")== -1) && (agt.indexOf("msie 7")== -1));
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6")!= -1));
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5); 
var is_ie7    = (is_ie && (is_major == 4) && (agt.indexOf("msie 7")!= -1));
var is_ie7up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5 && !is_ie6); 

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
// or if this is the first browser window opened.  Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);

var is_opera = (agt.indexOf("opera") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1);
    var is_opera5up = (is_opera && (is_major >=4));

var is_webtv = (agt.indexOf("webtv") != -1); 

    
var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

var is_hotjava = (agt.indexOf("hotjava") != -1);
var is_hotjava3 = (is_hotjava && (is_major == 3));
var is_hotjava3up = (is_hotjava && (is_major >= 3));

var is_safari = (agt.indexOf("safari") != -1);

// *** JAVASCRIPT VERSION CHECK ***
var is_js;
if (is_nav2 || is_ie3) is_js = 1.0;
else if (is_nav3 || is_opera) is_js = 1.1;
else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
    else if (is_hotjava3up) is_js = 1.4;
else if (is_nav6 || is_gecko) is_js = 1.5;
// NOTE: In the future, update this code when newer versions of JS
// are released. For now, we try to provide some upward compatibility
// so that future versions of Nav and IE will show they are at
// *least* JS 1.x capable. Always check for JS version compatibility
// with > or >=.
    else if (is_nav6up) is_js = 1.5;
else if (is_ie && (is_major > 5)) is_js = 1.3

// HACK: no idea for other browsers; always check for JS version with > or >=
else is_js = 0.0;

// *** PLATFORM ***
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
// NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
//        Win32, so you can't distinguish between Win95 and WinNT.
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

// is this a 16 bit compiled version?
var is_win16 = ((agt.indexOf("win16")!=-1) || 
           (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
           (agt.indexOf("windows 16-bit")!=-1) );  

var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                (agt.indexOf("windows 16-bit")!=-1));

// NOTE: Reliable detection of Win98 may not be possible. It appears that:
//       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
//       - On Mercury client, the 32-bit version will return "Win98", but
//         the 16-bit version running on Win98 will still return "Win95".
var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 || 
                ((is_major >= 4) && (navigator.platform == "Win32")) ||
                (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

var is_os2   = ((agt.indexOf("os/2")!=-1) || 
                (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                (agt.indexOf("ibm-webexplorer")!=-1));

var is_mac    = (agt.indexOf("mac")!=-1);
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 
                           (agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 
                            (agt.indexOf("powerpc")!=-1)));

var is_sun   = (agt.indexOf("sunos")!=-1);
var is_sun4  = (agt.indexOf("sunos 4")!=-1);
var is_sun5  = (agt.indexOf("sunos 5")!=-1);
var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
var is_irix5 = (agt.indexOf("irix 5") !=-1);
var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
var is_hpux  = (agt.indexOf("hp-ux")!=-1);
var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
var is_aix1  = (agt.indexOf("aix 1") !=-1);    
var is_aix2  = (agt.indexOf("aix 2") !=-1);    
var is_aix3  = (agt.indexOf("aix 3") !=-1);    
var is_aix4  = (agt.indexOf("aix 4") !=-1);    
var is_linux = (agt.indexOf("inux")!=-1);
var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
var is_mpras    = (agt.indexOf("ncr")!=-1); 
var is_reliant  = (agt.indexOf("reliantunix")!=-1);
var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
       (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
       (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
var is_sinix = (agt.indexOf("sinix")!=-1);
var is_freebsd = (agt.indexOf("freebsd")!=-1);
var is_bsd = (agt.indexOf("bsd")!=-1);
var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 
             is_sco ||is_unixware || is_mpras || is_reliant || 
             is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
bInit = true;

function GetBrowserInfo()
{
	// Not sure why this happens sometimes, but the above code doesn't always
	// execute.
	if (!bInit)
	{
		agt=navigator.userAgent.toLowerCase();

		// *** BROWSER VERSION ***
		// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
		is_major = parseInt(navigator.appVersion);
		is_minor = parseFloat(navigator.appVersion);

		// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
		// If you want to allow spoofing, take out the tests for opera and webtv.
		is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
						&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
						&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
		is_nav2 = (is_nav && (is_major == 2));
		is_nav3 = (is_nav && (is_major == 3));
		is_nav4 = (is_nav && (is_major == 4));
		is_nav4up = (is_nav && (is_major >= 4));
		is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
											(agt.indexOf("; nav") != -1)) );
		is_nav6 = (is_nav && (is_major == 5));
		is_nav6up = (is_nav && (is_major >= 5));
		is_gecko = (agt.indexOf('gecko') != -1);

		is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
		is_ie3    = (is_ie && (is_major < 4));
		is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) && (agt.indexOf("msie 6")== -1) );
		is_ie4up  = (is_ie  && (is_major >= 4));
		is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
		is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
		is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
		is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
		is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6")!= -1));
		is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5); 
	}

	// Duplicate variables for compatability with old scripts
	isWin32 = is_win32;
	isNav4 = is_nav4up;
	isIE4 = is_ie4up;
	isWinIE = isIE4 && is_win;
	isWin32 = is_win32;
	isMac = is_mac;
	isMacPPC = is_macppc;

	// Set variables used in GetObject below
	if (is_nav4) 
	{
		insideWindowWidth = window.innerWidth
	} 
	else if (isIE4) 
	{
		range = "all."
		styleObj = ".style"
	}
}

// Convert object name string or object reference
// into a valid object reference
function GetObject(obj) 
{
	var theObj
	if (typeof obj == "string") 
	{
		if (isIE4 && (document.getElementById(obj) != null))
		{
			theObj = document.getElementById(obj);
			return theObj.style;
		}
		else if (isIE4)
			theObj = eval("document." + range + obj + styleObj);
		if ( null == theObj )
		{
			theObj = document.getElementById(obj);
			if ( null == theObj)
			{
				//alert( "GetObj failed to find object " + obj );
				return;
			}
		}
	} else 
	{
		theObj = obj
	}
	return theObj
}

// Setting the visibility of an object to visible
function Show(obj) {
	var theObj = GetObject(obj)
	if (theObj != null)
	{
		if (is_nav6up)
			theObj.style.visibility = "visible";
		else
			theObj.visibility = "visible";
	}
}

// Setting the visibility of an object to hidden
function Hide(obj) {
	var theObj = GetObject(obj)
	if (theObj != null)
	{
		if (is_nav6up)
			theObj.style.visibility = "hidden";
		else
			theObj.visibility = "hidden";
	}
}

// Positioning an object at a specific pixel coordinate
function ShiftTo(obj, x, y) {
	var theObj = GetObject(obj)
	if (is_nav4)
	{
		theObj.moveTo(x,y)
	}
	else if (is_nav6up)
	{
		theObj.style.left = x + "px"
		theObj.style.top = y + "px"
	}
	else
	{
		theObj.pixelLeft = x
		theObj.pixelTop = y
	}
}

// Positioning an object at a specific pixel coordinate
function SizeTo(obj, wid, ht) {
	var theObj = GetObject(obj)
	if (is_nav4) 
	{
	}
	else if (is_nav6up)
	{
		theObj.style.width = wid;
		theObj.style.height = ht;
	}
	else
	{
		theObj.width = wid;
		theObj.height = ht;
	}
}

// Moving an object by x and/or y pixels
function ShiftBy(obj, deltaX, deltaY) {
	var theObj = GetObject(obj)
	if (is_nav4)
	{
		theObj.moveBy(deltaX, deltaY)
	}
	else if (is_nav6up)
	{
		theObj.style.left += deltaX
		theObj.style.top += deltaY
	}
	else
	{
		theObj.pixelLeft += deltaX
		theObj.pixelTop += deltaY
	}
}

// Setting the z-order of an object
function SetZIndex(obj, zOrder) {
	var theObj = GetObject(obj)
	theObj.zIndex = zOrder
}

// Setting the background color of an object
function SetBGColor(obj, color) {
	var theObj = GetObject(obj)
	if (is_nav4)
	{
		theObj.bgColor = color
	}
	else if (is_nav6up)
	{
		theObj.style.backgroundColor = color
	}
	else
	{
		theObj.backgroundColor = color
	}
}

// Retrieving the x coordinate of a positionable object
function GetObjectLeft(obj)  {
	var theObj = GetObject(obj)
	if (is_nav4)
	{
		var x = theObj.left;
		if (isNaN(x))
			x = theObj.x;
		return x;
	}
	else if (is_nav6up)
	{
		return theObj.offsetLeft;
	}
	else
	{
		theObj = eval("document." + range + obj)
		return theObj.offsetLeft
	}
}

// Retrieving the y coordinate of a positionable object
function GetObjectTop(obj)  {
	var theObj = GetObject(obj)
	if (is_nav4)
	{
		var y = theObj.top;
		if (isNaN(y))
			y = theObj.y;
		return y
	}
	else if (is_nav6up)
	{
		return theObj.offsetTop;
	}
	else
	{
		theObj = eval("document." + range + obj)
		return theObj.offsetTop
	}
}

// Retrieving the width of a positionable object
function GetObjectWidth(obj)  {
	var theObj = GetObject(obj)
	if (is_nav4)
	{
	}
	else
	{
		var theObj = document.getElementById(obj);
		if (theObj == null)
			return 0;
		return theObj.clientWidth;
	}
}

// Retrieving the height of a positionable object
function GetObjectHeight(obj)  {
	var theObj = GetObject(obj)
	if (is_nav4)
	{
	}
	else
	{
		var theObj = document.getElementById(obj);
		if (theObj == null)
			return 0;
		return theObj.clientHeight
	}
}

var plugInName = ""
var plugInVersion = 0
var smartUpdate = false;

function CheckPlugIn(name, version)
{
	// Save names for possible download
	plugInName = name;
	plugInVersion = version;

	// Determine whether browser supports SmartUpdate
	smartUpdate = navigator.javaEnabled() && netscape.softupdate.Trigger.UpdateEnabled();

	// Check to see if we've got a version of the plug-in
	var mime = "application/x-" + plugInName;
	var mimeType = navigator.mimeTypes[mime];
	var plugin = null;
	if (mimeType)
		plugin = mimeType.enabledPlugin;
	var hasPlugIn = 0;
	if (plugin)
	{
		// We've got the right plug-in.  Is the version okay?
		// Version is specified as (Vn) in the description.
		// Set flag to wrong version
		hasPlugIn = -1;
		var desc = plugin.description;
		var pos = desc.indexOf("(V");
		if (pos > -1)
		{
			// Check for full (1,1,0,32) style version
			var pos2 = desc.lastIndexOf(",");
			if (pos2 > pos)
				pos = pos2 - 1;
			var plugInVersion = parseInt(desc.substring(pos + 2));
			if (plugInVersion >= version)
				hasPlugIn = 1;
		}
	}
	return hasPlugIn;
}

function OnTimerInstallPlugin()
{
	var mime = "application/x-" + plugInName;
	var mimeType = navigator.mimeTypes[mime];
	var plugin = null;
	if (mimeType)
		plugin = mimeType.enabledPlugin;
	if (plugin)
	{
		// It's loaded - go
		window.location.reload();
		return;
	}
	navigator.plugins.refresh(false);
	window.setTimeout("OnTimerInstallPlugin()", 1000);
}

function InstallPlugin(serverPath)
{
	// If IE, then force reload of page with plug-in force flag set
	if (isIE4)
	{
		var url = window.location.href;
		url += (url.indexOf('?') > -1) ? '&' : '?';
		url += 'ForcePlugIn=1';
		window.location.href = url;
		return;
	}

	// Create base URL for server
	var baseUrl = serverPath;
	var index = baseUrl.lastIndexOf("/");
	baseUrl = baseUrl.substr(0, index + 1);

	// Check to see if we've got the plugin
	var mime = "application/x-" + plugInName;
	var mimeType = navigator.mimeTypes[mime];
	var plugin = null;
	if (mimeType)
		plugin = mimeType.enabledPlugin;

	// If has plug-in (version update) or SmartUpdate disabled, go to download page
	if (plugin || !smartUpdate)
	{
		var href = baseUrl + plugInName + "PluginDownload.htm"
		window.location.href = href;
	}
	else
	{
		url = baseUrl + plugInName + "Plugin.jar";
		var trigger = netscape.softupdate.Trigger;
		trigger.StartSoftwareUpdate(url, trigger.DEFAULT_MODE);
		window.setTimeout("OnTimerInstallPlugin()", 1000);
	}
}

function OSBrowserCanInstallPlugins()
{
//  alert( " is_mac = "+is_mac+
//	       " is_nav = "+is_nav+
//	       " is_ie = "+is_ie+
//	       " userAgent = "+navigator.userAgent+
//				 " appVersion = "+navigator.appVersion +
//			   " is_minor = "+is_minor+
//			   " is_win95 = "+is_win95
//				);

  if ( is_mac																// we don't do plugins for Mac
	     || ( !is_nav && !is_ie )							// we only support plugins on these browsers
	     || ( is_nav && is_minor <= 4.08 )		// earlier than NS 4.08 
	     || ( is_ie4 && is_minor < 4.01 )		// earlier than IE 4.01 
			 || is_win95													// win95 has DLL hell problems
		 )
	{ 
		return false;
	}

	return true;
}

var oldSelectFn = null;
function disableTextSelection(target)
{
	if (typeof target.onselectstart!="undefined") //IE route
	{
		oldSelectFn = target.onselectstart;
		target.onselectstart=function(){return false}
	}
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	{
		oldSelectFn = target.style.MozUserSelect;
		target.style.MozUserSelect="none"
	}
}

function enableTextSelection(target)
{
	if (typeof target.onselectstart!="undefined") //IE route
		target.onselectstart=oldSelectFn;
	else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
		target.style.MozUserSelect=oldSelectFn;
}


GetBrowserInfo();				// Force initialization

function toHex(val)
{
	var hex = val.toString(16);
	if (hex.length == 1)
		hex = "0" + hex;
	return hex;
}

function styleToRGB(style)
{
	// See if it's of the form rgb(r,g,b) from Firefox
	var idx = style.indexOf("rgb(");
	var rgb;
	if (idx == 0)
	{
		style = style.substring(idx+4);
		idx = style.indexOf(")");
		if (idx != -1)
			style = style.substring(0, idx);
		var argb = style.split(",");
		rgb = toHex(parseInt(argb[0])) + toHex(parseInt(argb[1])) + toHex(parseInt(argb[2]));
	}
	else
	{
		// Strip off leading #
		rgb = style;
		if (rgb.indexOf("#") == 0)
			rgb = rgb.substring(1);
	}
	return rgb;
}

function validateEmail(strEmail)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	return filter.test(strEmail);
}

/**
*
*  MD5 (Message-Digest Algorithm)
*  http://www.webtoolkit.info/
*
**/
 
var MD5 = function (string) {
 
	function RotateLeft(lValue, iShiftBits) {
		return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
	}
 
	function AddUnsigned(lX,lY) {
		var lX4,lY4,lX8,lY8,lResult;
		lX8 = (lX & 0x80000000);
		lY8 = (lY & 0x80000000);
		lX4 = (lX & 0x40000000);
		lY4 = (lY & 0x40000000);
		lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
		if (lX4 & lY4) {
			return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
		}
		if (lX4 | lY4) {
			if (lResult & 0x40000000) {
				return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
			} else {
				return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
			}
		} else {
			return (lResult ^ lX8 ^ lY8);
		}
 	}
 
 	function F(x,y,z) { return (x & y) | ((~x) & z); }
 	function G(x,y,z) { return (x & z) | (y & (~z)); }
 	function H(x,y,z) { return (x ^ y ^ z); }
	function I(x,y,z) { return (y ^ (x | (~z))); }
 
	function FF(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function GG(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function HH(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function II(a,b,c,d,x,s,ac) {
		a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
		return AddUnsigned(RotateLeft(a, s), b);
	};
 
	function ConvertToWordArray(string) {
		var lWordCount;
		var lMessageLength = string.length;
		var lNumberOfWords_temp1=lMessageLength + 8;
		var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
		var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
		var lWordArray=Array(lNumberOfWords-1);
		var lBytePosition = 0;
		var lByteCount = 0;
		while ( lByteCount < lMessageLength ) {
			lWordCount = (lByteCount-(lByteCount % 4))/4;
			lBytePosition = (lByteCount % 4)*8;
			lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
			lByteCount++;
		}
		lWordCount = (lByteCount-(lByteCount % 4))/4;
		lBytePosition = (lByteCount % 4)*8;
		lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
		lWordArray[lNumberOfWords-2] = lMessageLength<<3;
		lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
		return lWordArray;
	};
 
	function WordToHex(lValue) {
		var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
		for (lCount = 0;lCount<=3;lCount++) {
			lByte = (lValue>>>(lCount*8)) & 255;
			WordToHexValue_temp = "0" + lByte.toString(16);
			WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
		}
		return WordToHexValue;
	};
 
	function Utf8Encode(string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	};
 
	var x=Array();
	var k,AA,BB,CC,DD,a,b,c,d;
	var S11=7, S12=12, S13=17, S14=22;
	var S21=5, S22=9 , S23=14, S24=20;
	var S31=4, S32=11, S33=16, S34=23;
	var S41=6, S42=10, S43=15, S44=21;
 
	string = Utf8Encode(string);
 
	x = ConvertToWordArray(string);
 
	a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
 
	for (k=0;k<x.length;k+=16) {
		AA=a; BB=b; CC=c; DD=d;
		a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
		d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
		c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
		b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
		a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
		d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
		c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
		b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
		a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
		d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
		c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
		b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
		a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
		d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
		c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
		b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
		a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
		d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
		c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
		b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
		a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
		d=GG(d,a,b,c,x[k+10],S22,0x2441453);
		c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
		b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
		a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
		d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
		c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
		b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
		a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
		d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
		c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
		b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
		a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
		d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
		c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
		b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
		a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
		d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
		c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
		b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
		a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
		d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
		c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
		b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
		a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
		d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
		c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
		b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
		a=II(a,b,c,d,x[k+0], S41,0xF4292244);
		d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
		c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
		b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
		a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
		d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
		c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
		b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
		a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
		d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
		c=II(c,d,a,b,x[k+6], S43,0xA3014314);
		b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
		a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
		d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
		c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
		b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
		a=AddUnsigned(a,AA);
		b=AddUnsigned(b,BB);
		c=AddUnsigned(c,CC);
		d=AddUnsigned(d,DD);
	}
 
	var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
 
	return temp.toLowerCase();
}