(function($) {
	var _iCheck = 'iCheck',
		_iCheckHelper = _iCheck + '-helper',
		_checkbox = 'checkbox',
		_radio = 'radio',
		_checked = 'checked',
		_unchecked = 'un' + _checked,
		_disabled = 'disabled',
		_determinate = 'determinate',
		_indeterminate = 'in' + _determinate,
		_update = 'update',
		_type = 'type',
		_click = 'click',
		_touch = 'touchbegin.i touchend.i',
		_add = 'addClass',
		_remove = 'removeClass',
		_callback = 'trigger',
		_label = 'label',
		_cursor = 'cursor',
		_mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);
	$.fn[_iCheck] = function(options, fire) {
		var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]',
			stack = $(),
			walker = function(object) {
				object.each(function() {
					var self = $(this);
					if (self.is(handle)) {
						stack = stack.add(self)
					} else {
						stack = stack.add(self.find(handle))
					}
				})
			};
		if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {
			options = options.toLowerCase();
			walker(this);
			return stack.each(function() {
				var self = $(this);
				if (options == 'destroy') {
					tidy(self, 'ifDestroyed')
				} else {
					operate(self, true, options)
				}
				if ($.isFunction(fire)) {
					fire()
				}
			})
		} else if (typeof options == 'object' || !options) {
			var settings = $.extend({
				checkedClass: _checked,
				disabledClass: _disabled,
				indeterminateClass: _indeterminate,
				labelHover: true
			}, options),
				selector = settings.handle,
				hoverClass = settings.hoverClass || 'hover',
				focusClass = settings.focusClass || 'focus',
				activeClass = settings.activeClass || 'active',
				labelHover = !! settings.labelHover,
				labelHoverClass = settings.labelHoverClass || 'hover',
				area = ('' + settings.increaseArea).replace('%', '') | 0;
			if (selector == _checkbox || selector == _radio) {
				handle = 'input[type="' + selector + '"]'
			}
			if (area < -50) {
				area = -50
			}
			walker(this);
			return stack.each(function() {
				var self = $(this);
				tidy(self);
				var node = this,
					id = node.id,
					offset = -area + '%',
					size = 100 + (area * 2) + '%',
					layer = {
						position: 'absolute',
						top: offset,
						left: offset,
						display: 'block',
						width: size,
						height: size,
						margin: 0,
						padding: 0,
						background: '#fff',
						border: 0,
						opacity: 0
					},
					hide = _mobile ? {
						position: 'absolute',
						visibility: 'hidden'
					} : area ? layer : {
						position: 'absolute',
						opacity: 0
					},
					className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio,
					label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),
					aria = !! settings.aria,
					ariaID = _iCheck + '-' + Math.random().toString(36).substr(2, 6),
					parent = '<div class="' + className + '" ' + (aria ? 'role="' + node[_type] + '" ' : ''),
					helper;
				if (aria) {
					label.each(function() {
						parent += 'aria-labelledby="';
						if (this.id) {
							parent += this.id
						} else {
							this.id = ariaID;
							parent += ariaID
						}
						parent += '"'
					})
				}
				parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);
				helper = $('<ins class="' + _iCheckHelper + '"/>').css(layer).appendTo(parent);
				self.data(_iCheck, {
					o: settings,
					s: self.attr('style')
				}).css(hide); !! settings.inheritClass && parent[_add](node.className || ''); !! settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
				parent.css('position') == 'static' && parent.css('position', 'relative');
				operate(self, true, _update);
				if (label.length) {
					label.on(_click + '.i mouseover.i mouseout.i ' + _touch, function(event) {
						var type = event[_type],
							item = $(this);
						if (!node[_disabled]) {
							if (type == _click) {
								if ($(event.target).is('a')) {
									return
								}
								operate(self, false, true)
							} else if (labelHover) {
								if (/ut|nd/.test(type)) {
									parent[_remove](hoverClass);
									item[_remove](labelHoverClass)
								} else {
									parent[_add](hoverClass);
									item[_add](labelHoverClass)
								}
							}
							if (_mobile) {
								event.stopPropagation()
							} else {
								return false
							}
						}
					})
				}
				self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {
					var type = event[_type],
						key = event.keyCode;
					if (type == _click) {
						return false
					} else if (type == 'keydown' && key == 32) {
						if (!(node[_type] == _radio && node[_checked])) {
							if (node[_checked]) {
								off(self, _checked)
							} else {
								on(self, _checked)
							}
						}
						return false
					} else if (type == 'keyup' && node[_type] == _radio) {
						!node[_checked] && on(self, _checked)
					} else if (/us|ur/.test(type)) {
						parent[type == 'blur' ? _remove : _add](focusClass)
					}
				});
				helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) {
					var type = event[_type],
						toggle = /wn|up/.test(type) ? activeClass : hoverClass;
					if (!node[_disabled]) {
						if (type == _click) {
							operate(self, false, true)
						} else {
							if (/wn|er|in/.test(type)) {
								parent[_add](toggle)
							} else {
								parent[_remove](toggle + ' ' + activeClass)
							}
							if (label.length && labelHover && toggle == hoverClass) {
								label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass)
							}
						}
						if (_mobile) {
							event.stopPropagation()
						} else {
							return false
						}
					}
				})
			})
		} else {
			return this
		}
	};

	function operate(input, direct, method) {
		var node = input[0],
			state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,
			active = method == _update ? {
				checked: node[_checked],
				disabled: node[_disabled],
				indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
			} : node[state];
		if (/^(ch|di|in)/.test(method) && !active) {
			on(input, state)
		} else if (/^(un|en|de)/.test(method) && active) {
			off(input, state)
		} else if (method == _update) {
			for (var each in active) {
				if (active[each]) {
					on(input, each, true)
				} else {
					off(input, each, true)
				}
			}
		} else if (!direct || method == 'toggle') {
			if (!direct) {
				input[_callback]('ifClicked')
			}
			if (active) {
				if (node[_type] !== _radio) {
					off(input, state)
				}
			} else {
				on(input, state)
			}
		}
	}

	function on(input, state, keep) {
		var node = input[0],
			parent = input.parent(),
			checked = state == _checked,
			indeterminate = state == _indeterminate,
			disabled = state == _disabled,
			callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
			regular = option(input, callback + capitalize(node[_type])),
			specific = option(input, state + capitalize(node[_type]));
		if (node[state] !== true) {
			if (!keep && state == _checked && node[_type] == _radio && node.name) {
				var form = input.closest('form'),
					inputs = 'input[name="' + node.name + '"]';
				inputs = form.length ? form.find(inputs) : $(inputs);
				inputs.each(function() {
					if (this !== node && $(this).data(_iCheck)) {
						off($(this), state)
					}
				})
			}
			if (indeterminate) {
				node[state] = true;
				if (node[_checked]) {
					off(input, _checked, 'force')
				}
			} else {
				if (!keep) {
					node[state] = true
				}
				if (checked && node[_indeterminate]) {
					off(input, _indeterminate, false)
				}
			}
			callbacks(input, checked, state, keep)
		}
		if (node[_disabled] && !! option(input, _cursor, true)) {
			parent.find('.' + _iCheckHelper).css(_cursor, 'default')
		}
		parent[_add](specific || option(input, state) || '');
		if ( !! parent.attr('role') && !indeterminate) {
			parent.attr('aria-' + (disabled ? _disabled : _checked), 'true')
		}
		parent[_remove](regular || option(input, callback) || '')
	}

	function off(input, state, keep) {
		var node = input[0],
			parent = input.parent(),
			checked = state == _checked,
			indeterminate = state == _indeterminate,
			disabled = state == _disabled,
			callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
			regular = option(input, callback + capitalize(node[_type])),
			specific = option(input, state + capitalize(node[_type]));
		if (node[state] !== false) {
			if (indeterminate || !keep || keep == 'force') {
				node[state] = false
			}
			callbacks(input, checked, callback, keep)
		}
		if (!node[_disabled] && !! option(input, _cursor, true)) {
			parent.find('.' + _iCheckHelper).css(_cursor, 'pointer')
		}
		parent[_remove](specific || option(input, state) || '');
		if ( !! parent.attr('role') && !indeterminate) {
			parent.attr('aria-' + (disabled ? _disabled : _checked), 'false')
		}
		parent[_add](regular || option(input, callback) || '')
	}

	function tidy(input, callback) {
		if (input.data(_iCheck)) {
			input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
			if (callback) {
				input[_callback](callback)
			}
			input.off('.i').unwrap();
			$(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i')
		}
	}

	function option(input, state, regular) {
		if (input.data(_iCheck)) {
			return input.data(_iCheck).o[state + (regular ? '' : 'Class')]
		}
	}

	function capitalize(string) {
		return string.charAt(0).toUpperCase() + string.slice(1)
	}

	function callbacks(input, checked, callback, keep) {
		if (!keep) {
			if (checked) {
				input[_callback]('ifToggled')
			}
			input[_callback]('ifChanged')[_callback]('if' + capitalize(callback))
		}
	}
	$.fn.extend({
		slimScroll: function(options) {
			var defaults = {
				width: 'auto',
				height: '250px',
				size: '7px',
				color: '#D1D1D1',
				position: 'right',
				distance: '1px',
				start: 'top',
				opacity: 1,
				alwaysVisible: true,
				disableFadeOut: false,
				railVisible: false,
				railColor: '#333',
				railOpacity: .2,
				railDraggable: true,
				railClass: 'slimScrollRail',
				barClass: 'slimScrollBar',
				wrapperClass: 'slimScrollDiv',
				allowPageScroll: false,
				wheelStep: 20,
				touchScrollStep: 200,
				borderRadius: '7px',
				railBorderRadius: '7px'
			};
			var o = $.extend(defaults, options);
			this.each(function() {
				var isOverPanel, isOverBar, isDragg, queueHide, touchDif, barHeight, percentScroll, lastScroll, divS = '<div></div>',
					minBarHeight = 30,
					releaseScroll = false;
				var me = $(this);
				if (me.parent().hasClass(o.wrapperClass)) {
					var offset = me.scrollTop();
					bar = me.siblings('.' + o.barClass);
					rail = me.siblings('.' + o.railClass);
					getBarHeight();
					if ($.isPlainObject(options)) {
						if ('height' in options && options.height == 'auto') {
							me.parent().css('height', 'auto');
							me.css('height', 'auto');
							var height = me.parent().parent().height();
							me.parent().css('height', height);
							me.css('height', height)
						} else if ('height' in options) {
							var h = options.height;
							me.parent().css('height', h);
							me.css('height', h)
						}
						if ('scrollTo' in options) {
							offset = parseInt(o.scrollTo)
						} else if ('scrollBy' in options) {
							offset += parseInt(o.scrollBy)
						} else if ('destroy' in options) {
							bar.remove();
							rail.remove();
							me.unwrap();
							return
						}
						scrollContent(offset, false, true)
					}
					return
				} else if ($.isPlainObject(options)) {
					if ('destroy' in options) {
						return
					}
				}
				o.height = (o.height == 'auto') ? me.parent().height() : o.height;
				var wrapper = $(divS).addClass(o.wrapperClass).css({
					position: 'relative',
					overflow: 'hidden',
					width: o.width,
					height: o.height
				});
				me.css({
					overflow: 'hidden',
					width: o.width,
					height: o.height
				});
				var rail = $(divS).addClass(o.railClass).css({
					width: o.size,
					height: '100%',
					position: 'absolute',
					top: 0,
					display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none',
					'border-radius': o.railBorderRadius,
					background: o.railColor,
					opacity: o.railOpacity,
					zIndex: 90
				});
				var bar = $(divS).addClass(o.barClass).css({
					background: o.color,
					width: o.size,
					position: 'absolute',
					top: 0,
					opacity: o.opacity,
					display: o.alwaysVisible ? 'block' : 'none',
					'border-radius': o.borderRadius,
					BorderRadius: o.borderRadius,
					MozBorderRadius: o.borderRadius,
					WebkitBorderRadius: o.borderRadius,
					zIndex: 99
				});
				var posCss = (o.position == 'right') ? {
					right: o.distance
				} : {
					left: o.distance
				};
				rail.css(posCss);
				bar.css(posCss);
				me.wrap(wrapper);
				me.parent().append(bar);
				me.parent().append(rail);
				if (o.railDraggable) {
					bar.bind("mousedown", function(e) {
						var $doc = $(document);
						isDragg = true;
						t = parseFloat(bar.css('top'));
						pageY = e.pageY;
						$doc.bind("mousemove.slimscroll", function(e) {
							currTop = t + e.pageY - pageY;
							bar.css('top', currTop);
							scrollContent(0, bar.position().top, false)
						});
						$doc.bind("mouseup.slimscroll", function(e) {
							isDragg = false;
							hideBar();
							$doc.unbind('.slimscroll')
						});
						return false
					}).bind("selectstart.slimscroll", function(e) {
						e.stopPropagation();
						e.preventDefault();
						return false
					})
				}
				rail.hover(function() {
					showBar()
				}, function() {
					hideBar()
				});
				bar.hover(function() {
					isOverBar = true
				}, function() {
					isOverBar = false
				});
				me.hover(function() {
					isOverPanel = true;
					showBar();
					hideBar()
				}, function() {
					isOverPanel = false;
					hideBar()
				});
				me.bind('touchstart', function(e, b) {
					if (e.originalEvent.touches.length) {
						touchDif = e.originalEvent.touches[0].pageY
					}
				});
				me.bind('touchmove', function(e) {
					if (!releaseScroll) {
						e.originalEvent.preventDefault()
					}
					if (e.originalEvent.touches.length) {
						var diff = (touchDif - e.originalEvent.touches[0].pageY) / o.touchScrollStep;
						scrollContent(diff, true);
						touchDif = e.originalEvent.touches[0].pageY
					}
				});
				getBarHeight();
				if (o.start === 'bottom') {
					bar.css({
						top: me.outerHeight() - bar.outerHeight()
					});
					scrollContent(0, true)
				} else if (o.start !== 'top') {
					scrollContent($(o.start).position().top, null, true);
					if (!o.alwaysVisible) {
						bar.hide()
					}
				}
				attachWheel(this);

				function _onWheel(e) {
					if (!isOverPanel) {
						return
					}
					var e = e || window.event;
					var delta = 0;
					if (e.wheelDelta) {
						delta = -e.wheelDelta / 120
					}
					if (e.detail) {
						delta = e.detail / 3
					}
					var target = e.target || e.srcTarget || e.srcElement;
					if ($(target).closest('.' + o.wrapperClass).is(me.parent())) {
						scrollContent(delta, true)
					}
					if (e.preventDefault && !releaseScroll) {
						e.preventDefault()
					}
					if (!releaseScroll) {
						e.returnValue = false
					}
				}

				function scrollContent(y, isWheel, isJump) {
					releaseScroll = false;
					var delta = y;
					var maxTop = me.outerHeight() - bar.outerHeight();
					if (isWheel) {
						delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight();
						delta = Math.min(Math.max(delta, 0), maxTop);
						delta = (y > 0) ? Math.ceil(delta) : Math.floor(delta);
						bar.css({
							top: delta + 'px'
						})
					}
					percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight());
					delta = percentScroll * (me[0].scrollHeight - me.outerHeight());
					if (isJump) {
						delta = y;
						var offsetTop = delta / me[0].scrollHeight * me.outerHeight();
						offsetTop = Math.min(Math.max(offsetTop, 0), maxTop);
						bar.css({
							top: offsetTop + 'px'
						})
					}
					me.scrollTop(delta);
					me.trigger('slimscrolling', ~~delta);
					showBar();
					hideBar()
				}

				function attachWheel(target) {
					if (window.addEventListener) {
						target.addEventListener('DOMMouseScroll', _onWheel, false);
						target.addEventListener('mousewheel', _onWheel, false)
					} else {
						document.attachEvent("onmousewheel", _onWheel)
					}
				}

				function getBarHeight() {
					barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);
					bar.css({
						height: barHeight + 'px'
					});
					var display = barHeight == me.outerHeight() ? 'none' : 'block';
					bar.css({
						display: display
					})
				}

				function showBar() {
					getBarHeight();
					clearTimeout(queueHide);
					if (percentScroll == ~~percentScroll) {
						releaseScroll = o.allowPageScroll;
						if (lastScroll != percentScroll) {
							var msg = (~~percentScroll == 0) ? 'top' : 'bottom';
							me.trigger('slimscroll', msg)
						}
					} else {
						releaseScroll = false
					}
					lastScroll = percentScroll;
					if (barHeight >= me.outerHeight()) {
						releaseScroll = true;
						return
					}
					bar.stop(true, true).fadeIn('fast');
					if (o.railVisible) {
						rail.stop(true, true).fadeIn('fast')
					}
				}

				function hideBar() {
					if (!o.alwaysVisible) {
						queueHide = setTimeout(function() {
							if (!(o.disableFadeOut && isOverPanel) && !isOverBar && !isDragg) {
								bar.fadeOut('slow');
								rail.fadeOut('slow')
							}
						}, 1000)
					}
				}
			});
			return this
		}
	});

	//iCheck for checkbox and radio inputs
	$('input[type="radio"].flat-blue').iCheck({
		radioClass: 'iradio_flat-blue'
	});
	$('input[type="checkbox"].flat-blue, input[type="radio"].flat-blue').iCheck({
		checkboxClass: 'icheckbox_flat-blue',
		radioClass: 'iradio_flat-blue'
	})

	$.fn.extend({
		slimscroll: $.fn.slimScroll
	});
	$('#Leftbox').slimScroll({
		height: document.body.clientHeight - 175 + 'px'
	});
	//取色器
	$(function() {
		$('#cp1').colorpicker({
			extensions: [{
				name: 'swatches',
				colors: {
					'black': '#000000',
					'white': '#ffffff',
					'red': '#FF0000',
					'default': '#777777',
					'primary': '#337ab7',
					'success': '#5cb85c',
					'info': '#5bc0de',
					'warning': '#f0ad4e',
					'danger': '#d9534f'
				},
				namesAsValues: true
			}]
		});
	});
})(jQuery);

function GetRadioState(obj) {
	if (obj.checked) {
		return "1"
	} else {
		return "0"
	}
};

function ChosePlat(Str) {
	ProjConf_Plat.value = Str;
};

function MD5(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();
	}