Fx.Slide = new Class( {
	Extends : Fx,
	options : {
		mode : "vertical"
	},
	initialize : function(A, B) {
		this.addEvent("complete",
				function() {
					this.open = (this.wrapper["offset"
							+ this.layout.capitalize()] != 0);
					if (this.open && Browser.Engine.webkit419) {
						this.element.dispose().inject(this.wrapper)
					}
				}, true);
		this.element = this.subject = $(A);
		this.parent(B);
		var C = this.element.retrieve("wrapper");
		this.wrapper = C || new Element("div", {
			styles : $extend(this.element.getStyles("margin", "position"), {
				overflow : "hidden"
			})
		}).wraps(this.element);
		this.element.store("wrapper", this.wrapper).setStyle("margin", 0);
		this.now = [];
		this.open = true
	},
	vertical : function() {
		this.margin = "margin-top";
		this.layout = "height";
		this.offset = this.element.offsetHeight
	},
	horizontal : function() {
		this.margin = "margin-left";
		this.layout = "width";
		this.offset = this.element.offsetWidth
	},
	set : function(A) {
		this.element.setStyle(this.margin, A[0]);
		this.wrapper.setStyle(this.layout, A[1]);
		return this
	},
	compute : function(E, D, C) {
		var B = [];
		var A = 2;
		A.times(function(F) {
			B[F] = Fx.compute(E[F], D[F], C)
		});
		return B
	},
	start : function(D, E) {
		if (!this.check(arguments.callee, D, E)) {
			return this
		}
		this[E || this.options.mode]();
		var A = this.element.getStyle(this.margin).toInt();
		var B = this.wrapper.getStyle(this.layout).toInt();
		var C = [[A, B], [0, this.offset]];
		var G = [[A, B], [-this.offset, 0]];
		var F;
		switch (D) {
			case "in" :
				F = C;
				break;
			case "out" :
				F = G;
				break;
			case "toggle" :
				F = (this.wrapper["offset" + this.layout.capitalize()] == 0)
						? C
						: G
		}
		return this.parent(F[0], F[1])
	},
	slideIn : function(A) {
		return this.start("in", A)
	},
	slideOut : function(A) {
		return this.start("out", A)
	},
	hide : function(A) {
		this[A || this.options.mode]();
		this.open = false;
		return this.set([-this.offset, 0])
	},
	show : function(A) {
		this[A || this.options.mode]();
		this.open = true;
		return this.set([0, this.offset])
	},
	toggle : function(A) {
		return this.start("toggle", A)
	}
});
Element.Properties.slide = {
	set : function(B) {
		var A = this.retrieve("slide");
		if (A) {
			A.cancel()
		}
		return this.eliminate("slide").store("slide:options", $extend( {
			link : "cancel"
		}, B))
	},
	get : function(A) {
		if (A || !this.retrieve("slide")) {
			if (A || !this.retrieve("slide:options")) {
				this.set("slide", A)
			}
			this.store("slide", new Fx.Slide(this, this
					.retrieve("slide:options")))
		}
		return this.retrieve("slide")
	}
};
Element.implement( {
	slide : function(C, E) {
		C = C || "toggle";
		var A = this.get("slide"), D;
		switch (C) {
			case "hide" :
				A.hide(E);
				break;
			case "show" :
				A.show(E);
				break;
			case "toggle" :
				var B = this.retrieve("slide:flag", A.open);
				A[(B) ? "slideOut" : "slideIn"](E);
				this.store("slide:flag", !B);
				D = true;
				break;
			default :
				A.start(C, E)
		}
		if (!D) {
			this.eliminate("slide:flag")
		}
		return this
	}
});
Fx.Scroll = new Class( {
	Extends : Fx,
	options : {
		offset : {
			x : 0,
			y : 0
		},
		wheelStops : true
	},
	initialize : function(C, D) {
		this.element = this.subject = $(C);
		this.parent(D);
		var A = this.cancel.bind(this, false);
		if ($type(this.element) != "element") {
			this.element = $(this.element.getDocument().body)
		}
		var B = this.element;
		if (this.options.wheelStops) {
			this.addEvent("start", function() {
				B.addEvent("mousewheel", A)
			}, true);
			this.addEvent("complete", function() {
				B.removeEvent("mousewheel", A)
			}, true)
		}
	},
	set : function() {
		var A = Array.flatten(arguments);
		this.element.scrollTo(A[0], A[1])
	},
	compute : function(E, D, C) {
		var B = [];
		var A = 2;
		A.times(function(F) {
			B.push(Fx.compute(E[F], D[F], C))
		});
		return B
	},
	start : function(B, H) {
		if (!this.check(arguments.callee, B, H)) {
			return this
		}
		var C = this.element.getSize(), E = this.element.getScrollSize();
		var F = this.element.getScroll(), D = {
			x : B,
			y : H
		};
		for (var G in D) {
			var A = E[G] - C[G];
			if ($chk(D[G])) {
				D[G] = ($type(D[G]) == "number") ? D[G].limit(0, A) : A
			} else {
				D[G] = F[G]
			}
			D[G] += this.options.offset[G]
		}
		return this.parent([F.x, F.y], [D.x, D.y])
	},
	toTop : function() {
		return this.start(false, 0)
	},
	toLeft : function() {
		return this.start(0, false)
	},
	toRight : function() {
		return this.start("right", false)
	},
	toBottom : function() {
		return this.start(false, "bottom")
	},
	toElement : function(B) {
		var A = $(B).getPosition(this.element);
		return this.start(A.x, A.y)
	}
});
Fx.Elements = new Class( {
	Extends : Fx.CSS,
	initialize : function(A, B) {
		this.elements = this.subject = $$(A);
		this.parent(B)
	},
	compute : function(H, G, I) {
		var C = {};
		for (var D in H) {
			var A = H[D], F = G[D], E = C[D] = {};
			for (var B in A) {
				E[B] = this.parent(A[B], F[B], I)
			}
		}
		return C
	},
	set : function(B) {
		for (var C in B) {
			var A = B[C];
			for (var D in A) {
				this.render(this.elements[C], D, A[D], this.options.unit)
			}
		}
		return this
	},
	start : function(F) {
		if (!this.check(arguments.callee, F)) {
			return this
		}
		var I = {}, H = {};
		for (var E in F) {
			var B = F[E], C = I[E] = {}, G = H[E] = {};
			for (var D in B) {
				var A = this.prepare(this.elements[E], D, B[D]);
				C[D] = A.from;
				G[D] = A.to
			}
		}
		return this.parent(I, H)
	}
});
var Drag = new Class( {
	Implements : [Events, Options],
	options : {
		snap : 6,
		unit : "px",
		grid : false,
		style : true,
		limit : false,
		handle : false,
		invert : false,
		preventDefault : false,
		modifiers : {
			x : "left",
			y : "top"
		}
	},
	initialize : function() {
		var B = Array.link(arguments, {
			options : Object.type,
			element : $defined
		});
		this.element = $(B.element);
		this.document = this.element.getDocument();
		this.setOptions(B.options || {});
		var A = $type(this.options.handle);
		this.handles = (A == "array" || A == "collection")
				? $$(this.options.handle)
				: $(this.options.handle) || this.element;
		this.mouse = {
			now : {},
			pos : {}
		};
		this.value = {
			start : {},
			now : {}
		};
		this.selection = (Browser.Engine.trident) ? "selectstart" : "mousedown";
		this.bound = {
			start : this.start.bind(this),
			check : this.check.bind(this),
			drag : this.drag.bind(this),
			stop : this.stop.bind(this),
			cancel : this.cancel.bind(this),
			eventStop : $lambda(false)
		};
		this.attach()
	},
	attach : function() {
		this.handles.addEvent("mousedown", this.bound.start);
		return this
	},
	detach : function() {
		this.handles.removeEvent("mousedown", this.bound.start);
		return this
	},
	start : function(C) {
		if (this.options.preventDefault) {
			C.preventDefault()
		}
		this.fireEvent("beforeStart", this.element);
		this.mouse.start = C.page;
		var A = this.options.limit;
		this.limit = {
			x : [],
			y : []
		};
		for (var D in this.options.modifiers) {
			if (!this.options.modifiers[D]) {
				continue
			}
			if (this.options.style) {
				this.value.now[D] = this.element
						.getStyle(this.options.modifiers[D]).toInt()
			} else {
				this.value.now[D] = this.element[this.options.modifiers[D]]
			}
			if (this.options.invert) {
				this.value.now[D] *= -1
			}
			this.mouse.pos[D] = C.page[D] - this.value.now[D];
			if (A && A[D]) {
				for (var B = 2;B--; B) {
					if ($chk(A[D][B])) {
						this.limit[D][B] = $lambda(A[D][B])()
					}
				}
			}
		}
		if ($type(this.options.grid) == "number") {
			this.options.grid = {
				x : this.options.grid,
				y : this.options.grid
			}
		}
		this.document.addEvents( {
			mousemove : this.bound.check,
			mouseup : this.bound.cancel
		});
		this.document.addEvent(this.selection, this.bound.eventStop)
	},
	check : function(A) {
		if (this.options.preventDefault) {
			A.preventDefault()
		}
		var B = Math.round(Math.sqrt(Math.pow(A.page.x - this.mouse.start.x, 2)
				+ Math.pow(A.page.y - this.mouse.start.y, 2)));
		if (B > this.options.snap) {
			this.cancel();
			this.document.addEvents( {
				mousemove : this.bound.drag,
				mouseup : this.bound.stop
			});
			this.fireEvent("start", this.element).fireEvent("snap",
					this.element)
		}
	},
	drag : function(A) {
		if (this.options.preventDefault) {
			A.preventDefault()
		}
		this.mouse.now = A.page;
		for (var B in this.options.modifiers) {
			if (!this.options.modifiers[B]) {
				continue
			}
			this.value.now[B] = this.mouse.now[B] - this.mouse.pos[B];
			if (this.options.invert) {
				this.value.now[B] *= -1
			}
			if (this.options.limit && this.limit[B]) {
				if ($chk(this.limit[B][1])
						&& (this.value.now[B] > this.limit[B][1])) {
					this.value.now[B] = this.limit[B][1]
				} else {
					if ($chk(this.limit[B][0])
							&& (this.value.now[B] < this.limit[B][0])) {
						this.value.now[B] = this.limit[B][0]
					}
				}
			}
			if (this.options.grid[B]) {
				this.value.now[B] -= (this.value.now[B] % this.options.grid[B])
			}
			if (this.options.style) {
				this.element.setStyle(this.options.modifiers[B],
						this.value.now[B] + this.options.unit)
			} else {
				this.element[this.options.modifiers[B]] = this.value.now[B]
			}
		}
		this.fireEvent("drag", this.element)
	},
	cancel : function(A) {
		this.document.removeEvent("mousemove", this.bound.check);
		this.document.removeEvent("mouseup", this.bound.cancel);
		if (A) {
			this.document.removeEvent(this.selection, this.bound.eventStop);
			this.fireEvent("cancel", this.element)
		}
	},
	stop : function(A) {
		this.document.removeEvent(this.selection, this.bound.eventStop);
		this.document.removeEvent("mousemove", this.bound.drag);
		this.document.removeEvent("mouseup", this.bound.stop);
		if (A) {
			this.fireEvent("complete", this.element)
		}
	}
});
Element.implement( {
	makeResizable : function(A) {
		return new Drag(this, $merge( {
			modifiers : {
				x : "width",
				y : "height"
			}
		}, A))
	}
});
Drag.Move = new Class( {
	Extends : Drag,
	options : {
		droppables : [],
		container : false
	},
	initialize : function(B, C) {
		this.parent(B, C);
		this.droppables = $$(this.options.droppables);
		this.container = $(this.options.container);
		if (this.container && $type(this.container) != "element") {
			this.container = $(this.container.getDocument().body)
		}
		B = this.element;
		var D = B.getStyle("position");
		var A = (D != "static") ? D : "absolute";
		if (B.getStyle("left") == "auto" || B.getStyle("top") == "auto") {
			B.position(B.getPosition(B.offsetParent))
		}
		B.setStyle("position", A);
		this.addEvent("start", function() {
			this.checkDroppables()
		}, true)
	},
	start : function(B) {
		if (this.container) {
			var D = this.element, J = this.container, E = J
					.getCoordinates(D.offsetParent), F = {}, A = {};
			["top", "right", "bottom", "left"].each(function(K) {
				F[K] = J.getStyle("padding-" + K).toInt();
				A[K] = D.getStyle("margin-" + K).toInt()
			}, this);
			var C = D.offsetWidth + A.left + A.right, I = D.offsetHeight
					+ A.top + A.bottom;
			var H = [E.left + F.left, E.right - F.right - C];
			var G = [E.top + F.top, E.bottom - F.bottom - I];
			this.options.limit = {
				x : H,
				y : G
			}
		}
		this.parent(B)
	},
	checkAgainst : function(B) {
		B = B.getCoordinates();
		var A = this.mouse.now;
		return (A.x > B.left && A.x < B.right && A.y < B.bottom && A.y > B.top)
	},
	checkDroppables : function() {
		var A = this.droppables.filter(this.checkAgainst, this).getLast();
		if (this.overed != A) {
			if (this.overed) {
				this.fireEvent("leave", [this.element, this.overed])
			}
			if (A) {
				this.overed = A;
				this.fireEvent("enter", [this.element, A])
			} else {
				this.overed = null
			}
		}
	},
	drag : function(A) {
		this.parent(A);
		if (this.droppables.length) {
			this.checkDroppables()
		}
	},
	stop : function(A) {
		this.checkDroppables();
		this.fireEvent("drop", [this.element, this.overed]);
		this.overed = null;
		return this.parent(A)
	}
});
Element.implement( {
	makeDraggable : function(A) {
		return new Drag.Move(this, A)
	}
});
Hash.Cookie = new Class( {
	Extends : Cookie,
	options : {
		autoSave : true
	},
	initialize : function(A, B) {
		this.parent(A, B);
		this.load()
	},
	save : function() {
		var A = JSON.encode(this.hash);
		if (!A || A.length > 4096) {
			return false
		}
		if (A == "{}") {
			this.dispose()
		} else {
			this.write(A)
		}
		return true
	},
	load : function() {
		this.hash = new Hash(JSON.decode(this.read(), true));
		return this
	}
});
Hash.Cookie.implement((function() {
	var A = {};
	Hash.each(Hash.prototype, function(C, B) {
		A[B] = function() {
			var D = C.apply(this.hash, arguments);
			if (this.options.autoSave) {
				this.save()
			}
			return D
		}
	});
	return A
})());
var Color = new Native( {
	initialize : function(B, C) {
		if (arguments.length >= 3) {
			C = "rgb";
			B = Array.slice(arguments, 0, 3)
		} else {
			if (typeof B == "string") {
				if (B.match(/rgb/)) {
					B = B.rgbToHex().hexToRgb(true)
				} else {
					if (B.match(/hsb/)) {
						B = B.hsbToRgb()
					} else {
						B = B.hexToRgb(true)
					}
				}
			}
		}
		C = C || "rgb";
		switch (C) {
			case "hsb" :
				var A = B;
				B = B.hsbToRgb();
				B.hsb = A;
				break;
			case "hex" :
				B = B.hexToRgb(true);
				break
		}
		B.rgb = B.slice(0, 3);
		B.hsb = B.hsb || B.rgbToHsb();
		B.hex = B.rgbToHex();
		return $extend(B, this)
	}
});
Color.implement( {
	mix : function() {
		var B = Array.slice(arguments);
		var C = ($type(B.getLast()) == "number") ? B.pop() : 50;
		var A = this.slice();
		B.each(function(D) {
			D = new Color(D);
			for (var E = 0;E < 3; E++) {
				A[E] = Math.round((A[E] / 100 * (100 - C)) + (D[E] / 100 * C))
			}
		});
		return new Color(A, "rgb")
	},
	invert : function() {
		return new Color(this.map(function(A) {
			return 255 - A
		}))
	},
	setHue : function(A) {
		return new Color([A, this.hsb[1], this.hsb[2]], "hsb")
	},
	setSaturation : function(A) {
		return new Color([this.hsb[0], A, this.hsb[2]], "hsb")
	},
	setBrightness : function(A) {
		return new Color([this.hsb[0], this.hsb[1], A], "hsb")
	}
});
function $RGB(C, B, A) {
	return new Color([C, B, A], "rgb")
}
function $HSB(C, B, A) {
	return new Color([C, B, A], "hsb")
}
function $HEX(A) {
	return new Color(A, "hex")
}
Array
		.implement( {
			rgbToHsb : function() {
				var C = this[0], D = this[1], J = this[2];
				var G, B, I;
				var H = Math.max(C, D, J), F = Math.min(C, D, J);
				var K = H - F;
				I = H / 255;
				B = (H != 0) ? K / H : 0;
				if (B == 0) {
					G = 0
				} else {
					var E = (H - C) / K;
					var A = (H - D) / K;
					var L = (H - J) / K;
					if (C == H) {
						G = L - A
					} else {
						if (D == H) {
							G = 2 + E - L
						} else {
							G = 4 + A - E
						}
					}
					G /= 6;
					if (G < 0) {
						G++
					}
				}
				return [Math.round(G * 360), Math.round(B * 100),
						Math.round(I * 100)]
			},
			hsbToRgb : function() {
				var C = Math.round(this[2] / 100 * 255);
				if (this[1] == 0) {
					return [C, C, C]
				} else {
					var A = this[0] % 360;
					var E = A % 60;
					var F = Math.round((this[2] * (100 - this[1])) / 10000
							* 255);
					var D = Math.round((this[2] * (6000 - this[1] * E))
							/ 600000 * 255);
					var B = Math.round((this[2] * (6000 - this[1] * (60 - E)))
							/ 600000 * 255);
					switch (Math.floor(A / 60)) {
						case 0 :
							return [C, B, F];
						case 1 :
							return [D, C, F];
						case 2 :
							return [F, C, B];
						case 3 :
							return [F, D, C];
						case 4 :
							return [B, F, C];
						case 5 :
							return [C, F, D]
					}
				}
				return false
			}
		});
