if (!window.zp)
	window.zp = 1;


/*
 * jQuery Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */

(function(jQuery){

	// We override the animation for all of these color styles
	jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
		jQuery.fx.step[attr] = function(fx){
			if ( !fx.p_start ) {
				fx.p_start = getColor( fx.elem, attr );
				if (fx.p_start.length == 3) fx.p_start[3] = 1;
				fx.p_end = getRGB( fx.end );
				if (!fx.p_end) fx.p_end = fx.p_start;
				if (fx.p_end.length == 3) fx.p_end[3] = 1;
			}
			var pv = fx.pos;
			if (!pv) pv = 0;
			if (fx.p_start[3] == 1 && fx.p_end[3] == 1)
				fx.elem.style[attr] = "rgb(" + [
					Math.max(Math.min( parseInt((pv * (fx.p_end[0] - fx.p_start[0])) + fx.p_start[0]), 255), 0),
					Math.max(Math.min( parseInt((pv * (fx.p_end[1] - fx.p_start[1])) + fx.p_start[1]), 255), 0),
					Math.max(Math.min( parseInt((pv * (fx.p_end[2] - fx.p_start[2])) + fx.p_start[2]), 255), 0),
				].join(",") + ")";
			else
				(fx.elem.style[attr] = "rgba(" + [
					Math.max(Math.min( parseInt((pv * (fx.p_end[0] - fx.p_start[0])) + fx.p_start[0]), 255), 0),
					Math.max(Math.min( parseInt((pv * (fx.p_end[1] - fx.p_start[1])) + fx.p_start[1]), 255), 0),
					Math.max(Math.min( parseInt((pv * (fx.p_end[2] - fx.p_start[2])) + fx.p_start[2]), 255), 0),
					Math.max(Math.min( parseFloat((pv * (fx.p_end[3] - fx.p_start[3])) + fx.p_start[3]), 1), 0)
				].join(",") + ")");
		}
	});

	// Color Conversion functions from highlightFade
	// By Blair Mitchelmore
	// http://jquery.offput.ca/highlightFade/

	// Parse strings looking for color tuples [255,255,255]
	function getRGB(color) {
		var result;

		// Check if we're already dealing with an array of colors
		if ( color && color.constructor == Array && color.length == 3 )
			return [color[0], color[1], color[2], 1];
		if ( color && color.constructor == Array && color.length == 4 )
			return color;

		// Look for rgb(num,num,num)
		if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3]), 1];

		// Look for rgba(num,num,num,num]
		if (result = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]+)\s*\)/.exec(color)) {
			var p = [parseInt(result[1]), parseInt(result[2]), parseInt(result[3]), parseFloat(result[4])];
			return p;
		}
		// Look for rgb(num%,num%,num%)
		if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
			return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55, 1];

		// Look for #a0b1c2
		if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
			return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16), 1];

		// Look for #fff
		if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
			return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16), 1];

		// Otherwise, we're most likely dealing with a named color
		return colors[jQuery.trim(color).toLowerCase()];
	}
	
	function getColor(elem, attr) {
		var color;

		do {
			color = jQuery.curCSS(elem, attr);

			// Keep going until we find an element that has color, or we hit the body
			if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
				break; 

			attr = "backgroundColor";
		} while ( elem = elem.parentNode );
		
		if (!color) return getRGB($("body").css("backgroundColor"));
		
		return getRGB(color);
	};
	
	$.getColor = getColor;
	$.getRGB = getRGB;

	// Some named colors to work with
	// From Interface by Stefan Petre
	// http://interface.eyecon.ro/

	var colors = {
		aqua:[0,255,255],
		azure:[240,255,255],
		beige:[245,245,220],
		black:[0,0,0],
		blue:[0,0,255],
		brown:[165,42,42],
		cyan:[0,255,255],
		darkblue:[0,0,139],
		darkcyan:[0,139,139],
		darkgrey:[169,169,169],
		darkgreen:[0,100,0],
		darkkhaki:[189,183,107],
		darkmagenta:[139,0,139],
		darkolivegreen:[85,107,47],
		darkorange:[255,140,0],
		darkorchid:[153,50,204],
		darkred:[139,0,0],
		darksalmon:[233,150,122],
		darkviolet:[148,0,211],
		fuchsia:[255,0,255],
		gold:[255,215,0],
		green:[0,128,0],
		indigo:[75,0,130],
		khaki:[240,230,140],
		lightblue:[173,216,230],
		lightcyan:[224,255,255],
		lightgreen:[144,238,144],
		lightgrey:[211,211,211],
		lightpink:[255,182,193],
		lightyellow:[255,255,224],
		lime:[0,255,0],
		magenta:[255,0,255],
		maroon:[128,0,0],
		navy:[0,0,128],
		olive:[128,128,0],
		orange:[255,165,0],
		pink:[255,192,203],
		purple:[128,0,128],
		violet:[128,0,128],
		red:[255,0,0],
		silver:[192,192,192],
		white:[255,255,255],
		yellow:[255,255,0]
	};
	
})(jQuery);

