(function (window, undefined) {
	var FQuery = function (selector, context) {
		var j;
		if (typeof selector == "string") {
			j = $(selector, context).getObj();
			j.key = j.getKey();
		} else if (selector.key || typeof selector[0] == "string") {
			j = $(selector, context);
			j[0] = selector[0];
			j.key = selector.key;
		} else {
			j = $(selector, context).getObj();
			j.key = j.getKey();
		}
		j.length = 1;
		j.find = function ($find) {
			var f = F(this);
			var s = "main";
			if (f[0] && typeof f[0] == "string") {
				s = f[0];
			}
			var r = f.jfq({
				action: "find",
				selector: s,
				find: $find
			});
			f.length = r.length;
			f.key = this.key;
			for (var i = 0; i < r.length; i++) {
				f[i] = r[i];
			}
			return f;
		};
		j.children = function () {
			var f = F(this);
			var s = "main";
			if (f[0] != null && typeof f[0] == "string") {
				s = f[0];
			}
			var r = f.jfq({
				action: "children",
				selector: s
			});
			f.length = r.length;
			f.key = this.key;
			for (var i = 0; i < r.length; i++) {
				f[i] = r[i];
			}
			return f;
		};
		j.each = function (callback) {
			for (var i = 0; i < this.length; i++) {
				var f = F(this[i]);
				f[0] = this[i];
				f.key = this.key;
				callback.call(f);
			}
			return this;
		};
		j.props = function (pars) {
			for (var i = 0; i < this.length; i++) {
				var p = {
					action: "attr",
					selector: this[i]
				};
				for (var name in pars) {
					p[name] = pars[name];
				}
				var r = this.jfq(p);
			}
			return this;
		};
		j.jfq = function (pars) {
			var key = this.key;
			var r;
			if ($.browser.msie) {
				r = window[key].jfq(pars);
			} else {
				r = document[key].jfq(pars);
			}
			return r;
		};
		return j;
	};
	window.FQuery = window.F = FQuery;
})(window);
(function ($) {
	$.fn.extend({
		getObj: function () {
			var __e = this;
			if (typeof this[0] == "object") {
				var tag = this[0].tagName;
				if (tag) {
					__e = tag.toLowerCase() == "object" ? this: this.find("object");
				}
			}
			return __e;
		},
		getKey: function () {
			var key = null;
			if ($.browser.msie) {
				key = this.attr("id");
			} else {
				key = this.attr("name");
			}
			return key;
		},
		jfq_ready: function (callback) {
			return this.each(function () {
				var __e = $(this).getObj();
				if (__e.data("joined")) {
					callback.call(__e, JQuery);
				} else {
					if (key = __e.getKey()) {
						fjeready = fje.ready[key] ? fje.ready[key] : (fje.ready[key] = []);
						fjeready.push(callback);
					}
				}
			});
		},
		jfq: function (pars) {
			return this.each(function () {
				var __e = $(this).getObj();
				if (key = __e.getKey()) {
					var conn = fje.conn[key];
					if (conn) {
						if (conn.joined) {
							if ($.browser.msie) {
								window[key].jfq(pars);
							} else {
								document[key].jfq(pars);
							}
						} else {
							__e.jfe_push(key, "jfq", pars);
						}
					}
				}
			});
		},
		jfe: function (options) {
			var defaults = {
				ver: "6,0,0",
				display: "none",
				manual: false,
				alert: false,
				console: false,
				noflash: false,
				showId: false,
				showTag: false,
				timeout: 8000
			};
			var options = $.extend(defaults, options);
			options.ver = options.ver.split(",");
			return this.each(function () {
				var __e = $(this);
				__e.data("default", __e.html());
				var __o = __e.find("object:first");
				var key = "JFE";
				var keys = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Z"];
				while (key.length < 8) {
					key += keys[Math.floor(Math.random() * keys.length)];
				}
				var plugin = getPlugin(options.ver[0], options.ver[1], options.ver[2]);
				options.console && options.alert ? alert("JFE { hasflash: " + plugin.flash + ", version: " + plugin.version + ", display: " + options.display + " }\n\nto disable this message, set alert or console flag to false\n") : null;
				options.manual && options.alert ? alert("JFE { display: " + options.display + " } manual mode\n\nto disable this message, set alert or manual flag to false\n") : null;
				options.noflash && options.alert ? alert("JFE { display: " + options.display + " } noflash mode\n\nto disable this message, set alert or noflash flag to false\n") : null;
				options.showId && options.alert ? alert("JFE { display: " + options.display + " } showId mode\n\nto disable this message, set alert or showId flag to false\n") : null;
				options.showTag && options.alert ? alert("JFE { display: " + options.display + " } showTag mode\n\nto disable this message, set alert or showTag flag to false\n") : null;
				var object;
				var s = __o.attr("data");
				var WN = __o.attr("width");
				var HN = __o.attr("height");
				var wtype = WN.indexOf("%") != -1 ? "%": "px";
				var htype = HN.indexOf("%") != -1 ? "%": "px";
				var w = parseInt(WN);
				var h = parseInt(HN);
				if ($.browser.msie) {
					object = "<object width='" + w + wtype + "' height='" + h + htype + "' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' id='" + key + "'><param name='movie' value='" + s + "' />";
				} else {
					object = "<object width='" + w + wtype + "' height='" + h + htype + "' type='application/x-shockwave-flash' name='" + key + "' data='" + s + "'>";
				}
				var add_vars = "";
				if (options.console) {
					add_vars += "jfe_console=true";
				}
				if (options.showId) {
					add_vars != "" ? (add_vars += "&") : null;
					add_vars += "jfe_showId=true";
				}
				if (options.showTag) {
					add_vars != "" ? (add_vars += "&") : null;
					add_vars += "jfe_showTag=true";
				}
				var has_vars = false;
				__o.children().each(function () {
					var __p = $(this);
					var n = __p.attr("name").toLowerCase();
					var v = __p.val();
					switch (n) {
					case "movie":
					case "allowscriptaccess":
						break;
					case "flashvars":
						has_vars = true;
						if (add_vars != "") {
							object += "<param name=\"flashvars\" value=\"" + v + "&" + add_vars + "\" />";
						} else {
							object += "<param name=\"flashvars\" value=\"" + v + "\" />";
						}
						break;
					default:
						object += "<param name=\"" + n + "\" value=\"" + v + "\" />";
					}
				});
				__o.remove();
				__e.data("object") ? (object = __e.data("object")) : __e.data("object", object);
				__e.data("options") ? null: __e.data("options", options);
				__e.data("key", key);
				if (plugin.flash && options.manual) {
					__e.css("width", w + wtype);
					__e.css("height", h + htype);
					__e.find(".jfeHasFlash").empty().remove();
					__e.find(".jfeUpgrade").empty().remove();
					__e.find(".jfeAlternate").empty().remove();
					__e.find(".jfeManual").css({
						width: "100%",
						height: "100%"
					});
					__e.find(".jfeManual").css("display", "block");
					__e.find(".jfeManual").addClass("jfeRound");
					__e.find(".jfeManual a.jfeManualActivate").click(function () {
						$(this).parent().fadeOut(200, function () {
							var __e = $(this).parent();
							$(this).remove();
							__e.jfe_manual();
						});
						return false;
					});
				} else if (plugin.flash && !options.noflash) {
					__e.find(".jfeUpgrade").empty().remove();
					__e.find(".jfeAlternate").empty().remove();
					__o.empty();
					if (add_vars != "" && !has_vars) {
						object += "<param name=\"flashvars\" value=\"" + add_vars + "\" />";
					}
					object += "<param name=\"allowScriptAccess\" value=\"always\" />";
					object += "</object>";
					var has = __e.find(".jfeHasFlash");
					has.css("display", "block");
					has.insertAfter(__e);
					__e.html(object);
					if (options.console) {
						if ($.browser.msie) {
							__e.append("<!-- IE Browser [has Flash = " + plugin.flash + " (ver " + plugin.version + ") -->");
						} else {
							__e.append("<!-- Mozilla Browser [has Flash = " + plugin.flash + " (ver " + plugin.version + ") -->");
						}
					}
					fje.conn[key] = {
						joined: false,
						calls: [],
						pars: []
					};
				} else {
					__e.find(".jfeHasFlash").empty().remove();
					__e.find(".jfeManual").empty().remove();
					__e.find(".jfeUpgrade").css({
						width: "100%",
						height: "100%"
					});
					__e.find(".jfeAlternate").css({
						width: "100%",
						height: "100%"
					});
					if (navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)) {
						__e.find(".jfeAlternate").css("display", "block");
					} else {
						switch (options.display) {
						case "upgrade":
							__e.find(".jfeUpgrade").css("display", "block");
							__e.find(".jfeUpgrade").addClass("jfeRound");
							__e.find(".jfeAlternate").empty().remove();
							break;
						case "alternate":
							__e.css("width", w + wtype);
							__e.css("height", h + htype);
							__e.find(".jfeUpgrade").empty().remove();
							__e.find(".jfeAlternate").css("display", "block");
							break;
						case "both":
							__e.css("width", w + wtype);
							__e.css("height", h + htype);
							__e.find(".jfeAlternate").css("display", "block");
							__e.jfe_upgrade(options, key);
							break;
						default:
							__e.find(".jfeUpgrade").empty().remove();
							__e.find(".jfeAlternate").empty().remove();
						}
					}
				}
			});
		},
		jfe_onUpgrade: function ($options, $key) {
			return this.each(function () {
				var __e = $(this);
				var $e = {};
				$e.id = $key + "_upgrade";
				$e.code = "<div id=\"" + $e.id + "\" class=\"jfeUpgrade jfeRound\" style=\"display:none;\">\n";
				$e.code += "<a href=\"#\" class=\"jfeUpgradeClose\">close</a>\n";
				$e.code += __e.children(".jfeUpgrade").html();
				$e.code += "</div>";
				__e.children(".jfeUpgrade").remove();
				$e.top = parseInt(__e.offset().top) + parseInt(__e.css("padding-top"));
				$e.left = parseInt(__e.offset().left) + parseInt(__e.css("padding-left"));
				$e.width = parseInt(__e.width());
				$e.height = parseInt(__e.height());
				__e.append($e.code);
				var id = $e.id;
				var time = $options.timeout;
				var timeout = setTimeout(function () {
					jfeFadeIn(id, time);
				},
				100);
				$(window).scroll(function () {
					if ($("#" + id).css("display") == "none") {
						jfeFadeIn(id, time);
					}
				});
				$("#" + id + " a.jfeUpgradeClose").click(function () {
					$(this).parent().fadeOut(200, function () {
						$(this).css("display", "none");
					});
					return false;
				});
				$e = null;
			});
		},
		jfe_upgrade: function ($options, $key) {
			return this.each(function () {
				var __e = $(this);
				$(window).bind("load", function () {
					__e.jfe_onUpgrade($options, $key);
				});
			});
		},
		jfe_noflash: function () {
			return this.each(function () {
				var __e = $(this);
				__e.jfe_reset();
				var __o = __e.find("object:first");
				__o.remove();
				var w = __o.attr("width");
				var h = __o.attr("height");
				__e.find(".jfeUpgrade").css({
					width: "100%",
					height: "100%"
				});
				__e.find(".jfeAlternate").css({
					width: "100%",
					height: "100%"
				});
				__e.css("width", w + "px");
				__e.css("height", h + "px");
				__e.jfe_onUpgrade({
					timeout: 8000
				},
				__e.data("key"));
				__e.find(".jfeAlternate").css("display", "block");
			});
		},
		jfe_manual: function () {
			return this.each(function () {
				var __e = $(this);
				__e.jfe_reset();
				var options = __e.data("options");
				var $options = {};
				for (var p in options) {
					$options[p] = options[p];
				}
				$options.manual = false;
				$options.ver = $options.ver.join(",");
				__e.jfe($options);
			});
		},
		jfe_restart: function () {
			return this.each(function () {
				var __e = $(this);
				__e.jfe_reset();
				var options = __e.data("options");
				var $options = {};
				for (var p in options) {
					$options[p] = options[p];
				}
				$options.ver = $options.ver.join(",");
				__e.jfe($options);
			});
		},
		jfe_reset: function () {
			return this.each(function () {
				var __e = $(this);
				var key = __e.data("key");
				$("#" + key + "_upgrade").empty().remove();
				__e.html(__e.data("default"));
			});
		},
		jfe_connect: function (key) {
			return this.each(function () {
				var __e = $(this);
				var conn = fje.conn[key];
				if (conn) {
					conn.joined = true;
					__e.getObj().data("joined", true);
					fjeready = fje.ready[key];
					if (fjeready) {
						for (i = 0; i < fjeready.length; i++) {
							fjeready[i].call(__e[0]);
						}
						fje.ready[key] = null;
					}
					if (conn.calls.length) {
						for (i = 0; i < conn.calls.length; i++) {
							__e.jfe_custom(conn.calls[i], conn.pars[i]);
						}
						conn.calls = [];
						conn.pars = [];
					}
				}
			});
		},
		jfe_custom: function (func, pars) {
			return this.each(function () {
				var __e = $(this).getObj();
				if (key = __e.getKey()) {
					var res = null;
					var conn = fje.conn[key];
					if (conn) {
						if (conn.joined) {
							if ($.browser.msie) {
								res = window[key][func](pars);
							} else {
								res = document[key][func](pars);
							}
						} else {
							__e.jfe_push(key, func, pars);
						}
					}
				}
			});
		},
		jfe_call: function (pars) {
			return this.each(function () {
				var __e = $(this).getObj();
				if (key = __e.getKey()) {
					var conn = fje.conn[key];
					if (conn) {
						if (conn.joined) {
							if ($.browser.msie) {
								window[key].jfeMessage(pars);
							} else {
								document[key].jfeMessage(pars);
							}
						} else {
							__e.jfe_push(key, "jfeMessage", pars);
						}
					}
				}
			});
		},
		jfe_push: function (key, func, pars) {
			return this.each(function () {
				var __e = $(this);
				var conn = fje.conn[key];
				conn.calls.push(func);
				conn.pars.push(pars);
			});
		},
		jfe_analisy: function () {
			return this.each(function () {
				var __e = $(this);
				__e.find("object").children().each(function () {
					var __p = $(this);
					alert(__p.attr("name"));
					alert(__p.val());
				});
			});
		}
	});
	$.extend({
		fje: {
			ready: {},
			conn: {},
			connect: function (key) {
				if ($.browser.msie) {
					var __e = $("#" + key);
				} else {
					var __e = $("[name='" + key + "']");
				}
				__e.jfe_connect(key);
			},
			restart: function (key) {
				if ($.browser.msie) {
					var __e = $("#" + key);
				} else {
					var __e = $("[name='" + key + "']");
				}
				__e.parent("div").jfe_restart();
			},
			reset: function (key) {
				if ($.browser.msie) {
					var __e = $("#" + key);
				} else {
					var __e = $("[name='" + key + "']");
				}
				__e.parent("div").jfe_reset();
			}
		}
	});
	fje = $.fje;
})(jQuery);
var win = navigator.appVersion.toLowerCase().indexOf("win") != -1 ? true: false;
function getActiveX() {
	var version;
	var AX;
	var $e;
	try {
		AX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = AX.GetVariable("$version");
	} catch($e) {}
	if (!version) {
		try {
			AX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			version = "WIN 6,0,21,0";
			AX.AllowScriptAccess = "always";
			version = AX.GetVariable("$version");
		} catch($e) {}
	}
	if (!version) {
		try {
			AX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = AX.GetVariable("$version");
		} catch($e) {}
	}
	if (!version) {
		try {
			AX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch($e) {}
	}
	if (!version) {
		try {
			AX = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch($e) {
			version = -1;
		}
	}
	return version;
}
function getInfo() {
	var np = navigator.plugins;
	var ua = navigator.userAgent.toLowerCase();
	var info = -1;
	if (np != null && np.length > 0) {
		if (np['Shockwave Flash 2.0'] || np['Shockwave Flash']) {
			var software = np['Shockwave Flash 2.0'] ? " 2.0": "";
			var description = np["Shockwave Flash" + software].description;
			var words = description.split(" ");
			var splits = words[2].split(".");
			var major = splits[0];
			var minor = splits[1];
			var revision = words[3];
			if (revision == "") {
				revision = words[4];
			}
			if (revision[0] == "d") {
				revision = revision.substring(1);
			} else if (revision[0] == "r") {
				revision = revision.substring(1);
				if (revision.indexOf("d") > 0) {
					revision = revision.substring(0, revision.indexOf("d"));
				}
			}
			var info = major + "." + minor + "." + revision;
		}
	} else if (ua.indexOf("webtv/2.6") != -1) {
		info = 4;
	} else if (ua.indexOf("webtv/2.5") != -1) {
		info = 3;
	} else if (ua.indexOf("webtv") != -1) {
		info = 2;
	} else if ($.browser.msie && win && !$.browser.opera) {
		info = getActiveX();
	}
	return info;
}
function getPlugin(vmajor, vminor, vrevision) {
	var plugin = {
		flash: false,
		version: ""
	};
	info = getInfo();
	plugin.version = info;
	if (info == -1) {} else if (info != 0) {
		if ($.browser.msie && win && !$.browser.opera) {
			splits = info.split(" ");
			tempString = splits[1];
			versionArray = tempString.split(",");
		} else {
			versionArray = info.split(".");
		}
		var major = versionArray[0];
		var minor = versionArray[1];
		var revision = versionArray[2];
		if (major > parseFloat(vmajor)) {
			plugin.flash = true;
		} else if (major == parseFloat(vmajor)) {
			if (minor > parseFloat(vminor)) {
				plugin.flash = true;
			} else if (minor == parseFloat(vminor)) {
				if (revision >= parseFloat(vrevision)) {
					plugin.flash = true;
				}
			}
		}
	}
	return plugin;
}
function jfeFadeIn($id, $out) {
	$("#" + $id).fadeIn(200, function () {
		var timeout = setTimeout(function () {
			jfeFadeOut($id);
		},
		$out);
	});
}
function jfeFadeOut($id) {
	$("#" + $id).fadeOut(200, function () {
		$(this).css("display", "none");
	});
} (function ($) {
	$.event.special.load = {
		add: function (hollaback) {
			if (this.nodeType === 1 && this.tagName.toLowerCase() === "img" && this.src !== "") {
				if (this.complete || this.readyState === 4) {
					hollaback.handler.apply(this);
				} else if (this.readyState === "uninitialized" && this.src.indexOf("data:") === 0) {
					$(this).trigger("error");
				} else {
					$(this).bind("load", hollaback.handler);
				}
			}
		}
	};
})(jQuery);