String.implement( {
	rgbToHsb : function() {
		var A = this.match(/\d{1,3}/g);
		return (A) ? hsb.rgbToHsb() : null
	},
	hsbToRgb : function() {
		var A = this.match(/\d{1,3}/g);
		return (A) ? A.hsbToRgb() : null
	}
});
var Group = new Class( {
	initialize : function() {
		this.instances = Array.flatten(arguments);
		this.events = {};
		this.checker = {}
	},
	addEvent : function(B, A) {
		this.checker[B] = this.checker[B] || {};
		this.events[B] = this.events[B] || [];
		if (this.events[B].contains(A)) {
			return false
		} else {
			this.events[B].push(A)
		}
		this.instances.each(function(C, D) {
			C.addEvent(B, this.check.bind(this, [B, C, D]))
		}, this);
		return this
	},
	check : function(C, A, B) {
		this.checker[C][B] = true;
		var D = this.instances.every(function(F, E) {
			return this.checker[C][E] || false
		}, this);
		if (!D) {
			return
		}
		this.checker[C] = {};
		this.events[C].each(function(E) {
			E.call(this, this.instances, A)
		}, this)
	}
});
var Asset = new Hash( {
	javascript : function(A, D) {
		D = $extend( {
			onload : $empty,
			document : document,
			check : $lambda(true)
		}, D);
		var E = new Element("script", {
			src : A,
			type : "text/javascript"
		});
		var F = D.onload.bind(E), B = D.check, G = D.document;
		delete D.onload;
		delete D.check;
		delete D.document;
		E.addEvents( {
			load : F,
			readystatechange : function() {
				if (["loaded", "complete"].contains(this.readyState)) {
					F()
				}
			}
		}).setProperties(D);
		if (Browser.Engine.webkit419) {
			var C = (function() {
				if (!$try(B)) {
					return
				}
				$clear(C);
				F()
			}).periodical(50)
		}
		return E.inject(G.head)
	},
	css : function(A, B) {
		return new Element("link", $merge( {
			rel : "stylesheet",
			media : "screen",
			type : "text/css",
			href : A
		}, B)).inject(document.head)
	},
	image : function(A, C) {
		C = $merge( {
			onload : $empty,
			onabort : $empty,
			onerror : $empty
		}, C);
		var D = new Image();
		var B = $(D) || new Element("img");
		["load", "abort", "error"].each(function(E) {
			var F = "on" + E;
			var G = C[F];
			delete C[F];
			D[F] = function() {
				if (!D) {
					return
				}
				if (!B.parentNode) {
					B.width = D.width;
					B.height = D.height
				}
				D = D.onload = D.onabort = D.onerror = null;
				G.delay(1, B, B);
				B.fireEvent(E, B, 1)
			}
		});
		D.src = B.src = A;
		if (D && D.complete) {
			D.onload.delay(1)
		}
		return B.setProperties(C)
	},
	images : function(C, B) {
		B = $merge( {
			onComplete : $empty,
			onProgress : $empty
		}, B);
		if (!C.push) {
			C = [C]
		}
		var D = [];
		var A = 0;
		C.each(function(E) {
			var F = new Asset.image(E, {
				onload : function() {
					B.onProgress.call(this, A, C.indexOf(E));
					A++;
					if (A == C.length) {
						B.onComplete()
					}
				}
			});
			D.push(F)
		});
		return new Elements(D)
	}
});
var Sortables = new Class( {
	Implements : [Events, Options],
	options : {
		snap : 4,
		opacity : 1,
		clone : false,
		revert : false,
		handle : false,
		constrain : false
	},
	initialize : function(A, B) {
		this.setOptions(B);
		this.elements = [];
		this.lists = [];
		this.idle = true;
		this.addLists($$($(A) || A));
		if (!this.options.clone) {
			this.options.revert = false
		}
		if (this.options.revert) {
			this.effect = new Fx.Morph(null, $merge( {
				duration : 250,
				link : "cancel"
			}, this.options.revert))
		}
	},
	attach : function() {
		this.addLists(this.lists);
		return this
	},
	detach : function() {
		this.lists = this.removeLists(this.lists);
		return this
	},
	addItems : function() {
		Array.flatten(arguments).each(
				function(A) {
					this.elements.push(A);
					var B = A.retrieve("sortables:start", this.start
							.bindWithEvent(this, A));
					(this.options.handle ? A.getElement(this.options.handle)
							|| A : A).addEvent("mousedown", B)
				}, this);
		return this
	},
	addLists : function() {
		Array.flatten(arguments).each(function(A) {
			this.lists.push(A);
			this.addItems(A.getChildren())
		}, this);
		return this
	},
	removeItems : function() {
		var A = [];
		Array.flatten(arguments).each(
				function(B) {
					A.push(B);
					this.elements.erase(B);
					var C = B.retrieve("sortables:start");
					(this.options.handle ? B.getElement(this.options.handle)
							|| B : B).removeEvent("mousedown", C)
				}, this);
		return $$(A)
	},
	removeLists : function() {
		var A = [];
		Array.flatten(arguments).each(function(B) {
			A.push(B);
			this.lists.erase(B);
			this.removeItems(B.getChildren())
		}, this);
		return $$(A)
	},
	getClone : function(B, A) {
		if (!this.options.clone) {
			return new Element("div").inject(document.body)
		}
		if ($type(this.options.clone) == "function") {
			return this.options.clone.call(this, B, A, this.list)
		}
		return A.clone(true).setStyles( {
			margin : "0px",
			position : "absolute",
			visibility : "hidden",
			width : A.getStyle("width")
		}).inject(this.list).position(A.getPosition(A.getOffsetParent()))
	},
	getDroppables : function() {
		var A = this.list.getChildren();
		if (!this.options.constrain) {
			A = this.lists.concat(A).erase(this.list)
		}
		return A.erase(this.clone).erase(this.element)
	},
	insert : function(A, C) {
		var B = "inside";
		if (this.lists.contains(C)) {
			this.list = C;
			this.drag.droppables = this.getDroppables()
		} else {
			B = this.element.getAllPrevious().contains(C) ? "before" : "after"
		}
		this.element.inject(C, B);
		this.fireEvent("sort", [this.element, this.clone])
	},
	start : function(B, A) {
		if (!this.idle) {
			return
		}
		this.idle = false;
		this.element = A;
		this.opacity = A.get("opacity");
		this.list = A.getParent();
		this.clone = this.getClone(B, A);
		this.drag = new Drag.Move(this.clone, {
			snap : this.options.snap,
			container : this.options.constrain && this.element.getParent(),
			droppables : this.getDroppables(),
			onSnap : function() {
				B.stop();
				this.clone.setStyle("visibility", "visible");
				this.element.set("opacity", this.options.opacity || 0);
				this.fireEvent("start", [this.element, this.clone])
			}.bind(this),
			onEnter : this.insert.bind(this),
			onCancel : this.reset.bind(this),
			onComplete : this.end.bind(this)
		});
		this.clone.inject(this.element, "before");
		this.drag.start(B)
	},
	end : function() {
		this.drag.detach();
		this.element.set("opacity", this.opacity);
		if (this.effect) {
			var A = this.element.getStyles("width", "height");
			var B = this.clone.computePosition(this.element
					.getPosition(this.clone.offsetParent));
			this.effect.element = this.clone;
			this.effect.start( {
				top : B.top,
				left : B.left,
				width : A.width,
				height : A.height,
				opacity : 0.25
			}).chain(this.reset.bind(this))
		} else {
			this.reset()
		}
	},
	reset : function() {
		this.idle = true;
		this.clone.destroy();
		this.fireEvent("complete", this.element)
	},
	serialize : function() {
		var C = Array.link(arguments, {
			modifier : Function.type,
			index : $defined
		});
		var B = this.lists.map(function(D) {
			return D.getChildren().map(C.modifier || function(E) {
				return E.get("id")
			}, this)
		}, this);
		var A = C.index;
		if (this.lists.length == 1) {
			A = 0
		}
		return $chk(A) && A >= 0 && A < this.lists.length ? B[A] : B
	}
});
var Tips = new Class( {
	Implements : [Events, Options],
	options : {
		onShow : function(A) {
			A.setStyle("visibility", "visible")
		},
		onHide : function(A) {
			A.setStyle("visibility", "hidden")
		},
		showDelay : 100,
		hideDelay : 100,
		className : null,
		offsets : {
			x : 16,
			y : 16
		},
		fixed : false
	},
	initialize : function() {
		var C = Array.link(arguments, {
			options : Object.type,
			elements : $defined
		});
		this.setOptions(C.options || null);
		this.tip = new Element("div").inject(document.body);
		if (this.options.className) {
			this.tip.addClass(this.options.className)
		}
		var B = new Element("div", {
			"class" : "tip-top"
		}).inject(this.tip);
		this.container = new Element("div", {
			"class" : "tip"
		}).inject(this.tip);
		var A = new Element("div", {
			"class" : "tip-bottom"
		}).inject(this.tip);
		this.tip.setStyles( {
			position : "absolute",
			top : 0,
			left : 0,
			visibility : "hidden"
		});
		if (C.elements) {
			this.attach(C.elements)
		}
	},
	attach : function(A) {
		$$(A).each(
				function(D) {
					var G = D.retrieve("tip:title", D.get("title"));
					var F = D.retrieve("tip:text", D.get("rel")
							|| D.get("href"));
					var E = D.retrieve("tip:enter", this.elementEnter
							.bindWithEvent(this, D));
					var C = D.retrieve("tip:leave", this.elementLeave
							.bindWithEvent(this, D));
					D.addEvents( {
						mouseenter : E,
						mouseleave : C
					});
					if (!this.options.fixed) {
						var B = D.retrieve("tip:move", this.elementMove
								.bindWithEvent(this, D));
						D.addEvent("mousemove", B)
					}
					D.store("tip:native", D.get("title"));
					D.erase("title")
				}, this);
		return this
	},
	detach : function(A) {
		$$(A).each(function(B) {
			B.removeEvent("mouseenter", B.retrieve("tip:enter") || $empty);
			B.removeEvent("mouseleave", B.retrieve("tip:leave") || $empty);
			B.removeEvent("mousemove", B.retrieve("tip:move") || $empty);
			B.eliminate("tip:enter").eliminate("tip:leave")
					.eliminate("tip:move");
			var C = B.retrieve("tip:native");
			if (C) {
				B.set("title", C)
			}
		});
		return this
	},
	elementEnter : function(B, A) {
		$A(this.container.childNodes).each(Element.dispose);
		var D = A.retrieve("tip:title");
		if (D) {
			this.titleElement = new Element("div", {
				"class" : "tip-title"
			}).inject(this.container);
			this.fill(this.titleElement, D)
		}
		var C = A.retrieve("tip:text");
		if (C) {
			this.textElement = new Element("div", {
				"class" : "tip-text"
			}).inject(this.container);
			this.fill(this.textElement, C)
		}
		this.timer = $clear(this.timer);
		this.timer = this.show.delay(this.options.showDelay, this);
		this.position((!this.options.fixed) ? B : {
			page : A.getPosition()
		})
	},
	elementLeave : function(A) {
		$clear(this.timer);
		this.timer = this.hide.delay(this.options.hideDelay, this)
	},
	elementMove : function(A) {
		this.position(A)
	},
	position : function(C) {
		var A = window.getSize(), E = window.getScroll();
		var D = {
			x : this.tip.offsetWidth,
			y : this.tip.offsetHeight
		};
		var B = {
			x : "left",
			y : "top"
		};
		for (var F in B) {
			var G = C.page[F] + this.options.offsets[F];
			if ((G + D[F] - E[F]) > A[F]) {
				G = C.page[F] - this.options.offsets[F] - D[F]
			}
			this.tip.setStyle(B[F], G)
		}
	},
	fill : function(B, A) {
		(typeof A == "string") ? B.set("html", A) : B.adopt(A)
	},
	show : function() {
		this.fireEvent("show", this.tip)
	},
	hide : function() {
		this.fireEvent("hide", this.tip)
	}
});
var SmoothScroll = new Class( {
	Extends : Fx.Scroll,
	initialize : function(C, B) {
		B = B || document;
		var E = B.getDocument(), D = B.getWindow();
		this.parent(E, C);
		this.links = (this.options.links)
				? $$(this.options.links)
				: $$(E.links);
		var A = D.location.href.match(/^[^#]*/)[0] + "#";
		this.links.each(function(G) {
			if (G.href.indexOf(A) != 0) {
				return
			}
			var F = G.href.substr(A.length);
			if (F && $(F)) {
				this.useLink(G, F)
			}
		}, this);
		if (!Browser.Engine.webkit419) {
			this.addEvent("complete", function() {
				D.location.hash = this.anchor
			}, true)
		}
	},
	useLink : function(B, A) {
		B.addEvent("click", function(C) {
			this.anchor = A;
			this.toElement(A);
			C.stop()
		}.bind(this))
	}
});
var Slider = new Class( {
	Implements : [Events, Options],
	options : {
		onTick : function(A) {
			if (this.options.snap) {
				A = this.toPosition(this.step)
			}
			this.knob.setStyle(this.property, A)
		},
		snap : false,
		offset : 0,
		range : false,
		wheel : false,
		steps : 100,
		mode : "horizontal"
	},
	initialize : function(C, A, E) {
		this.setOptions(E);
		this.element = $(C);
		this.knob = $(A);
		this.previousChange = this.previousEnd = this.step = -1;
		this.element.addEvent("mousedown", this.clickedElement.bind(this));
		if (this.options.wheel) {
			this.element.addEvent("mousewheel", this.scrolledElement
					.bindWithEvent(this))
		}
		var F, B = {}, D = {
			x : false,
			y : false
		};
		switch (this.options.mode) {
			case "vertical" :
				this.axis = "y";
				this.property = "top";
				F = "offsetHeight";
				break;
			case "horizontal" :
				this.axis = "x";
				this.property = "left";
				F = "offsetWidth"
		}
		this.half = this.knob[F] / 2;
		this.full = this.element[F] - this.knob[F] + (this.options.offset * 2);
		this.min = $chk(this.options.range[0]) ? this.options.range[0] : 0;
		this.max = $chk(this.options.range[1])
				? this.options.range[1]
				: this.options.steps;
		this.range = this.max - this.min;
		this.steps = this.options.steps || this.full;
		this.stepSize = Math.abs(this.range) / this.steps;
		this.stepWidth = this.stepSize * this.full / Math.abs(this.range);
		this.knob.setStyle("position", "relative").setStyle(this.property,
				-this.options.offset);
		D[this.axis] = this.property;
		B[this.axis] = [-this.options.offset, this.full - this.options.offset];
		this.drag = new Drag(this.knob, {
			snap : 0,
			limit : B,
			modifiers : D,
			onDrag : this.draggedKnob.bind(this),
			onStart : this.draggedKnob.bind(this),
			onComplete : function() {
				this.draggedKnob();
				this.end()
			}.bind(this)
		});
		if (this.options.snap) {
			this.drag.options.grid = Math.ceil(this.stepWidth);
			this.drag.options.limit[this.axis][1] = this.full
		}
	},
	set : function(A) {
		if (!((this.range > 0) ^ (A < this.min))) {
			A = this.min
		}
		if (!((this.range > 0) ^ (A > this.max))) {
			A = this.max
		}
		this.step = Math.round(A);
		this.checkStep();
		this.end();
		this.fireEvent("tick", this.toPosition(this.step));
		return this
	},
	clickedElement : function(C) {
		var B = this.range < 0 ? -1 : 1;
		var A = C.page[this.axis] - this.element.getPosition()[this.axis]
				- this.half;
		A = A.limit(-this.options.offset, this.full - this.options.offset);
		this.step = Math.round(this.min + B * this.toStep(A));
		this.checkStep();
		this.end();
		this.fireEvent("tick", A)
	},
	scrolledElement : function(A) {
		var B = (this.options.mode == "horizontal")
				? (A.wheel < 0)
				: (A.wheel > 0);
		this.set(B ? this.step - this.stepSize : this.step + this.stepSize);
		A.stop()
	},
	draggedKnob : function() {
		var B = this.range < 0 ? -1 : 1;
		var A = this.drag.value.now[this.axis];
		A = A.limit(-this.options.offset, this.full - this.options.offset);
		this.step = Math.round(this.min + B * this.toStep(A));
		this.checkStep()
	},
	checkStep : function() {
		if (this.previousChange != this.step) {
			this.previousChange = this.step;
			this.fireEvent("change", this.step)
		}
	},
	end : function() {
		if (this.previousEnd !== this.step) {
			this.previousEnd = this.step;
			this.fireEvent("complete", this.step + "")
		}
	},
	toStep : function(A) {
		var B = (A + this.options.offset) * this.stepSize / this.full
				* this.steps;
		return this.options.steps ? Math.round(B -= B % this.stepSize) : B
	},
	toPosition : function(A) {
		return (this.full * Math.abs(this.min - A))
				/ (this.steps * this.stepSize) - this.options.offset
	}
});
var Scroller = new Class( {
	Implements : [Events, Options],
	options : {
		area : 20,
		velocity : 1,
		onChange : function(A, B) {
			this.element.scrollTo(A, B)
		}
	},
	initialize : function(A, B) {
		this.setOptions(B);
		this.element = $(A);
		this.listener = ($type(this.element) != "element") ? $(this.element
				.getDocument().body) : this.element;
		this.timer = null;
		this.coord = this.getCoords.bind(this)
	},
	start : function() {
		this.listener.addEvent("mousemove", this.coord)
	},
	stop : function() {
		this.listener.removeEvent("mousemove", this.coord);
		this.timer = $clear(this.timer)
	},
	getCoords : function(A) {
		this.page = (this.listener.get("tag") == "body") ? A.client : A.page;
		if (!this.timer) {
			this.timer = this.scroll.periodical(50, this)
		}
	},
	scroll : function() {
		var A = this.element.getSize(), B = this.element.getScroll(), E = this.element
				.getPosition(), C = {
			x : 0,
			y : 0
		};
		for (var D in this.page) {
			if (this.page[D] < (this.options.area + E[D]) && B[D] != 0) {
				C[D] = (this.page[D] - this.options.area - E[D])
						* this.options.velocity
			} else {
				if (this.page[D] + this.options.area > (A[D] + E[D])
						&& A[D] + A[D] != B[D]) {
					C[D] = (this.page[D] - A[D] + this.options.area - E[D])
							* this.options.velocity
				}
			}
		}
		if (C.y || C.x) {
			this.fireEvent("change", [B.x + C.x, B.y + C.y])
		}
	}
});
var Accordion = new Class( {
	Extends : Fx.Elements,
	options : {
		display : 0,
		show : false,
		height : true,
		width : false,
		opacity : true,
		fixedHeight : false,
		fixedWidth : false,
		wait : false,
		alwaysHide : false
	},
	initialize : function() {
		var C = Array.link(arguments, {
			container : Element.type,
			options : Object.type,
			togglers : $defined,
			elements : $defined
		});
		this.parent(C.elements, C.options);
		this.togglers = $$(C.togglers);
		this.container = $(C.container);
		this.previous = -1;
		if (this.options.alwaysHide) {
			this.options.wait = true
		}
		if ($chk(this.options.show)) {
			this.options.display = false;
			this.previous = this.options.show
		}
		if (this.options.start) {
			this.options.display = false;
			this.options.show = false
		}
		this.effects = {};
		if (this.options.opacity) {
			this.effects.opacity = "fullOpacity"
		}
		if (this.options.width) {
			this.effects.width = this.options.fixedWidth
					? "fullWidth"
					: "offsetWidth"
		}
		if (this.options.height) {
			this.effects.height = this.options.fixedHeight
					? "fullHeight"
					: "scrollHeight"
		}
		for (var B = 0, A = this.togglers.length;B < A; B++) {
			this.addSection(this.togglers[B], this.elements[B])
		}
		this.elements.each(function(E, D) {
			if (this.options.show === D) {
				this.fireEvent("active", [this.togglers[D], E])
			} else {
				for (var F in this.effects) {
					E.setStyle(F, 0)
				}
			}
		}, this);
		if ($chk(this.options.display)) {
			this.display(this.options.display)
		}
	},
	addSection : function(C, D, G) {
		C = $(C);
		D = $(D);
		var F = this.togglers.contains(C);
		var B = this.togglers.length;
		this.togglers.include(C);
		this.elements.include(D);
		if (B && (!F || G)) {
			G = $pick(G, B - 1);
			C.inject(this.togglers[G], "before");
			D.inject(C, "after")
		} else {
			if (this.container && !F) {
				C.inject(this.container);
				D.inject(this.container)
			}
		}
		var A = this.togglers.indexOf(C);
		C.addEvent("click", this.display.bind(this, A));
		if (this.options.height) {
			D.setStyles( {
				"padding-top" : 0,
				"border-top" : "none",
				"padding-bottom" : 0,
				"border-bottom" : "none"
			})
		}
		if (this.options.width) {
			D.setStyles( {
				"padding-left" : 0,
				"border-left" : "none",
				"padding-right" : 0,
				"border-right" : "none"
			})
		}
		D.fullOpacity = 1;
		if (this.options.fixedWidth) {
			D.fullWidth = this.options.fixedWidth
		}
		if (this.options.fixedHeight) {
			D.fullHeight = this.options.fixedHeight
		}
		D.setStyle("overflow", "hidden");
		if (!F) {
			for (var E in this.effects) {
				D.setStyle(E, 0)
			}
		}
		return this
	},
	display : function(A) {
		A = ($type(A) == "element") ? this.elements.indexOf(A) : A;
		if ((this.timer && this.options.wait)
				|| (A === this.previous && !this.options.alwaysHide)) {
			return this
		}
		this.previous = A;
		var B = {};
		this.elements.each(function(E, D) {
			B[D] = {};
			var C = (D != A)
					|| (this.options.alwaysHide && (E.offsetHeight > 0));
			this.fireEvent(C ? "background" : "active", [this.togglers[D], E]);
			for (var F in this.effects) {
				B[D][F] = C ? 0 : E[this.effects[F]]
			}
		}, this);
		return this.start(B)
	}
});
var protect_id = false;
var Album = new Class( {
	initialize : function() {
	}
});
Album
		.implement( {
			getImages : function(D) {
				var A = this;
				var C = this.wait("gallery");
				C.start();
				var B = new Request( {
					method : "get",
					url : "/dashboard/albums/index/id/" + D,
					onComplete : function(F) {
						C.stop();
						$$(".updated.page").set("html", F);
						var E = new Utils();
						E.initSimpleUpload();
						E.checkFlash();
						E.hoverCell();
						E.setEvents();
						A.bulidPage();
						setAlbumId(D)
					}
				}).send()
			},
			add : function() {
				var A = new Utils();
				var B = new Box(A.createAlbumForm())
			},
			deletealbum : function() {
				var B = new Utils();
				var C = new Box(B.deleteAlbumForm());
				var D = getParam("albumId");
				if ($("select_album_" + D)) {
					$("select_album_" + D).dispose()
				}
				if ($("album-delete-text")) {
					var A = $("album-name").get("html");
					$("album-delete-text")
							.set(
									"html",
									'This action will delete album <strong>"'
											+ A.substr(0, 20)
											+ '"</strong><br />  Please select album to move images to: ')
				}
			},
			del : function() {
				var A = this;
				var E = getParam("albumId");
				var C = $("select-album").getSelected().get("value");
				if (E <= 0) {
					alert(localMessage.cantDelete);
					return true
				}
				if (confirm(localMessage.areYouSureDeletAlbum)) {
					var B = new Waiter("gallery", {
						layer : {
							id : "waitingDiv",
							background : "#fff",
							opacity : 0.9
						}
					});
					B.start();
					var D = new Request.JSON( {
						url : "/dashboard/albums/del/id/" + E + "/move/" + C,
						onComplete : function(F) {
							B.stop();
							if (F.result) {
								document.location = "/personal/albums"
							}
						}
					}).get()
				}
			},
			moveimages : function(D) {
				var A = this;
				var B = $("sel-album").getSelected().get("value");
				var E = getParam("albumId");
				if (confirm("This action will move selected images to another album. Are you sure?")) {
					var C = new Request.JSON( {
						url : "/dashboard/albums/moveimages/?move_in=" + E
								+ "&move_to=" + B + D,
						onComplete : function(F) {
							if (!F.error) {
								document.location = document.location
							}
						}
					}).get()
				}
			},
			getBulkLinks : function(D, B, E) {
				var A = this;
				var C = new Request.JSON( {
					url : "/dashboard/albums/getbulklinks/?format=" + E
							+ "&size=" + B + D,
					onComplete : function(F) {
						if (F) {
							if (!F.error) {
								return F
							}
						}
					}
				}).get()
			},
			deleteall : function() {
				var C = getParam("albumId");
				if (confirm(localMessage.areYouSureAlbum)) {
					var A = new Waiter("gallery", {
						layer : {
							id : "waitingDiv",
							background : "#fff",
							opacity : 0.9
						}
					});
					A.start();
					var B = new Request.JSON( {
						url : "/dashboard/albums/deleteall/id/" + C,
						onComplete : function(D) {
							A.stop();
							if (D.result) {
								document.location = document.location
							}
						}
					}).get()
				}
			},
			rename : function() {
				var A = new Utils();
				var B = new Box(A.renameAlbumForm());
				if ($("input-album-name") && $("album-name")) {
					$("input-album-name").set("value",
							$("album-name").get("html").unescapeHtml())
				}
			},
			protect : function(C) {
				var A = new Utils();
				if ($("link-lock-image").get("class") == "lock") {
				} else {
				}
				protect_id = C;
				var B = new Box(A.protectAlbumForm())
			},
			saveRename : function() {
				var C = getParam("albumId");
				var A = $("input-album-name").get("value");
				var B = new Request.JSON( {
					url : "/dashboard/albums/rename/id/" + C + "/name/" + A,
					onComplete : function(D) {
						if (D.result) {
							document.location = "/dashboard/albums/index/id/"
									+ C
						}
					}
				}).get()
			},
			saveProtect : function() {
				var C = getParam("albumId");
				if (protect_id != C && protect_id) {
					C = protect_id
				}
				var A = $("input-album-protect").get("value");
				var B = new Request.JSON( {
					url : "/dashboard/albums/protect/id/" + C + "/name/" + A,
					onComplete : function(D) {
						if (D.result) {
							if (D.result == "ok") {
								if ($("link-lock-image")) {
									if (D.protect == "1") {
										$("album-secret").set("name", A);
										$("link-lock-image")
												.set(
														"src",
														"http://"
																+ localvars.domain
																+ "/images/img/lock.png");
										$("lock-album-" + C)
												.removeClass("hide")
									} else {
										$("link-lock-image")
												.set(
														"src",
														"http://"
																+ localvars.domain
																+ "/images/img/lock_unlock.png");
										$("lock-album-" + C).addClass("hide")
									}
								}
							}
							if ($$(".modal")) {
								$$(".modal").dispose()
							}
							myModalizer.modalHide();
							protect_id = false
						}
					}
				}).get()
			},
			save : function() {
				var B = this;
				$$(".modal div.error").setStyle("display", "none");
				if (!$("input-album-name").getProperty("value").length) {
					$$(".modal div.error").setStyle("display", "block");
					$$(".modal div.error .text").set("html",
							localMessage.wrongAlbumName);
					return false
				} else {
					if ($("save_button")) {
						$("save_button").set("value", "saving...");
						$("save_button").set("disabled", true)
					}
					var A = $("input-album-name").getProperty("value");
					var C = new Request.JSON( {
						url : "/dashboard/albums/add",
						onComplete : function(D) {
							if ($("save_button")) {
								$("save_button").set("value", "OK");
								$("save_button").set("disabled", false)
							}
							if (D.result == "error") {
								if (D.code == "502") {
									closeModal();
									paymentError(-1, D.message)
								} else {
									$$(".modal div.error").setStyle("display",
											"block");
									$$(".modal div.error .text").set("html",
											D.message)
								}
							} else {
								if (D.id) {
									document.location = "/dashboard/albums/index/id/"
											+ D.id
								} else {
									document.location = document.location.href
								}
							}
						}
					}).get( {
						name : escape(A),
						auth : Cookie.read("auth")
					})
				}
			},
			bulidPage : function() {
				if ($$(".page")) {
					$$(".page").addEvent("click", function(A) {
						A.stop();
						getPage($(this));
						$(this).removeEvents("click")
					})
				}
			},
			wait : function(B) {
				var A = new Waiter(B, {
					layer : {
						id : "waitingDiv",
						background : "#fff",
						opacity : 0.9
					}
				});
				return A
			}
		});
var Social = new Class( {
	Implements : [Options],
	options : {
		sites : null
	},
	initialize : function(A, B) {
		this.setOptions(B);
		if (typeof this.options.sites == "string") {
			this.sites = JSON.decode(this.options.sites)
		} else {
			if (typeof this.options.sites == "object") {
				this.sites = this.options.sites
			} else {
				return false
			}
		}
		if (this.sites == null) {
			return false
		}
		this.element = A;
		this.init()
	}
});
Social
		.implement( {
			init : function() {
				var B = this;
				var G = encodeURIComponent(location.href);
				var E = "Image Hosting";
				var F = new Element("ul", {
					"class" : "icons"
				});
				var D = new Element("div", {
					"class" : "name"
				});
				var A = new Element("a", {
					"class" : "icon",
					href : "#",
					html : '<img width="16" height="16" src="'
							+ this.getBrowserIcon() + '"/>',
					events : {
						click : function(I) {
							I.stop();
							B.bookmarksite(E, G)
						}
					}
				});
				var C = new Element("li");
				C.adopt(A);
				F.adopt(C);
				this.sites.each(function(L) {
					L.url = L.url.replace(/\{url\}/, G);
					L.url = L.url.replace(/\{title\}/, E);
					var K = new Element("img", {
						styles : {
							width : "16px",
							height : "16px"
						},
						src : L.icon,
						alt : L.name
					});
					var J = new Element("a", {
						"class" : "icon",
						href : L.url,
						title : L.name,
						target : "_blank"
					});
					var I = new Element("li");
					J.adopt(K);
					I.adopt(J);
					F.adopt(I)
				});
				var H = new Element("div", {
					"class" : "bookmark"
				});
				H.adopt(F);
				$(this.element).adopt(H)
			},
			getFx : function(A) {
				return new Fx.Morph(A, {
					duration : "short",
					transition : Fx.Transitions.Sine.easeOut
				})
			},
			getBrowserIcon : function() {
				switch (true) {
					case Browser.Engine.trident :
						return "http://" + localvars.domain
								+ "/images/img/ie.png";
						break;
					case Browser.Engine.gecko :
						return "http://" + localvars.domain
								+ "/images/img/firefox.png";
						break;
					case Browser.Engine.presto :
						return "http://" + localvars.domain
								+ "/images/img/opera.png";
						break;
					default :
						return "http://" + localvars.domain
								+ "/images/img/ie.png"
				}
			},
			bookmarksite : function(C, B) {
				C = decodeURIComponent(C);
				B = decodeURIComponent(B);
				if (window.sidebar) {
					window.sidebar.addPanel(C, B, "")
				} else {
					if (window.opera && window.print) {
						var A = document.createElement("A");
						if (!A) {
							return false
						}
						A.setAttribute("rel", "sidebar");
						A.setAttribute("href", B);
						A.setAttribute("title", C);
						document.appendChild(A);
						A.onclick = function() {
							return false
						};
						A.click()
					} else {
						if (document.all) {
							window.external.AddFavorite(B, C)
						}
					}
				}
			}
		});
var Tooltip = new Class( {
	Implements : [Options],
	options : {
		top : 200,
		left : 200,
		width : 350,
		pointer : true,
		closeEvent : false
	},
	initialize : function(B, A) {
		this.setOptions(A);
		this.content = B;
		if (B) {
			this.create();
			$(this.tipbox).setStyles( {
				top : this.options.top,
				left : this.options.left,
				width : this.options.width
			})
		}
	}
});
Tooltip.implement( {
	create : function() {
		var A = this;
		this.tipbox = new Element("div", {
			html : this.content,
			"class" : "tipbox"
		});
		this.close_anchor = new Element("a", {
			href : "#",
			"class" : "close"
		});
		this.close_image = new Element("img", {
			src : "http://" + localvars.domain + "/images/img/close.png",
			"class" : "close",
			alt : "Close",
			events : {
				click : function(B) {
					B.stop();
					A.close()
				}
			}
		});
		if (this.options.pointer) {
			this.pointer = new Element("div", {
				"class" : "pointer"
			});
			this.pointer.inject(this.tipbox)
		}
		this.close_image.inject(this.close_anchor);
		this.close_anchor.inject(this.tipbox);
		this.tipbox.inject(document.body)
	},
	close : function() {
		this.options.closeEvent();
		this.tipbox.dispose()
	}
});
Element.implement( {
	shorten : function(G) {
		var J = this;
		if (!$(J)) {
			return false
		}
		if ($(J).hasClass("shorted")) {
			return
		}
		var N = $(J).get("html").length + 3;
		if (!G) {
			var G = 10
		}
		var I = 10;
		if ($(J).get("rel")) {
			$(J).get("rel").split(" ").each(function(O) {
				if (O.test(/maxlength-/)) {
					I = O.replace(/maxlength-/, "")
				}
				if (O.test(/size-/)) {
					G = O.replace(/size-/, "")
				}
			})
		}
		var F = N - I;
		var M = $(J).get("html");
		var E = M.substr(0, I);
		var B = M.substr(I, N);
		var D = "";
		if (B.length < 3) {
			return
		}
		var A = 1 / G;
		for (var H = 0;H < G; H++) {
			var K = 1 - (A * H);
			K = K.toString().substr(0, 3).toFloat();
			if (B[H]) {
				if (Browser.Engine.trident) {
					var C = "margin:0;padding:0;filter:alpha(opacity=" + K
							+ ")"
				} else {
					var C = "margin:0;padding:0;opacity:" + K + ""
				}
				if (Browser.Engine.trident) {
					var L = B[H]
				} else {
					var L = '<span style="' + C + '">' + B[H] + "</span>"
				}
				D += L
			}
		}
		$(J).set("html", E + D).addClass("shorted")
	}
});
var Clientcide = {
	version : "700",
	setAssetLocation : function(B) {
		if (window.StickyWin && StickyWin.ui) {
			var D = StickyWin.ui.bind(window);
			StickyWin.ui = function(F, E, G) {
				return D(F, E, $merge( {
					baseHref : B + "/stickyWinHTML/"
				}, G))
			};
			if (StickyWin.alert) {
				var C = StickyWin.alert.bind(window);
				StickyWin.alert = function(G, F, E) {
					return C(G, F, E || B + "/simple.error.popup")
				}
			}
		}
		if (window.TagMaker) {
			TagMaker = TagMaker.refactor( {
				options : {
					baseHref : B + "/tips/"
				}
			})
		}
		if (window.ProductPicker) {
			ProductPicker.refactor( {
				options : {
					baseHref : B + "/Picker"
				}
			})
		}
		if (window.Autocompleter) {
			var A = {
				options : {
					baseHref : B + "/autocompleter/"
				}
			};
			Autocompleter.Base.refactor(A);
			if (Autocompleter.Ajax) {
				["Base", "Xhtml", "Json"].each(function(E) {
					if (Autocompleter.Ajax[E]) {
						Autocompleter.Ajax[E].refactor(A)
					}
				})
			}
			if (Autocompleter.Local) {
				Autocompleter.Local.refactor(A)
			}
			if (Autocompleter.JsonP) {
				Autocompleter.JsonP.refactor(A)
			}
		}
		if (window.Lightbox) {
			Lightbox.refactor( {
				options : {
					assetBaseUrl : B + "/slimbox/"
				}
			})
		}
		if (window.Waiter) {
			Waiter.refactor( {
				options : {
					baseHref : B + "/waiter/"
				}
			})
		}
	}
};
setCNETAssetBaseHref = Clientcide.setAssetLocation;
var dbug = {
	logged : [],
	timers : {},
	firebug : false,
	enabled : false,
	log : function() {
		dbug.logged.push(arguments)
	},
	nolog : function(A) {
		dbug.logged.push(arguments)
	},
	time : function(A) {
		dbug.timers[A] = new Date().getTime()
	},
	timeEnd : function(B) {
		if (dbug.timers[B]) {
			var A = new Date().getTime() - dbug.timers[B];
			dbug.timers[B] = false;
			dbug.log("%s: %s", B, A)
		} else {
			dbug.log("no such timer: %s", B)
		}
	},
	enable : function(B) {
		if (dbug.firebug) {
			try {
				dbug.enabled = true;
				dbug.log = function() {
					(console.debug || console.log).apply(console, arguments)
				};
				dbug.time = function() {
					console.time.apply(console, arguments)
				};
				dbug.timeEnd = function() {
					console.timeEnd.apply(console, arguments)
				};
				if (!B) {
					dbug.log("enabling dbug")
				}
				for (var A = 0;A < dbug.logged.length; A++) {
					dbug.log.apply(console, dbug.logged[A])
				}
				dbug.logged = []
			} catch (C) {
				dbug.enable.delay(400)
			}
		}
	},
	disable : function() {
		if (dbug.firebug) {
			dbug.enabled = false
		}
		dbug.log = dbug.nolog;
		dbug.time = function() {
		};
		dbug.timeEnd = function() {
		}
	},
	cookie : function(D) {
		var C = document.cookie.match("(?:^|;)\\s*jsdebug=([^;]*)");
		var B = C ? unescape(C[1]) : false;
		if ((!$defined(D) && B != "true") || ($defined(D) && D)) {
			dbug.enable();
			dbug.log("setting debugging cookie");
			var A = new Date();
			A.setTime(A.getTime() + (24 * 60 * 60 * 1000));
			document.cookie = "jsdebug=true;expires=" + A.toGMTString()
					+ ";path=/;"
		} else {
			dbug.disableCookie()
		}
	},
	disableCookie : function() {
		dbug.log("disabling debugging cookie");
		document.cookie = "jsdebug=false;path=/;"
	}
};
(function() {
	var C = typeof console != "undefined";
	var B = ["debug", "info", "warn", "error", "assert", "dir", "dirxml"];
	var A = ["trace", "group", "groupEnd", "profile", "profileEnd", "count"];
	function D(E, G) {
		for (var F = 0;F < E.length; F++) {
			dbug[E[F]] = (C && console[E[F]]) ? console[E[F]] : G
		}
	}
	D(B, dbug.log);
	D(A, function() {
	})
})();
if (typeof console != "undefined" && console.warn) {
	dbug.firebug = true;
	var value = document.cookie.match("(?:^|;)\\s*jsdebug=([^;]*)");
	var debugCookie = value ? unescape(value[1]) : false;
	if (window.location.href.indexOf("jsdebug=true") > 0
			|| debugCookie == "true") {
		dbug.enable()
	}
	if (debugCookie == "true") {
		dbug.log("debugging cookie enabled")
	}
	if (window.location.href.indexOf("jsdebugCookie=true") > 0) {
		dbug.cookie();
		if (!dbug.enabled) {
			dbug.enable()
		}
	}
	if (window.location.href.indexOf("jsdebugCookie=false") > 0) {
		dbug.disableCookie()
	}
}
Class.refactor = function(C, A) {
	A = $extend($unlink(A), {
		Extends : C
	});
	var B = new Class(A);
	$each(C, function(E, D) {
		B[D] = B[D] || E
	});
	return B
};
$extend(Class.prototype, {
	refactor : function(A) {
		this.prototype = Class.refactor(this, A).prototype;
		return this
	}
});
var IframeShim = new Class( {
	Implements : [Options, Events],
	options : {
		name : "",
		className : "iframeShim",
		display : false,
		zindex : null,
		margin : 0,
		offset : {
			x : 0,
			y : 0
		},
		browsers : (Browser.Engine.trident4 || (Browser.Engine.gecko
				&& !Browser.Engine.gecko19 && Browser.Platform.mac))
	},
	initialize : function(A, B) {
		this.setOptions(B);
		if (this.options.offset && this.options.offset.top) {
			this.options.offset.y = this.options.offset.top
		}
		if (this.options.offset && this.options.offset.left) {
			this.options.offset.x = this.options.offset.left
		}
		this.element = $(A);
		this.makeShim();
		return
	},
	makeShim : function() {
		this.shim = new Element("iframe");
		this.id = this.options.name || new Date().getTime() + "_shim";
		if (!this.options.browsers) {
			return
		}
		if (this.element.getStyle("z-Index").toInt() < 1
				|| isNaN(this.element.getStyle("z-Index").toInt())) {
			this.element.setStyle("z-Index", 5)
		}
		var B = this.element.getStyle("z-Index") - 1;
		if ($chk(this.options.zindex)
				&& this.element.getStyle("z-Index").toInt() > this.options.zindex) {
			B = this.options.zindex
		}
		this.shim
				.setStyles( {
					position : "absolute",
					zIndex : B,
					border : "none",
					filter : "progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"
				}).setProperties( {
					src : (window.location.protocol == "https")
							? "://0"
							: "javascript:void(0)",
					frameborder : "0",
					scrolling : "no",
					id : this.id
				}).addClass(this.options.className);
		this.element.store("shim", this);
		var A = function() {
			this.shim.inject(this.element, "after");
			if (this.options.display) {
				this.show()
			} else {
				this.hide()
			}
			this.fireEvent("onInject")
		};
		if (this.options.browsers) {
			if (Browser.Engine.trident && !IframeShim.ready) {
				window.addEvent("load", A.bind(this))
			} else {
				A.run(null, this)
			}
		}
	},
	position : function(C) {
		if (!this.options.browsers || !IframeShim.ready) {
			return this
		}
		var A = this.element.expose();
		var B = this.element.getSize();
		A();
		if ($type(this.options.margin)) {
			B.x = B.x - (this.options.margin * 2);
			B.y = B.y - (this.options.margin * 2);
			this.options.offset.x += this.options.margin;
			this.options.offset.y += this.options.margin
		}
		this.shim.setStyles( {
			width : B.x,
			height : B.y
		}).setPosition( {
			relativeTo : this.element,
			offset : this.options.offset
		});
		return this
	},
	hide : function() {
		if (this.options.browsers) {
			this.shim.setStyle("display", "none")
		}
		return this
	},
	show : function() {
		if (!this.options.browsers) {
			return this
		}
		this.shim.setStyle("display", "block");
		return this.position()
	},
	dispose : function() {
		if (this.options.browsers) {
			this.shim.dispose()
		}
		return this
	}
});
window.addEvent("load", function() {
	IframeShim.ready = true
});
Element.implement( {
	expose : function() {
		if (this.getStyle("display") != "none") {
			return $empty
		}
		var A = {};
		var B = {
			visibility : "hidden",
			display : "block",
			position : "absolute"
		};
		$each(B, function(D, C) {
			A[C] = this.style[C] || ""
		}, this);
		this.setStyles(B);
		return (function() {
			this.setStyles(A)
		}).bind(this)
	},
	getDimensions : function(A) {
		A = $merge( {
			computeSize : false
		}, A);
		var D = {};
		function E(G, F) {
			return (F.computeSize) ? G.getComputedSize(F) : G.getSize()
		}
		if (this.getStyle("display") == "none") {
			var B = this.expose();
			D = E(this, A);
			B()
		} else {
			try {
				D = E(this, A)
			} catch (C) {
			}
		}
		return $chk(D.x) ? $extend(D, {
			width : D.x,
			height : D.y
		}) : $extend(D, {
			x : D.width,
			y : D.height
		})
	},
	getComputedSize : function(D) {
		D = $merge( {
			styles : ["padding", "border"],
			plains : {
				height : ["top", "bottom"],
				width : ["left", "right"]
			},
			mode : "both"
		}, D);
		var C = {
			width : 0,
			height : 0
		};
		switch (D.mode) {
			case "vertical" :
				delete C.width;
				delete D.plains.width;
				break;
			case "horizontal" :
				delete C.height;
				delete D.plains.height;
				break
		}
		var B = [];
		$each(D.plains, function(G, F) {
			G.each(function(H) {
				D.styles.each(function(I) {
					B.push((I == "border") ? I + "-" + H + "-width" : I + "-"
							+ H)
				})
			})
		});
		var A = this.getStyles.apply(this, B);
		var E = [];
		$each(D.plains, function(G, F) {
			C["total" + F.capitalize()] = 0;
			C["computed" + F.capitalize()] = 0;
			G.each(function(H) {
				C["computed" + H.capitalize()] = 0;
				B.each(function(J, I) {
					if (J.test(H)) {
						A[J] = A[J].toInt();
						if (isNaN(A[J])) {
							A[J] = 0
						}
						C["total" + F.capitalize()] = C["total"
								+ F.capitalize()]
								+ A[J];
						C["computed" + H.capitalize()] = C["computed"
								+ H.capitalize()]
								+ A[J]
					}
					if (J.test(H) && F != J
							&& (J.test("border") || J.test("padding"))
							&& !E.contains(J)) {
						E.push(J);
						C["computed" + F.capitalize()] = C["computed"
								+ F.capitalize()]
								- A[J]
					}
				})
			})
		});
		if ($chk(C.width)) {
			C.width = C.width + this.offsetWidth + C.computedWidth;
			C.totalWidth = C.width + C.totalWidth;
			delete C.computedWidth
		}
		if ($chk(C.height)) {
			C.height = C.height + this.offsetHeight + C.computedHeight;
			C.totalHeight = C.height + C.totalHeight;
			delete C.computedHeight
		}
		return $extend(A, C)
	}
});
Element
		.implement( {
			setPosition : function(J) {
				$each(J || {}, function(P, O) {
					if (!$defined(P)) {
						delete J[O]
					}
				});
				J = $merge( {
					relativeTo : document.body,
					position : {
						x : "center",
						y : "center"
					},
					edge : false,
					offset : {
						x : 0,
						y : 0
					},
					returnPos : false,
					relFixedPosition : false,
					ignoreMargins : false
				}, J);
				var A = {
					x : 0,
					y : 0
				};
				var H = false;
				var F = this.expose();
				var B = $(this.getOffsetParent());
				F();
				if (B && B != this.getDocument().body) {
					var F = B.expose();
					A = B.getPosition();
					F();
					H = true;
					J.offset.x = J.offset.x - A.x;
					J.offset.y = J.offset.y - A.y
				}
				function L(O) {
					if ($type(O) != "string") {
						return O
					}
					O = O.toLowerCase();
					var P = {};
					if (O.test("left")) {
						P.x = "left"
					} else {
						if (O.test("right")) {
							P.x = "right"
						} else {
							P.x = "center"
						}
					}
					if (O.test("upper") || O.test("top")) {
						P.y = "top"
					} else {
						if (O.test("bottom")) {
							P.y = "bottom"
						} else {
							P.y = "center"
						}
					}
					return P
				}
				J.edge = L(J.edge);
				J.position = L(J.position);
				if (!J.edge) {
					if (J.position.x == "center" && J.position.y == "center") {
						J.edge = {
							x : "center",
							y : "center"
						}
					} else {
						J.edge = {
							x : "left",
							y : "top"
						}
					}
				}
				this.setStyle("position", "absolute");
				var M = $(J.relativeTo) || document.body;
				var K = (M == document.body) ? window.getScroll().y : M
						.getPosition().y;
				var E = (M == document.body) ? window.getScroll().x : M
						.getPosition().x;
				if (K < 0) {
					K = 0
				}
				if (E < 0) {
					E = 0
				}
				var G = this.getDimensions( {
					computeSize : true,
					styles : ["padding", "border", "margin"]
				});
				if (J.ignoreMargins) {
					J.offset.x = J.offset.x - G["margin-left"];
					J.offset.y = J.offset.y - G["margin-top"]
				}
				var I = {};
				var C = J.offset.y.toInt();
				var D = J.offset.x.toInt();
				switch (J.position.x) {
					case "left" :
						I.x = E + D;
						break;
					case "right" :
						I.x = E + D + M.offsetWidth;
						break;
					default :
						I.x = E
								+ (((M == document.body)
										? window.getSize().x
										: M.offsetWidth) / 2) + D;
						break
				}
				switch (J.position.y) {
					case "top" :
						I.y = K + C;
						break;
					case "bottom" :
						I.y = K + C + M.offsetHeight;
						break;
					default :
						I.y = K
								+ (((M == document.body)
										? window.getSize().y
										: M.offsetHeight) / 2) + C;
						break
				}
				if (J.edge) {
					var N = {};
					switch (J.edge.x) {
						case "left" :
							N.x = 0;
							break;
						case "right" :
							N.x = -G.x - G.computedRight - G.computedLeft;
							break;
						default :
							N.x = -(G.x / 2);
							break
					}
					switch (J.edge.y) {
						case "top" :
							N.y = 0;
							break;
						case "bottom" :
							N.y = -G.y - G.computedTop - G.computedBottom;
							break;
						default :
							N.y = -(G.y / 2);
							break
					}
					I.x = I.x + N.x;
					I.y = I.y + N.y
				}
				I = {
					left : ((I.x >= 0 || H) ? I.x : 0).toInt(),
					top : ((I.y >= 0 || H) ? I.y : 0).toInt()
				};
				if (M.getStyle("position") == "fixed" || J.relFixedPosition) {
					I.top = I.top.toInt() + window.getScroll().y;
					I.left = I.left.toInt() + window.getScroll().x
				}
				if (J.returnPos) {
					return I
				} else {
					this.setStyles(I)
				}
				return this
			}
		});
Element.implement( {
	isVisible : function() {
		return this.getStyle("display") != "none"
	},
	toggle : function() {
		return this[this.isVisible() ? "hide" : "show"]()
	},
	hide : function() {
		var B;
		try {
			if ("none" != this.getStyle("display")) {
				B = this.getStyle("display")
			}
		} catch (A) {
		}
		this.store("originalDisplay", B || "block");
		this.setStyle("display", "none");
		return this
	},
	show : function(A) {
		original = this.retrieve("originalDisplay") ? this
				.retrieve("originalDisplay") : this.get("originalDisplay");
		this.setStyle("display", (A || original || "block"));
		return this
	},
	swapClass : function(A, B) {
		return this.removeClass(A).addClass(B)
	},
	fxOpacityOk : function() {
		return !Browser.Engine.trident4
	}
});
var Modalizer = new Class( {
	defaultModalStyle : {
		display : "block",
		position : "fixed",
		top : 0,
		left : 0,
		"z-index" : 5000,
		"background-color" : "#333",
		opacity : 0.8
	},
	setModalOptions : function(A) {
		this.modalOptions = $merge( {
			width : (window.getScrollSize().x + 300),
			height : (window.getScrollSize().y + 300),
			elementsToHide : "select",
			hideOnClick : true,
			modalStyle : {},
			updateOnResize : true,
			layerId : "modalOverlay",
			onModalHide : $empty,
			onModalShow : $empty
		}, this.modalOptions, A);
		return this
	},
	layer : function() {
		if (!this.modalOptions.layerId) {
			this.setModalOptions()
		}
		return $(this.modalOptions.layerId) || new Element("div", {
			id : this.modalOptions.layerId
		}).inject(document.body)
	},
	resize : function() {
		if (this.layer()) {
			this.layer().setStyles( {
				width : (window.getScrollSize().x + 300),
				height : (window.getScrollSize().y + 300)
			})
		}
	},
	setModalStyle : function(A) {
		this.modalOptions.modalStyle = A;
		this.modalStyle = $merge(this.defaultModalStyle, {
			width : this.modalOptions.width,
			height : this.modalOptions.height
		}, A);
		if (this.layer()) {
			this.layer().setStyles(this.modalStyle)
		}
		return (this.modalStyle)
	},
	modalShow : function(A) {
		this.setModalOptions(A);
		this.layer()
				.setStyles(this.setModalStyle(this.modalOptions.modalStyle));
		if (Browser.Engine.trident4) {
			this.layer().setStyle("position", "absolute")
		}
		this.layer().removeEvents("click").addEvent("click", function() {
			this.modalHide(this.modalOptions.hideOnClick)
		}.bind(this));
		this.bound = this.bound || {};
		if (!this.bound.resize && this.modalOptions.updateOnResize) {
			this.bound.resize = this.resize.bind(this);
			window.addEvent("resize", this.bound.resize)
		}
		if ($type(this.modalOptions.onModalShow) == "function") {
			this.modalOptions.onModalShow()
		}
		this.togglePopThroughElements(0);
		this.layer().setStyle("display", "block");
		return this
	},
	modalHide : function(A, B) {
		if (A === false) {
			return false
		}
		this.togglePopThroughElements(1);
		if ($type(this.modalOptions.onModalHide) == "function") {
			this.modalOptions.onModalHide()
		}
		this.layer().setStyle("display", "none");
		if (this.modalOptions.updateOnResize) {
			this.bound = this.bound || {};
			if (!this.bound.resize) {
				this.bound.resize = this.resize.bind(this)
			}
			window.removeEvent("resize", this.bound.resize)
		}
		return this
	},
	togglePopThroughElements : function(A) {
		if (Browser.Engine.trident4
				|| (Browser.Engine.gecko && Browser.Platform.mac)) {
			$$(this.modalOptions.elementsToHide).each(function(B) {
				B.setStyle("opacity", A)
			})
		}
	}
});
var Waiter = new Class( {
	Implements : [Options, Events, Chain],
	options : {
		baseHref : "http://www.cnet.com/html/rb/assets/global/waiter/",
		containerProps : {
			styles : {
				position : "absolute",
				"text-align" : "center"
			},
			"class" : "waiterContainer"
		},
		containerPosition : {},
		msg : false,
		msgProps : {
			styles : {
				"text-align" : "center",
				fontWeight : "bold"
			},
			"class" : "waiterMsg"
		},
		img : {
			src : "loading.gif",
			styles : {
				width : 24,
				height : 24
			},
			"class" : "waiterImg"
		},
		layer : {
			styles : {
				width : 0,
				height : 0,
				position : "absolute",
				zIndex : 999,
				display : "none",
				opacity : 0.9,
				background : "#fff"
			},
			"class" : "waitingDiv"
		},
		useIframeShim : true,
		fxOptions : {}
	},
	initialize : function(C, A) {
		this.target = $(C) || $(document.body);
		this.setOptions(A);
		if ($(this.options.containerProps.id)) {
			$(this.options.containerProps.id).dispose()
		}
		this.waiterContainer = $(this.options.containerProps.id)
				|| new Element("div", this.options.containerProps)
						.inject(document.body);
		if (this.options.msg) {
			this.msgContainer = new Element("div", this.options.msgProps);
			this.waiterContainer.adopt(this.msgContainer);
			if (!$(this.options.msg)) {
				this.msg = new Element("p").appendText(this.options.msg)
			} else {
				this.msg = $(this.options.msg)
			}
			this.msgContainer.adopt(this.msg)
		}
		if ($(this.options.img.id)) {
			$(this.options.img.id).dispose()
		}
		if (this.options.img) {
			this.waiterImg = $(this.options.img.id)
					|| new Element("img").inject(this.waiterContainer)
		}
		if ($(this.options.layer.id)) {
			$(this.options.layer.id).dispose()
		}
		this.waiterOverlay = $(this.options.layer.id)
				|| new Element("div").inject(document.body)
						.adopt(this.waiterContainer);
		this.waiterOverlay.set(this.options.layer);
		try {
			if (this.options.useIframeShim) {
				this.shim = new IframeShim(this.waiterOverlay,
						this.options.iframeShimOptions)
			}
		} catch (B) {
			dbug
					.log(
							"Waiter attempting to use IframeShim but failed; did you include IframeShim? Error: ",
							B);
			this.options.useIframeShim = false
		}
		this.waiterFx = this.waiterFx
				|| new Fx.Elements(
						$$(this.waiterContainer, this.waiterOverlay),
						this.options.fxOptions)
	},
	toggle : function(B, A) {
		B = $(B) || $(this.active) || $(this.target);
		if (!$(B)) {
			return this
		}
		if (this.active && B != this.active) {
			return this.stop(this.start.bind(this, B))
		}
		if ((!this.active || A) && A !== false) {
			this.start(B)
		} else {
			if (this.active && !A) {
				this.stop()
			}
		}
		return this
	},
	reset : function() {
		this.waiterFx.cancel().set( {
			0 : {
				opacity : [0]
			},
			1 : {
				opacity : [0]
			}
		})
	},
	start : function(A) {
		this.reset();
		A = $(A) || $(this.target);
		if (this.options.img) {
			this.waiterImg.set($merge(this.options.img, {
				src : this.options.baseHref + this.options.img.src
			}))
		}
		var B = function() {
			var C = A.getComputedSize();
			this.active = A;
			this.waiterOverlay.setStyles( {
				width : this.options.layer.width || C.totalWidth,
				height : this.options.layer.height || C.totalHeight,
				display : "block"
			}).setPosition( {
				relativeTo : A,
				position : "upperLeft"
			});
			this.waiterContainer.setPosition($merge( {
				relativeTo : this.waiterOverlay
			}, this.options.containerPosition));
			if (this.options.useIframeShim) {
				this.shim.show()
			}
			this.waiterFx.start( {
				0 : {
					opacity : [1]
				},
				1 : {
					opacity : [this.options.layer.styles.opacity]
				}
			}).chain(function() {
				if (this.active == A) {
					this.fireEvent("onShow", A)
				}
				this.callChain()
			}.bind(this))
		}.bind(this);
		if (this.active && this.active != A) {
			this.stop(B)
		} else {
			B()
		}
		return this
	},
	stop : function(A) {
		if (!this.active) {
			if ($type(A) == "function") {
				A.attempt()
			}
			return this
		}
		this.waiterFx.cancel();
		this.waiterFx.clearChain();
		this.waiterFx.start( {
			0 : {
				opacity : [0]
			},
			1 : {
				opacity : [0]
			}
		}).chain(function() {
			this.active = null;
			this.waiterOverlay.hide();
			if (this.options.useIframeShim) {
				this.shim.hide()
			}
			this.fireEvent("onHide", this.active);
			this.callChain();
			this.clearChain();
			if ($type(A) == "function") {
				A.attempt()
			}
		}.bind(this));
		return this
	}
});
if (typeof Request != "undefined" && Request.HTML) {
	Request.HTML = Class
			.refactor(
					Request.HTML,
					{
						options : {
							useWaiter : false,
							waiterOptions : {},
							waiterTarget : false
						},
						initialize : function(A) {
							this._send = this.send;
							this.send = function(B) {
								if (this.waiter) {
									this.waiter.start().chain(this._send.bind(
											this, B))
								} else {
									this._send(B)
								}
								return this
							};
							this.parent(A);
							if (this.options.useWaiter
									&& ($(this.options.update) || $(this.options.waiterTarget))) {
								this.waiter = new Waiter(
										this.options.waiterTarget
												|| this.options.update,
										this.options.waiterOptions);
								["onComplete", "onException", "onCancel"].each(
										function(B) {
											this.addEvent(B, this.waiter.stop
													.bind(this.waiter))
										}, this)
							}
						}
					})
}
Element.Properties.waiter = {
	set : function(B) {
		var A = this.retrieve("waiter");
		return this.eliminate("wait").store("waiter:options")
	},
	get : function(A) {
		if (A || !this.retrieve("waiter")) {
			if (A || !this.retrieve("waiter:options")) {
				this.set("waiter", A)
			}
			this.store("waiter", new Waiter(this, this
					.retrieve("waiter:options")))
		}
		return this.retrieve("waiter")
	}
};
Element.implement( {
	wait : function(A) {
		this.get("waiter", A).start();
		return this
	},
	release : function() {
		var A = Array.link(arguments, {
			options : Object.type,
			callback : Function.type
		});
		this.get("waiter", A.options).stop(A.callback);
		return this
	}
});
var Clipboard = {
	swfLocation : "http://www.cnet.com/html/rb/assets/global/clipboard/_clipboard.swf",
	copyFromElement : function(A) {
		A = $(A);
		if (!A) {
			return null
		}
		if (Browser.Engine.trident) {
			try {
				window.addEvent("domready", function() {
					var D = A.createTextRange();
					if (D) {
						D.execCommand("Copy")
					}
				})
			} catch (B) {
				dbug.log("cannot copy to clipboard: %s", o)
			}
		} else {
			var C = (A.getSelectedText) ? A.getSelectedText() : A.get("value");
			if (C) {
				Clipboard.copy(C)
			}
		}
		return A
	},
	copy : function(B) {
		if (Browser.Engine.trident) {
			window.addEvent("domready", function() {
				var C = new Element("textarea", {
					styles : {
						display : "none"
					}
				}).inject(document.body);
				C.set("value", B).select();
				Clipboard.copyFromElement(C);
				C.dispose()
			})
		} else {
			var A = ($("flashcopier")) ? $("flashcopier") : new Element("div",
					{
						id : "flashcopier"
					}).inject(document.body);
			A.empty();
			A
					.set(
							"html",
							'<embed src="'
									+ this.swfLocation
									+ '" FlashVars="clipboard='
									+ escape(B)
									+ '" width="0" height="0" type="application/x-shockwave-flash"></embed>')
		}
	}
};
var Box = new Class( {
	initialize : function(A) {
		this.content = A;
		if (A) {
			return this.createBox()
		}
	}
});
Box.implement( {
	createBox : function() {
		myModalizer.modalShow( {
			hideOnClick : false
		});
		var A = new Element("div", {
			"class" : "modal",
			styles : {
				"z-index" : $("modalOverlay").getStyle("z-index") + 1
			}
		});
		this.content.inject(A);
		A.inject(document.body);
		$$(".modal .close").addEvent("click", function() {
			myModalizer.modalHide()
		});
		return myModalizer
	}
});
var Utils = new Class( {
	initialize : function() {
	}
});
Utils
		.implement( {
			isNumeric : function(C) {
				var D = "0123456789.";
				var B = true;
				var A;
				for (i = 0;i < C.length && B == true; i++) {
					A = C.charAt(i);
					if (D.indexOf(A) == -1) {
						B = false;
						z
					}
				}
				return B
			},
			createCells : function(A) {
				if (!A) {
					A = localvars.cellInPage
				}
				var C = $("gallery").getElements("li");
				var B = 0;
				for (B = 0;B < A; B++) {
					this.createCell(C.length + B)
				}
				this.setEvents(1)
			},
			createCell : function(C) {
				var B = this;
				if ((C % 5) == 4) {
					var D = "empty-cell last-in-row"
				} else {
					var D = "empty-cell"
				}
				var A = new Element("li", {
					id : "cell_" + C,
					"class" : D,
					html : localMessage.uploadPhoto
				});
				$("gallery").adopt(A)
			},
			checkCells : function(B) {
				var A = $$(".empty-cell");
				if (B > 0) {
					if (A.length <= B) {
						var D = (B - A.length);
						var C = Math.ceil(D / localvars.cellInPage)
								* localvars.cellInPage;
						if (C == 0) {
							C = localvars.cellInPage
						}
						this.createCells(C);
						this.checkFlash();
						this.hoverCell()
					}
				} else {
					if (A) {
						if (A.length == 1) {
							this.createCells();
							this.checkFlash();
							this.hoverCell()
						}
					} else {
						this.createCells();
						this.checkFlash();
						this.hoverCell()
					}
				}
			},
			initSimpleUpload : function(C) {
				var A = this;
				if (C) {
					var B = new App(C);
					B.simpleUpload(C)
				}
				if ($("Datafile")) {
					$("Datafile").addEvent("change", function(D) {
						var E = new App();
						E.simpleUpload()
					})
				}
			},
			hoverCell : function() {
				var A = this;
				$$(".cell").removeEvents("mouseenter");
				$$(".cell").removeEvents("mouseleave");
				$$(".cell").each(function(C) {
					C.addEvent("mouseenter", function(D) {
						$(C).addClass("active");
						if ($("Datafile")) {
							$("Datafile").setStyles( {
								top : "-110px",
								left : "-150px"
							})
						}
						D.stop()
					});
					C.addEvent("mouseleave", function(D) {
						$(C).removeClass("active");
						D.stop()
					})
				});
				if (Browser.Plugins.Flash.version > 8) {
					var B = $$(".empty-cell");
					if (B) {
						B.removeEvents("mouseenter");
						B.removeEvents("mouseover");
						B.addEvent("mouseenter", function(F) {
							if ($$(".selected")) {
								$$(".selected").removeClass("selected")
							}
							if ($("flash-go")) {
								$("flash-go").setStyle("display", "block");
								var D = $(this).getPosition();
								$(this).addClass("selected");
								var C = "150px";
								var E = "110px";
								$("flash-go").setStyle("width", C);
								$("flash-go").setStyle("height", E);
								if ($("flash-content")) {
									if (Browser.Engine.trident) {
										$("flash-content").width = C;
										$("flash-content").height = E
									} else {
										$("flash-content").set("width", C);
										$("flash-content").set("height", E)
									}
								}
								$("flash-go").setStyle("top", D.y + 5);
								$("flash-go").setStyle("left", D.x + 5)
							}
						})
					}
				}
			},
			setEvents : function(C) {
				var A = this;
				if (C) {
					var B = $$(".empty-cell")
				} else {
					var B = $$("#gallery li.cell")
				}
				$$("p.get-links a").removeEvents("click");
				$$("p.get-links a").addEvent("click", function(E) {
					var F = $(this).className;
					classes = F.split(" ");
					var G = classes[0].replace(/image_/, "");
					var D = classes[1].replace(/cell_/, "");
					new Utils().loadLinksContent(D, G, $(this));
					if (D % 5 == "0") {
						$("dialog_" + D).setStyle("left", "-30px")
					} else {
						if (D % 5 == "4") {
							$("dialog_" + D).setStyle("left", "-306px")
						}
					}
					E.stop()
				});
				$$("li a.del").removeEvents("click");
				$$("li a.del").addEvent("click", function(F) {
					F.stop();
					var E = $(this).className;
					classes = E.split(" ");
					var G = classes[1].replace(/image_/, "");
					var D = classes[2].replace(/cell_/, "");
					new Utils().clearImage(G, D);
					return false
				});
				B.removeEvents("click");
				B.addEvent("click", function(E) {
					var D = $(E.target).getParent().get("href");
					if (D != null) {
						window.open(D)
					}
					if (!E.target.hasClass("cb")) {
						E.stop()
					} else {
					}
				})
			},
			setSimpleUpload : function() {
				$$(".flash-warning").each(function(A) {
					if ($(A).hasClass("hide")) {
						$(A).removeClass("hide")
					}
				});
				if ($("form-upload")) {
					$("form-upload").removeClass("hide")
				}
				if ($("simpleButton")) {
					$("simpleButton").removeClass("hide")
				}
				if ($("form-upload")) {
					$("form-upload").removeClass("hide")
				}
				$$(".empty-cell span").set("html", localMessage.uploadPhoto);
				$$(".empty-cell").addEvent("mousemove", function(B) {
					$$(".selected").removeClass("selected");
					$(this).addClass("selected");
					var C = B.page;
					var A = $(this).getProperty("id").replace(/cell_/, "");
					if (A >= 0) {
						$("form_cell_id").setProperty("value", A)
					}
					if (Browser.Engine.gecko) {
						$("Datafile").setStyles( {
							top : C.y - 10,
							left : C.x - 200
						})
					}
					if (Browser.Engine.webkit) {
						$("Datafile").setStyles( {
							top : C.y - 10,
							left : C.x - 40
						})
					}
					if (Browser.Engine.presto) {
						$("Datafile").setStyles( {
							top : C.y - 10,
							left : C.x - 150
						})
					}
					if (Browser.Engine.trident) {
						$("Datafile").setStyles( {
							top : C.y - 7,
							left : C.x - 200
						})
					}
				})
			},
			checkFlash : function() {
				var A = this;
				try {
					var B = Browser.Plugins.Flash;
					if (!Browser.Plugins.Flash
							|| !Browser.Plugins.Flash.version
							|| Browser.Plugins.Flash.version < 8) {
						if (!window.google && !google.gears) {
							A.setSimpleUpload()
						}
					}
					$$(".empty-cell")
							.each(function(D) {
								D.removeEvents("click");
								D.removeEvents("mouseleave");
								var E = D.getProperty("id");
								E = E.replace(/cell_/, "");
								if (window.google && google.gears) {
									if (E >= 0) {
										D.getChildren("span").set("html",
												localMessage.uploadPhoto);
										D
												.addEvent(
														"click",
														function(G) {
															G.stop();
															if (!$(G.target)
																	.hasClass("close_link")) {
																var I = D
																		.getProperty("id")
																		.replace(
																				/cell_/,
																				"");
																D
																		.addClass("selected");
																var H = new MooGears("beta.desktop");
																var F = [
																		"image/jpg",
																		"image/jpeg",
																		"image/gif",
																		"image/png"];
																if (H.userPermission) {
																	d = H.factory;
																	d
																			.openFiles(
																					function(
																							J) {
																						new App()
																								.gearsUpload(
																										I,
																										getAlbumId(),
																										getPid(),
																										J)
																					},
																					{
																						filter : F
																					})
																}
															}
														})
									}
								} else {
									if (Browser.Plugins.Flash.version > 8) {
										$("flash-go").setStyle("display",
												"block");
										$("flash-go").removeClass("hide");
										if (E >= 0) {
											D.getChildren("span").set("html",
													localMessage.uploadPhoto);
											D
													.addEvent(
															"click",
															function(F) {
																F.stop();
																if (!$(F.target)
																		.hasClass("close_link")) {
																	var G = D
																			.getProperty("id")
																			.replace(
																					/cell_/,
																					"");
																	D
																			.addClass("selected")
																}
															})
										}
									} else {
										if (A.isNumeric(E)) {
											D.addClass("no-flash")
										} else {
										}
									}
								}
							})
				} catch (C) {
					A.setSimpleUpload()
				}
			},
			setCellMessage : function(B, C) {
				var A = $("file_" + B + "_messageBox");
				if (A) {
					A.set("html", C)
				}
			},
			createSimpleUploadForm : function() {
				var A = this;
				if ($("Datafile")) {
					$("Datafile").dispose()
				}
				var B = new Element("input", {
					id : "Datafile",
					name : "Datafile",
					type : "file"
				});
				B.addEvent("change", function(D) {
					var C = $$(".empty-cell");
					A.checkCells();
					if (C[0]) {
						var F = $(C[0]).getProperty("id").replace(/cell_/, "");
						var E = new App(F);
						E.simpleUpload(F)
					}
				});
				B.inject($("updateSimpleForm"))
			},
			getFreeCell : function() {
				var A = $$(".empty-cell");
				if (A[0]) {
					return A[0]
				}
			},
			creatUploadForm : function() {
				var Q = "form-upload-from-url";
				var F = "1";
				if ($(Q)) {
					$(Q).dispose()
				}
				var H = new Element("div", {});
				var D = new Element("form", {
					events : {
						submit : function(U) {
							U.stop();
							uploadFromUrlStart()
						}
					}
				});
				var T = new Element("fieldset", {
					id : Q,
					"class" : "box"
				});
				var R = new Element("h4", {
					html : localMessage.uploadFromUrl
				});
				var S = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose();
							$$(".shadow").dispose()
						}
					}
				});
				var C = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var J = new Element("ol");
				var L = new Element("li");
				var G = new Element("label", {
					html : "URL " + F
				});
				var K = new Element("input", {
					"class" : "txt uploadUrl",
					name : "uploadUrl[]"
				});
				var N = new Element("p", {
					"class" : "buttons"
				});
				function I() {
					$$("li .add").setStyle("display", "none");
					F = count($$(".txt"));
					if (F < 10) {
						var U = L.clone();
						U.getChildren()[0].set("html", "URL " + (F));
						U.getChildren()[1].setProperty("value", "");
						J.adopt(U);
						U.getChildren()[1].focus();
						$(U.getLast()).addEvent("click", function(V) {
							V.stop();
							I()
						});
						$(U.getLast()).setStyle("display", "inline")
					}
				}
				var M = new Element("a", {
					"class" : "add",
					href : "#",
					html : '<img src="http://' + localvars.domain
							+ '/images/img/add.png" alt="'
							+ localMessage.add + '" />',
					events : {
						click : function(U) {
							U.stop();
							I()
						}
					}
				});
				var A = new Element("span", {
					"class" : "button2"
				});
				var O = new Element("input", {
					type : "submit",
					value : localMessage.upload
				});
				var B = new Element("p", {
					html : localMessage.uploadUrlExample
				});
				var E = new Element("div", {
					"class" : "bottom"
				});
				var P = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				S.adopt(C);
				L.adopt(G);
				L.adopt(K);
				L.adopt(M);
				J.adopt(L);
				A.adopt(O);
				N.adopt(A);
				T.adopt(J);
				T.adopt(N);
				D.adopt(T);
				H.adopt(R);
				H.adopt(P);
				H.adopt(D);
				H.adopt(B);
				H.adopt(S);
				$(L.getLast()).setStyle("display", "inline");
				P.adopt(E);
				H.adopt(E);
				return H
			},
			createAlbumForm : function() {
				var Q = "add-album";
				if ($(Q)) {
					$(Q).dispose()
				}
				var C = new Element("div", {});
				var D = new Element("form", {
					events : {
						submit : function(R) {
							R.stop();
							new Album().save()
						}
					}
				});
				var N = new Element("fieldset", {
					id : Q,
					"class" : "box"
				});
				var F = new Element("h4", {
					html : localMessage.albumAdd
				});
				var E = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var B = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var K = new Element("ol");
				var P = new Element("li", {
					id : "parentUrl"
				});
				var M = new Element("label", {
					html : localMessage.albumName
				});
				var L = new Element("input", {
					"class" : "txt uploadUrl",
					id : "input-album-name",
					name : "album-name"
				});
				var O = new Element("p", {
					"class" : "buttons"
				});
				var G = new Element("span", {
					"class" : "button2"
				});
				var A = new Element("input", {
					type : "submit",
					id : "save_button",
					value : localMessage.ok
				});
				var H = new Element("p", {
					html : ""
				});
				var J = new Element("div", {
					"class" : "bottom"
				});
				var I = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				E.adopt(B);
				P.adopt(M);
				P.adopt(L);
				K.adopt(P);
				G.adopt(A);
				O.adopt(G);
				N.adopt(K);
				N.adopt(O);
				D.adopt(N);
				C.adopt(F);
				C.adopt(I);
				C.adopt(D);
				C.adopt(H);
				C.adopt(E);
				C.adopt(J);
				return C
			},
			createAuthTwitterForm : function(D) {
				var C = new Element("div");
				var F = new Element("h4");
				var J = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/twitter.png",
					"class" : "twitter"
				});
				var I = new Element("span", {
					html : "Check auth."
				});
				F.adopt(J);
				F.adopt(I);
				var G = new Element("div", {
					"class" : "inner center"
				});
				var K = new Element("p", {
					html : "Please wait while we check authentication"
				});
				G.adopt(K);
				var E = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var B = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				E.adopt(B);
				var H = new Element("div", {
					"class" : "bottom"
				});
				C.adopt(F);
				C.adopt(G);
				C.adopt(E);
				C.adopt(H);
				var A = new Request.JSON( {
					url : "/twitter",
					onComplete : function(L) {
						if (L) {
							if (L.auth) {
								new Box(new Utils().TwitterFormStepThree(D))
							} else {
								new Box(new Utils().TwitterFormStepOne(L.link,
										D))
							}
						}
					}
				}).get();
				return C
			},
			TwitterWindowOpen : function(A) {
				popupWin = window.open(A);
				popupWin.focus()
			},
			TwitterFormStepOne : function(H, D) {
				var K = new Element("div");
				var Q = new Element("h4");
				var O = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/twitter.png",
					"class" : "twitter"
				});
				var N = new Element("span", {
					html : "Submit to Twitter.com"
				});
				Q.adopt(O);
				Q.adopt(N);
				var C = new Element("form", {
					"class" : "center",
					action : "#",
					events : {
						submit : function(T) {
							T.stop();
							new Box(new Utils().TwitterFormStepTwo(D));
							new Utils().TwitterWindowOpen(H)
						}
					}
				});
				var G = new Element("p", {
					html : "<strong>Step 1</strong>"
				});
				var M = new Element(
						"p",
						{
							html : ""
						});
				C.adopt(G);
				C.adopt(M);
				var R = new Element("p", {
					"class" : "buttons"
				});
				var L = new Element("span", {
					"class" : "button2"
				});
				var P = new Element("input", {
					value : "Authorize",
					type : "submit"
				});
				L.adopt(P);
				R.adopt(L);
				var I = new Element("span", {
					html : "&nbsp;"
				});
				R.adopt(I);
				var A = new Element("span", {
					"class" : "button2"
				});
				var J = new Element("input", {
					value : "Cancel",
					type : "button",
					events : {
						click : function() {
							$("modalOverlay").dispose();
							$$(".modal").dispose()
						}
					}
				});
				A.adopt(J);
				R.adopt(A);
				C.adopt(R);
				var E = new Element(
						"p",
						{
							"class" : "links",
							html : '<a target="_blank" href="http://twitter.com/about#about">Click here</a> to learn what is Twitter.com'
						});
				var S = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var B = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				S.adopt(B);
				var F = new Element("div", {
					"class" : "bottom"
				});
				K.adopt(Q);
				K.adopt(C);
				K.adopt(E);
				K.adopt(S);
				K.adopt(F);
				return K
			},
			TwitterFormStepTwo : function(C) {
				var J = new Element("div");
				var O = new Element("h4");
				var M = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/twitter.png",
					"class" : "twitter"
				});
				var L = new Element("span", {
					html : "Submit to Twitter.com"
				});
				O.adopt(M);
				O.adopt(L);
				var N = new Element("div", {
					"class" : "error"
				});
				var I = new Element("p", {
					html : ""
				});
				var E = new Element("div", {
					"class" : "bottom"
				});
				N.adopt(I);
				N.adopt(E);
				var B = new Element(
						"form",
						{
							"class" : "center",
							action : "#",
							events : {
								submit : function(T) {
									T.stop();
									var S = new Request.JSON( {
										url : "/twitter",
										onComplete : function(U) {
											if (U.auth) {
												new Box(new Utils()
														.TwitterFormStepThree(C))
											} else {
												N.setStyle("display", "block");
												I
														.set("html",
																"");
												var V = new Element("a", {
													html : "Close",
													href : "#",
													events : {
														click : function(W) {
															W.stop();
															$("modalOverlay")
																	.dispose();
															$$(".modal")
																	.dispose()
														}
													}
												});
												I.adopt(V)
											}
										}
									}).get()
								}
							}
						});
				var H = new Element("p", {
					html : "<strong>Step 2</strong>"
				});
				var K = new Element(
						"p",
						{
							html : "Please click &quot;Continue&quot; button to check authorization"
						});
				B.adopt(H);
				B.adopt(K);
				var P = new Element("p", {
					"class" : "buttons"
				});
				var R = new Element("span", {
					"class" : "button2"
				});
				var F = new Element("input", {
					value : "Continue",
					type : "submit"
				});
				R.adopt(F);
				P.adopt(R);
				B.adopt(P);
				var D = new Element(
						"p",
						{
							"class" : "links",
							html : '<a target="_blank" href="http://twitter.com/about#about">Click here</a> to learn what is Twitter.com'
						});
				var Q = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var A = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				Q.adopt(A);
				var G = new Element("div", {
					"class" : "bottom"
				});
				J.adopt(O);
				J.adopt(N);
				J.adopt(B);
				J.adopt(D);
				J.adopt(Q);
				J.adopt(G);
				return J
			},
			TwitterFormStepThree : function(D) {
				var J = $(D).get("value");
				var L = new Element("div");
				var W = new Element("h4");
				var T = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/twitter.png",
					"class" : "twitter"
				});
				var Q = new Element("span", {
					html : "Submit to Twitter.com"
				});
				W.adopt(T);
				W.adopt(Q);
				var U = new Element("div", {
					"class" : "error"
				});
				var K = new Element("p", {
					html : ""
				});
				var F = new Element("div", {
					"class" : "bottom"
				});
				U.adopt(K);
				U.adopt(F);
				var H = new Element("div", {
					"class" : "ok",
					style : "display:none;"
				});
				var R = new Element("p", {
					html : ""
				});
				var S = new Element("div", {
					"class" : "bottom"
				});
				H.adopt(R);
				H.adopt(S);
				var C = new Element(
						"form",
						{
							"class" : "center",
							action : "#",
							events : {
								submit : function(a) {
									a.stop();
									var Z = new Request.JSON( {
										url : "/twitter",
										onComplete : function(b) {
											H.setStyle("display", "block");
											R
													.set("html",
															"Message: Image was successfully posted on your Twitter.<br/>");
											var c = new Element("a", {
												html : "Close",
												href : "#",
												events : {
													click : function(f) {
														f.stop();
														$("modalOverlay")
																.dispose();
														$$(".modal").dispose()
													}
												}
											});
											R.adopt(c)
										}
									}).get( {
										message : $("twitter-message")
												.get("value")
									})
								}
							}
						});
				var I = new Element("p", {
					html : "<strong>Step 3</strong>"
				});
				var P = new Element(
						"p",
						{
							html : 'Create your post for Twitter.com, <span id="wordcount" class="remains">120</span> symbols remains'
						});
				C.adopt(I);
				C.adopt(P);
				var M = new Element("div");
				var N = new Element("textarea", {
					style : "width:334px;height:150px;",
					id : "twitter-message",
					events : {
						keyup : function() {
							var Z = $("twitter-message").get("value").length;
							$("wordcount").set("html", 120 - Z)
						},
						blur : function() {
							var Z = $("twitter-message").get("value").length;
							$("wordcount").set("html", 120 - Z)
						}
					}
				});
				M.adopt(N);
				C.adopt(N);
				var V = new Element("p", {
					"class" : "buttons"
				});
				var Y = new Element("span", {
					"class" : "button2"
				});
				var E = new Element("input", {
					value : "Submit",
					type : "submit"
				});
				Y.adopt(E);
				V.adopt(Y);
				C.adopt(V);
				var B = new Element(
						"p",
						{
							"class" : "links",
							html : '<a target="_blank" href="http://twitter.com/about#about">Click here</a> to learn what is Twitter.com'
						});
				var X = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var A = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				X.adopt(A);
				var G = new Element("div", {
					"class" : "bottom"
				});
				L.adopt(W);
				L.adopt(U);
				L.adopt(H);
				L.adopt(C);
				L.adopt(B);
				L.adopt(X);
				L.adopt(G);
				var O = new Request.JSON( {
					url : "/tiny.php",
					onComplete : function(a) {
						if (a.link) {
							N.set("html", a.link);
							var Z = 120;
							$("wordcount").set("html", Z - a.link.length)
						}
					}
				}).get( {
					url : J
				});
				return L
			},
			createDescrForm : function(N, O, A) {
				var M = new Element("div");
				var S = new Element("h4", {
					html : "Image tags & description"
				});
				var R = new Element("div", {
					"class" : "error"
				});
				var K = new Element("p", {
					html : ""
				});
				var G = new Element("div", {
					"class" : "bottom"
				});
				R.adopt(K);
				R.adopt(G);
				var F = new Element(
						"form",
						{
							"class" : "form-img-tags",
							events : {
								submit : function(X) {
									X.stop();
									var W = new Request.JSON( {
										url : "/index/saveimageinfo",
										onComplete : function(Y) {
											if (Y) {
												if (Y.result == "error") {
													R.setStyle("display",
															"block");
													K
															.set("html",
																	"Error occured. Please try again later.")
												} else {
													if ($("cell_" + A
															+ "_image")) {
														$("cell_" + A
																+ "_image")
																.set(
																		"alt",
																		P
																				.get("value"))
													}
													$("modalOverlay").dispose();
													$$(".modal").dispose()
												}
											}
										}
									}).get( {
										descr : P.get("value"),
										tags : O.get("value"),
										image_id : A
									})
								}
							}
						});
				var U = new Element("fieldset");
				var V = new Element("p");
				var I = new Element("label", {
					html : "Description"
				});
				var P = new Element("textarea", {
					rows : 5,
					cols : 20,
					value : N
				});
				var J = new Element("p");
				var L = new Element("label", {
					html : "Tags"
				});
				var O = new Element("input", {
					"class" : "txt",
					value : O
				});
				var Q = new Element("p", {
					"class" : "buttons"
				});
				var B = new Element("span", {
					"class" : "button2"
				});
				var D = new Element("input", {
					type : "submit",
					value : "Save"
				});
				var T = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose();
							$("modalOverlay").dispose()
						}
					}
				});
				var E = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var C = new Element(
						"p",
						{
							html : 'Image description will be shown near your image on "Show to friends" page.'
						});
				var H = new Element("div", {
					"class" : "bottom"
				});
				M.adopt(S);
				M.adopt(R);
				M.adopt(F);
				F.adopt(U);
				U.adopt(V);
				V.adopt(I);
				V.adopt(P);
				J.adopt(L);
				J.adopt(O);
				F.adopt(Q);
				Q.adopt(B);
				B.adopt(D);
				M.adopt(C);
				M.adopt(T);
				T.adopt(E);
				M.adopt(H);
				return M
			},
			createErrorForm : function(A) {
				var C = new Element("div", {
					id : "payment_modal"
				});
				var D = new Element("h4", {
					html : "Please read carefully..."
				});
				var E = new Element("a", {
					"class" : "close",
					html : '<img src="http://' + localvars.domain
							+ '/images/img/close.png" alt="Close" />',
					events : {
						click : function(F) {
							F.stop();
							closeModal()
						}
					}
				});
				var A = new Element("div", {
					"class" : "error",
					html : '<div style="margin:10px;"><span class="text">' + A
							+ '</span></div><div class="bottom"></div>'
				});
				A.setStyle("display", "block");
				var B = new Element("div", {
					"class" : "bottom"
				});
				C.adopt(D);
				C.adopt(A);
				C.adopt(E);
				C.adopt(B);
				return C
			},
			createRotateForm : function(A, G, Q) {
				var D = new Element("div");
				var F = new Element("h4", {
					html : "Image Rotation"
				});
				var I = new Element("div", {
					"class" : "img-transform",
					id : "place_image_rotate"
				});
				var C = new Element("div", {
					id : "draw_image_" + G,
					html : '<img src="http://img.' + localvars.domain
							+ '/loading.gif" />'
				});
				C.setStyles( {
					width : "320px",
					height : "320px"
				});
				var H = new Element("img", {
					"class" : "src",
					src : "http://" + localvars.domain
							+ "/images/img/loading.gif",
					id : "rotate_image"
				});
				var M = new Element("p", {
					"class" : "buttons"
				});
				var B = new Element("a", {
					"class" : "tools-draw hide",
					html : '<img style="cursor:pointer" src="http://img.'
							+ localvars.domain
							+ '/rotate-right.gif" alt="Rotate right" />'
				});
				var P = new Element("a", {
					"class" : "tools-draw hide",
					html : '<img style="cursor:pointer" src="http://img.'
							+ localvars.domain
							+ '/rotate-left.gif" alt="Rotate left" />'
				});
				var E = new Element("a", {
					"class" : "tools-draw hide",
					html : '<img style="cursor:pointer" src="http://img.'
							+ localvars.domain
							+ '/flip-vert.gif" alt="Flip vertical" />'
				});
				var J = new Element("a", {
					"class" : "tools-draw hide",
					html : '<img style="cursor:pointer" src="http://img.'
							+ localvars.domain
							+ '/flip-horiz.gif" alt="Flip horizontal" />'
				});
				var N = new Element("span", {
					"class" : "button2"
				});
				var L = new Element("input", {
					type : "button",
					value : "Save & Upload",
					events : {
						click : function(S) {
							S.stop();
							$(O).dispose();
							$(this).set("value", "Please wait...");
							$(this).set("disabled", true);
							$("cell_" + Q).addClass("no-draw");
							var R = A.substring(strrpos(A, "/") + 1);
							downloadPic(R, G)
						}
					}
				});
				B.addEvent("click", function(R) {
					R.stop();
					rotate(90, G)
				});
				P.addEvent("click", function(R) {
					R.stop();
					rotate(-90, G)
				});
				E.addEvent("click", function(R) {
					R.stop();
					flip("h", G)
				});
				J.addEvent("click", function(R) {
					R.stop();
					flip("v", G)
				});
				var O = new Element("a", {
					"class" : "close",
					html : '<img src="http://' + localvars.domain
							+ '/images/img/close.png" alt="Close" />',
					events : {
						click : function(R) {
							R.stop();
							closeModal()
						}
					}
				});
				var K = new Element("div", {
					"class" : "bottom"
				});
				D.adopt(F);
				D.adopt(I);
				I.adopt(C);
				I.adopt(M);
				M.adopt(B);
				M.adopt(P);
				M.adopt(E);
				M.adopt(J);
				M.adopt(N);
				N.adopt(L);
				D.adopt(O);
				D.adopt(K);
				return D
			},
			createTwitterForm : function(F) {
				var S = "add-album";
				if ($(S)) {
					$(S).dispose()
				}
				var J = new Element("div", {});
				var D = new Element("form", {
					events : {
						submit : function(X) {
							X.stop();
							var W = M.get("html");
							new Utils().sendTwitter()
						}
					}
				});
				var V = new Element("fieldset", {
					id : S,
					"class" : "box"
				});
				var T = new Element("h4");
				var G = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/twitter.png",
					width : 32,
					height : 32,
					styles : {
						position : "relative",
						top : "10px",
						left : "-5px"
					}
				});
				var K = new Element("span", {
					html : "Post in Twitter"
				});
				G.inject(T);
				K.inject(T);
				var U = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var C = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var L = new Element("ol");
				var O = new Element("li", {
					id : "parentUrl"
				});
				var I = new Element("li", {
					html : "Loading..."
				});
				var H = new Element("label", {
					html : localMessage.albumName
				});
				var M = new Element("textarea", {
					"class" : "txt uploadUrl",
					id : "twitter-message",
					name : "message"
				});
				var P = new Element("p", {
					"class" : "buttons"
				});
				var A = new Element("span", {
					"class" : "button2"
				});
				var Q = new Element("input", {
					type : "submit",
					id : "save_button",
					value : "twetter"
				});
				var B = new Element("p", {
					html : ""
				});
				var E = new Element("div", {
					"class" : "bottom"
				});
				var R = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				L.adopt(I);
				A.adopt(Q);
				P.adopt(A);
				V.adopt(L);
				D.adopt(V);
				J.adopt(D);
				var N = new Request.JSON( {
					url : "/twitter",
					onComplete : function(Z) {
						if (Z.auth) {
							U.adopt(C);
							I.dispose();
							J.adopt(T);
							J.adopt(R);
							J.adopt(B);
							L.adopt(O);
							O.adopt(H);
							O.adopt(M);
							V.adopt(P);
							var X = new Request.JSON( {
								url : "http://" + localvars.domain
										+ "/tiny.php",
								onComplete : function(a) {
									if (a.link) {
										M.set("html", a.link)
									}
								}
							}).get( {
								url : F
							})
						} else {
							$$(".modal").dispose();
							var W = new Utils();
							var Y = new Box(W.createAuthTwitterForm(Z.link))
						}
					}
				}).get();
				J.adopt(U);
				J.adopt(E);
				return J
			},
			sendTwitter : function(B) {
				var A = new Request.JSON( {
					url : "/twitter",
					onComplete : function(C) {
					}
				}).get( {
					message : B
				})
			},
			renameAlbumForm : function() {
				var O = "rename-album";
				if ($(O)) {
					$(O).dispose()
				}
				var G = new Element("div", {});
				var K = getParam("albumId");
				var D = new Element("form", {
					action : "/dashboard/albums/rename/id/" + K,
					events : {
						submit : function(S) {
						}
					}
				});
				var R = new Element("fieldset", {
					id : O,
					"class" : "box"
				});
				var P = new Element("h4", {
					html : localMessage.albumRename
				});
				var Q = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var C = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var H = new Element("ol");
				var J = new Element("li", {
					id : "parentUrl"
				});
				var F = new Element("label", {
					html : localMessage.albumName
				});
				var I = new Element("input", {
					"class" : "txt uploadUrl",
					id : "input-album-name",
					name : "name"
				});
				var L = new Element("p", {
					"class" : "buttons"
				});
				var A = new Element("span", {
					"class" : "button2"
				});
				var M = new Element("input", {
					type : "submit",
					id : "save_button",
					value : localMessage.ok
				});
				var B = new Element("p", {
					html : ""
				});
				var E = new Element("div", {
					"class" : "bottom"
				});
				var N = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				Q.adopt(C);
				J.adopt(F);
				J.adopt(I);
				H.adopt(J);
				A.adopt(M);
				L.adopt(A);
				R.adopt(H);
				R.adopt(L);
				D.adopt(R);
				G.adopt(P);
				G.adopt(N);
				G.adopt(D);
				G.adopt(B);
				G.adopt(Q);
				G.adopt(E);
				return G
			},
			protectAlbumForm : function() {
				var Q = "protect-album";
				if ($(Q)) {
					$(Q).dispose()
				}
				var C = new Element("div", {});
				var D = new Element("form", {
					events : {
						submit : function(R) {
							new Album().saveProtect();
							R.stop()
						}
					}
				});
				var N = new Element("fieldset", {
					id : Q,
					"class" : "box"
				});
				var F = new Element("h4", {
					html : localMessage.albumProtectName
				});
				var E = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var B = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var K = new Element("ol");
				var P = new Element("li", {
					id : "parentUrl"
				});
				var M = new Element("label", {
					html : localMessage.albumProtectName
				});
				var L = new Element("input", {
					"class" : "txt uploadUrl",
					id : "input-album-protect",
					name : "album-protect",
					value : $("album-secret").get("name")
				});
				var O = new Element("p", {
					"class" : "buttons"
				});
				var G = new Element("span", {
					"class" : "button2"
				});
				var A = new Element("input", {
					type : "submit",
					id : "save_button",
					value : localMessage.save
				});
				var H = new Element("p", {
					html : ""
				});
				var J = new Element("div", {
					"class" : "bottom"
				});
				var I = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				E.adopt(B);
				P.adopt(M);
				P.adopt(L);
				K.adopt(P);
				G.adopt(A);
				O.adopt(G);
				N.adopt(K);
				N.adopt(O);
				D.adopt(N);
				C.adopt(F);
				C.adopt(I);
				C.adopt(D);
				C.adopt(H);
				C.adopt(E);
				C.adopt(J);
				return C
			},
			deleteAlbumForm : function() {
				var C = getParam("albumId");
				if (albums[C]) {
					var H = albums[C]
				} else {
					var H = false
				}
				var R = "delete-album";
				if ($(R)) {
					$(R).dispose()
				}
				var J = new Element("div", {});
				var F = new Element("form", {
					events : {
						submit : function(V) {
							new Album().del();
							V.stop()
						}
					}
				});
				var U = new Element("fieldset", {
					id : R,
					"class" : "box"
				});
				var N = new Element("p", {
					id : "album-delete-text",
					"class" : "center"
				});
				var S = new Element("h4", {
					html : localMessage.albumDel
				});
				var T = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var E = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var K = new Element("ol");
				var M = new Element("li", {
					id : "parentUrl"
				});
				var I = new Element("label");
				var L = new Element("select", {
					"class" : "",
					id : "select-album",
					name : "select-album"
				});
				var A = new Element("option", {
					value : "deleteall",
					html : localMessage.deleteAllImages
				});
				L.adopt(A);
				if (albums) {
					albums.each(function(W) {
						var V = new Element("option", {
							value : W.id,
							html : W.name.substr(0, 15),
							id : "select_album_" + W.id
						});
						if (max_imgs_cnt > 1) {
							if (W.count >= max_imgs_cnt
									|| (W.count + H.count) > max_imgs_cnt) {
								V.set("disabled", 1);
								V.set("html", W.name.substr(0, 15)
										+ " limit ex. *")
							}
						}
						L.adopt(V)
					})
				}
				var O = new Element("p", {
					"class" : "buttons"
				});
				var B = new Element("span", {
					"class" : "button2"
				});
				var P = new Element("input", {
					type : "submit",
					id : "save_button",
					value : localMessage.ok
				});
				var D = new Element("p", {
					html : "* Image limit exceeded. "
				});
				var G = new Element("div", {
					"class" : "bottom"
				});
				var Q = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				T.adopt(E);
				M.adopt(I);
				M.adopt(L);
				K.adopt(M);
				B.adopt(P);
				O.adopt(B);
				U.adopt(N);
				U.adopt(K);
				U.adopt(O);
				F.adopt(U);
				J.adopt(S);
				J.adopt(Q);
				J.adopt(F);
				J.adopt(D);
				J.adopt(T);
				J.adopt(G);
				return J
			},
			creatFriendForm : function() {
				var X = "tell-a-friend";
				if ($(X)) {
					$(X).dispose()
				}
				var K = new Element("div", {});
				var E = new Element("form", {
					events : {
						submit : function(j) {
							saveTellFriend();
							j.stop()
						}
					}
				});
				var f = new Element("fieldset", {
					id : X,
					"class" : "box"
				});
				var Y = new Element("h4", {
					html : localMessage.tellFriend
				});
				var a = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var D = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var L = new Element("ol");
				var P = new Element("li", {
					id : "parentUrl"
				});
				var I = new Element("label", {
					html : localMessage.yourName
				});
				var M = new Element("input", {
					"class" : "txt",
					id : "your-name",
					name : "your-name"
				});
				var c = new Element("li");
				var G = new Element("label", {
					html : localMessage.yourEmail
				});
				var V = new Element("input", {
					"class" : "txt",
					id : "your-email",
					name : "your-email"
				});
				var g = new Element("li");
				var W = new Element("label", {
					html : localMessage.friendsEmails
				});
				var B = new Element("input", {
					"class" : "txt",
					id : "friend-email",
					name : "friend-email"
				});
				var Z = new Element("li");
				var Q = new Element("label", {
					html : localMessage.comment
				});
				var b = new Element("textarea", {
					"class" : "txt",
					id : "friend-comment",
					name : "friend-comment"
				});
				var N = new Element("li");
				var e = new Element("label", {
					html : localMessage.captcha
				});
				var H = new Element("input", {
					id : "image_captcha",
					name : "image_captcha",
					type : "hidden",
					value : (new Date().getTime())
				});
				var T = new Element("li");
				var J = new Element("label", {
					html : localMessage.answer
				});
				var O = new Element("input", {
					"class" : "txt",
					id : "friend-captcha",
					name : "friend-captcha"
				});
				var R = new Element("p", {
					"class" : "buttons"
				});
				var A = new Element("span", {
					"class" : "button2"
				});
				var S = new Element("input", {
					type : "submit",
					id : "save_button",
					value : localMessage.send
				});
				var C = new Element(
						"p",
						{
							html : "Duis tortor magna, lacinia eu, euismod in, sagittis et, lorem. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris semper. Donec suscipit aliquam massa."
						});
				var F = new Element("div", {
					"class" : "bottom"
				});
				var U = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				a.adopt(D);
				P.adopt(I);
				P.adopt(M);
				c.adopt(G);
				c.adopt(V);
				g.adopt(W);
				g.adopt(B);
				Z.adopt(Q);
				Z.adopt(b);
				N.adopt(e);
				N.adopt(H);
				T.adopt(J);
				T.adopt(O);
				L.adopt(P);
				L.adopt(c);
				L.adopt(g);
				L.adopt(Z);
				A.adopt(S);
				R.adopt(A);
				f.adopt(L);
				f.adopt(R);
				E.adopt(f);
				K.adopt(Y);
				K.adopt(U);
				K.adopt(E);
				K.adopt(C);
				K.adopt(a);
				K.adopt(F);
				return K
			},
			checkEmail : function(A) {
				var B = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
				return B.test(A)
			},
			count : function(A) {
				return A.length
			},
			trim : function(A) {
				return A.replace(/(^\s+)|(\s+$)/g, "")
			},
			creatEmailForm : function() {
				var Q = "save-to-email";
				if ($(Q)) {
					$(Q).dispose()
				}
				var C = new Element("div", {});
				var D = new Element("form", {
					events : {
						submit : function(R) {
							saveToEmailStart();
							R.stop()
						}
					}
				});
				var N = new Element("fieldset", {
					id : Q,
					"class" : "box"
				});
				var F = new Element("h4", {
					html : localMessage.saveToEmail
				});
				var E = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose();
							$$(".shadow").dispose()
						}
					}
				});
				var B = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				var K = new Element("ol");
				var P = new Element("li", {
					id : "parentUrl"
				});
				var M = new Element("label", {
					html : localMessage.email
				});
				var L = new Element("input", {
					"class" : "txt uploadUrl",
					id : "emailPlace",
					name : "uploadUrl[]"
				});
				var O = new Element("p", {
					"class" : "buttons"
				});
				var G = new Element("span", {
					"class" : "button2"
				});
				var A = new Element("input", {
					type : "submit",
					id : "save_button",
					value : localMessage.send
				});
				var H = new Element("p", {
					html : localMessage.saveToEmailExample
				});
				var J = new Element("div", {
					"class" : "bottom"
				});
				var I = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				E.adopt(B);
				P.adopt(M);
				P.adopt(L);
				K.adopt(P);
				G.adopt(A);
				O.adopt(G);
				N.adopt(K);
				N.adopt(O);
				D.adopt(N);
				C.adopt(F);
				C.adopt(I);
				C.adopt(D);
				C.adopt(H);
				C.adopt(E);
				C.adopt(J);
				return C
			},
			creatErrorForm : function(B, F) {
				var E = "errorForm_" + B;
				if ($(E)) {
					$(E).dispose()
				}
				var G = new Element("div", {
					id : E,
					"class" : "dialog-error",
					html : localMessage.uploadError + ": " + F
				});
				var D = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							closeError(B)
						}
					}
				});
				var C = new Element("div", {
					"class" : "bottom"
				});
				var A = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					"class" : "close_link",
					alt : localMessage.close
				});
				D.adopt(A);
				G.adopt(D);
				G.adopt(C);
				return G
			},
			cloneInput : function() {
				var C = $$(".uploadUrl");
				var B = C.length;
				var A = C[(B - 1)];
				if (B < 10) {
					var D = A.clone()
				}
				D.setProperty("value", "");
				D.injectAfter(A)
			},
			check_url : function(B) {
				var D = B;
				var C = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
				var A = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
				if (A.test(D)) {
					return true
				} else {
					return false
				}
			},
			clearBoard : function() {
				var A = this;
				if (confirm(localMessage.areYouSureAll)) {
					var B = new Request.JSON( {
						url : "/index/clear/album_id/" + getParam("albumId"),
						onComplete : function(C) {
							if (C.result) {
								var D = $("gallery").getElements("li");
								if ($$(".navigation")) {
									$$(".navigation").dispose()
								}
								D.each(function(E) {
									if (E) {
										E.dispose()
									}
								});
								A.createCells();
								A.checkFlash();
								A.hoverCell();
								A.toggleExpoLink()
							}
						}
					}).get()
				}
			},
			clearImage : function(E, C) {
				var A = this;
				if (confirm(localMessage.areYouSure) && E > 0) {
					var B = new Waiter("cell_" + C, {
						layer : {
							id : "waitingDiv",
							background : "#fff",
							opacity : 0.9
						}
					});
					B.start();
					var D = new Request.JSON( {
						onComplete : function(F) {
							B.stop();
							if (F) {
								if (F.result) {
									A.emptyCell(C);
									A.hoverCell();
									A.toggleExpoLink()
								}
							}
						}
					}).get("/index/delete/image_id/" + E)
				}
				return false
			},
			toggleExpoLink : function() {
				var A = $$(".cell");
				if ($("expo_link")) {
					if (A.length > 0) {
						$("expo_link").removeClass("hide")
					} else {
						$("expo_link").addClass("hide")
					}
				}
			},
			emptyCell : function(B) {
				if ((B % 5) == 4) {
					var A = "empty-cell last-in-row"
				} else {
					var A = "empty-cell"
				}
				$("cell_" + B).setProperty("class", A);
				$("cell_" + B).set("html", localMessage.uploadPhoto);
				$("cell_" + B).removeEvents("click");
				this.checkFlash()
			},
			urldecode : function(B) {
				var A = B;
				A = A.replace(/\+/g, "%20");
				A = decodeURIComponent(A);
				A = A.toString();
				return A
			},
			getLinks : function(B) {
				updateFlashPosition();
				var A = $("content_link_" + B);
				$$(".window").each(function(C) {
					if (C != A) {
						C.setStyle("display", "none")
					} else {
						if (A) {
							if (A.getStyle("display") == "none") {
								A.setStyle("display", "block")
							} else {
								A.setStyle("display", "none")
							}
						}
					}
				});
				return false
			},
			closeWindows : function() {
				$$(".window").each(function(A) {
					A.setStyle("display", "none")
				})
			},
			getInfo : function(B) {
				var A = $("content_info_" + B);
				$$(".window").each(function(C) {
					if (C != A) {
						C.setStyle("display", "none")
					} else {
						if (A) {
							if (A.getStyle("display") == "none") {
								A.setStyle("display", "block")
							} else {
								A.setStyle("display", "none")
							}
						}
					}
				});
				return false
			},
			loadLinksContent : function(B, D, G) {
				if ($("context-menu")) {
					$("context-menu").dispose()
				}
				var A = $("cell_" + B);
				function F(I) {
					$(I).addEvent("mouseenter", function(J) {
						$(I).addClass("active")
					});
					$(I).addEvent("mouseleave", function(J) {
						$(I).removeClass("active")
					})
				}
				function H(I, J) {
					if (!I) {
						return
					}
					$$("#cell_" + I + " a.close").set("html",
							localMessage.getLinks);
					$(G).set("html", localMessage.getLinks);
					$(G).removeClass("close");
					$(G).removeClass("loading");
					if ($("links_" + J)) {
						$("links_" + J).dispose()
					}
					$("cell_" + I).removeClass("dialog");
					$("cell_" + I).removeClass("active");
					$("dialog_" + I).set("html", "");
					$("dialog_" + I).setStyle("display", "none");
					F($("cell_" + I))
				}
				if (A) {
					$$("li.cell.active.dialog").each(function(I) {
						var J = $(I).getProperty("id").replace(/cell_/, "");
						if (J != B) {
							H(J, D)
						}
					});
					$("cell_" + B).removeEvents("mouseleave");
					$("cell_" + B).removeEvents("mouseenter");
					$("cell_" + B).addClass("dialog");
					$("cell_" + B).addClass("active");
					if ($("links_" + D)) {
						H(B, D)
					} else {
						$(G).set("html", localMessage.load);
						$(G).addClass("html", "loading");
						var C = new Element("div", {
							id : "links_" + D,
							"class" : "links",
							styles : {
								display : "none"
							}
						});
						$$("#update p.get-links").each(function(J) {
							J.dispose();
							var K = $(this).className;
							K = K.split(" ");
							var L = K[1].replace(/image_/, "");
							var I = K[2].replace(/cell_/, "");
							H(I, L)
						});
						$("dialog_" + B).adopt(C);
						var E = new Waiter("cell_" + B, {
							layer : {
								id : "waitingDiv",
								background : "#fff",
								opacity : 0.9
							}
						});
						E.start();
						C.set("load", {
							evalScripts : true,
							onComplete : function() {
								updateFlashPosition();
								$("dialog_" + B).setStyle("display", "block");
								if ($("dialog_" + B)) {
									$("dialog_" + B).addEvent("mouseover",
											function(I) {
												updateFlashPosition()
											})
								}
								$(G).set("html", localMessage.close);
								$(G).addClass("close");
								$(G).removeClass("loading");
								$("links_" + D).setStyle("display", "block");
								if ($("closeLinks")) {
									$("closeLinks").addEvent("click",
											function(I) {
												H(B, D);
												I.stop()
											})
								}
								E.stop()
							}
						});
						C.load("/view/links/id/" + D)
					}
				}
			},
			closeLinks : function(A) {
				$("links_" + A).dispose()
			},
			closeInfo : function(A) {
				$("info_" + A).dispose()
			},
			loadInfoContent : function(H, A, F) {
				var K = $("cell_" + H);
				var I = getStyle(F, "width").toInt();
				var C = findPos(F);
				var G = C[0];
				var E = C[1];
				if (K) {
					if ($("info_" + A)) {
						F.innerHTML = localMessage.descr;
						RemoveClassName(F, "descr-close");
						RemoveClassName(F, "loading");
						$("info_" + A).dispose()
					} else {
						var J = 125;
						if (Browser.Engine.trident) {
							J = 132
						}
						F.innerHTML = localMessage.load;
						AddClassName(F, "loading");
						var B = new Element("div", {
							id : "info_" + A,
							"class" : "info",
							styles : {
								display : "none",
								left : (G - 185) + "px",
								top : "" + (E - J) + "px"
							}
						});
						$$("#update .info")
								.each(function(L) {
									L.dispose();
									var M = L.getProperty("id").replace(
											/info_/, "");
									RemoveClassName($$("a.image_" + M)[0],
											"descr-close");
									$$("a.image_" + M)[0].innerHTML = localMessage.getLinks
								});
						$("update").adopt(B);
						B
								.set("html",
										'<img src="http://css.imagetabs.com/img/load.gif" />');
						var D = new Request( {
							method : "get",
							onFailure : function(L) {
								alert(L)
							},
							onSuccess : function(L) {
								$("info_" + A).set("html", L);
								F.innerHTML = localMessage.close;
								AddClassName(F, "descr-close");
								RemoveClassName(F, "loading");
								$("info_" + A).setStyle("display", "block");
								$("closeInfo").addEvent("click", function(M) {
									F.innerHTML = localMessage.descr;
									RemoveClassName(F, "descr-close");
									$("info_" + A).dispose()
								})
							},
							url : "/view/info/id/" + A
						}).send()
					}
				}
			},
			setActiveTab : function(A, B) {
				$$(".type_link_" + B).each(function(C) {
					C.removeClass("current")
				});
				$(A + "_link").addClass("current")
			},
			getTab : function(A, C) {
				var B = A + "_" + C;
				this.setActiveTab(A, C);
				$$(".typeThumb_" + C).each(function(D) {
					if (D.getProperty("id") != B) {
						D.addClass("hide")
					} else {
						D.removeClass("hide")
					}
				});
				$$(".dialog-links").getHeight().each(function(D) {
					if (D > 0) {
						$("bottom_div").setStyle("top", D)
					}
				});
				return false
			},
			expandCollapse : function(B) {
				var D = $(B).getParents("fieldset");
				var C = B.getChildren("a").get("html");
				var A = D.getParent("div")[0];
				A.getChildren(".expanded").each(function(E) {
					$(E).removeClass("expanded");
					$(E).addClass("collapsed")
				});
				$(B).getParents("fieldset").removeClass("collapsed");
				$(B).getParents("fieldset").addClass("expanded");
				return false
			},
			moveImages : function() {
				var A = getParam("albumId");
				if (albums[A]) {
					var F = albums[A]
				} else {
					var F = false
				}
				var I = new Element("div");
				var O = new Element("h4", {
					html : "Move images to album"
				});
				var M = new Element("span", {});
				O.adopt(M);
				var L = new Element(
						"div",
						{
							"class" : "error",
							html : '<span class="text"></span><div class="bottom"></div>'
						});
				var D = new Element("form", {
					action : "/dashboard/albums/getbulklinks",
					method : "get",
					events : {
						submit : function(U) {
							U.stop();
							var T = "&";
							$$("input.cb:checked").get("value").each(function(
									W, V) {
								T += "&image_id[]=" + W
							});
							new Album().moveimages(T)
						}
					}
				});
				var S = new Element("fieldset");
				D.adopt(S);
				var J = new Element("ol");
				S.adopt(J);
				var K = new Element("li");
				J.adopt(K);
				var H = new Element("label", {
					"for" : "sel-album",
					html : "Move images to "
				});
				K.adopt(H);
				var P = new Element("p", {
					"class" : "buttons"
				});
				D.adopt(P);
				var G = new Element("span", {
					"class" : "button2"
				});
				var N = new Element("input", {
					value : "Move",
					type : "submit"
				});
				G.adopt(N);
				var B = new Element("p", {
					html : ""
				});
				if (albums && albums.length > 1) {
					P.adopt(G);
					var R = new Element("select", {
						id : "sel-album",
						styles : {
							width : 130
						}
					});
					K.adopt(R);
					albums
							.each(function(U) {
								var T = new Element("option", {
									value : U.id,
									html : U.name.substr(0, 15),
									id : "select_album_" + U.id
								});
								R.adopt(T);
								if (max_imgs_cnt > 1) {
									if (U.count >= max_imgs_cnt
											|| (U.count + F.count) > max_imgs_cnt) {
										T.set("disabled", 1);
										T.set("html", "*"
												+ U.name.substr(0, 15));
										B
												.set(
														"html",
														'* Notice: you are unable to move images to albums marked with star (*), because "maximum images per album" limit will be exeeded after moving.Please <a href="/limits/" target="_blank">click here</a> to view limits table.')
									}
								}
							})
				} else {
					H.set("html", "Add more albums");
					B.set("html", "")
				}
				var Q = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var C = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				Q.adopt(C);
				var E = new Element("div", {
					"class" : "bottom"
				});
				I.adopt(O);
				I.adopt(D);
				I.adopt(B);
				I.adopt(Q);
				I.adopt(E);
				return I
			},
			getBulk : function(L, Q) {
				var M = new Element("div");
				var U = new Element("h4", {
					html : "Get bulk of links"
				});
				var R = new Element("span", {});
				U.adopt(R);
				var E = new Element("form", {
					action : ".",
					"class" : "center",
					method : "get",
					events : {
						submit : function(c) {
							c.stop();
							var f = $("sel-format").getSelected().get("value");
							P.empty();
							A.dispose();
							var b = new Element("textarea", {
								styles : {
									width : 300,
									height : 150
								},
								events : {
									focus : function(g) {
										g.stop();
										this.select()
									},
									mouseup : function(g) {
										g.stop()
									}
								}
							});
							P.adopt(b);
							var a = new Element("input", {
								value : "Back",
								type : "button",
								events : {
									click : function(l) {
										l.stop();
										$$(".modal").dispose();
										var j = new Utils().getBulk(L, B);
										var g = new Box(j)
									}
								}
							});
							S.adopt(a);
							for (i in B) {
								if (B[i].image_id) {
									var Z = htmlentities(generateLinks(B[i],
											f[0]));
									if (Z) {
										var Y = b.get("html") + "\n";
										b.set("html", Y + Z)
									} else {
										dbug.log("error: %s", Z)
									}
								}
							}
						}
					}
				});
				var X = new Element("fieldset");
				E.adopt(X);
				var N = new Element("ol");
				X.adopt(N);
				var P = new Element("li");
				N.adopt(P);
				var G = new Element("label", {
					"for" : "sel-size",
					html : "Image size"
				});
				var D = new Element("select", {
					id : "sel-size",
					disabled : true,
					styles : {
						width : 130
					}
				});
				var T = new Element("label", {
					"for" : "sel-format",
					html : "Link code format"
				});
				P.adopt(T);
				var H = new Element("select", {
					id : "sel-format",
					disabled : true,
					styles : {
						width : 130
					}
				});
				P.adopt(H);
				var K = new Array;
				K[0] = {
					name : "Share with friends",
					value : "friend"
				};
				K[1] = {
					name : "Forum Style",
					value : "board"
				};
				K[2] = {
					name : "Banner Style",
					value : "blogs"
				};
				K[3] = {
					name : "Direct link",
					value : "direct"
				};
				if (K) {
					K.each(function(a, Z) {
						var Y = new Element("option", {
							value : a.value,
							html : a.name,
							id : "select_format_" + Z
						});
						H.adopt(Y)
					})
				}
				var V = new Element("p", {
					"class" : "buttons"
				});
				E.adopt(V);
				var S = new Element("span", {
					"class" : "button2"
				});
				var A = new Element("input", {
					value : "Generate",
					disabled : true,
					type : "submit"
				});
				S.adopt(A);
				V.adopt(S);
				var W = new Element("a", {
					"class" : "close",
					events : {
						click : function() {
							$$(".modal").dispose()
						}
					}
				});
				var C = new Element("img", {
					src : "http://" + localvars.domain
							+ "/images/img/close.png",
					alt : localMessage.close
				});
				W.adopt(C);
				var I = new Element("div", {
					"class" : "bottom"
				});
				M.adopt(U);
				M.adopt(E);
				M.adopt(W);
				M.adopt(I);
				var F = "";
				var B = "";
				if ($$("input.cb:checked").length > 0) {
					if (L) {
						var J = "/index/getbulklinks/?"
					} else {
						var J = "/dashboard/albums/getbulklinks/?"
					}
					$$("input.cb:checked").get("value").each(function(Z, Y) {
						F += "&image_id[]=" + Z
					});
					if (Q && Q.length > 0) {
						B = Q;
						D.set("disabled", false);
						H.set("disabled", false);
						A.set("disabled", false)
					} else {
						var O = new Request.JSON( {
							url : J + F,
							onComplete : function(Y) {
								if (Y) {
									if (!Y.error) {
										B = Y.images;
										D.set("disabled", false);
										H.set("disabled", false);
										A.set("disabled", false);
										for (i in Y.sizes) {
											var Z = new Element("option", {
												value : Y.sizes[i],
												html : Y.sizes[i],
												id : "select_size_"
														+ Y.sizes[i]
											});
											D.adopt(Z)
										}
									}
								}
							}
						}).get()
					}
				} else {
					return false
				}
				return M
			},
			makeMenu : function() {
				var A = this;
				resetFlashPosition();
				$$(".cell").each(function(C) {
					var B = $(C).getChildren();
					A.setContextMenu($(B[0]))
				})
			},
			setContextMenu : function(B) {
				resetFlashPosition();
				var A = this;
				B.removeEvents("keypress");
				B.removeEvents("contextmenu");
				B.removeEvents("mouseover");
				B.addEvent("mouseover", resetFlashPosition);
				B.addEvent("contextmenu", function(C) {
					C.stop();
					dbug.log(B);
					A.onHotKeyPress(C, B)
				})
			},
			onHotKeyPress : function(R, T) {
				var I = R.page;
				var K = T.getParent().get("id").replace(/cell_/, "");
				var N = $(T).getParent().getChildren();
				if (!N[0]) {
					return true
				}
				var B = $(N[0]).get("id").replace(/image_/, "");
				if ($("context-menu")) {
					$("context-menu").dispose()
				}
				var C = new Element("div", {
					id : "context-menu",
					"class" : "dialog-more body close",
					styles : {
						"z-index" : 1005,
						position : "absolute",
						top : I.y,
						left : I.x
					}
				});
				var F = new Element("ul", {
					"class" : "actions no-bullets"
				});
				C.adopt(F);
				var H = new Element("div", {
					"class" : "dialog-bottom"
				});
				C.adopt(H);
				var P = new Element("a", {
					"class" : "dont-close",
					href : "#",
					html : "Share It!",
					events : {
						click : function(X) {
							X.stop();
							$("context-menu").dispose();
							var W = $$("a.cell_" + K);
							new Utils().loadLinksContent(K, B, $(W[0]));
							if (K % 5 == "0") {
								$("dialog_" + K).setStyle("left", "-30px")
							} else {
								if (K % 5 == "4") {
									$("dialog_" + K).setStyle("left", "-306px")
								}
							}
						}
					}
				});
				var V = new Element("li", {
					"class" : "dont-close"
				});
				V.adopt(P);
				F.adopt(V);
				if (Browser.Plugins.Flash.version >= "8" && draw_enable
						&& $(T).getParent().get("rel") != "animated"
						&& !T.getParent().hasClass("no-draw")) {
					var Q = new Element("a", {
						"class" : "dont-close",
						href : "#",
						html : "Rotate image",
						events : {
							click : function(a) {
								a.stop();
								var W = "albumid/" + getParam("albumId")
										+ "/cellid/" + getEmptyCellId();
								var Z = $("cell_" + B + "_image");
								var b = Z.get("src").replace(/\/150/, "");
								var X = Z.get("src").replace(/\/150/, "320");
								var Y = new Box(new Utils().createRotateForm(X,
										B, K));
								$("context-menu").dispose();
								new App().startDraw(W, B);
								dbug.log(getEmptyCellId());
								setTimeout('loadPic("' + b + '",' + B + ")",
										500 * 2)
							}
						}
					});
					var D = new Element("li", {
						"class" : "dont-close"
					});
					D.adopt(Q);
					F.adopt(D)
				}
				var U = $(T).getParent().getChildren("input.cb");
				var J = $(U[0]).get("checked");
				var M = new Element("a", {
					"class" : "dont-close",
					href : "#",
					html : J ? "Deselect image" : "Select image",
					events : {
						click : function(W) {
							W.stop();
							$("context-menu").dispose();
							$(U[0]).set("checked", !J)
						}
					}
				});
				var G = new Element("li", {
					"class" : "dont-close"
				});
				G.adopt(M);
				F.adopt(G);
				var L = new Element("a", {
					"class" : "dont-close",
					href : "#",
					html : "Describe image",
					events : {
						click : function(a) {
							a.stop();
							var Z = $("cell_" + B + "_image").get("alt");
							if (Z) {
								Z = Z.split("::")
							} else {
								Z = false
							}
							var Y = Z[0] ? Z[0] : "";
							var W = Z[1] ? Z[1] : "";
							var X = new Box(new Utils()
									.createDescrForm(Y, W, B));
							$("context-menu").dispose()
						}
					}
				});
				var S = new Element("li", {
					"class" : "dont-close"
				});
				S.adopt(L);
				F.adopt(S);
				var O = new Element("li", {
					html : "<br/>",
					"class" : "dont-close"
				});
				F.adopt(O);
				var A = new Element("a", {
					"class" : "dont-close",
					href : "#",
					html : "Delete image",
					events : {
						click : function(W) {
							W.stop();
							var X = T.getParent().getChildren();
							if (X.length > 0) {
								parent.clearImage(B, K)
							}
							$("context-menu").dispose()
						}
					}
				});
				var E = new Element("li", {
					"class" : "dont-close"
				});
				E.adopt(A);
				F.adopt(E);
				$$("body").adopt(C)
			}
		});