$(function() {
	var classToggleElementQ = {};
	var ctqIndex = 1;

	function runNextQItem(node) {
		if (!node.getAttribute('q-index')) {
			node.removeAttribute('animation-is-running');
			return;
		}
		setTimeout(function() {
			if (classToggleElementQ[node.getAttribute('q-index')].length) {
				var next = classToggleElementQ[node.getAttribute('q-index')].shift();
				node.removeAttribute('animation-is-running');
				$(node).animateClass(next.delClass, next.addClass, next.options);
			} else {
				node.removeAttribute('q-index');
				node.removeAttribute('animation-is-running');
			}
		}, 13);
	}
	
	/* Animation: -moz-box-shadow, -webkit-box-shadow */
	$.fx.step['MozBoxShadow'] = function(fx) {
		if (!fx.p_start) {
			// -moz-box-shadow: inset? offset-x offset-y blur-radius? spread-radius? color?
			var start = [ "transparent", "0px", "0px", "0px", "0px" ];
			var end   = [ "transparent", "0px", "0px", "0px", "0px" ];
			var p = jQuery.curCSS(fx.elem, fx.prop);
			if (p != 'none' && p) {
				var n = 0;
				if (/rgb\([^)]+\)/.test(p))
				{
					var s = p.split(')');
					start[0] = s.shift() + ')';
					p = s[0].replace(/^\s+/, '').split(/\s+/);
				}
				else
				{
					p = p.split(/\s+/);
					start[0] = p.shift();
				}
				start[1] = p[n++];
				start[2] = p[n++];
				if (parseInt(p[n])) start[3] = p[n++];
				if (parseInt(p[n])) start[4] = p[n++];
			}
			p = (fx.end);
			if (p != 'none' && p) 
			{
				var n = 0;
				if (/rgb\([^)]+\)/.test(p))
				{
					var s = p.split(')');
					end[0] = s.shift() + ')';
					p = s[0].replace(/^\s+/, '').split(/\s+/);
				}
				else
				{
					p = p.split(/\s+/);
					end[0] = p.shift();
				}
				end[1] = p[n++];
				end[2] = p[n++];
				if (parseInt(p[n])) end[3] = p[n++];
				if (parseInt(p[n])) end[4] = p[n++];
			}
			fx.p_start = start;
			fx.p_end   = end;
			fx.start   = 0;
			fx.end     = 1;
		}
		var now = [];
		for (var i = 0; i < fx.p_start.length; i++) now[i] = fx.p_start[i];
		var c0 = fx.p_start[0] == 'transparent' ? $.getColor(fx.elem, 'color') : $.getRGB(fx.p_start[0]);
		var c1 = fx.p_end[0] == 'transparent' ? $.getColor(fx.elem, 'color') : $.getRGB(fx.p_end[0]);
		now[0] = 'rgb(' + [ 
			Math.max(Math.min(parseInt((fx.pos * (c1[0] - c0[0])) + c0[0]), 255), 0),
			Math.max(Math.min(parseInt((fx.pos * (c1[1] - c0[1])) + c0[1]), 255), 0),
			Math.max(Math.min(parseInt((fx.pos * (c1[2] - c0[2])) + c0[2]), 255), 0)
		].join(',') + ')';
		// now[0] = fx.p_end[0];
		var nv = fx.now ? fx.now : 0;
		now[1] = (parseFloat(fx.p_start[1]) + (parseFloat(fx.p_end[1]) - parseFloat(fx.p_start[1])) * nv) + 'px';
		now[2] = (parseFloat(fx.p_start[2]) + (parseFloat(fx.p_end[2]) - parseFloat(fx.p_start[2])) * nv) + 'px';
		now[3] = (parseFloat(fx.p_start[3]) + (parseFloat(fx.p_end[3]) - parseFloat(fx.p_start[3])) * nv) + 'px';
		now[4] = (parseFloat(fx.p_start[4]) + (parseFloat(fx.p_end[4]) - parseFloat(fx.p_start[4])) * nv) + 'px';
		fx.elem.style[fx.prop] = now.join(" ");
	}
	$.fx.step['WebkitBoxShadow'] = $.fx.step['MozBoxShadow'];
	$.fn.extend({
		animateClass: function(removeClass, addClass, options) {
			var animateProperties = [ 
				'width', 'height',
				'top', 'left',
				'marginLeft', 'marginRight', 'marginTop', 'marginBottom',
				'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth',
				'borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor',
				'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom',
				'opacity',
				'fontSize',
				'WebkitBoxShadow', 'MozBoxShadow',
				'WebkitBorderTopLeftRadius', 'WebkitBorderTopRightRadius', 'WebkitBorderBottomLeftRadius', 'WebkitBorderBottomRightRadius',
				'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius',
				'MozBorderRadiusTopleft', 'MozBorderRadiusTopright', 'MozBorderRadiusBottomleft', 'MozBorderRadiusBottomright',
				'color', 'backgroundColor'
			];
			this.each(function() {
				if (this.getAttribute("animation-is-running"))
				{
					if (!this.getAttribute("q-index"))
						this.getAttribute("q-index", ctqIndex++);
					if (!classToggleElementQ[this.getAttribute('q-index')])
						classToggleElementQ[this.getAttribute('q-index')] = [];
					classToggleElementQ[this.getAttribute('q-index')].push({ delClass: removeClass, addClass: addClass, options: options });
					return;
				}

				this.setAttribute('animation-is-running', 1);
				
				if (removeClass && !$(this).hasClass(removeClass)) {
					if (options && options.complete)
						options.complete();

					runNextQItem(this);
					return;
				}

				var p = 0;
				var n = this.getElementsByTagName('*');
				for (var i = 0; i < n.length; i++) {
					if (n[i].nodeType == 1) n[i].setAttribute('p', i + 1);
				}
				if ($.browser.msie) {
					d = document.createElement('div');
					d.innerHTML = this.outerHTML;
					d = d.firstChild;
					if (!d)
						d = this.cloneNode(true);
				} else {
					d = this.cloneNode(true);
				}
				d.style.visibility = 'hidden';
				if (removeClass)
					$(d).removeClass(removeClass);
				if (addClass) 
					$(d).addClass(addClass);
				this.parentNode.appendChild(d);

				var st = {};
				var st0 = {};
				for (var i = 0; i < animateProperties.length; i++) {
					st0[animateProperties[i]] = $(this).css(animateProperties[i]);
					st[animateProperties[i]] = $(d).css(animateProperties[i]);
					if (st[animateProperties[i]] == st0[animateProperties[i]])
					{
						delete st[animateProperties[i]];
						delete st0[animateProperties[i]];
						continue;
					}						
					if (st0[animateProperties[i]] == 'auto') {
						if (animateProperties[i] == 'height')
							st0[animateProperties[i]] = this.offsetHeight;
						else if (animateProperties[i] == 'width')
							st0[animateProperties[i]] = this.offsetWidth;
						else
							st0[animateProperties[i]] = 0;
					}
					if (st[animateProperties[i]] == 'auto') {
						if (animateProperties[i] == 'height')
							st[animateProperties[i]] = d.offsetHeight;
						else if (animateProperties[i] == 'width')
							st[animateProperties[i]] = d.offsetWidth;
						else
							st[animateProperties[i]] = 0;
					}
					if (st[animateProperties[i]] == st0[animateProperties[i]])
					{
						delete st[animateProperties[i]];
						delete st0[animateProperties[i]];
					}
				}
				
				var tc = 0, cc = 0;
				var self = this;
				
				$("[p]", this).each(function() {
					var st0, st1;
					var o = $.extend({}, options, { 
						complete: function() {
							var stext = this.getAttribute('original-style');
							if (!stext) stext = "";
							// if ($.support.style) this.setAttribute('style', stext);
							this.style.cssText = stext;
							cc++;
							if (cc == tc) {
								if (options && options.complete) {
									options.complete();
								}
								runNextQItem(self);
							}
						} 
					});
					var p = $("[p='" + this.getAttribute('p') + "']", d)[0];
					st0 = {};
					st1 = {};
					if ($(this).css("display") != "none" || $(p).css("display") != "none") {
						for (var i = 0; i < animateProperties.length; i++) {
							st0[animateProperties[i]] = $(this).css(animateProperties[i]);
							st1[animateProperties[i]] = $(p).css(animateProperties[i]);
							if (st0[animateProperties[i]] == st1[animateProperties[i]])
							{
								delete st1[animateProperties[i]];
								delete st0[animateProperties[i]];
								continue;
							}						
							if (st0[animateProperties[i]] == 'auto') {
								if (animateProperties[i] == 'height')
									st0[animateProperties[i]] = this.offsetHeight;
								else if (animateProperties[i] == 'width')
									st0[animateProperties[i]] = this.offsetWidth;
								else
									st0[animateProperties[i]] = 0;
							}
							if (st1[animateProperties[i]] == 'auto') {
								if (animateProperties[i] == 'height')
									st1[animateProperties[i]] = p.offsetHeight;
								else if (animateProperties[i] == 'width')
									st1[animateProperties[i]] = p.offsetWidth;
								else
									st1[animateProperties[i]] = 0;
							}
							if (st0[animateProperties[i]] == st1[animateProperties[i]])
							{
								delete st0[animateProperties[i]];
								delete st1[animateProperties[i]];
							}
						}
						var pc = 0;
						for (var i in st0) pc++;
						if (pc) {
							tc++;
							var stext;
							this.setAttribute('original-style', stext = ($.support.style ? this.getAttribute('style') : this.style.cssText));
							if (!stext) this.removeAttribute('original-style');
							$(this).css(st0).animate(st1, $.extend({}, o, { queue: false }));
						} else {
							;
						}
					}
				});
				var o = $.extend({}, options, { queue: false, complete: function() {
					var stext = this.getAttribute('original-style');
					if (!stext) { stext = ""; }
					this.style.cssText = stext;
					
					cc++;
					if (cc == tc) {
						if (options && options.complete) options.complete.apply(this, arguments);
						runNextQItem(this);
					}
				} });
				var stext;
				this.setAttribute('original-style', stext = ($.support.style ? this.getAttribute('style') : this.style.cssText));
				if (!stext) this.removeAttribute('original-style');
				$(this).css(st0);
				if (removeClass) $(this).removeClass(removeClass);
				if (addClass) $(this).addClass(addClass);
				d.parentNode.removeChild(d);
				tc++;
				$(this).animate(st, o);
			});
		}
	});
        /*@cc_on
        	if (/MSIE [678]/.test(navigator.userAgent) || (/MSIE 9/.test(navigator.userAgent) && document.documentMode < 9)) {
                window.onload = (function(old) {
                	return function() {
                    	var ss = document.createElement("style");
                        ss.setAttribute('type', 'text/css');
                        for (var i = 0; i < document.styleSheets.length; i++) {
                        	try {
                                for (var j = 0; j < document.styleSheets[i].rules.length; j++) {
                                	try {
                                        if (document.styleSheets[i].rules[j].style.opacity) {
                                        	if (document.styleSheets[i].rules[j].style['-sw-no-filter']) continue;
                                        	
                                        	var rule;
                                        		if (parseFloat(document.styleSheets[i].rules[j].style.opacity) == 1) {
                                        			rule = "visibility:visible;";
                                        		} else if (parseFloat(document.styleSheets[i].rules[j].style.opacity) == 0) {
                                        			rule = "visibility:hidden";
                                        		} else {
                                                	rule = "filter:alpha(opacity=" + Math.floor(parseFloat(document.styleSheets[i].rules[j].style.opacity) * 100) + ")";
                                                }
                                                ss.styleSheet.addRule(document.styleSheets[i].rules[j].selectorText, rule);
                                                try {
                                                        document.styleSheets[i].rules[j].opacity = "";
                                                } catch (e) {
                                                        ;
                                                }
                                        }
                                    } catch (e) {
                                        ;
                                    }
                                }
                            } catch (e) {
                                ;
                            }
                        }
                        document.getElementsByTagName('head')[0].appendChild(ss);
                        if (old)
                        	return old.apply(this, arguments);
                    }
                })(window.onload);
            }
        @*/
});

