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 );
				fx.p_end = getRGB( fx.end );
			}
			var pv = fx.pos;
			if (!pv) pv = 0;
			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(",") + ")";
		}
	});

	// 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))
			return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3]), parseFloat(result[4])];

		// 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 galleries = [ { dummy: true } ];
		
	$.fn.extend({
		boxHover: function() {
			var self = this;
			$(".record-body", this).css({ height: '0', overflow: 'hidden', opacity: 0, visibility: 'visible', minHeight: '0' });
			$(this).hover(function() {
				$(".record-body", this).stop();
				$(".wrapper", this).stop();
				$(".record-body", this).css({ opacity: 0, height: 0 });
				$(this).css({ position: 'relative', width: $(this).width(), height: $(this).height(), zIndex: zp++ });
				$(".wrapper", this).css({
					position: 'absolute',
					width: $(this).width(),
					top: 0,
					left: 0,
					padding: 0,
					border: '0px solid black',
					background: 'white',
					MozBoxShadow: '#000 0 -3px 8px',
					WebkitBoxShadow: '#000 0 -3px 8px',
					boxShadow: '#000 0 -3px 8px',
					MozBorderRadius: '0px',
					WebkitBorderRadius: '0px',
					borderRadius: '0px'
				});
				var H = $(".record-body .title", this).height();
				$(".record-body", this).animate({ opacity: 1, height: H });
				$(".wrapper", this).animate({
					padding: '15px',
					top: '-17px',
					left: '-17px',
					MozBorderRadius: '5px',
					WebkitBorderRadius: '5px',
					borderRadius: '5px',
					borderLeftWidth: '5px',
					borderRightWidth: '2px',
					borderTopWidth: '2px',
					borderBottomWidth: '2px'
				});
			}, function() {
				$(".record-body", this).stop();
				$(".wrapper", this).stop();
				var cp = parseInt($(".wrapper", this).css("left")) / -17;
				var T = cp * 600;
				$(".record-body", this).animate({ height: '0', opacity: 0 }, T);
				$(".wrapper", this).animate({
					padding: '0px',
					borderLeftWidth: '0px',
					borderRightWidth: '0px',
					borderTopWidth: '0px',
					borderBottomWidth: '0px',
					top: '0px',
					left: '0px',
					MozBorderRadius: 0,
					WebkitBorderRadius: 0,
					borderRadius: 0
				}, {
					duration: T,
					complete: function() {
						$(this).css({ position: 'static', width: 'auto', height: 'auto', MozBoxShadow: '', WebkitBoxShadow: '', boxShadow: '' });
						$(self).css({zIndex: ''});
					}
				});
			});
		},
		gallery: function(images) {
			var self = this;
			var id = galleries.length;
			this.attr("gallery-id", id);
			galleries.push({
				activate: function(options) {
					var gallery = $(".gallery", self);
					gallery_properties = { position: 'fixed', opacity: 0, top: 0, left: 0, right: 0, bottom: 0, zIndex: 10001 };
					var isIE6 = false;
				
					/*@cc_on
						@if (@_jscript_version <= 5.7)
							if (/MSIE 6/.test(navigator.userAgent)) {
								isIE6 = true;
								gallery_properties.position = 'absolute';
								delete gallery_properties.right;
								gallery_properties.width = $(window).width();
								gallery_properties.height = $(window).height();
								delete gallery_properties.bottom;
							}
							@end
					@*/
					gallery.css(gallery_properties);
					if (isIE6) {
						$(document.documentElement) /* .css({ overflow: 'hidden' }) */ .bind("scroll.gallery", function() {
							gallery.css({
								top: document.documentElement.scrollTop,
								left: document.documentElement.scrollLeft
							});
							$(".gallery-overlay").css({
								top: document.documentElement.scrollTop,
								left: document.documentElement.scrollLeft
							});
						});
						$(window).bind("resize.gallery", function() {
							gallery.css({ width: $(window).width(), height: $(window).height() });
							$(".gallery-overlay").css({ width: $(window).width(), height: $(window).height() });
						});
					}
					$("body").append("<div class='gallery-overlay'>\xa0<" + "/div>");
					gallery_properties.background = 'black';
					gallery_properties.zIndex = 10000;
					$(".gallery-overlay").css(gallery_properties);
					$("body").append(gallery);
					if (!gallery.hasClass("gallery-initialized")) {
						var handleResize;
						$(".gallery-title-container", gallery).css({ position: 'absolute', top: '0', left: '0', right: '0', fontSize: '32px', lineHeight: '44px', color: 'white', zIndex: 1 });
						$(".gallery-title").css({ position: 'relative', padding: '6px 164px 6px 44px', maxWidth: '816px', margin: '0 auto' });
						function setupDescriptionContainer() {
							if ($(".description-container", gallery).size()) {
								$(".description-container", gallery).css({ position: 'absolute', bottom: '-1000px', left: '0', right: '0', background: 'black', fontSize: '14px', zIndex: 1, color: 'white', borderTop: '1px solid #ccc' });
								$(".description-container .toggle-up", gallery).css({ position: 'absolute', cursor: 'pointer', top: '0', left: '50%', textIndent: '-10000px', marginLeft: '-13.5px', textAlign: 'center', width: '27px', height: '0', overflow: 'hidden', background: "url(/images/but-pop-info.gif) no-repeat top left" }).mouseenter(function() {
									$(this).css('background-image', 'url(/images/but-pop-info-hover.gif)');
								}).mouseleave(function() {
									$(this).css('background-image', 'url(/images/but-pop-info.gif)');
								});
								$(".description-container .toggle-down", gallery).css({ position: 'absolute', cursor: 'pointer', bottom: '8px', left: '50%', textIndent: '-10000px', marginLeft: '-13.5px', textAlign: 'center', width: '27px', overflow: 'hidden', height: '27px', background: "url(/images/but-pop-info-close.gif) no-repeat top left" }).mouseenter(function() {
									$(this).css('background-image', 'url(/images/but-pop-info-close-hover.gif)');
								}).mouseleave(function() {
									$(this).css('background-image', 'url(/images/but-pop-info-close.gif)');
								});
								$(".description-container .toggle-up", gallery).click(function() {
									// $(".gallery-title-container", gallery).animate({ top: '0' });
									$(".description-container", gallery).animate({ bottom: '0', borderTopWidth:'1px' }, { step: handleResize });
									$(".description-container .toggle-up", gallery).animate({ height: '0', top: '0' });
								});
								$(".description-container .toggle-down", gallery).click(function() {
									// $(".gallery-title-container", gallery).animate({ top: 0 - $(".gallery-title-container", gallery).height() });
									$(".description-container", gallery).animate({ bottom: 0 - $(".description-container", gallery).height(), borderTopWidth: '0' }, { step: handleResize });
									$(".description-container .toggle-up", gallery).animate({ height: '27px', top: '-35px' });
								});
								$('.description', gallery).css({ padding: '0 44px 44px 44px', margin: '0 auto', maxWidth: '936px' });
								$(".description-container .toggle-up", gallery).css({ height: '27px', top: '-35px' });
								$(".description-container", gallery).css({ bottom: 0 - $(".description-container", gallery).height(), borderTopWidth: '0' });
							}
						}
						$(".gallery-close", gallery).css({ position: 'absolute', cursor: 'pointer', right: '0', top: '0', fontSize: '16px', background: "url(/images/but-pop-closed.gif) no-repeat top left", width: '93px', height: '32px', color: 'white', zIndex: 2, textIndent: '-100000px' }).click(function() {
							$(".gallery-overlay").animate({ opacity: 0 }, function() { $(this).remove(); });
							gallery.animate({ opacity: 0 }, function() {
								if ($(".record-body", self).size())
									$(".record-body", self).append(this);
								else
									$(self).append(this);
							});
							$(window).unbind(".gallery");
							$(document.documentElement).unbind(".gallery"); // .css({ overflow: '' });
							$("body").css({ overflow: '' });
						}).mouseenter(function() { 
							$(this).css({ backgroundImage: 'url(/images/but-pop-closed-hover.gif)' }); 
						}).mouseleave(function() {
							$(this).css({ backgroundImage: 'url(/images/but-pop-closed.gif)' }); 
						});
						
						var currentIndex = 0;
						var setGalleryImage = function(index) {
							$(".gallery-images .gallery-image.active", gallery).removeClass('active').fadeOut();
							$(".gallery-images .gallery-image:eq(" + index + ")", gallery).addClass('active').fadeIn();
							var img = $(".gallery-images .gallery-image.active img");
							if (img.attr('image-title') && img.attr('image-description')) {
								if ($(".description-container", gallery).size() == 0)
									$(gallery).append("<div class='description-container'><div class='toggle-up'>+</div><div class='description'><h2 class='entry-title'></h2><div class='description-content'></div></div><div class='toggle-down'>(down)</div></div>");
								$(".description > .entry-title", gallery).text(img.attr('image-title'));
								$(".description > .description-content", gallery).html(img.attr('image-description'));
								setupDescriptionContainer();
							}
							else
							{
								$(".description-container .toggle-up", gallery).animate({ height: '0', top: '0' });
								$(".description-container", gallery).animate({ bottom: 0 - $(".description-container", gallery).height(), borderTopWidth: '0' }, {
									step: handleResize,
									complete: function() {
										$(this).remove();
									}
								});
							}
							handleResize();		
						}
						var np = new Date().getTime(), index = 0;
						$.each(images, function(i, image) {
							index++;
							$(".gallery-images", gallery).append("<div class='gallery-image'><img style='behavior: none;' class='image-zoom-out' id='image_" + np + index + "' /><" + "/div>");
							$(".gallery-images #image_" + np + index, gallery).attr("src", image.src);
							$(".gallery-images #image_" + np + index, gallery).attr("width", image.width).attr("original-width", image.width);
							$(".gallery-images #image_" + np + index, gallery).attr("height", image.height).attr("original-height", image.height);
							if (image.title)
								$(".gallery-images #image_" + np + index, gallery).attr("image-title", image.title);
							if (image.description)
								$(".gallery-images #image_" + np + index, gallery).attr("image-description", image.description);
						});
					
						$(".gallery-images .gallery-image").hide();
						$(".gallery-images .gallery-image:eq(" + options.index + ")").show();
						
						$(".gallery-previous", gallery)
							.css({ background: "url(/images/arrow-back.png) no-repeat top left", width: '41px', height: '88px', position: 'absolute', top: '50%', left: '25px', marginTop: '-44px', zIndex: 10 })
							.hover(function() { $(this).css({ backgroundImage: 'url(/images/arrow-back-hover.png)' }); },
							       function() { $(this).css({ backgroundImage: 'url(/images/arrow-back.png)' }); })
							.click(function() {
								currentIndex--;
								if (currentIndex < 0)
									currentIndex = $(".gallery-images .gallery-image").size() - 1;
								setGalleryImage(currentIndex);
							});
						$(".gallery-next", gallery)
							.css({ background: "url(/images/arrow-next.png) no-repeat top left", width: '41px', height: '88px', position: 'absolute', top: '50%', right: '25px', marginTop: '-44px', zIndex: 10 })
							.hover(function() { $(this).css({ backgroundImage: 'url(/images/arrow-next-hover.png)' }); },
							       function() { $(this).css({ backgroundImage: 'url(/images/arrow-next.png)' }); })
							.click(function() {
								currentIndex++;
								if (currentIndex == $(".gallery-images .gallery-image").size())
									currentIndex = 0;
								setGalleryImage(currentIndex);
							});
						 
						handleResize = function() {
							var width = gallery.width(), height = gallery.height();
							width -= 100; // For the previous / next buttons
							// height -= ($(".gallery-title-container", gallery).height() + parseInt($('.gallery-title-container', gallery).css('top')));
							if ($(".description-container", gallery).size())
								height -= ($(".description-container", gallery).height() + parseInt($('.description-container', gallery).css('bottom')));
							height -= 30;
							var imageWidth = Math.min(width - 100, 1024);
							var imageHeight = Math.min(height - 100, 768);
							width = imageWidth + 100
							height = imageHeight + 100;
							var left = (gallery.width() - width) / 2, top = 15;
							// top = $(".gallery-title-container", gallery).height() + parseInt($(".gallery-title-container", gallery).css('top')) + 15;
							
							$(".gallery-images", gallery).css({
								position: 'absolute',
								width: width + 'px', 
								height: height + 'px',
								left: left + 'px',
								top: top + 'px'
							});
							$(".gallery-images .gallery-image", gallery).css({
								width: (20 + imageWidth) + 'px',
								height: (20 + imageHeight) + 'px',
								overflow: 'hidden',
								position: 'absolute',
								top: '40px',
								left: '40px',
								border: '0px solid black'
							});							
							$(".gallery-images img", gallery).each(function() {
								var w = this.getAttribute('original-width'), h = this.getAttribute('original-height'); // $(this).attr("width"), h = $(this).attr("height");
								var sw = imageWidth / w, sh = imageHeight / h;
								sw = Math.min(1, sw);
								sh = Math.min(1, sh);
								var sf;
								if ($(this).hasClass('image-zoom-out')) {
									sf = Math.min(sh, sw);
								} else {
									sf = sw;
								}
								var m = $(this).hasClass('image-zoom-animate') ? 'animate' : 'css';
								var pv = ({
									width: (w * sf) + 'px',
									height: (h * sf) + 'px',
									position: 'absolute',
									// top: '0px',
									// left: '0px',
									cursor: 'url(/images/zoom-out.png), all-scroll'
								});
								$(this).css({ border: '10px solid white' });
								var window_width = $(window).width();
								var lp = window_width - (w * sf);
								lp /= 2;
								lp -= $(".gallery-previous", gallery).width();
								lp -= 24;
								var tp = $(window).height();
								if ($(".description-container", gallery).size())
									tp -= ($(".description-container", gallery).height() + parseInt($('.description-container', gallery).css('bottom')));
								tp -= $(".gallery-previous").height();							
								tp /= 2;
								if ($(this.parentNode).hasClass('active')) {
									var clp = parseFloat($(".gallery-previous", gallery).css('left'));
									var ctp = parseFloat($(".gallery-previous", gallery).css('top'));
									if (Math.floor(clp) != Math.floor(lp) || Math.floor(ctp) != Math.floor(tp)) {
										$(".gallery-previous", gallery).stop().animate({ left: lp, top: tp, marginTop: 0, marginLeft: 0 });
										$(".gallery-next", gallery).stop().animate({ right: lp, top: tp, marginTop: 0, marginLeft: 0 });
									}
								}
								if (m == 'css') {
									$(this).css(pv);
								}							
								else {
									delete pv.left;
									delete pv.position;
									delete pv.cursor;
									$(this).css({ cursor: 'url(/images/zoom-out.png), all-scroll', position: 'absolute' });
									$(this).animate(pv, { queue: 'false' });
								}
								
								if ($(this).hasClass('image-zoom-out') || sw == sh == 1) {
									var hv = h * sf, wv = w * sf;
									var tp = (imageHeight - hv) / 2, lp = (imageWidth - wv) / 2;
									tp += 0;
									lp += 0;
									$(this).css({ cursor: 'url(/images/zoom-in.png), auto' });
									if ($(this).hasClass('image-zoom-animate'))
										$(this).animate({ top: tp + 'px', left: lp + 'px', cursor: 'auto' }, { queue: false });
									else
										$(this).css({
											top: tp + 'px',
											left: lp + 'px',
											cursor: 'url(/images/zoom-in.png), auto'
										});
								} else {
									if ($(this).css('top') == 'auto') {
										this.style.top = '0px';
									}
									// if ($(this).hasClass('image-zoom-animate')) {
									var hv = h * sf, wv = w * sf;
									var tp = (imageHeight - hv) / 2, lp = (imageWidth - wv) / 2;
									tp += 0;
									lp += 0;
									var b = { left: 0, top: 0 };
									if (sw == 1)
										b.left = lp;
									else if (sh == 1)
										b.top = tp;
			
									if ($(this).hasClass('image-zoom-animate'))
										$(this).animate(b, { queue: false });
									else
										$(this).css(b);
								}
								$(this).removeClass('image-zoom-animate');
								
								if (!$(this).hasClass('image-drag-setup')) {
									var ctime = 0;
									$(this).bind("move-element", function(event, change) {
										if (change === void(0)) return;
										var minValue = 0 - $(this).height() + imageHeight;
										var maxValue = 0;
										var tp = parseInt($(this).css('top'));
										if (isNaN(tp)) tp = 0;
										tp += change;
										tp = Math.max(minValue, tp);
										tp = Math.min(maxValue, tp);
										$(this).css({ top: tp + 'px' });
									});
									$(this).bind("zoom", function(event) {
										$(this).addClass('image-zoom-animate');
										if ($(this).hasClass('image-zoom-out')) {
											$(this).removeClass('image-zoom-out');
										}
										else
											$(this).addClass('image-zoom-out').addClass('image-zoom-animate');
										
										handleResize();
									});
									$(this).dblclick(function(e) {
										$(this).addClass('image-zoom-animate').toggleClass('image-zoom-out');
										handleResize();
										ctime = 0;
									});
									this.ondragstart = function() { return false; }
									$(this).mousedown(function(e) {
										var t = new Date().getTime();
									/*
										if ((t - ctime) < 300) {
											$(this).addClass('image-zoom-animate');
											if ($(this).hasClass('image-zoom-out')) {
												$(this).removeClass('image-zoom-out');
											}
											else
												$(this).addClass('image-zoom-out').addClass('image-zoom-animate');
											
											handleResize();
											ctime = 0;
											return;
										}
									*/
										ctime = t;
										var yp = e.clientY, tp = parseInt($(this).css("top")), n = this;
										if (isNaN(tp)) tp = 0;
										var minValue = 0 - $(this).height() + imageHeight;
										var maxValue = 0;
										$([window, document]).bind("mousemove.drag", function(e) {
											var nyp = e.clientY;
											var d = nyp - yp;
											d += tp;
											d = Math.max(minValue, d);
											d = Math.min(maxValue, d);
											
											$(n).css({ top: d + 'px' });
										});
										$([window, document]).bind("mouseup.drag", function(e) {
											$([window, document]).unbind(".drag");
										});
										e.preventDefault();
										e.stopPropagation();
										return false;
									});
									$(this).addClass('image-drag-setup');
								}
							});
							
						}
						handleResize();
						$(window).bind("resize.gallery", handleResize);
						gallery.addClass('gallery-initialized');
						gallery[0].methods = { setGalleryImage: setGalleryImage, handleResize: handleResize };
					}
					$(window).bind("keydown.gallery", function(e) {
						if (e.keyCode == 39)
							$(".gallery-next", gallery).click();
						else if (e.keyCode == 37)
							$(".gallery-previous", gallery).click();
						else if (e.keyCode == 27)
							$(".gallery-close", gallery).click();
						else if (e.keyCode == 40) {
							$(".gallery-image.active img").trigger("move-element", [ -10 ]);
						} else if (e.keyCode == 38) {
							$(".gallery-image.active img").trigger("move-element", [ 10 ]);				
						} else if (e.keyCode == 32) {
							$(".gallery-image.active img").trigger("zoom");
						}
					});
					$("body").css({ overflow: 'hidden' });
					gallery[0].methods.setGalleryImage(options.index);
					$(".gallery-overlay").animate({ opacity: 0.7 });
					gallery.animate({ opacity: 1 });
				}	
			});
		},
		showGallery: function(options) {
			options = $.extend({ index: 1 }, options);
			options.index--;
			var gid = null;
			var n = this[0];
			do {
				if (n.getAttribute('gallery-id'))
					gid = n.getAttribute('gallery-id');
				else n = n.parentNode;
			} while (n && !gid);
			if (gid)
			{
			 	galleries[gid].activate(options);
			}
		}
	});
	
	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).animateToggleClass(next.delClass, next.addClass, next.options);
			} else {
				node.removeAttribute('q-index');
				node.removeAttribute('animation-is-running');
			}
		}, 0);
	}
	
	/* 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({
		animateToggleClass: 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',
				'MozBorderRadiusTopleft', 'MozBorderRadiusTopright', 'MozBorderRadiusBottomleft', 'MozBorderRadiusBottomright',
				'color', 'backgroundColor'
			];
			this.each(function() {
				if (this.getAttribute("animation-is-running"))
				{
					if (!this.getAttribute("q-index"))
						this.setAttribute("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)) {
					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;
				} 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, animatedNode = 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) {
								runNextQItem(animatedNode);
							}
						} 
					});
					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)
						runNextQItem(this);

					if (options && options.complete) options.complete.apply(this, arguments);
				} });
				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
		window.onload = function() {
			var ss = document.createElement("style");
			ss.setAttribute('type', 'text/css');
			for (var i = 0; i < document.styleSheets.length; i++) {
				for (var j = 0; j < document.styleSheets[i].rules.length; j++) {
					if (document.styleSheets[i].rules[j].style.opacity) {
						ss.styleSheet.addRule(document.styleSheets[i].rules[j].selectorText, "filter:alpha(opacity=" + Math.floor(parseFloat(document.styleSheets[i].rules[j].style.opacity) * 100) + ")");
						try {
							document.styleSheets[i].rules[j].opacity = "";
						} catch (e) {
							;
						}
					}
				}
			}
			document.getElementsByTagName('head')[0].appendChild(ss);
		};
	@*/
});
	