var App = new Class( {
	initialize : function(A) {
		this.cell_id
	}
});
App.implement( {
	gearsUpload : function(C, A, B, E) {
		dbug.log("gears upload");
		var F = new MooGears("beta.httprequest");
		if (!C) {
			return false
		}
		if (E.length > 0) {
			var D = intilizeUploads(C, E.length);
			E.each(function(I, H) {
				var G = D[H];
				var J = google.gears.factory.create("beta.httprequest");
				var K = "/upload/gears/name/" + I.name + "/cellid/" + G
						+ "/albumid/" + A + "/auth/" + getAuth() + "/pid/" + B;
				J.open("POST", K);
				J.send(I.blob);
				J.upload.onprogress = function(M) {
					var L = Math.round((M.loaded / M.total) * 100);
					showProgress(G, L)
				};
				J.onreadystatechange = function() {
					if (J.readyState == 4) {
						var L = J.responseText;
						dbug.log("gears answer %s", L);
						onComplete(L)
					}
				}
			})
		} else {
			return false
		}
	},
	startDraw : function(E, F) {
		if (Browser.Plugins.Flash.version >= "8") {
			var A = "100%";
			var C = "100%";
			var B = {
				allowScriptAccess : "always",
				name : "drawer",
				wmode : "transparent",
				scale : "noscale"
			};
			var D = new Swiff("/swf/drawer.swf?phpPath=http://"
					+ localvars.domain_upload + "/rotate/true/auth/"
					+ getParam("auth") + "/" + E + "/&rand=" + Math.random(), {
				id : "drawer_" + F,
				container : "draw_image_" + F,
				width : A,
				allowScriptAccess : "always",
				height : C,
				params : B,
				vars : {
					smallWidth : 300,
					smallHeight : 300,
					isShowSmall : 1,
					phpPath : "http://" + localvars.domain_upload
							+ "/rotate/true/auth/" + getParam("auth") + "/" + E
				}
			})
		}
	},
	startUpload : function() {
		if (Browser.Plugins.Flash.version >= "8") {
			if (Browser.Plugins.Flash.version > 8) {
				var A = "150";
				var C = "110"
			} else {
				var A = 1;
				var C = 1
			}
			var B = {
				allowScriptAccess : "always",
				name : "multiupload",
				wmode : "transparent",
				scale : "noscale"
			};
			var E = "flash-go";
			var D = new Swiff("/swf/multiupload.swf?maxSize="
					+ localvars.maxFileSize + "&dom=" + localvars.domain_upload
					+ "&auth=" + getParam("auth") + "&rand=" + Math.random(), {
				id : "flash-content",
				container : E,
				width : A,
				allowScriptAccess : "always",
				height : C,
				params : B,
				vars : {
					maxSize : localvars.maxFileSize,
					dom : localvars.domain_upload,
					auth : getParam("auth")
				}
			})
		}
	},
	simpleUpload : function(A) {
		var G = new Utils();
		var I = $$(".empty-cell");
		G.checkCells();
		if ($("form_cell_id")) {
			var F = $("form_cell_id").get("value");
			if (F >= 0) {
				var A = F
			} else {
				var A = getStartCell()
			}
		} else {
			var A = getStartCell()
		}
		var H = $("cell_" + A);
		if ($(A + "_iframe")) {
			var D = $(A + "_iframe")
		} else {
			var D = new Element("iframe", {
				id : A + "_iframe",
				"class" : "iframe",
				name : A + "_iframe",
				styles : {
					width : "0",
					height : "0",
					border : "0"
				}
			});
			D.inject($("gallery"))
		}
		if ($("cellToID")) {
			$("cellToID").dispose()
		}
		var B = new Element("input", {
			id : "cellToID",
			type : "hidden",
			name : "cellId",
			value : A
		});
		var C = new Element("input", {
			id : "album_id",
			type : "hidden",
			name : "albumid",
			value : getParam("albumId")
		});
		var E = new Element("input", {
			id : "pid",
			type : "hidden",
			name : "pid",
			value : getParam("pid")
		});
		$("form-upload").adopt(B);
		$("form-upload").adopt(C);
		$("form-upload").adopt(E);
		$("form-upload").setProperty("target", A + "_iframe");
		$("form-upload").submit();
		H.set("html", '<div class="loading"/>');
		H.removeClass("empty-cell");
		H.addClass("cell");
		G.createSimpleUploadForm()
	},
	finishUpload : function(A, E, D, F, C) {
		var B = new Utils();
		if ($("file_" + A + "_messageBox")) {
			cell.set("html", '<div class="loading"/>');
			var G = new Asset.image(F, {
				id : "cell_" + E + "_image",
				title : "myImage",
				onload : function(H) {
					$("place_for_image_" + A).set(
							"html",
							'<a href="/view/image/id/' + E
									+ '"><img class="p_thumbnail" id="cell_'
									+ E + '_image" src="' + F + '" /></a>')
				}
			})
		}
		B.loadLinksContent(A, E);
		$("file_photo_actions_" + A).setStyle("display", "block");
		if (D.length > 0) {
			Cookie.write("auth", D, {
				duration : 360
			})
		}
	},
	saveInfo : function(E, H) {
		var F = E.id + "_" + H;
		var C = E.action;
		var B = $("tag_info_" + H);
		B.setProperty("disabled", "disabled");
		var G = $("descr_info_" + H);
		G.setProperty("disabled", "disabled");
		var A = $("submit_info_" + H);
		A.setProperty("value", localMessage.saving);
		A.setProperty("disabled", "disabled");
		var D = new Request.JSON( {
			url : C,
			onComplete : function(I) {
				B.setProperty("disabled", false);
				G.setProperty("disabled", false);
				A.setProperty("disabled", false);
				A.setProperty("value", localMessage.save);
				if (I.tags) {
					B.value = I.tags
				}
				if (I.descr) {
					G.value = I.descr
				}
			}
		}).post( {
			tags : B.value,
			descr : G.value,
			json : 1
		});
		return false
	}
});
if (window.google && google.gears) {
}
var myModalizer = new Modalizer();
var array_images = new Array;
var current_image_i = 0;
var al_current_image_i = 0;
var draw_enable = true;
var draw_download = false;
window
		.addEvent(
				"domready",
				function() {
					$$("body").addEvent("click", function(F) {
						if (!F.target.hasClass("dont-close")) {
							$$(".body.close").dispose()
						}
					});
					if (Browser.Engine.version == 4) {
						$$("div.bottom").setStyle("display", "none")
					}
					var E = new App();
					var B = Cookie.read("localset");
					if (B) {
						B = JSON.decode(B);
						if (B.first_tooltip === true) {
							setFirstLookTooltip()
						}
					} else {
						setFirstLookTooltip()
					}
					if (window.google && google.gears) {
					} else {
						E.startUpload()
					}
					var A = new Utils();
					var D = new Array();
					A.initSimpleUpload();
					A.checkFlash();
					A.hoverCell();
					A.setEvents();
					A.makeMenu();
					if ($("border-cleaner")) {
						$("border-cleaner").addEvent("click", function() {
							A.clearBoard();
							return false
						})
					}
					$$(".cell").each(function(F) {
						F.addEvent("mouseenter", function(G) {
							$(F).addClass("active")
						});
						F.addEvent("mouseleave", function(G) {
							$(F).removeClass("active")
						})
					});
					if ($$("a.page")) {
						$$("a.page").addEvent("click", function(F) {
							F.stop();
							getPage($(this));
							$(this).removeEvents("click")
						})
					}
					if ($("image_exif")) {
						$("image_exif").addEvent("click", function(F) {
							A.getJson();
							F.stop()
						})
					}
					if ($("lang_selector")) {
						$("lang_selector").addEvent(
								"change",
								function() {
									var F = this.selectedIndex;
									var G = $$(".lang");
									if (G[F - 1]) {
										new Cookie.write("lang", G[F - 1]
												.getProperty("value"), {
											domain : "." + localvars.domain,
											duration : 365
										});
										window.location.reload()
									}
								})
					}
					if ($$(".get-image")) {
						$$(".get-image").addEvent("click", function(F) {
						})
					}
					if ($("social")) {
						var C = new Request.JSON( {
							url : "/bookmarks.php",
							onComplete : function(F) {
								var G = new Social($("social"), {
									sites : F
								})
							}
						}).get()
					}
					if ($("clickUpload")) {
						$("clickUpload").addEvent("mouseover", function(F) {
							singleButtonUpload(F)
						})
					}
					if ($("page-index")) {
						$("page-index")
								.addEvent(
										"mouseout",
										function(F) {
											if (Browser.Engine.trident) {
												if (F.target.id == "page-index"
														| F.target.id == "gallery") {
													$$(".selected")
															.removeClass("selected")
												}
											} else {
												if (!$(F.target)
														.hasClass("empty-cell")) {
													$$(".selected")
															.removeClass("selected")
												}
											}
										})
					}
					$$(".expanded .txt").addEvent("focus", function(F) {
						F.stop();
						this.select();
						$(this).set("readonly", true)
					});
					$$(".expanded .txt").addEvent("mouseup", function(F) {
						F.stop()
					});
					$$("#fotocontext a.button-next").addEvent("click",
							function(F) {
								F.stop();
								checkNextAlbumImage()
							});
					$$("#fotocontext a.button-previous").addEvent("click",
							function(F) {
								F.stop();
								checkPrevAlbumImage()
							});
					$$("li.preview-cell a").addEvent(
							"click",
							function(H) {
								H.stop();
								var F = $(this).get("id").replace(
										/preview_link_/, "").toInt();
								var G = getImagesArray(F);
								if (G) {
									setAlbumImage(G, F)
								}
							});
					$$(".dialog-more-narrow").addEvent("mouseenter",
							updateFlashPosition);
					$$(".dialog-more").addEvent("mouseenter",
							updateFlashPosition);
					getAlbumImages();
					bindEmptyAlbum();
					updateFlashPosition();
					if ($$(".short").length > 0) {
						$$(".short").shorten(30)
					}
					document.addEvent("keydown", function(G) {
						switch (G.key) {
							case "esc" :
								if (draw_download) {
									return
								}
								if ($("modalOverlay")) {
									$("modalOverlay").dispose();
									$$(".modal").dispose()
								}
								closeShare();
								break;
							case "space" :
								if ($$("li.active input.cb").length > 0) {
									var F = $$("li.active input.cb");
									$(F[0]).set("checked",
											!$(F[0]).get("checked"));
									G.stop()
								}
								break;
							case "a" :
								if (G.control) {
									if ($$("li input.cb").length > 0) {
										var F = $$("li input.cb").set(
												"checked", true);
										G.stop()
									}
								}
								break;
							default :
								break
						}
					});
					if ($("more-album")) {
						$("more-album").addEvent("mouseenter", function(F) {
							F.stop();
							if (!$(this).hasClass("button-active1")) {
								$(this).addClass("button-active1");
								if ($("dialog-more2")) {
									$("dialog-more2").removeClass("hide")
								}
							}
						});
						$("more-album").addEvent("mouseleave", function(F) {
							F.stop();
							if ($(this).hasClass("button-active1")) {
								$(this).removeClass("button-active1");
								$("dialog-more2").addClass("hide")
							}
						});
						$("dialog-more2").addEvent("mouseenter", function(F) {
							F.stop();
							if (!$("more-album").hasClass("button-active1")) {
								$("more-album").addClass("button-active1");
								if ($("dialog-more2")) {
									$("dialog-more2").removeClass("hide")
								}
							}
						});
						$("dialog-more2").addEvent("mouseleave", function(F) {
							F.stop();
							if ($("more-album").hasClass("button-active1")) {
								$("more-album").removeClass("button-active1");
								$("dialog-more2").addClass("hide")
							}
						})
					}
					if ($("select_all")) {
						$("select_all").addEvent("click", function(F) {
							F.stop();
							$$("input.cb").set("checked", true)
						})
					}
					if ($("deselect_all")) {
						$("deselect_all").addEvent("click", function(F) {
							F.stop();
							$$("input.cb").set("checked", false)
						})
					}
					if ($("delete_select")) {
						$("delete_select")
								.addEvent(
										"click",
										function(H) {
											H.stop();
											if (checkSelect()) {
												if (confirm("This action will remove selected images from the board. Are you sure?")) {
													var G = "?";
													$$("input.cb:checked")
															.get("value")
															.each(function(J, I) {
																G += "&image_id[]="
																		+ J
															});
													var F = new Request.JSON( {
														url : "/index/deleteimages/"
																+ G,
														onComplete : function(I) {
															if (I) {
																if (!I.error) {
																	document.location = document.location
																}
															}
														}
													}).get()
												}
											} else {
												alert("Please select at least one image.")
											}
										})
					}
					if ($("move_select")) {
						$("move_select").addEvent("click", function(G) {
							G.stop();
							if (checkSelect()) {
								var F = new Box(new Utils().moveImages());
								var H = getParam("albumId");
								if ($("select_album_" + H)) {
									$("select_album_" + H).dispose()
								}
							} else {
								alert("Please select at least one image.")
							}
						})
					}
					if ($("get_bulk")) {
						$("get_bulk").addEvent("click", function(G) {
							G.stop();
							if (checkSelect()) {
								var F = new Box(new Utils().getBulk(true))
							} else {
								alert("Please select at least one image.")
							}
						})
					}
					$$(".albums-list .thumbnails").addEvent("mousewheel",
							function(F) {
								F.stop();
								if (F.wheel > 0 && myElementSlide) {
									myElementSlide.prev()
								}
								if (F.wheel < 0 && myElementSlide) {
									myElementSlide.next()
								}
							});
					$$(".product_option").addEvent(
							"click",
							function(I) {
								I.stop();
								$$(".selected_product")
										.addClass("unselected_product")
										.removeClass("selected_product");
								$(this).addClass("selected_product")
										.removeClass("unselected_product");
								var F = $(this).get("rel");
								var G = $("paypal_link").get("rel");
								var H = $("segpay_link").get("rel");
								if (F == 6199) {
									$("paypal_link").set("href",
											G + "&pid=" + 6300)
								} else {
									$("paypal_link").set("href",
											G + "&pid=" + F)
								}
								$("segpay_link").set("href", H + "&pid=" + F)
							});
					bindImagesStats();
					bindAlbumStats();
					if (getstarted) {
						getstartedUpload()
					}
				});
