/**
* @author Pedro
*/

/*!
* jCarousel - Riding carousels with jQuery
*   http://sorgalla.com/jcarousel/
*
* Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Built on top of the jQuery library
*   http://jquery.com
*
* Inspired by the "Carousel Component" by Bill Scott
*   http://billwscott.com/carousel/
*/

(function(i) { var q = { vertical: false, rtl: false, start: 1, offset: 1, size: null, scroll: 3, visible: null, animation: "normal", easing: "swing", auto: 0, wrap: null, initCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, buttonNextHTML: "<div></div>", buttonPrevHTML: "<div></div>", buttonNextEvent: "click", buttonPrevEvent: "click", buttonNextCallback: null, buttonPrevCallback: null, itemFallbackDimension: null }, r = false; i(window).bind("load.jcarousel", function() { r = true }); i.jcarousel = function(a, c) { this.options = i.extend({}, q, c || {}); this.autoStopped = this.locked = false; this.buttonPrevState = this.buttonNextState = this.buttonPrev = this.buttonNext = this.list = this.clip = this.container = null; if (!c || c.rtl === undefined) this.options.rtl = (i(a).attr("dir") || i("html").attr("dir") || "").toLowerCase() == "rtl"; this.wh = !this.options.vertical ? "width" : "height"; this.lt = !this.options.vertical ? this.options.rtl ? "right" : "left" : "top"; for (var b = "", d = a.className.split(" "), f = 0; f < d.length; f++) if (d[f].indexOf("jcarousel-skin") != -1) { i(a).removeClass(d[f]); b = d[f]; break } if (a.nodeName.toUpperCase() == "UL" || a.nodeName.toUpperCase() == "OL") { this.list = i(a); this.container = this.list.parent(); if (this.container.hasClass("jcarousel-clip")) { if (!this.container.parent().hasClass("jcarousel-container")) this.container = this.container.wrap("<div></div>"); this.container = this.container.parent() } else if (!this.container.hasClass("jcarousel-container")) this.container = this.list.wrap("<div></div>").parent() } else { this.container = i(a); this.list = this.container.find("ul,ol").eq(0) } b !== "" && this.container.parent()[0].className.indexOf("jcarousel-skin") == -1 && this.container.wrap('<div class=" ' + b + '"></div>'); this.clip = this.list.parent(); if (!this.clip.length || !this.clip.hasClass("jcarousel-clip")) this.clip = this.list.wrap("<div></div>").parent(); this.buttonNext = i(".jcarousel-next", this.container); if (this.buttonNext.size() === 0 && this.options.buttonNextHTML !== null) this.buttonNext = this.clip.after(this.options.buttonNextHTML).next(); this.buttonNext.addClass(this.className("jcarousel-next")); this.buttonPrev = i(".jcarousel-prev", this.container); if (this.buttonPrev.size() === 0 && this.options.buttonPrevHTML !== null) this.buttonPrev = this.clip.after(this.options.buttonPrevHTML).next(); this.buttonPrev.addClass(this.className("jcarousel-prev")); this.clip.addClass(this.className("jcarousel-clip")).css({ overflow: "hidden", position: "relative" }); this.list.addClass(this.className("jcarousel-list")).css({ overflow: "hidden", position: "relative", top: 0, margin: 0, padding: 0 }).css(this.options.rtl ? "right" : "left", 0); this.container.addClass(this.className("jcarousel-container")).css({ position: "relative" }); !this.options.vertical && this.options.rtl && this.container.addClass("jcarousel-direction-rtl").attr("dir", "rtl"); var j = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null; b = this.list.children("li"); var e = this; if (b.size() > 0) { var g = 0, k = this.options.offset; b.each(function() { e.format(this, k++); g += e.dimension(this, j) }); this.list.css(this.wh, g + 100 + "px"); if (!c || c.size === undefined) this.options.size = b.size() } this.container.css("display", "block"); this.buttonNext.css("display", "block"); this.buttonPrev.css("display", "block"); this.funcNext = function() { e.next() }; this.funcPrev = function() { e.prev() }; this.funcResize = function() { e.reload() }; this.options.initCallback !== null && this.options.initCallback(this, "init"); if (!r && i.browser.safari) { this.buttons(false, false); i(window).bind("load.jcarousel", function() { e.setup() }) } else this.setup() }; var h = i.jcarousel; h.fn = h.prototype = { jcarousel: "0.2.7" }; h.fn.extend = h.extend = i.extend; h.fn.extend({ setup: function() { this.prevLast = this.prevFirst = this.last = this.first = null; this.animating = false; this.tail = this.timer = null; this.inTail = false; if (!this.locked) { this.list.css(this.lt, this.pos(this.options.offset) + "px"); var a = this.pos(this.options.start, true); this.prevFirst = this.prevLast = null; this.animate(a, false); i(window).unbind("resize.jcarousel", this.funcResize).bind("resize.jcarousel", this.funcResize) } }, reset: function() { this.list.empty(); this.list.css(this.lt, "0px"); this.list.css(this.wh, "10px"); this.options.initCallback !== null && this.options.initCallback(this, "reset"); this.setup() }, reload: function() { this.tail !== null && this.inTail && this.list.css(this.lt, h.intval(this.list.css(this.lt)) + this.tail); this.tail = null; this.inTail = false; this.options.reloadCallback !== null && this.options.reloadCallback(this); if (this.options.visible !== null) { var a = this, c = Math.ceil(this.clipping() / this.options.visible), b = 0, d = 0; this.list.children("li").each(function(f) { b += a.dimension(this, c); if (f + 1 < a.first) d = b }); this.list.css(this.wh, b + "px"); this.list.css(this.lt, -d + "px") } this.scroll(this.first, false) }, lock: function() { this.locked = true; this.buttons() }, unlock: function() { this.locked = false; this.buttons() }, size: function(a) { if (a !== undefined) { this.options.size = a; this.locked || this.buttons() } return this.options.size }, has: function(a, c) { if (c === undefined || !c) c = a; if (this.options.size !== null && c > this.options.size) c = this.options.size; for (var b = a; b <= c; b++) { var d = this.get(b); if (!d.length || d.hasClass("jcarousel-item-placeholder")) return false } return true }, get: function(a) { return i(".jcarousel-item-" + a, this.list) }, add: function(a, c) { var b = this.get(a), d = 0, f = i(c); if (b.length === 0) { var j, e = h.intval(a); for (b = this.create(a); ; ) { j = this.get(--e); if (e <= 0 || j.length) { e <= 0 ? this.list.prepend(b) : j.after(b); break } } } else d = this.dimension(b); if (f.get(0).nodeName.toUpperCase() == "LI") { b.replaceWith(f); b = f } else b.empty().append(c); this.format(b.removeClass(this.className("jcarousel-item-placeholder")), a); f = this.options.visible !== null ? Math.ceil(this.clipping() / this.options.visible) : null; d = this.dimension(b, f) - d; a > 0 && a < this.first && this.list.css(this.lt, h.intval(this.list.css(this.lt)) - d + "px"); this.list.css(this.wh, h.intval(this.list.css(this.wh)) + d + "px"); return b }, remove: function(a) { var c = this.get(a); if (!(!c.length || a >= this.first && a <= this.last)) { var b = this.dimension(c); a < this.first && this.list.css(this.lt, h.intval(this.list.css(this.lt)) + b + "px"); c.remove(); this.list.css(this.wh, h.intval(this.list.css(this.wh)) - b + "px") } }, next: function() { this.tail !== null && !this.inTail ? this.scrollTail(false) : this.scroll((this.options.wrap == "both" || this.options.wrap == "last") && this.options.size !== null && this.last == this.options.size ? 1 : this.first + this.options.scroll) }, prev: function() { this.tail !== null && this.inTail ? this.scrollTail(true) : this.scroll((this.options.wrap == "both" || this.options.wrap == "first") && this.options.size !== null && this.first == 1 ? this.options.size : this.first - this.options.scroll) }, scrollTail: function(a) { if (!(this.locked || this.animating || !this.tail)) { this.pauseAuto(); var c = h.intval(this.list.css(this.lt)); c = !a ? c - this.tail : c + this.tail; this.inTail = !a; this.prevFirst = this.first; this.prevLast = this.last; this.animate(c) } }, scroll: function(a, c) { if (!(this.locked || this.animating)) { this.pauseAuto(); this.animate(this.pos(a), c) } }, pos: function(a, c) { var b = h.intval(this.list.css(this.lt)); if (this.locked || this.animating) return b; if (this.options.wrap != "circular") a = a < 1 ? 1 : this.options.size && a > this.options.size ? this.options.size : a; for (var d = this.first > a, f = this.options.wrap != "circular" && this.first <= 1 ? 1 : this.first, j = d ? this.get(f) : this.get(this.last), e = d ? f : f - 1, g = null, k = 0, l = false, m = 0; d ? --e >= a : ++e < a; ) { g = this.get(e); l = !g.length; if (g.length === 0) { g = this.create(e).addClass(this.className("jcarousel-item-placeholder")); j[d ? "before" : "after"](g); if (this.first !== null && this.options.wrap == "circular" && this.options.size !== null && (e <= 0 || e > this.options.size)) { j = this.get(this.index(e)); if (j.length) g = this.add(e, j.clone(true)) } } j = g; m = this.dimension(g); if (l) k += m; if (this.first !== null && (this.options.wrap == "circular" || e >= 1 && (this.options.size === null || e <= this.options.size))) b = d ? b + m : b - m } f = this.clipping(); var p = [], o = 0, n = 0; j = this.get(a - 1); for (e = a; ++o; ) { g = this.get(e); l = !g.length; if (g.length === 0) { g = this.create(e).addClass(this.className("jcarousel-item-placeholder")); j.length === 0 ? this.list.prepend(g) : j[d ? "before" : "after"](g); if (this.first !== null && this.options.wrap == "circular" && this.options.size !== null && (e <= 0 || e > this.options.size)) { j = this.get(this.index(e)); if (j.length) g = this.add(e, j.clone(true)) } } j = g; m = this.dimension(g); if (m === 0) throw Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting..."); if (this.options.wrap != "circular" && this.options.size !== null && e > this.options.size) p.push(g); else if (l) k += m; n += m; if (n >= f) break; e++ } for (g = 0; g < p.length; g++) p[g].remove(); if (k > 0) { this.list.css(this.wh, this.dimension(this.list) + k + "px"); if (d) { b -= k; this.list.css(this.lt, h.intval(this.list.css(this.lt)) - k + "px") } } k = a + o - 1; if (this.options.wrap != "circular" && this.options.size && k > this.options.size) k = this.options.size; if (e > k) { o = 0; e = k; for (n = 0; ++o; ) { g = this.get(e--); if (!g.length) break; n += this.dimension(g); if (n >= f) break } } e = k - o + 1; if (this.options.wrap != "circular" && e < 1) e = 1; if (this.inTail && d) { b += this.tail; this.inTail = false } this.tail = null; if (this.options.wrap != "circular" && k == this.options.size && k - o + 1 >= 1) { d = h.margin(this.get(k), !this.options.vertical ? "marginRight" : "marginBottom"); if (n - d > f) this.tail = n - f - d } if (c && a === this.options.size && this.tail) { b -= this.tail; this.inTail = true } for (; a-- > e; ) b += this.dimension(this.get(a)); this.prevFirst = this.first; this.prevLast = this.last; this.first = e; this.last = k; return b }, animate: function(a, c) { if (!(this.locked || this.animating)) { this.animating = true; var b = this, d = function() { b.animating = false; a === 0 && b.list.css(b.lt, 0); if (!b.autoStopped && (b.options.wrap == "circular" || b.options.wrap == "both" || b.options.wrap == "last" || b.options.size === null || b.last < b.options.size || b.last == b.options.size && b.tail !== null && !b.inTail)) b.startAuto(); b.buttons(); b.notify("onAfterAnimation"); if (b.options.wrap == "circular" && b.options.size !== null) for (var f = b.prevFirst; f <= b.prevLast; f++) if (f !== null && !(f >= b.first && f <= b.last) && (f < 1 || f > b.options.size)) b.remove(f) }; this.notify("onBeforeAnimation"); if (!this.options.animation || c === false) { this.list.css(this.lt, a + "px"); d() } else this.list.animate(!this.options.vertical ? this.options.rtl ? { right: a} : { left: a} : { top: a }, this.options.animation, this.options.easing, d) } }, startAuto: function(a) { if (a !== undefined) this.options.auto = a; if (this.options.auto === 0) return this.stopAuto(); if (this.timer === null) { this.autoStopped = false; var c = this; this.timer = window.setTimeout(function() { c.next() }, this.options.auto * 1E3) } }, stopAuto: function() { this.pauseAuto(); this.autoStopped = true }, pauseAuto: function() { if (this.timer !== null) { window.clearTimeout(this.timer); this.timer = null } }, buttons: function(a, c) { if (a == null) { a = !this.locked && this.options.size !== 0 && (this.options.wrap && this.options.wrap != "first" || this.options.size === null || this.last < this.options.size); if (!this.locked && (!this.options.wrap || this.options.wrap == "first") && this.options.size !== null && this.last >= this.options.size) a = this.tail !== null && !this.inTail } if (c == null) { c = !this.locked && this.options.size !== 0 && (this.options.wrap && this.options.wrap != "last" || this.first > 1); if (!this.locked && (!this.options.wrap || this.options.wrap == "last") && this.options.size !== null && this.first == 1) c = this.tail !== null && this.inTail } var b = this; if (this.buttonNext.size() > 0) { this.buttonNext.unbind(this.options.buttonNextEvent + ".jcarousel", this.funcNext); a && this.buttonNext.bind(this.options.buttonNextEvent + ".jcarousel", this.funcNext); this.buttonNext[a ? "removeClass" : "addClass"](this.className("jcarousel-next-disabled")).attr("disabled", a ? false : true); this.options.buttonNextCallback !== null && this.buttonNext.data("jcarouselstate") != a && this.buttonNext.each(function() { b.options.buttonNextCallback(b, this, a) }).data("jcarouselstate", a) } else this.options.buttonNextCallback !== null && this.buttonNextState != a && this.options.buttonNextCallback(b, null, a); if (this.buttonPrev.size() > 0) { this.buttonPrev.unbind(this.options.buttonPrevEvent + ".jcarousel", this.funcPrev); c && this.buttonPrev.bind(this.options.buttonPrevEvent + ".jcarousel", this.funcPrev); this.buttonPrev[c ? "removeClass" : "addClass"](this.className("jcarousel-prev-disabled")).attr("disabled", c ? false : true); this.options.buttonPrevCallback !== null && this.buttonPrev.data("jcarouselstate") != c && this.buttonPrev.each(function() { b.options.buttonPrevCallback(b, this, c) }).data("jcarouselstate", c) } else this.options.buttonPrevCallback !== null && this.buttonPrevState != c && this.options.buttonPrevCallback(b, null, c); this.buttonNextState = a; this.buttonPrevState = c }, notify: function(a) { var c = this.prevFirst === null ? "init" : this.prevFirst < this.first ? "next" : "prev"; this.callback("itemLoadCallback", a, c); if (this.prevFirst !== this.first) { this.callback("itemFirstInCallback", a, c, this.first); this.callback("itemFirstOutCallback", a, c, this.prevFirst) } if (this.prevLast !== this.last) { this.callback("itemLastInCallback", a, c, this.last); this.callback("itemLastOutCallback", a, c, this.prevLast) } this.callback("itemVisibleInCallback", a, c, this.first, this.last, this.prevFirst, this.prevLast); this.callback("itemVisibleOutCallback", a, c, this.prevFirst, this.prevLast, this.first, this.last) }, callback: function(a, c, b, d, f, j, e) { if (!(this.options[a] == null || typeof this.options[a] != "object" && c != "onAfterAnimation")) { var g = typeof this.options[a] == "object" ? this.options[a][c] : this.options[a]; if (i.isFunction(g)) { var k = this; if (d === undefined) g(k, b, c); else if (f === undefined) this.get(d).each(function() { g(k, this, d, b, c) }); else { a = function(m) { k.get(m).each(function() { g(k, this, m, b, c) }) }; for (var l = d; l <= f; l++) l !== null && !(l >= j && l <= e) && a(l) } } } }, create: function(a) { return this.format("<li></li>", a) }, format: function(a, c) { a = i(a); for (var b = a.get(0).className.split(" "), d = 0; d < b.length; d++) b[d].indexOf("jcarousel-") != -1 && a.removeClass(b[d]); a.addClass(this.className("jcarousel-item")).addClass(this.className("jcarousel-item-" + c)).css({ "float": this.options.rtl ? "right" : "left", "list-style": "none" }).attr("jcarouselindex", c); return a }, className: function(a) { return a + " " + a + (!this.options.vertical ? "-horizontal" : "-vertical") }, dimension: function(a, c) { var b = a.jquery !== undefined ? a[0] : a, d = !this.options.vertical ? (b.offsetWidth || h.intval(this.options.itemFallbackDimension)) + h.margin(b, "marginLeft") + h.margin(b, "marginRight") : (b.offsetHeight || h.intval(this.options.itemFallbackDimension)) + h.margin(b, "marginTop") + h.margin(b, "marginBottom"); if (c == null || d == c) return d; d = !this.options.vertical ? c - h.margin(b, "marginLeft") - h.margin(b, "marginRight") : c - h.margin(b, "marginTop") - h.margin(b, "marginBottom"); i(b).css(this.wh, d + "px"); return this.dimension(b) }, clipping: function() { return !this.options.vertical ? this.clip[0].offsetWidth - h.intval(this.clip.css("borderLeftWidth")) - h.intval(this.clip.css("borderRightWidth")) : this.clip[0].offsetHeight - h.intval(this.clip.css("borderTopWidth")) - h.intval(this.clip.css("borderBottomWidth")) }, index: function(a, c) { if (c == null) c = this.options.size; return Math.round(((a - 1) / c - Math.floor((a - 1) / c)) * c) + 1 } }); h.extend({ defaults: function(a) { return i.extend(q, a || {}) }, margin: function(a, c) { if (!a) return 0; var b = a.jquery !== undefined ? a[0] : a; if (c == "marginRight" && i.browser.safari) { var d = { display: "block", "float": "none", width: "auto" }, f, j; i.swap(b, d, function() { f = b.offsetWidth }); d.marginRight = 0; i.swap(b, d, function() { j = b.offsetWidth }); return j - f } return h.intval(i.css(b, c)) }, intval: function(a) { a = parseInt(a, 10); return isNaN(a) ? 0 : a } }); i.fn.jcarousel = function(a) { if (typeof a == "string") { var c = i(this).data("jcarousel"), b = Array.prototype.slice.call(arguments, 1); return c[a].apply(c, b) } else return this.each(function() { i(this).data("jcarousel", new h(this, a)) }) } })(jQuery);


/*
* Metadata - jQuery plugin for parsing metadata from elements
*
* Copyright (c) 2006 John Resig, Yehuda Katz, J?örn Zaefferer, Paul McLanahan
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id$
*
*/

/**
* Sets the type of metadata to use. Metadata is encoded in JSON, and each property
* in the JSON will become a property of the element itself.
*
* There are three supported types of metadata storage:
*
*   attr:  Inside an attribute. The name parameter indicates *which* attribute.
*          
*   class: Inside the class attribute, wrapped in curly braces: { }
*   
*   elem:  Inside a child element (e.g. a script tag). The
*          name parameter indicates *which* element.
*          
* The metadata for an element is loaded the first time the element is accessed via jQuery.
*
* As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
* matched by expr, then redefine the metadata type and run another $(expr) for other elements.
* 
* @name $.metadata.setType
*
* @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("class")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from the class attribute
* 
* @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("attr", "data")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a "data" attribute
* 
* @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
* @before $.metadata.setType("elem", "script")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a nested script element
* 
* @param String type The encoding type
* @param String name The name of the attribute to be used to get metadata (optional)
* @cat Plugins/Metadata
* @descr Sets the type of encoding to be used when loading metadata for the first time
* @type undefined
* @see metadata()
*/

(function($) {

    $.extend({
        metadata: {
            defaults: {
                type: 'class',
                name: 'metadata',
                cre: /({.*})/,
                single: 'metadata'
            },
            setType: function(type, name) {
                this.defaults.type = type;
                this.defaults.name = name;
            },
            get: function(elem, opts) {
                var settings = $.extend({}, this.defaults, opts);
                // check for empty string in single property
                if (!settings.single.length) settings.single = 'metadata';

                var data = $.data(elem, settings.single);
                // returned cached data if it already exists
                if (data) return data;

                data = "{}";

                if (settings.type == "class") {
                    var m = settings.cre.exec(elem.className);
                    if (m)
                        data = m[1];
                } else if (settings.type == "elem") {
                    if (!elem.getElementsByTagName) return;
                    var e = elem.getElementsByTagName(settings.name);
                    if (e.length)
                        data = $.trim(e[0].innerHTML);
                } else if (elem.getAttribute != undefined) {
                    var attr = elem.getAttribute(settings.name);
                    if (attr)
                        data = attr;
                }

                if (data.indexOf('{') < 0)
                    data = "{" + data + "}";

                data = eval("(" + data + ")");

                $.data(elem, settings.single, data);
                return data;
            }
        }
    });

    /**
    * Returns the metadata object for the first member of the jQuery object.
    *
    * @name metadata
    * @descr Returns element's metadata object
    * @param Object opts An object contianing settings to override the defaults
    * @type jQuery
    * @cat Plugins/Metadata
    */
    $.fn.metadata = function(opts) {
        return $.metadata.get(this[0], opts);
    };

})(jQuery);

/*
* jQuery Media Plugin for converting elements into rich media content.
*
* Examples and documentation at: http://malsup.com/jquery/media/
* Copyright (c) 2007-2008 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* @author: M. Alsup
* @version: 0.92 (24-SEP-2009)
* @requires jQuery v1.1.2 or later
* $Id: jquery.media.js 2460 2007-07-23 02:53:15Z malsup $
*
* Supported Media Players:
*	- Flash
*	- Quicktime
*	- Real Player
*	- Silverlight
*	- Windows Media Player
*	- iframe
*
* Supported Media Formats:
*	 Any types supported by the above players, such as:
*	 Video: asf, avi, flv, mov, mpg, mpeg, mp4, qt, smil, swf, wmv, 3g2, 3gp
*	 Audio: aif, aac, au, gsm, mid, midi, mov, mp3, m4a, snd, rm, wav, wma
*	 Other: bmp, html, pdf, psd, qif, qtif, qti, tif, tiff, xaml
*
* Thanks to Mark Hicken and Brent Pedersen for helping me debug this on the Mac!
* Thanks to Dan Rossi for numerous bug reports and code bits!
* Thanks to Skye Giordano for several great suggestions!
* Thanks to Richard Connamacher for excellent improvements to the non-IE behavior!
*/
; (function($) {

    /**
    * Chainable method for converting elements into rich media.
    *
    * @param options
    * @param callback fn invoked for each matched element before conversion
    * @param callback fn invoked for each matched element after conversion
    */
    $.fn.media = function(options, f1, f2) {
        if (options == 'undo') {
            return this.each(function() {
                var $this = $(this);
                var html = $this.data('media.origHTML');
                if (html)
                    $this.replaceWith(html);
            });
        }

        return this.each(function() {
            if (typeof options == 'function') {
                f2 = f1;
                f1 = options;
                options = {};
            }
            var o = getSettings(this, options);
            // pre-conversion callback, passes original element and fully populated options
            if (typeof f1 == 'function') f1(this, o);

            var r = getTypesRegExp();
            var m = r.exec(o.src.toLowerCase()) || [''];

            o.type ? m[0] = o.type : m.shift();
            for (var i = 0; i < m.length; i++) {
                fn = m[i].toLowerCase();
                if (isDigit(fn[0])) fn = 'fn' + fn; // fns can't begin with numbers
                if (!$.fn.media[fn])
                    continue;  // unrecognized media type
                // normalize autoplay settings
                var player = $.fn.media[fn + '_player'];
                if (!o.params) o.params = {};
                if (player) {
                    var num = player.autoplayAttr == 'autostart';
                    o.params[player.autoplayAttr || 'autoplay'] = num ? (o.autoplay ? 1 : 0) : o.autoplay ? true : false;
                }
                var $div = $.fn.media[fn](this, o);

                $div.css('backgroundColor', o.bgColor).width(o.width);

                if (o.canUndo) {
                    var $temp = $('<div></div>').append(this);
                    $div.data('media.origHTML', $temp.html()); // store original markup
                }

                // post-conversion callback, passes original element, new div element and fully populated options
                if (typeof f2 == 'function') f2(this, $div[0], o, player.name);
                break;
            }
        });
    };

    /**
    * Non-chainable method for adding or changing file format / player mapping
    * @name mapFormat
    * @param String format File format extension (ie: mov, wav, mp3)
    * @param String player Player name to use for the format (one of: flash, quicktime, realplayer, winmedia, silverlight or iframe
    */
    $.fn.media.mapFormat = function(format, player) {
        if (!format || !player || !$.fn.media.defaults.players[player]) return; // invalid
        format = format.toLowerCase();
        if (isDigit(format[0])) format = 'fn' + format;
        $.fn.media[format] = $.fn.media[player];
        $.fn.media[format + '_player'] = $.fn.media.defaults.players[player];
    };

    // global defautls; override as needed
    $.fn.media.defaults = {
        standards: false,      // use object tags only (no embeds for non-IE browsers)
        canUndo: true,       // tells plugin to store the original markup so it can be reverted via: $(sel).mediaUndo()
        width: 575,
        height: 330,
        autoplay: 0, 	   	// normalized cross-player setting
        bgColor: '#ffffff', 	// background color
        params: { wmode: 'transparent', allowfullscreen: 'true' }, // added to object element as param elements; added to embed element as attrs
        attrs: {}, 		// added to object and embed elements as attrs
        flvKeyName: 'file', 	// key used for object src param (thanks to Andrea Ercolino)
        flashvars: { stretching: 'exactfit' }, 		// added to flash content as flashvars param/attr
        flashVersion: '7', // required flash version
        expressInstaller: null, // src for express installer

        // default flash video and mp3 player (@see: http://jeroenwijering.com/?item=Flash_Media_Player)
        flvPlayer: '/DesktopModules/IDGL_Home/swfs/mediaplayer55.swf',
        mp3Player: '/DesktopModules/IDGL_Home/swfs/mediaplayer55.swf',
        // @see http://msdn2.microsoft.com/en-us/library/bb412401.aspx
        silverlight: {
            inplaceInstallPrompt: 'true', // display in-place install prompt?
            isWindowless: 'true', // windowless mode (false for wrapping markup)
            framerate: '24',   // maximum framerate
            version: '0.9',  // Silverlight version
            onError: null,   // onError callback
            onLoad: null,   // onLoad callback
            initParams: null,   // object init params
            userContext: null	  // callback arg passed to the load callback
        }
    };

    // Media Players; think twice before overriding
    $.fn.media.defaults.players = {
        flash: {
            name: 'flash',
            title: 'Flash',
            types: 'mp3,swf,flv',
            mimetype: 'application/x-shockwave-flash',
            pluginspage: 'http://www.adobe.com/go/getflashplayer',
            ieAttrs: {
                classid: 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
                type: 'application/x-oleobject',
                codebase: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + $.fn.media.defaults.flashVersion
            }
        },
        quicktime: {
            name: 'quicktime',
            title: 'QuickTime',
            mimetype: 'video/quicktime',
            pluginspage: 'http://www.apple.com/quicktime/download/',
            types: 'aif,aiff,aac,au,bmp,gsm,mov,mid,midi,mpg,mpeg,mp4,m4a,psd,qt,qtif,qif,qti,snd,tif,tiff,wav,3g2,3gp',
            ieAttrs: {
                classid: 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
                codebase: 'http://www.apple.com/qtactivex/qtplugin.cab'
            }
        },
        realplayer: {
            name: 'real',
            title: 'RealPlayer',
            types: 'ra,ram,rm,rpm,rv,smi,smil',
            mimetype: 'audio/x-pn-realaudio-plugin',
            pluginspage: 'http://www.real.com/player/',
            autoplayAttr: 'autostart',
            ieAttrs: {
                classid: 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'
            }
        },
        winmedia: {
            name: 'winmedia',
            title: 'Windows Media',
            types: 'asx,asf,avi,wma,wmv',
            mimetype: $.browser.mozilla && isFirefoxWMPPluginInstalled() ? 'application/x-ms-wmp' : 'application/x-mplayer2',
            pluginspage: 'http://www.microsoft.com/Windows/MediaPlayer/',
            autoplayAttr: 'autostart',
            oUrl: 'url',
            ieAttrs: {
                classid: 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6',
                type: 'application/x-oleobject'
            }
        },
        // special cases
        iframe: {
            name: 'iframe',
            types: 'html,pdf'
        },
        silverlight: {
            name: 'silverlight',
            types: 'xaml'
        }
    };

    //
    //	everything below here is private
    //


    // detection script for FF WMP plugin (http://www.therossman.org/experiments/wmp_play.html)
    // (hat tip to Mark Ross for this script)
    function isFirefoxWMPPluginInstalled() {
        var plugs = navigator.plugins;
        for (i = 0; i < plugs.length; i++) {
            var plugin = plugs[i];
            if (plugin['filename'] == 'np-mswmp.dll')
                return true;
        }
        return false;
    }

    var counter = 1;

    for (var player in $.fn.media.defaults.players) {
        var types = $.fn.media.defaults.players[player].types;
        $.each(types.split(','), function(i, o) {
            if (isDigit(o[0])) o = 'fn' + o;
            $.fn.media[o] = $.fn.media[player] = getGenerator(player);
            $.fn.media[o + '_player'] = $.fn.media.defaults.players[player];
        });
    };

    function getTypesRegExp() {
        var types = '';
        for (var player in $.fn.media.defaults.players) {
            if (types.length) types += ',';
            types += $.fn.media.defaults.players[player].types;
        };
        return new RegExp('\\.(' + types.replace(/,/ig, '|') + ')\\b');
    };

    function getGenerator(player) {
        return function(el, options) {
            return generate(el, options, player);
        };
    };

    function isDigit(c) {
        return '0123456789'.indexOf(c) > -1;
    };

    // flatten all possible options: global defaults, meta, option obj
    function getSettings(el, options) {
        options = options || {};
        var $el = $(el);
        var cls = el.className || '';
        // support metadata plugin (v1.0 and v2.0)
        var meta = $.metadata ? $el.metadata() : $.meta ? $el.data() : {};
        meta = meta || {};
        var w = meta.width || parseInt(((cls.match(/w:(\d+)/) || [])[1] || 0));
        var h = meta.height || parseInt(((cls.match(/h:(\d+)/) || [])[1] || 0));

        if (w) meta.width = w;
        if (h) meta.height = h;
        if (cls) meta.cls = cls;

        var a = $.fn.media.defaults;
        var b = options;
        var c = meta;

        var p = { params: { bgColor: options.bgColor || $.fn.media.defaults.bgColor} };
        var opts = $.extend({}, a, b, c);
        $.each(['attrs', 'params', 'flashvars', 'silverlight'], function(i, o) {
            opts[o] = $.extend({}, p[o] || {}, a[o] || {}, b[o] || {}, c[o] || {});
        });

        if (typeof opts.caption == 'undefined') opts.caption = $el.text();

        // make sure we have a source!
        opts.src = opts.src || $el.attr('href') || $el.attr('src') || 'unknown';
        return opts;
    };

    //
    //	Flash Player
    //

    // generate flash using SWFObject library if possible
    $.fn.media.swf = function(el, opts) {
        if (!window.SWFObject && !window.swfobject) {
            // roll our own
            if (opts.flashvars) {
                var a = [];
                for (var f in opts.flashvars)
                    a.push(f + '=' + opts.flashvars[f]);
                if (!opts.params) opts.params = {};
                opts.params.flashvars = a.join('&');
            }
            return generate(el, opts, 'flash');
        }

        var id = el.id ? (' id="' + el.id + '"') : '';
        var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
        var $div = $('<div' + id + cls + '>');

        // swfobject v2+
        if (window.swfobject) {
            $(el).after($div).appendTo($div);
            if (!el.id) el.id = 'movie_player_' + counter++;

            // replace el with swfobject content
            swfobject.embedSWF(opts.src, el.id, opts.width, opts.height, opts.flashVersion,
			opts.expressInstaller, opts.flashvars, opts.params, opts.attrs);
        }
        // swfobject < v2
        else {
            $(el).after($div).remove();
            var so = new SWFObject(opts.src, 'movie_player_' + counter++, opts.width, opts.height, opts.flashVersion, opts.bgColor);
            if (opts.expressInstaller) so.useExpressInstall(opts.expressInstaller);

            for (var p in opts.params)
                if (p != 'bgColor') so.addParam(p, opts.params[p]);
            for (var f in opts.flashvars)
                so.addVariable(f, opts.flashvars[f]);
            so.write($div[0]);
        }

        if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
        return $div;
    };

    // map flv and mp3 files to the swf player by default 
    $.fn.media.mp3 = function(el, opts) {
        var src = opts.src;
        var player = /\.mp3\b/i.test(src) ? $.fn.media.defaults.mp3Player : $.fn.media.defaults.flvPlayer;
        var key = opts.flvKeyName;
        src = encodeURIComponent(src);
        opts.src = player;
        opts.src = opts.src + '?' + key + '=' + (src);
        var srcObj = {};
        srcObj[key] = src;
        opts.flashvars = $.extend({}, srcObj, opts.flashvars);
        return $.fn.media.swf(el, opts);
    };

    $.fn.media.flv  = function(el, opts) {
        var src = opts.src;
        var player =  $.fn.media.defaults.flvPlayer;
        var key = opts.flvKeyName;
        opts.src = player;
        opts.src = opts.src + '?' + key + '=' + (src);
        var srcObj = {};
        srcObj[key] = src;
        opts.flashvars = $.extend({}, srcObj, opts.flashvars);
        return $.fn.media.swf(el, opts);
    };

    //
    //	Silverlight
    //
    $.fn.media.xaml = function(el, opts) {
        if (!window.Sys || !window.Sys.Silverlight) {
            if ($.fn.media.xaml.warning) return;
            $.fn.media.xaml.warning = 1;
            alert('You must include the Silverlight.js script.');
            return;
        }

        var props = {
            width: opts.width,
            height: opts.height,
            background: opts.bgColor,
            inplaceInstallPrompt: opts.silverlight.inplaceInstallPrompt,
            isWindowless: opts.silverlight.isWindowless,
            framerate: opts.silverlight.framerate,
            version: opts.silverlight.version
        };
        var events = {
            onError: opts.silverlight.onError,
            onLoad: opts.silverlight.onLoad
        };

        var id1 = el.id ? (' id="' + el.id + '"') : '';
        var id2 = opts.id || 'AG' + counter++;
        // convert element to div
        var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
        var $div = $('<div' + id1 + cls + '>');
        $(el).after($div).remove();

        Sys.Silverlight.createObjectEx({
            source: opts.src,
            initParams: opts.silverlight.initParams,
            userContext: opts.silverlight.userContext,
            id: id2,
            parentElement: $div[0],
            properties: props,
            events: events
        });

        if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
        return $div;
    };

    //
    // generate object/embed markup
    //
    function generate(el, opts, player) {
        var $el = $(el);
        var o = $.fn.media.defaults.players[player];

        if (player == 'iframe') {
            var o = $('<iframe' + ' width="' + opts.width + '" height="' + opts.height + '" >');
            o.attr('src', opts.src);
            o.css('backgroundColor', o.bgColor);
        }
        else if ($.browser.msie) {
            var a = ['<object width="' + opts.width + '" height="' + opts.height + '" '];
            for (var key in opts.attrs)
                a.push(key + '="' + opts.attrs[key] + '" ');
            for (var key in o.ieAttrs || {}) {
                var v = o.ieAttrs[key];
                if (key == 'codebase' && window.location.protocol == 'https:')
                    v = v.replace('http', 'https');
                a.push(key + '="' + v + '" ');
            }
            a.push('></ob' + 'ject' + '>');
            var p = ['<param name="' + (o.oUrl || 'src') + '" value="' + opts.src + '">'];
            for (var key in opts.params)
                p.push('<param name="' + key + '" value="' + opts.params[key] + '">');
            var o = document.createElement(a.join(''));
            for (var i = 0; i < p.length; i++)
                o.appendChild(document.createElement(p[i]));
        }
        else if (o.standards) {
            // Rewritten to be standards compliant by Richard Connamacher
            var a = ['<object type="' + o.mimetype + '" width="' + opts.width + '" height="' + opts.height + '"'];
            if (opts.src) a.push(' data="' + opts.src + '" ');
            a.push('>');
            a.push('<param name="' + (o.oUrl || 'src') + '" value="' + opts.src + '">');
            for (var key in opts.params) {
                if (key == 'wmode' && player != 'flash') // FF3/Quicktime borks on wmode
                    continue;
                a.push('<param name="' + key + '" value="' + opts.params[key] + '">');
            }
            // Alternate HTML
            a.push('<div><p><strong>' + o.title + ' Required</strong></p><p>' + o.title + ' is required to view this media. <a href="' + o.pluginspage + '">Download Here</a>.</p></div>');
            a.push('</ob' + 'ject' + '>');
        }
        else {
            var a = ['<embed width="' + opts.width + '" height="' + opts.height + '" style="display:block"'];
            if (opts.src) a.push(' src="' + opts.src + '" ');
            for (var key in opts.attrs)
                a.push(key + '="' + opts.attrs[key] + '" ');
            for (var key in o.eAttrs || {})
                a.push(key + '="' + o.eAttrs[key] + '" ');
            for (var key in opts.params) {
                if (key == 'wmode' && player != 'flash') // FF3/Quicktime borks on wmode
                    continue;
                a.push(key + '="' + opts.params[key] + '" ');
            }
            a.push('></em' + 'bed' + '>');
        }
        // convert element to div
        var id = el.id ? (' id="' + el.id + '"') : '';
        var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
        var $div = $('<div' + id + cls + '>');
        $el.after($div).remove();
        ($.browser.msie || player == 'iframe') ? $div.append(o) : $div.html(a.join(''));
        if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
        return $div;
    };


})(jQuery);



$(document).ready(function() {
    tab_videos();

    $("#tabs").tabs({

        select: function(event, ui) {

            var selected = parseInt(ui.index) + 1;

            if (selected == 1) {
                var colortab = 'A01C21';
            }
            if (selected == 2) {
                var colortab = '799435';
            }
            if (selected == 3) {
                var colortab = '355689';
            }
            if (selected == 4) {
                var colortab = 'D57920';
            }
            if (selected == 5) {
                var colortab = '4C539C';
            }
            if (selected == 6) {
                var colortab = 'A41D22';
            }

            var principal = "#tabs_" + selected + "_1";
            var contenido = $(principal).html();
            var img_principal = principal + " .img_home";

            var background = $(img_principal).attr('src');
            $(img_principal).css('display', 'none');
            $('#front_main').css({ 'border': '1px #' + colortab + ' solid' });
            $('.ui-tabs .ui-tabs-nav li').css({ 'background': '#FFFFFF url(/DesktopModules/IDGL_Home/images/bg_tab.png) top left no-repeat' });
            $('.ui-state-focus').css({ 'background': '#' + colortab + ' url(/DesktopModules/IDGL_Home/images/bg_tabselected.png) top left no-repeat' });
            $('.ui-tabs .ui-tabs-panel').css({ 'border': '4px #' + colortab + ' solid' });
            $('.colorlink').css({ 'color': '#' + colortab + '' });
            $('.span-arrow').html('<img src="/DesktopModules/IDGL_Home/images/arrow_' + colortab + '.png" border="0" />');

            if (selected == 1) {
                $('#front_main').css({ 'background': '#E1E1E1' });
                tab_videos();

            } else {
                options = {};
                $('#front_main').html('<div id="front_img"><div id="front_text" class="ui-corner-all" style="background: url(/DesktopModules/IDGL_Home/images/bg_text_' + colortab + '.png) no-repeat top left;">' + contenido + '</div></div>').effect("slide", options, 500);
                $('#front_main div h2 a').css({ 'color': '#' + colortab + '', 'font-size': '26px', 'font-weight': 'normal', 'font-family': 'Arial, Sans-serif' });
                $('#front_text .colorlink').css({ 'color': '#' + colortab + '' });
                $('#front_text .span-arrow').html('<img src="/DesktopModules/IDGL_Home/images/arrow_' + colortab + '.png" border="0" />');
                $('#front_img').css({ 'background': '#E6E6E6 url(' + background + ') top left no-repeat' });

            }



        }

    });

    $('.ui-tabs .ui-tabs-nav li').css({ 'background': '#FFFFFF url(/DesktopModules/IDGL_Home/images/bg_tab.png) top left no-repeat' });
    $('.ui-state-focus').css({ 'background': '#A01C21 url(/DesktopModules/IDGL_Home/images/bg_tabselected.png) top left no-repeat' });
    $('.ui-tabs .ui-tabs-panel').css({ 'border': '4px #A01C21 solid' });
    $('.ui-tabs-nav').css({ 'background': '#FFF' });
    $('.colorlink').css({ 'color': '#A01C21' });
    $('.span-arrow').html('<img src="/DesktopModules/IDGL_Home/images/arrow_A01C21.png" border="0" />');



});

function tab_videos() {

    $('#front_main').html('');
    $('<div id="player" ></div>').appendTo('#front_main');
    $('<ul id="list_items" class="jcarousel jcarousel-skin-tango" ></ul>').appendTo('#front_main');

    $.ajax({
        type: "GET",
        url: "/videos.xml",
        dataType: "xml",
        success: function(xml) {
            $(xml).find('video').each(function() {
                var id = $(this).find('id').text();
                var title = $(this).find('title').text();
                var description = $(this).find('description').text();
                var imagefilename = $(this).find('imageFileName').text();
                var url = $(this).find('fileName').text();
                var position = $(this).find('position').text();
                //var obj=$(this);
                $('<li class="items ui-corner-all" id="' + id + '"></li>').html('<img src="' + imagefilename + '" width="90" height="50" /><h3>' + title + '</h3><p>' + description + '</p>').appendTo('#list_items');
                if (position == 1) {
                    selected_video(id);
                }

            });


            jQuery('#list_items').jcarousel({
                vertical: true,
                scroll: 2
            });
            $(".items").click(function() {
                //alert($(this).attr('id'));
                selected_video($(this).attr('id'));
            });
            $(".items").mouseover(function() {
                $(this).css({ 'background': '#FFFFFF', 'cursor': 'pointer' });
            });
            $(".items").mouseout(function() {
                $(this).css({ 'background': '#CCCCCC' });
            });
        }
    });

}

function selected_video(id_video) {

    //var ruta="/id:contains('"+id_video+"')/..";
    var ruta = "video";
    $.ajax({
        type: "GET",
        url: "/videos.xml",
        dataType: "xml",
        success: function(xml) {
            $(xml).find(ruta).each(function() {

                var id = $(this).find('id').text();
                if (id_video == id) {

                    var title = $(this).find('title').text();
                    var description = $(this).find('description').text();
                    var imagefilename = $(this).find('imageFileName').text();
                    var url = $(this).find('fileName').text();
                    var position = $(this).find('position').text();
                    var ext = url.substring(url.lastIndexOf(".") + 1);

                    if (ext == "flv") {
                        //$('#player').html('<embed width="575" height="330" src="/DesktopModules/IDGL_Home/swfs/mediaplayer55.swf?file=' + url + '&image=' + imagefilename + '" style="display: block;" flashvars="autostart=false&repeat=false&shuffle=false&displayclick=none" autoplay="true" allowfullscreen="false" wmode="transparent" bgcolor="#ffffff"/>');
                        //$('#player').html('<a class="media {width:575, height:330}" href="/DesktopModules/IDGL_Home/swfs/mediaplayer55.swf?file=' + url + '&image=' + imagefilename + '" ></a>');
                        $('#player').html('<a class="media {width:575, height:330}" href="' + url + '&image=' + imagefilename + '" ></a>');
                        //$('#player').html('<a class="media {width:575, height:330}" href="' + url + '&amp;imagefilename=' + imagefilename + '" ></a>');
                        $('.media').media();
                    } else {
                        if (ext == "aspx") {
                            $('#player').html('<div class="preview_video ui-corner-all" style="background: #FFFFFF url(' + imagefilename + ') no-repeat center center" ><div class="preview_description" >' + title + '</div><div class="preview_title" style="width:500px" >' + description + '<a target="_self" class="button_play" href="' + url + '">&nbsp;</a></div></div>');
                        } else {
                            $('#player').html('<div class="preview_video ui-corner-all" style="background: #FFFFFF url(' + imagefilename + ') no-repeat center center" ><div class="preview_description">' + title + '</div><div class="preview_title">' + description + '<a target="_blank" class="button_play" href="' + url + '">&nbsp;</a></div></div>');
                        }
                    }
                }

            });
        }
    });





}