function bindAlbumStats() {
	$$("a.album.views span").addEvent("mouseenter", function(E) {
		var D = $(this).getParent("li.album-cell");
		var C = $(D).getSize();
		var A = $(D).getChildren("a").get("id")[0].replace(/album-/, "");
		var F = $(this).getPosition();
		var B = $("wrap").getCoordinates();
		$("stats-album-" + A).setStyles( {
			left : (F.x - B.left) - 80,
			top : F.y + 30
		});
		$("stats-album-" + A).removeClass("hide")
	});
	$$("a.album.views span").addEvent("mouseleave", function(C) {
		var B = $(this).getParent("li.album-cell");
		var A = $(B).getChildren("a").get("id")[0].replace(/album-/, "");
		$("stats-album-" + A).addClass("hide")
	})
}
function bindImagesStats() {
	var A = $$("a.image.views span");
	A.removeEvent("mouseenter");
	A.addEvent("mouseenter", function(E) {
		var D = $(this).getParent("li.cell");
		var C = $(D).getSize();
		var G = $(D).getChildren("a.img").get("id")[0].replace(/image_/, "");
		var F = $(this).getPosition();
		var B = $("wrap").getCoordinates();
		$("stats-image-" + G).setStyles( {
			left : (F.x - B.left) - 77,
			top : F.y + 30
		});
		$("stats-image-" + G).removeClass("hide")
	});
	A.removeEvent("mouseleave");
	A.addEvent("mouseleave", function(C) {
		var B = $(this).getParent("li.cell");
		var D = $(B).getChildren("a.img").get("id")[0].replace(/image_/, "");
		$("stats-image-" + D).addClass("hide")
	})
}
function checkSelect() {
	if ($$("input.cb:checked").length > 0) {
		return true
	} else {
		return false
	}
}
function bindAlbumCells() {
	$$(".album-cell p.album-get-links").removeEvents("click");
	$$(".album-cell p.album-get-links").addEvent("click", function(C) {
		C.stop(C);
		$$(".album-cell p.album-get-links").each(function(F) {
			F.addClass("hide").removeClass("show");
			var E = $(F).getChildren();
			if (E) {
				E.set("html", localMessage.getLinks)
			}
		});
		$$(".album-cell").removeClass("active").removeClass("dialog");
		var A = $(this).getParent();
		$(A).addClass("active").addClass("dialog");
		$(this).removeClass("hide");
		var B = $(this).getChildren();
		if (B) {
			B.set("html", localMessage.close)
		}
		var D = $(this).getCoordinates();
		if (Browser.Engine.trident) {
			$("album-dialog-links").setStyles( {
				top : D.top + 25,
				left : D.left
			})
		} else {
			$("album-dialog-links").setStyles( {
				top : D.top + 25,
				left : D.left
			})
		}
		$("album-share-url").set("value", $(A).get("rel"));
		$("album-dialog-links").removeClass("hide");
		$(this).removeEvents("click");
		$(this).addEvent("click", function(E) {
			E.stop();
			closeAlbumShare();
			bindAlbumCells()
		})
	})
}
function closeAlbumShare() {
	$$(".album-get-links").each(function(B) {
		var A = B.getChildren("a");
		A.set("html", localMessage.getLinks)
	});
	$("album-dialog-links").addClass("hide");
	$$(".album-get-links").addClass("hide");
	$$(".album-get-links").removeClass("show");
	$$(".album-cell").removeClass("active").removeClass("dialog")
}
function closeShare() {
	$$(".cell a.close").set("html", localMessage.getLinks).removeClass("close")
			.removeClass("loading");
	$$(".links").dispose();
	$$(".cell").removeClass("dialog").removeClass("active");
	$$(".dialog-links").set("html", "").setStyle("display", "none");
	$$(".cell").removeEvents("mouseenter").removeEvents("mouseleave");
	$$(".cell").addEvent("mouseenter", function(A) {
		$(this).addClass("active")
	});
	$$(".cell").addEvent("mouseleave", function(A) {
		$(this).removeClass("active")
	})
}
function setFirstLookTooltip() {
	var D = $$(".empty-cell");
	if (D[0]) {
		var B = D[0].getPosition();
		var A = B.x - 30;
		var F = B.y + 80
	} else {
		return
	}
	var C = localMessage.first_tooltip;
	if (Browser.Plugins.Flash.version > 8) {
		var E = new Tooltip(C + localMessage.first_tooltip_notice, {
			left : A,
			top : F,
			closeEvent : function() {
				new Cookie.write("localset", JSON.encode( {
					first_tooltip : "false"
				}), {
					domain : "." + localvars.domain,
					duration : 365
				})
			}
		})
	} else {
		var E = new Tooltip(C, {
			left : A,
			top : F + 35,
			closeEvent : function() {
				new Cookie.write("localset", JSON.encode( {
					first_tooltip : "false"
				}), {
					domain : "." + localvars.domain,
					duration : 365
				})
			}
		})
	}
}
function switchPanel(A) {
	var B = $(A).get("id");
	if (B == "simple-link") {
		$("simple-panel").removeClass("hide");
		$("advanced-panel").addClass("hide")
	} else {
		$("advanced-panel").removeClass("hide");
		$("simple-panel").addClass("hide")
	}
	return false
}
function getAlbumImages() {
}
function bindEmptyAlbum() {
	if ($$(".albums-list .thumbnails ul li.empty a")) {
		$$(".albums-list .thumbnails ul li.empty a").addEvent("click",
				function(A) {
					A.stop();
					new Album().add()
				})
	}
}
function startUpload(B) {
	var A = new App(B);
	A.startUpload()
}
function getstartedUpload() {
	if (Browser.Plugins.Flash.version > 8) {
		if ($("flash-go")) {
			if ($("getstarted-upload")) {
				var A = $("getstarted-upload").getPosition();
				$("flash-go").setStyle("top", A.y);
				$("flash-go").setStyle("left", A.x);
				$("flash-go").setStyle("width", $("clickUpload").getWidth());
				$("flash-go").setStyle("height", $("clickUpload").getHeight());
				if ($("flash-content")) {
					if (Browser.Engine.trident) {
						$("flash-content").width = $("getstarted-upload")
								.getWidth();
						$("flash-content").height = $("getstarted-upload")
								.getHeight()
					} else {
						$("flash-content").set("width",
								$("getstarted-upload").getWidth());
						$("flash-content").set("height",
								$("getstarted-upload").getHeight())
					}
				}
			}
		}
	}
}
function updateFlashPosition() {
	$$(".selected").removeClass("selected");
	if (Browser.Plugins.Flash.version > 8) {
		if ($("flash-go")) {
			if ($("clickUpload")) {
				var A = $("clickUpload").getPosition();
				$("flash-go").setStyle("top", A.y);
				$("flash-go").setStyle("left", A.x);
				$("flash-go").setStyle("width", $("clickUpload").getWidth());
				$("flash-go").setStyle("height", $("clickUpload").getHeight());
				if ($("flash-content")) {
					if (Browser.Engine.trident) {
						$("flash-content").width = $("clickUpload").getWidth();
						$("flash-content").height = $("clickUpload")
								.getHeight()
					} else {
						$("flash-content").set("width",
								$("clickUpload").getWidth());
						$("flash-content").set("height",
								$("clickUpload").getHeight())
					}
				}
			}
		}
	} else {
		if ($("Datafile")) {
			$("Datafile").setStyles( {
				top : -1,
				left : -1
			})
		}
	}
}
function singleButtonUpload(A) {
	if ($("clickUpload")) {
		if (Browser.Plugins.Flash.version > 8) {
			updateFlashPosition()
		} else {
			$$(".selected").removeClass("selected");
			$("form_cell_id").set("value", 0);
			var B = A.page;
			if (Browser.Engine.gecko) {
				$("Datafile").setStyles( {
					top : $(this).getTop() + 80,
					left : B.x - 200
				})
			}
			if (Browser.Engine.webkit) {
				$("Datafile").setStyles( {
					top : $(this).getTop() + 80,
					left : B.x - 40
				})
			}
			if (Browser.Engine.presto) {
				$("Datafile").setStyles( {
					top : $(this).getTop() + 80,
					left : B.x - 150
				})
			}
			if (Browser.Engine.trident) {
				$("Datafile").setStyles( {
					top : $(this).getTop() + 85,
					left : B.x - 205
				})
			}
		}
	}
}
function resetFlashPosition() {
	if ($("flash-go")) {
		$("flash-go").setStyle("top", -110);
		$("flash-go").setStyle("left", -150)
	}
}
function setImageLinks(O) {
	if ($("friend_link")) {
		var E = $("friend_link");
		var P = E.get("value").split("/");
		var C = image_id;
		var J = "http://{domain}/view/{img_id}";
		if (O != "") {
			J += "/{w}"
		}
		J += "/{image_name}";
		J = J.replace(/\{domain\}/, localvars.domain);
		J = J.replace(/\{img_id\}/, C);
		J = J.replace(/\{w\}/, O);
		J = J.replace(/\{image_name\}/, image_name);
		E.set("value", J)
	}
	if ($("direct_link")) {
		var M = $("direct_link");
		var L = M.get("value").split("/");
		var H = L[(L.length - 1)]
	}
	if ($("board_link")) {
		var N = $("board_link");
		var B = N.get("value").split("/");
		var K = B[2];
		var A = "[img]http://{img_domain}/{path}";
		var D = B[3] + "/" + B[4] + "/" + B[5] + "/" + B[6] + "/" + B[7];
		if (O != "") {
			A += "/{w}"
		}
		A += "/{img}[/img]";
		A = A.replace(/\{img_domain\}/, K);
		A = A.replace(/\{path\}/, D);
		A = A.replace(/\{img\}/, H);
		A = A.replace(/\{w\}/, O);
		$("board_link").set("value", A)
	}
	if ($("blog_link")) {
		var F = $("blog_link");
		var G = "<a href='http://{domain}/'><img src='http://{img_domain}/{path}";
		if (O != "") {
			G += "/{w}"
		}
		G += "/{img}' /></a>";
		G = G.replace(/\{domain\}/, localvars.domain);
		G = G.replace(/\{img_domain\}/, K);
		G = G.replace(/\{path\}/, D);
		G = G.replace(/\{img\}/, H);
		G = G.replace(/\{w\}/, O);
		$("blog_link").set("value", G)
	}
	if ($("direct_link")) {
		var I = "http://{img_domain}/{path}";
		if (O != "") {
			I += "/{w}"
		}
		I += "/{img}";
		I = I.replace(/\{img_domain\}/, K);
		I = I.replace(/\{path\}/, D);
		I = I.replace(/\{img\}/, H);
		I = I.replace(/\{w\}/, O);
		$("direct_link").set("value", I)
	}
}
function getImage(E) {
	var A = $(E).getProperty("href").split("/");
	if (image_id) {
		var B = image_id
	} else {
		return false
	}
	if (!image_width) {
		return false
	}
	if (!image_height) {
		return false
	}
	if (!image_name) {
		return false
	}
	var J = E.getParent().get("id").replace(/image-size-/, "");
	h = Math.ceil((image_height * J) / image_width);
	this_h = Math.ceil((image_height * this_w) / image_width);
	var K = new Waiter("image_" + B, {
		layer : {
			id : "waitingDiv",
			background : "#fff",
			opacity : 0.9
		}
	}).start();
	setImageLinks(J);
	var D = $("image_" + B).getProperty("src").split("/");
	if ($("image-size-" + J)) {
		$("image-size-" + J).set("html", "[" + J + " x " + h + "]")
	}
	if ($("image-size-" + this_w)) {
		var C = "/view/image/id/" + B + "/" + this_w + "/" + image_name;
		var I = "[" + this_w + " x " + this_h + "]";
		var H = new Element("a", {
			"class" : "get-image",
			href : C,
			html : I,
			events : {
				click : function(L) {
					L.stop();
					getImage(this)
				}
			}
		});
		$("image-size-" + this_w).empty();
		$("image-size-" + this_w).adopt(H);
		this_w = J
	}
	D[8] = J;
	var F = D.join("/");
	if (F.indexOf(image_name) < 0) {
		F = F + "/" + image_name
	}
	var G = new Asset.image(F, {
		onload : function() {
			$("image_" + B).setProperty("src", F);
			K.stop()
		}
	})
}
function setProportionalImage(C) {
	var B = window.getSize();
	var D = C.getSize();
	var A = Math.round(B.x / D.x);
	if (A > 1) {
		C.setStyles( {
			width : D.x / (A),
			height : D.y / (A)
		})
	}
	if (A == 1) {
		C.setStyles( {
			width : D.x / (A + 1),
			height : D.y / (A + 1)
		})
	}
}
function genEmptyImageStats(E) {
	var C = "<dt>Total</dt><dd>0</dd><dt>Today</dt><dd>0</dd><dt>Yesterday</dt><dd>0</dd>";
	var B = new Element("div", {
		id : "stats-image-" + E,
		"class" : "tipbox-views hide"
	});
	var A = new Element("dl", {
		"class" : "views"
	});
	A.set("html", C);
	A.inject(B);
	var D = new Element("div", {
		"class" : "pointer"
	});
	D.inject(B);
	B.inject($("content"), "bottom")
}
function getAuth() {
	if (Cookie.read("auth_internal")) {
		return Cookie.read("auth_internal")
	} else {
		if (Cookie.read("auth")) {
			return Cookie.read("auth")
		} else {
			return false
		}
	}
}
function uploadFromUrlStart() {
	$$(".modal div.error").setStyle("display", "none");
	$$(".modal div.error .text").set("text", "");
	var E = $$(".empty-cell");
	var H = new Utils();
	var F = false;
	var C = "";
	if (count(E) > 0) {
		var G = new Array;
		$$(".uploadUrl").each(function(K, J) {
			if (K.getProperty("value") != "") {
				G[J] = K.getProperty("value")
			}
		});
		G = array_unique(G);
		G = G.filter(function(K, J) {
			if (K != "") {
				if (H.check_url(K)) {
					return H.check_url(K)
				} else {
					F = true;
					C += "<p> URL " + J + ": Wrong adress</p>"
				}
			}
		});
		var B = true;
		if (B) {
			var A = G.length;
			H.checkCells(A);
			var D = 0;
			var I = $$(".empty-cell");
			G.each(function(L) {
				if (I[D]) {
					var J = I[D];
					var M = J.getProperty("id").replace(/cell_/, "");
					J.set("html", '<div class="loading"/>');
					J.removeClass("empty-cell");
					J.addClass("cell");
					var K = new Request.JSON( {
						url : "/upload/url/cellid/" + M + "/albumid/"
								+ getParam("albumId"),
						onComplete : function(N) {
							if (N.error) {
								N.error = unhtmlentities(N.error);
								if (N.code) {
									if (N.code == 502) {
										paymentError(N.cellId, N.error)
									} else {
										if (N.code == 413) {
											fileSizeError(N.cellId)
										} else {
											reportError(N.cellId, N.error)
										}
									}
								} else {
									reportError(N.cellId, N.error)
								}
							} else {
								finishUpload(N.cellId, N.imgId, N.album_id,
										N.name, N.sid, N.img)
							}
						}
					}).post( {
						url : escape(L)
					});
					D++
				}
			})
		}
	}
	if (!F) {
		if ($$(".modal")) {
			$$(".modal").dispose()
		}
		myModalizer.modalHide()
	} else {
		G.getParent().dispose();
		$$(".modal div.error").setStyle("display", "block");
		$$(".modal div.error .text").set("html", C)
	}
}
function saveTellFriend() {
	var D = "";
	var C = new Date();
	var F = C.getDay() + C.getMonth() + C.getYear();
	var A = new Utils();
	$$(".modal div.error").setStyle("display", "none");
	$$(".modal div.error .text").empty();
	if (!A.count($("your-name").getProperty("value"))) {
		D = D + "<p>" + localMessage.emptyName + "</p>"
	}
	if (!A.checkEmail($("your-email").getProperty("value"))) {
		D = D + "<p>" + localMessage.wrongEmail + "</p>"
	}
	if (!A.count($("friend-email").getProperty("value"))) {
		D = D + "<p>" + localMessage.emptyFriendEmail + "</p>"
	} else {
		var B = $("friend-email").getProperty("value").split(",");
		var B = B.filter(function(H, G) {
			H = A.trim(H);
			if (A.checkEmail(H)) {
				return A.checkEmail(H)
			} else {
				D = D + "<p>" + localMessage.wrongEmail + ":" + H + "</p>"
			}
		})
	}
	if (A.count(D)) {
		$$(".modal div.error").setStyle("display", "block");
		$$(".modal div.error .text").set("html", D);
		return
	}
	var E = new Request.JSON( {
		url : "/index/tell/capcha/" + F,
		onComplete : function(G) {
			if (G.error) {
				$$(".modal div.error").setStyle("display", "block");
				$$(".modal div.error .text").set("html", G.error)
			} else {
				if ($$(".modal")) {
					$$(".modal").dispose()
				}
				myModalizer.modalHide()
			}
		}
	}).post($("tell-a-friend"))
}
function saveToEmailStart() {
	var A = new Utils();
	if (A.checkEmail($("emailPlace").getProperty("value"))) {
		$$(".modal div.error").setStyle("display", "none");
		if ($("parentUrl").hasClass("error")) {
			$("parentUrl").removeClass("error")
		}
		if ($("save_button")) {
			$("save_button").removeEvents("click");
			$("save_button").setProperty("value", localMessage.sending);
			$("save_button").setProperty("disabled", true);
			$("save_button").setStyle("cursor", "default")
		}
		var B = new Request.JSON( {
			url : "/index/email",
			onComplete : function(C) {
				if (C) {
					if (C.error) {
						$$(".modal div.error").setStyle("display", "block");
						$$(".modal div.error .text").set("html", C.error)
					} else {
						if ($$(".modal")) {
							$$(".modal").dispose()
						}
						myModalizer.modalHide()
					}
				} else {
					if ($$(".modal")) {
						$$(".modal").dispose()
					}
					myModalizer.modalHide()
				}
			}
		}).post( {
			email : escape($("emailPlace").getProperty("value"))
		})
	} else {
		if ($empty($("emailPlace").getProperty("value"))) {
			if ($$(".modal")) {
				$$(".modal").dispose()
			}
			myModalizer.modalHide()
		} else {
			$$(".modal div.error").setStyle("display", "block");
			$$(".modal div.error .text").set("html", localMessage.wrongEmail)
		}
	}
}
function saveAlbum() {
	var A = new Utils();
	if (1) {
		if ($("errorEmailMessage")) {
			$("errorEmailMessage").dispose()
		}
		if ($("parentUrl").hasClass("error")) {
			$("parentUrl").removeClass("error")
		}
		if ($("save_button")) {
			$("save_button").removeEvents("click");
			$("save_button").setProperty("value", localMessage.sending)
		}
		var B = new Request.JSON( {
			url : "/album/add",
			onComplete : function(C) {
				if (C.result == "ok") {
					$("gallery").load("/album/get")
				}
				new Box().closeBox()
			}
		}).get( {
			name : escape($("albumName").getProperty("value")),
			descr : escape($("albumDescr").getProperty("value"))
		})
	}
}
function uploadFromUrl() {
	var A = new Utils();
	var B = new Box(A.creatUploadForm())
}
function sendToEmail() {
	var A = new Utils();
	var B = new Box(A.creatEmailForm())
}
function tellAFriend() {
	var A = new Utils();
	var B = new Box(A.creatFriendForm())
}
function addAlbum() {
	var A = new Utils();
	var B = new Box(A.creatAlbumForm())
}
function onComplete(B) {
	var A = new Utils();
	var C = JSON.decode(A.urldecode(B));
	dbug.log("on complete:");
	dbug.log(B);
	if (C.error) {
		C.error = unhtmlentities(C.error);
		if (C.code == 502) {
			paymentError(C.cellId, C.error)
		} else {
			if (C.code == 413) {
				filesizeError(C.cellId)
			} else {
				reportError(C.cellId, C.error)
			}
		}
	} else {
		finishUpload(C.cellId, C.imgId, C.album_id, C.name, C.sid, C.img)
	}
}
function paymentError(C, B) {
	B = unhtmlentities(B);
	if ($("payment_modal")) {
		$$("#payment_modal .error .text").set("html", B);
		new Utils().emptyCell(C);
		new Utils().hoverCell();
		return
	}
	var A = new Utils();
	var E = new Box(A.createErrorForm(B));
	var D = "errorForm_" + C;
	if ($(D)) {
		$(D).dispose()
	}
	new Utils().emptyCell(C);
	new Utils().hoverCell()
}
function filesizeError(B) {
	dbug.log(B);
	if (user.pro) {
		var E = "Error. <a href='/limits' target='_blank'>Maximum image size</a> exeeded.";
		reportError(B, E);
		return
	} else {
		if (user.registered) {
			var E = "<span style=\"font-size:13px; color:#000;\">You have tried to upload image(s) <a href='/limits' target='_blank'>more than "
					+ Math.round(localvars.maxFileSize / 1024 / 1024 * 10)
					/ 10
					+ " Mb in size</a>.<br/><br />Please <a href='/profile/upgrade'>upgrade your account to Premium</a> to upload this image(s).With your Premium account you will be able to upload images up to 12Mb in size.<br/><br /><a href='/profile/upgrade' style='font-size:15px; font-weight:bold;'>Upgrade your account to Premium now!</a></span>"
		} else {
			var E = "<span style=\"font-size:13px; color:#000;\">You have tried to upload image(s) <a href='/limits' target='_blank'>more than "
					+ Math.round(localvars.maxFileSize / 1024 / 1024 * 10)
					/ 10
					+ " Mb in size</a>.<br/><br />Please <a href='/registration'>sign up for a Free personal account</a> and then upgrade to Premium account.&nbsp;With your Premium account you will be able to create albums and upload unlimited number of images up to 12Mb in size. <a href='/limits' target='_blank'>View limits table</a> for more details.<br/><br /><a href='/registration' style='font-size:15px; font-weight:bold;'>Sign up now!</a></span>"
		}
	}
	if ($("payment_modal")) {
		$$("#payment_modal .error .text").set("html", E);
		new Utils().emptyCell(B);
		new Utils().hoverCell();
		return
	}
	var A = new Utils();
	var D = new Box(A.createErrorForm(E));
	var C = "errorForm_" + B;
	if ($(C)) {
		$(C).dispose()
	}
	new Utils().emptyCell(B);
	new Utils().hoverCell()
}
function intilizeUploads(C, D) {
	if (getstarted && $("getstarted")) {
		$("getstarted-waiter").removeClass("hide")
	}
	var E = 0;
	var B = new Utils();
	B.checkCells(D);
	if ($("cell_" + C)) {
		$("cell_" + C).set("html", '<div class="loading"/>');
		$("cell_" + C).removeClass("empty-cell");
		$("cell_" + C).removeEvents("mouseenter");
		updateFlashPosition();
		D = D - 1
	}
	var G = $$(".empty-cell");
	for (E = 0;E < D; E++) {
		if (G[E]) {
			G[E].set("html", localMessage.pending);
			G[E].removeEvents("mouseenter");
			G[E].removeClass("empty-cell")
		}
	}
	var F = new Array;
	var E = 1;
	F[0] = C;
	G.each(function(H) {
		var I = H.getProperty("id");
		I = I.replace(/cell_/, "");
		F[E] = I;
		E++
	});
	var E = 0;
	var A = new Array;
	for (E = 0;E <= D; E++) {
		A[E] = F[E]
	}
	return A
}
function finishUpload(G, A, F, J, C, H, I) {
	if (getstarted && $("getstarted")) {
		$("getstarted").fade(0);
		var E = Cookie.read("localset");
		if (E) {
			E = JSON.decode(E);
			E.getstarted = 0;
			new Cookie.write("localset", JSON.encode(E), {
				domain : "." + localvars.domain,
				duration : 365
			})
		}
	}
	var B = (F > 0 ? F + "/" : "");
	var K = new Utils();
	if ($("cell_" + G)) {
		$("cell_" + G).set("html", "Please wait...");
		var D = new Asset.image(
				H,
				{
					title : "myImage",
					onload : function(N) {
						var L = "/view/" + B + A + "/0/" + J;
						$("cell_" + G)
								.set(
										"html",
										'<a class="img" id="image_'
												+ A
												+ '" href="'
												+ L
												+ '"><img  class="thumbnail" id="cell_'
												+ A
												+ '_image" src="'
												+ H
												+ '" /></a>			   <p class="get-links"><a class="image_'
												+ A
												+ " cell_"
												+ G
												+ '" href="#">'
												+ localMessage.getLinks
												+ '</a></p>			   <a class="del image_'
												+ A
												+ " cell_"
												+ G
												+ '"><img  class="del" alt="Delete" src="http://'
												+ localvars.domain
												+ '/images/img/del.png"/></a>    		    <div id="dialog_'
												+ G
												+ '" class="dialog-links"></div>				<input checked="checked" class="cb" type="checkbox" value="'
												+ A
												+ '" name="image_id[]"/>				<a class="image views"><span>0 views</span></a>				');
						new Utils().setEvents();
						$("cell_" + G).removeEvents("click");
						$("cell_" + G).removeEvents("mouseenter");
						$("cell_" + G).removeEvents("mousemove");
						$("cell_" + A + "_image").addEvent("click",
								function(O) {
									if (O.target.className == "thumbnail") {
										O.stop();
										window.open($("image_" + A).href)
									}
								});
						$("cell_" + G).addEvent("mouseenter", function(O) {
							$("cell_" + G).addClass("active")
						});
						$("cell_" + G).addEvent("mouseleave", function(O) {
							$("cell_" + G).removeClass("active")
						});
						$("cell_" + G).addClass("cell");
						K.toggleExpoLink();
						var M = $("cell_" + G).getChildren();
						K.setContextMenu(M[0]);
						genEmptyImageStats(A);
						bindImagesStats()
					}
				})
	}
	if ($(G + "_iframe")) {
		$(G + "_iframe").dispose()
	}
	if (C.length > 0) {
		Cookie.write("auth", C, {
			domain : "." + localvars.domain,
			duration : 365
		})
	}
	updateFlashPosition()
}
function createBar(B) {
	var A = new dwProgressBar( {
		container : $("progressbar_" + B),
		startPercentage : 0,
		speed : 1000,
		boxID : "box_" + B,
		percentageID : "perc_" + B
	});
	return A
}
function showProgress(B, A) {
	if ($("cell_" + B) && $("cell_" + B).hasClass("empty")) {
		$("cell_" + B).set("html", A + "%");
		dbug.log(A + "%")
	}
}
function reportError(B, C) {
	var A = $("cell_" + B);
	if (A) {
		A.removeEvents("mouseenter");
		A.removeEvents("mouseleave");
		A.removeEvents("mousemove");
		if ($("flash-go")) {
			$("flash-go").setStyle("top", 0);
			$("flash-go").setStyle("left", 0)
		}
		A.addClass("error");
		A.removeClass("cell");
		A.set("html", '<a class="error" href="#"><strong>'
				+ localMessage.uploadError + "</strong></a>");
		A.removeEvents("click");
		A.addEvent("click", function(D) {
			D.stop();
			$(D.target).addClass("active");
			showError(B, C)
		})
	}
}
function showError(A, B) {
	$("cell_" + A).addClass("dialog");
	var C = new Utils().creatErrorForm(A, B);
	$("cell_" + A).adopt(C)
}
function closeError(A) {
	var B = "errorForm_" + A;
	if ($(B)) {
		$(B).dispose()
	}
	new Utils().emptyCell(A);
	new Utils().hoverCell()
}
function count(A) {
	return A.length
}
function closeBox() {
	if ($("blankBox")) {
		$("blankBox").dispose()
	}
	if ($("box")) {
		$("box").dispose()
	}
}
function closeModal() {
	if ($("modalOverlay")) {
		$("modalOverlay").dispose()
	}
	$$(".modal").dispose()
}
function findPos(A) {
	var B = curtop = 0;
	if (A.offsetParent) {
		do {
			B += A.offsetLeft;
			curtop += A.offsetTop
		} while (A = A.offsetParent)
	}
	return [B, curtop]
}
function getStyle(B, A) {
	if (B.currentStyle) {
		var C = B.currentStyle[A]
	} else {
		if (window.getComputedStyle) {
			var C = document.defaultView.getComputedStyle(B, null)
					.getPropertyValue(A)
		}
	}
	return C
}
function copyToClipboard(B) {
	B.focus();
	B.select();
	if (Browser.Plugins.Flash.version >= 9) {
		if (window.clipboardData) {
			var A = clipboardData.setData("Text", B.value);
			return 1
		} else {
			if ($chk(Clipboard)) {
				Clipboard.swfLocation = "http://swf." + localvars.domain
						+ "/_clipboard.swf";
				Clipboard.copy(B.value);
				return 1
			}
		}
	} else {
		if (window.clipboardData) {
			var A = clipboardData.setData("Text", B.value);
			return 1
		} else {
			return 0
		}
	}
}
function grabTab(C, B) {
	if (C) {
		var A = C + "_anchor";
		if ($(A)) {
			$(A).addEvent("click", function(D) {
				D.stop();
				new Utils().getTab(C, B)
			})
		}
	}
}
function getPage(C) {
	if ($("context-menu")) {
		$("context-menu").dispose()
	}
	if ($(C).getProperty("href")) {
		var B = new Waiter("gallery", {
			layer : {
				id : "waitingDiv",
				background : "#fff",
				opacity : 0.9
			}
		});
		B.start();
		var A = new Request( {
			method : "get",
			url : C.getProperty("href"),
			evalScripts : true,
			onSuccess : function(E) {
				$$(".updated.page").set("html", E);
				$$("a.page").addEvent("click", function(F) {
					F.stop();
					getPage($(this))
				});
				var D = new Utils();
				D.setEvents();
				D.hoverCell();
				D.checkFlash();
				updateFlashPosition();
				D.makeMenu();
				bindImagesStats();
				bindAlbumStats();
				B.stop();
				if ($("enable_click")) {
					$$(".album-expo-cell .img").addEvent("click", function(F) {
						F.stop();
						document.location = $(this).get("href")
					})
				}
			}
		}).send()
	}
}
function thisMovie(B) {
	var A = false;
	if (navigator.appName.indexOf("Microsoft") != -1) {
		A = window[B]
	} else {
		A = document[B];
		dbug.log(document)
	}
	return A
}
function getAlbumId() {
	if ($("album-id")) {
		if ($("album-id").getProperty("name").length > 0) {
			var A = $("album-id").getProperty("name").replace(/album-/, "");
			if (A > 0) {
				return A
			} else {
				return 0
			}
		} else {
			return 0
		}
	} else {
		return 0
	}
}
function getPid() {
	if (Cookie.read("pid") > 0) {
		return Cookie.read("pid")
	} else {
		return 0
	}
}
function setAlbumId(A) {
	if (!A) {
		var A = 0
	}
	document.location.href = document.location.href.split("#")[0] + "#album-"
			+ Base64.encode(A);
	if ($("album-id")) {
		$("album-id").setProperty("name", "album-" + Base64.encode(A));
		return true
	} else {
		return false
	}
}
function getStartCell() {
	if ($$(".selected") && $$(".selected").length > 0) {
		var A = $$(".selected")[0];
		var B = A.getProperty("id").replace(/cell_/, "");
		if (B >= 0) {
			return B
		} else {
			return 0
		}
	} else {
		if ($$(".empty-cell")) {
			var B = $$(".empty-cell")[0].getProperty("id").replace(/cell_/, "");
			if (B >= 0) {
				return B
			} else {
				return 0
			}
		}
	}
}
function getParam(A) {
	switch (A) {
		case "auth" :
			return getAuth();
			break;
		case "albumId" :
			return getAlbumId();
			break;
		case "startId" :
			return getStartCell();
			break;
		case "pId" :
			return getPid();
			break;
		default :
			return 0
	}
}
function getUserInfo(A) {
	switch (A) {
		case "pro" :
			return user.pro;
			break;
		default :
			return user
	}
}
function posAdv() {
	var A = $$(".advbox")[0];
	if (A) {
		var C = A.getCoordinates();
		if ($("image_" + image_id).getWidth() > A.getWidth()) {
			var B = ($("image_" + image_id).getWidth() - A.getWidth()) / 2;
			A.setStyle("top", (A.getHeight() / 2) * -1)
		} else {
			var B = ($("image_" + image_id).getWidth() / 2) + 45;
			A.setStyle("top", (A.getHeight() / 2) * -1)
		}
		A.setStyle("left", B);
		A.setStyle("visibility", "visible")
	}
}
function goSecretAlbum() {
	if ($("secret")) {
		document.location.href = document.location.href + "/secret/"
				+ $("secret").get("value")
	}
	return false
}
function setCurrentImage() {
	if ($("image_18")) {
	}
}
function getNextImage() {
	if (array_images) {
		if (array_images[current_image_i + 1]) {
			this_w = 800;
			return array_images[current_image_i + 1]
		}
	}
	return false
}
function getPrevImage() {
	if (array_images) {
		if (array_images[current_image_i - 1]) {
			this_w = 800;
			return array_images[current_image_i - 1]
		}
	}
	return false
}
function getImagesArray(A) {
	if (!array_images) {
		return false
	}
	if (array_images) {
		if (array_images[A]) {
			return array_images[A]
		}
	}
	return false
}
function getEmptyCellId() {
	var A = $$(".empty-cell");
	return A[0].get("id").replace(/cell_/, "")
}
function setAlbumImage(F, G) {
	if (getImagesArray(G - 1)) {
		$$("#fotocontext a.button-previous").removeClass("invisible")
	} else {
		$$("#fotocontext a.button-previous").addClass("invisible")
	}
	if (getImagesArray(G + 1)) {
		$$("#fotocontext a.button-next").removeClass("invisible")
	} else {
		$$("#fotocontext a.button-next").addClass("invisible")
	}
	var C = $$(".big")[0];
	if (!F.image_id) {
		return false
	}
	var B = new Waiter(C, {
		layer : {
			id : "waitingDiv",
			background : "#fff",
			opacity : 0.5
		}
	}).start();
	if (this_w) {
		var D = "/" + this_w
	} else {
		if (F.width > 800) {
			var D = "/800"
		} else {
			var D = ""
		}
	}
	if (F.proportions.indexOf("800") < 0) {
		var A = "http://" + F.domain + F.path + F.randomName + "/" + F.filename
				+ "." + F.ext
	} else {
		var A = "http://" + F.domain + F.path + F.randomName + "/800/"
				+ F.filename + "." + F.ext
	}
	active_image = F;
	var E = new Asset.image(A, {
		onload : function() {
			$(C).setProperty("src", A);
			$(C).setProperty("alt", F.name);
			$(C).setProperty("id", "image_" + F.image_id);
			current_image_i = G;
			if (myElementSlide) {
				$$("li.preview-cell").removeClass("current");
				$("preview_" + current_image_i).addClass("current");
				myElementSlide.setImage(current_image_i);
				setImagePreference(this_w);
				this_w = 800
			}
			B.stop()
		}
	})
}
function setImagePreference(B) {
	var F = active_image;
	if (F.animated == 1) {
		$$(".sizes").addClass("hide")
	} else {
		$$(".sizes").removeClass("hide")
	}
	$("original-link").set(
			"href",
			"http://" + F.domain + F.path + F.randomName + "/" + F.filename
					+ "." + F.ext);
	$$("#sizes li.size").dispose();
	F.proportions.sort(sortNumber);
	F.proportions.each(function(J) {
		if (J > 300) {
			var K = "[" + J + " x " + getHeight(J, F.width, F.height) + "]";
			var H = new Element("li", {
				"class" : "size"
			});
			if (J == B) {
				H.set("html", K)
			} else {
				var I = new Element("a", {
					html : K,
					href : "http://" + localvars.domain + "/aview/" + album_id
							+ "/" + F.image_id + "/" + J + "/" + F.filename
				});
				if (J > 800) {
					I.set("target", "_blank");
					I.set("href", "http://" + F.domain + F.path + F.randomName
							+ "/" + J + "/" + F.filename + "." + F.ext)
				} else {
					$(I).addEvent("click", function(L) {
						L.stop();
						setImage(J)
					})
				}
				I.inject(H)
			}
			H.inject("sizes")
		}
	});
	var C = "http://" + F.domain + F.path + F.randomName + "/" + F.filename
			+ "." + F.ext;
	var E = "http://" + F.domain + F.path + F.randomName + "/300/" + F.filename
			+ "." + F.ext;
	var G = "http://" + localvars.domain + "/";
	var A = C;
	var B = this_w;
	if (!F.animate) {
		if (F.width > 300) {
			if (F.size < 800000) {
				G = C;
				A = E
			} else {
				if (F.proportions[0] >= 800) {
					B = "/800/"
				} else {
					B = "/"
				}
				G = "http://" + F.domain + F.path + F.randomName + B
						+ F.filename + "." + F.ext;
				A = E
			}
		}
	}
	if (album_id) {
		$("friend_link").set(
				"value",
				"http://" + localvars.domain + "/aview/" + album_id + "/"
						+ F.image_id + "/" + this_w + "/" + F.filename)
	} else {
		$("friend_link").set(
				"value",
				"http://" + localvars.domain + "/view/" + F.image_id + "/"
						+ this_w + "/" + F.filename)
	}
	$("friend_link").set(
			"value",
			"http://" + localvars.domain + "/view/" + F.image_id + "/" + this_w
					+ "/" + F.filename);
	$("board_link").set("value", "[url=" + G + "][img]" + E + "[/img][/url]");
	$("blog_link").set(
			"value",
			'<a href="http://' + localvars.domain + '"><img src="http://'
					+ F.domain + F.path + F.randomName + "/" + this_w + "/"
					+ F.filename + "." + F.ext + '" /></a>');
	$("direct_link").set(
			"value",
			"http://" + F.domain + F.path + F.randomName + "/" + this_w + "/"
					+ F.filename + "." + F.ext);
	if ($("description") && F.description) {
		$("description").set("html", F.description)
	}
	var D = F.realname.length > 0 ? F.realname : F.name;
	$$("div.block strong.short").set("html", D)
}
function generateLinks(B, I) {
	if (!B) {
		return false
	}
	if (!I) {
		return false
	}
	var D = "http://" + B.domain + B.path + /*B.randomName + "/" +*/ B.filename
			//+ "." + B.ext;
	var H = "http://" + B.domain + B.path + /*B.randomName + "/300/" +*/ B.filename
			//+ "." + B.ext;
	var E = "http://" + localvars.domain + "/";
	var A = D;
	var G = "800";
	var C = 0;
	var J = new Array;
	for (k in B.proportions) {
		J[C] = B.proportions[k];
		C++
	}
	if (B.animate == 0) {
		if (J.length > 0) {
			if (B.width > 300) {
				if (J[J.length - 1] >= 800) {
					G = 800
				} else {
					if (B.width <= 800) {
						G = 0
					} else {
						G = J[J.length - 1];
						if (G == 300) {
							G = 320
						}
					}
				}
				if (B.size < 800000) {
					E = D;
					A = H
				} else {
					if (G) {
						E = "http://" + B.domain + B.path + /*B.randomName + "/"
								+ G + "/" +*/ B.filename //+ "." + B.ext
					} else {
						E = "http://" + B.domain + B.path + /*B.randomName
								+*/ B.filename //+ "." + B.ext
					}
					A = H
				}
			} else {
				G = B.width
			}
		} else {
			G = false;
			E = "http://" + B.domain + B.path + /*B.randomName +*/ B.filename /*+ "."
					+ B.ext*/;
			A = E
		}
		var F = "";
		switch (I) {
			case "friend" :
				if (G) {
					F = "http://" + localvars.domain + "/view/" + B.image_id
							+ "/" + G + "/" + B.filename
				} else {
					F = "http://" + localvars.domain + "/view/" + B.image_id
							+ "/0/" + B.filename
				}
				break;
			case "board" :
				if (G || (B.width > 300 && B.animate == 0)) {
					F = "[url=" + E + "][img]" + H + "[/img][/url]"
				} else {
					F = "[url=" + E + "][img]http://" + B.domain + B.path
							+ /*B.randomName + "/" +*/ B.filename /*+ "." + B.ext*/;
					+"[/img][/url]"
				}
				break;
			case "blogs" :
				if (G || (B.width > 300 && B.animate == 0)) {
					F = '<a target="_blank" href="' + E + '"><img src="' + H
							+ '" /></a>'
				} else {
					F = '<a target="_blank" href="' + E + '"><img src="http://'
							+ B.domain + B.path + /*B.randomName + "/"
							+*/ B.filename /*+ "." + B.ext*/ + '" /></a>'
				}
				break;
			case "direct" :
				if (G) {
					F = "http://" + B.domain + B.path + /*B.randomName + "/" + G
							+ "/" +*/ B.filename /*+ "." + B.ext*/
				} else {
					F = "http://" + B.domain + B.path + /*B.randomName + "/"
							+*/ B.filename /*+ "." + B.ext*/
				}
				break;
			default :
				if (G) {
					F = "http://" + localvars.domain + "/view/" + B.image_id
							+ "/" + G + "/" + B.filename
				} else {
					F = "http://" + localvars.domain + "/view/" + B.image_id
							+ "/0/" + B.filename
				}
				break
		}
	} else {
		var F = "";
		switch (I) {
			case "friend" :
				F = "http://" + localvars.domain + "/view/" + B.image_id
						+ "/0/" + B.filename;
				break;
			case "board" :
				F = "[url=" + E + "][img]" + D + "[/img][/url]";
				break;
			case "blog" :
				F = '<a href="http://' + localvars.domain + '"><img src="' + D
						+ '" /></a>';
				break;
			case "direct" :
				F = D;
				break;
			default :
				F = "http://" + localvars.domain + "/view/" + B.image_id
						+ "/0/" + B.filename;
				break
		}
	}
	return F
}
function setImage(A) {
	var D = $$(".big")[0];
	var F = active_image;
	if (!F.image_id) {
		return false
	}
	var C = new Waiter(D, {
		layer : {
			id : "waitingDiv",
			background : "#fff",
			opacity : 0.5
		}
	}).start();
	var B = "http://" + F.domain + F.path + F.randomName + "/" + A + "/"
			+ F.filename + "." + F.ext;
	this_w = A;
	var E = new Asset.image(B, {
		onload : function() {
			$(D).setProperty("src", B);
			$(D).setProperty("alt", F.name);
			$(D).setProperty("id", "image_" + F.image_id);
			C.stop();
			setImagePreference(A)
		}
	})
}
function loadPageImage() {
	if (!array_images) {
		return false
	}
	if (!myElementSlide) {
		return false
	}
}
function checkNextAlbumImage() {
	var A = getNextImage();
	if (A) {
		setAlbumImage(A, current_image_i + 1);
		if (getImagesArray(current_image_i + 2)) {
			$$("#fotocontext a.button-next").removeClass("invisible")
		} else {
			$$("#fotocontext a.button-next").addClass("invisible")
		}
		if (getImagesArray(current_image_i)) {
			$$("#fotocontext a.button-previous").removeClass("invisible")
		} else {
			$$("#fotocontext a.button-previous").addClass("invisible")
		}
	}
}
function getHeight(B, C, A) {
	return Math.ceil((A * B) / C)
}
function checkPrevAlbumImage() {
	var A = getPrevImage();
	if (A) {
		setAlbumImage(A, current_image_i - 1);
		if (getImagesArray(current_image_i - 2)) {
			$$("#fotocontext a.button-previous").removeClass("invisible")
		} else {
			$$("#fotocontext a.button-previous").addClass("invisible")
		}
		if (getImagesArray(current_image_i)) {
			$$("#fotocontext a.button-next").removeClass("invisible")
		} else {
			$$("#fotocontext a.button-next").addClass("invisible")
		}
	}
}
function reload() {
	location.refresh(true)
}
function sortNumber(B, A) {
	return B - A
}
String.prototype.unescapeHtml = function() {
	var A = document.createElement("div");
	A.innerHTML = this;
	var B = A.childNodes[0].nodeValue;
	A.removeChild(A.firstChild);
	return B
};
function htmlentities(B) {
	var C = new Element("div");
	var A = B.replace(/</g, "&lt;").replace(/>/g, "&gt;");
	C.set("html", A);
	return C.get("html")
}
function unhtmlentities(B) {
	var A = B.replace(/\&lt;/g, "<").replace(/\&gt;/g, ">").replace(/\&quot;/g,
			'"');
	return A
}
function onDrawerInitilized() {
	draw_enable = true
}
function onPicLoaded() {
	sendToJS();
	$$("a.tools-draw").removeClass("hide")
}
function loadPic(A, B) {
	Swiff.remote($("drawer_" + B), "loadPic", A)
}
function flip(B, A) {
	if ($("drawer_" + A)) {
		if (B == "h") {
			Swiff.remote($("drawer_" + A), "flipH")
		}
		if (B == "v") {
			Swiff.remote($("drawer_" + A), "flipV")
		}
	}
	sendToJS()
}
function sendToJS() {
	if ($("drawer")) {
		Swiff.remote($("drawer"), "sendToJS")
	}
}
function rotate(A, B) {
	if ($("drawer_" + B)) {
		Swiff.remote($("drawer_" + B), "rotatePic", A)
	}
	sendToJS()
}
function onSendToJS(A, B, C) {
}
function downloadPic(C, E) {
	var D = thisMovie("drawer_" + E);
	var B = $$(".empty-cell");
	draw_download = true;
	if (B[0]) {
		var A = $(B[0]).get("id").replace(/cell_/, "");
		if (A >= 0) {
			D.downloadPic(C, A)
		}
	}
	$$("div.modal").setStyles( {
		"z-index" : "-1"
	});
	if ($("modalOverlay")) {
		$("modalOverlay").dispose()
	}
	intilizeUploads(A, 1)
}
function onServerAnswered(A) {
	var B = new Utils();
	var C = JSON.decode(B.urldecode(A));
	if (!C) {
		C = JSON.decode(A)
	}
	if (C.error) {
		C.error = unhtmlentities(C.error);
		if (C.code) {
			if (C.code == 502) {
				paymentError(C.cellId, C.error)
			} else {
				if (C.code == 413) {
					filesizeError(C.cellId)
				} else {
					reportError(C.cellId, C.error)
				}
			}
		} else {
			reportError(C.cellId, C.error)
		}
	} else {
		finishUpload(C.cellId, C.imgId, C.album_id, C.name, C.sid, C.img)
	}
}
function strpos(B, D, C) {
	var A = (B + "").indexOf(D, (C ? C : 0));
	return A === -1 ? false : A
}
function strrpos(B, D, C) {
	var A = (B + "").lastIndexOf(D, C);
	return A >= 0 ? A : false
}
function array_unique(A) {
	var B = new Array();
	for (i = 0;i < A.length; i++) {
		if (B.indexOf(A[i]) == "-1") {
			B.push(A[i])
		}
	}
	return B
}
function validAlbums() {
	if (albums_cnt >= max_alubms_cnt) {
		return false
	} else {
		return true
	}
}
function validImages() {
	if (imgs_cnt >= max_imgs_cnt) {
		return false
	} else {
		return true
	}
}
function validPayment(A) {
	switch (A) {
		case "albums" :
			break;
		case "images" :
			break
	}
}
var ElementSlide = new Class( {
	initialize : function(A) {
		if (!A) {
			return false
		}
		this.page = 0;
		this.temp_page = 0;
		this.prev_button = $$(".button-previous.button-slide");
		this.next_button = $$(".button-next.button-slide");
		this.element = typeof A == "object" ? A : $$(A)[0];
		this.element_slide = this.element.getChildren()[0];
		this.slide_width = $(this.element).getCoordinates().width;
		this.open = false;
		if (this.element_slide.getChildren("li")) {
			this.children = $(this.element.getChildren()[0]).getChildren("li");
			this.el_width = this.children[0].getCoordinates().width;
			this.children_width = $(this.children[0]).getRealWidth();
			this.children_height = $(this.children[0]).getRealHeight();
			this.el_height = this.children[0].getCoordinates().height;
			this.total_children = this.children.length;
			this.total_width = this.total_children * this.el_width;
			this.total_height = this.total_children * this.el_height;
			this.element_slide.setStyle("width", this.total_width
					+ this.slide_width);
			if (this.total_children > 5) {
				this.total_pages = Math.floor(this.total_width
						/ this.slide_width)
			} else {
				this.total_pages = 0
			}
			dbug.log("this.total_width %n", this.total_width);
			dbug.log("this.slide_width %n", this.slide_width);
			this.temp_total_pages = this.total_pages;
			this.page_el_count = Math.floor(this.slide_width / this.el_width);
			this.vertical_height = Math.floor((Math.ceil(this.total_children
					/ this.page_el_count))
					* this.children_height)
					+ 20;
			this.children_in_page = 5
		}
	}
});
ElementSlide.implement( {
	verticalSlide : function(B, A) {
		if (this.element.getCoordinates().height != this.vertical_height) {
			this.element.tween("height", this.vertical_height);
			this.element_slide.setStyle("width",
					this.element.getCoordinates().width);
			this.temp_page = this.page;
			this.page = 0;
			this.setPage();
			this.open = true;
			this.total_pages = 0;
			$$(".button-slide").addClass("hide");
			this.loadAllImages();
			if (A) {
				$(B).getChildren().set("html", localMessage.closeAllImages)
			} else {
				$(B).getChildren().set("html", localMessage.closeAllAlbums)
			}
		} else {
			this.open = false;
			this.element.tween("height", this.el_height);
			this.element_slide.setStyle("width", this.total_width
					+ this.slide_width);
			this.total_pages = this.temp_total_pages;
			this.page = this.temp_page;
			$$(".button-slide").removeClass("hide");
			this.setPage();
			this.setImage(current_image_i);
			if (A) {
				$(B).getChildren().set("html", localMessage.viewAllImages)
			} else {
				$(B).getChildren().set("html", localMessage.viewAllAlbums)
			}
			this.checkPrevLink()
		}
		return false
	},
	getPage : function() {
		return this.page
	},
	verticalClose : function() {
		if (this.element.getCoordinates().height == this.vertical_height) {
			dbug.log("закрыть бы")
		}
	},
	setPage : function() {
		if (this.open) {
			return
		}
		this.loadPageImage();
		if ($("album-dialog-links")) {
			$("album-dialog-links").addClass("hide")
		}
		dbug.log("setPage");
		this.element_slide.tween("margin-left", (this.page * this.slide_width)
				* (-1))
	},
	loadPageImage : function() {
		dbug.log("loadPageImage:");
		if (!array_images) {
			return false
		}
		if (this.total_children <= 5) {
			this.loadAllImages()
		} else {
			var C = (this.page * this.children_in_page);
			var A = C + this.children_in_page;
			dbug.log("start %s", C);
			dbug.log("end %s", A);
			for (var B = C;B < A; B++) {
				if (!this._assetLoad(B)) {
					continue
				}
			}
		}
		return true
	},
	loadAllImages : function() {
		if (!array_images) {
			return false
		}
		var C = new Array;
		var A = new Array;
		for (var B = 0;B < this.total_children; B++) {
			if (!this._assetLoad(B)) {
				continue
			}
		}
	},
	_assetLoad : function(E) {
		var G = new Array;
		var C = new Array;
		var H = array_images[E];
		if (!H) {
			return false
		}
		var D = $("preview_" + E).getChildren("div.loading");
		if (!D.length) {
			return false
		}
		var B = "http://" + H.domain + H.path + H.randomName + "/150/"
				+ H.filename + "." + H.ext;
		C[E] = new Element("a", {
			id : "preview_link_" + H.index,
			href : "/view/" + H.album_id + "/" + H.image_id + "/0/"
					+ escape(H.filename),
			events : {
				click : function(I) {
					I.stop();
					setAlbumImage(H, E)
				}
			}
		});
		var A = new Element("img", {
			"class" : "thumbnail",
			id : "cell_" + H.image_id + "_image",
			alt : H.name,
			src : B
		});
		var F = new Asset.image(B, {
			id : "cell_" + H.image_id + "_image",
			title : H.name,
			"class" : "thumbnail",
			rel : H.index,
			onload : function() {
				var I = $(this).get("rel");
				if ($("preview_" + I)) {
					$$("#preview_" + I + " div.loading").dispose();
					this.inject(C[I]);
					$("preview_" + I).empty();
					C[I].inject("preview_" + I)
				}
			}
		})
	},
	setImage : function(A) {
		if (A > 0) {
			if (this.children_in_page % A == 0
					|| this.children_in_page % A == this.children_in_page
					|| this.total_pages == 3) {
				A = A - 1
			}
			this.page = Math.floor(A / this.children_in_page);
			var B = A / this.children_in_page;
			dbug.log("children_in_page = %s", this.children_in_page);
			this.setPage();
			this.checkNextLink();
			this.checkPrevLink();
			return false
		} else {
			this.setPage(0);
			this.checkNextLink();
			this.checkPrevLink();
			return false
		}
	},
	next : function() {
		if (this.page < this.total_pages) {
			this.page++;
			dbug.log("next");
			this.setPage();
			this.checkNextLink()
		}
	},
	prev : function() {
		if (this.page > 0) {
			this.page--;
			dbug.log("prev");
			this.setPage();
			this.checkPrevLink()
		}
	},
	checkNextLink : function() {
		if (this.open) {
			return
		}
		if (this.page != 0) {
			this.prev_button.removeClass("hide")
		}
		dbug.log("this.page : %s", this.page);
		dbug.log("this.total_pages : %s", this.total_pages);
		if (this.page == this.total_pages) {
			dbug.log("hide");
			this.next_button.addClass("hide")
		}
	},
	checkPrevLink : function() {
		if (this.open) {
			return
		}
		if (this.page == 0) {
			this.prev_button.addClass("hide")
		}
		if (this.page != this.total_pages) {
			this.next_button.removeClass("hide")
		}
	},
	fullWidth : function(B) {
		var A = $(B).getStyle("width").toInt();
		A = A + $(B).getStyle("padding-left").toInt();
		A = A + $(B).getStyle("padding-right").toInt();
		A = A + $(B).getStyle("margin-left").toInt();
		A = A + $(B).getStyle("margin-right").toInt();
		return A
	}
});
Element.implement( {
	getRealWidth : function() {
		var A = this;
		var B = $(A).getStyle("width").toInt();
		B = B + $(A).getStyle("padding-left").toInt();
		B = B + $(A).getStyle("padding-right").toInt();
		B = B + $(A).getStyle("margin-left").toInt();
		B = B + $(A).getStyle("margin-right").toInt();
		return B
	},
	getRealHeight : function() {
		var A = this;
		var B = $(A).getStyle("height").toInt();
		B = B + $(A).getStyle("padding-top").toInt();
		B = B + $(A).getStyle("padding-bottom").toInt();
		B = B + $(A).getStyle("margin-top").toInt();
		B = B + $(A).getStyle("margin-bottom").toInt();
		return B
	}
});
var MooGears = new Class( {
	Implements : [Options],
	options : {
		siteName : null,
		imageUrl : null,
		extraMessage : null,
		installMessage : "Install Gears support.",
		htmlMessage : "<u>Click to install Gears to enable!</u>",
		installElement : document.body
	},
	initialize : function(B, A) {
		this.setOptions(A);
		this.needPermission = false;
		this.userPermission = false;
		this.factory = false;
		this.cFactory = false;
		this.factoryname = B;
		if (this.init()) {
			this.factoryInit()
		} else {
			this.install()
		}
		return this
	}
});
MooGears.implement( {
	init : function() {
		if (window.google && google.gears) {
			return true
		}
		var A = null;
		if (Browser.Engine.gecko) {
			try {
				A = new GearsFactory()
			} catch (B) {
				return false
			}
		} else {
			if (Browser.Engine.webkit) {
				A = document.createElement("object");
				var A = new Element("object", {
					type : "application/x-googlegears",
					width : 0,
					height : 0,
					styles : {
						display : "none"
					}
				});
				document.inject(A, "inside")
			} else {
				if (Browser.Engine.trident) {
					try {
						A = new ActiveXObject("Gears.Factory");
						if (A.getBuildInfo().indexOf("ie_mobile") != -1) {
							A.privateSetGlobalObject(this)
						}
					} catch (B) {
						return false
					}
				} else {
					if (Browser.Engine.presto) {
						return false
					} else {
						return false
					}
				}
			}
		}
		if (!window.google) {
			google = {}
		}
		if (!google.gears) {
			google.gears = {
				factory : A
			}
		}
		return true
	},
	factoryInit : function() {
		console.log("Factory name: %s", this.factoryname);
		switch (this.factoryname) {
			case "beta.database" :
			case "beta.geolocation" :
			case "beta.localserver" :
			case "beta.workerpool" :
				this.needPermission = true;
				break;
			case "beta.httprequest" :
			case "beta.desktop" :
			case "beta.timer" :
				this.needPermission = false;
				break;
			default :
				return false
		}
		console.log("Factory permission: %s ", this.hasPermission());
		console.log("Factory need permission: %s ", this.needPermission);
		this.factory = google.gears.factory.create(this.factoryname);
		if (this.needPermission && !this.hasPermission()) {
			this.userPermission = this.getPermission()
		} else {
			this.userPermission = true
		}
	},
	hasPermission : function() {
		if (typeof this.factory.hasPermission == "undefined") {
			return google.gears.factory.hasPermission
		} else {
			return this.factory.hasPermission
		}
	},
	getPermission : function() {
		var B = this.options.siteName;
		var A = this.options.imageUrl;
		var C = this.options.extraMessage;
		if (typeof this.factory.hasPermission == "undefined") {
			return google.gears.factory.getPermission(B, A, C)
		} else {
			return this.factory.getPermission(B, A, C)
		}
	},
	install : function() {
		var B = this.options.installElement;
		var A = "http://gears.google.com/?action=install&message="
				+ encodeURIComponent(this.options.installMessage) + "&return="
				+ encodeURIComponent(window.location.href);
		if ($(B).getProperty("tagName") == "A") {
			$(B).setProperty("href", A)
		} else {
			$(B).setStyle("cursor", "pointer").addEvent("click", function() {
				window.location.href = A
			})
		}
		$(B).set("html", this.options.htmlMessage)
	}
});
