/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* $LastChangedDate: 2007-06-19 20:25:28 -0500 (Tue, 19 Jun 2007) $
* $Rev: 2111 $
*
* Version 2.1
*/
(function($) { $.fn.bgIframe = $.fn.bgiframe = function(s) { if ($.browser.msie && parseInt($.browser.version) <= 6) { s = $.extend({ top: 'auto', left: 'auto', width: 'auto', height: 'auto', opacity: true, src: 'javascript:false;' }, s || {}); var prop = function(n) { return n && n.constructor == Number ? n + 'px' : n; }, html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' + 'style="display:block;position:absolute;z-index:-1;' + (s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') + 'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : prop(s.top)) + ';' + 'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : prop(s.left)) + ';' + 'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : prop(s.width)) + ';' + 'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' + '"/>'; return this.each(function() { if ($('> iframe.bgiframe', this).length == 0) this.insertBefore(document.createElement(html), this.firstChild); }); } return this; }; if (!$.browser.version) $.browser.version = navigator.userAgent.toLowerCase().match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)[1]; })(jQuery);


/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) { $.fn.hoverIntent = function(f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function(ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } }; var delay = function(ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function(e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function() { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function() { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);


/*
* Superfish v1.4.8 - jQuery menu widget
* Copyright (c) 2008 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
* 	http://www.opensource.org/licenses/mit-license.php
* 	http://www.gnu.org/licenses/gpl.html
*
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
*/
; (function($) {
    $.fn.superfish = function(op) { var sf = $.fn.superfish, c = sf.c, $arrow = $(['<span class="', c.arrowClass, '"> &#187;</span>'].join('')), over = function() { var $$ = $(this), menu = getMenu($$); clearTimeout(menu.sfTimer); $$.showSuperfishUl().siblings().hideSuperfishUl(); }, out = function() { var $$ = $(this), menu = getMenu($$), o = sf.op; clearTimeout(menu.sfTimer); menu.sfTimer = setTimeout(function() { o.retainPath = ($.inArray($$[0], o.$path) > -1); $$.hideSuperfishUl(); if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) { over.call(o.$path); } }, o.delay); }, getMenu = function($menu) { var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0]; sf.op = sf.o[menu.serial]; return menu; }, addArrow = function($a) { $a.addClass(c.anchorClass).append($arrow.clone()); }; return this.each(function() { var s = this.serial = sf.o.length; var o = $.extend({}, sf.defaults, op); o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function() { $(this).addClass([o.hoverClass, c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass); }); sf.o[s] = sf.op = o; $('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over, out).each(function() { if (o.autoArrows) addArrow($('>a:first-child', this)); }).not('.' + c.bcClass).hideSuperfishUl(); var $a = $('a', this); $a.each(function(i) { var $li = $a.eq(i).parents('li'); $a.eq(i).focus(function() { over.call($li); }).blur(function() { out.call($li); }); }); o.onInit.call(this); }).each(function() { var menuClasses = [c.menuClass]; if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass); $(this).addClass(menuClasses.join(' ')); }); }; var sf = $.fn.superfish; sf.o = []; sf.op = {}; sf.IE7fix = function() {
        var o = sf.op; if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined)
            this.toggleClass(sf.c.shadowClass + '-off');
    }; sf.c = { bcClass: 'sf-breadcrumb', menuClass: 'sf-js-enabled', anchorClass: 'sf-with-ul', arrowClass: 'sf-sub-indicator', shadowClass: 'sf-shadow' }; sf.defaults = { hoverClass: 'sfHover', pathClass: 'overideThisToUse', pathLevels: 1, delay: 800, animation: { opacity: 'show' }, speed: 'normal', autoArrows: true, dropShadows: true, disableHI: false, onInit: function() { }, onBeforeShow: function() { }, onShow: function() { }, onHide: function() { } }; $.fn.extend({ hideSuperfishUl: function() { var o = sf.op, not = (o.retainPath === true) ? o.$path : ''; o.retainPath = false; var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility', 'hidden'); o.onHide.call($ul); return this; }, showSuperfishUl: function() { var o = sf.op, sh = sf.c.shadowClass + '-off', $ul = this.addClass(o.hoverClass).find('>ul:hidden').css('visibility', 'visible'); sf.IE7fix.call($ul); o.onBeforeShow.call($ul); $ul.animate(o.animation, o.speed, function() { sf.IE7fix.call($ul); o.onShow.call($ul); }); return this; } });
})(jQuery);

/*
* Supersubs v0.2b - jQuery plugin
* Copyright (c) 2008 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
* 	http://www.opensource.org/licenses/mit-license.php
* 	http://www.gnu.org/licenses/gpl.html
*
*
* This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
* their longest list item children. If you use this, please expect bugs and report them
* to the jQuery Google Group with the word 'Superfish' in the subject line.
*
*/
; (function($) {
    $.fn.supersubs = function(options) {
        var opts = $.extend({}, $.fn.supersubs.defaults, options); return this.each(function() {
            var $$ = $(this); var o = $.meta ? $.extend({}, opts, $$.data()) : opts; var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({ 'padding': 0, 'position': 'absolute', 'top': '-999em', 'width': 'auto' }).appendTo($$).width(); $('#menu-fontsize').remove(); $ULs = $$.find('ul'); $ULs.each(function(i) {
                var $ul = $ULs.eq(i); var $LIs = $ul.children(); var $As = $LIs.children('a'); var liFloat = $LIs.css('white-space', 'nowrap').css('float'); var emWidth = $ul.add($LIs).add($As).css({ 'float': 'none', 'width': 'auto' }).end().end()[0].clientWidth / fontsize; emWidth += o.extraWidth; if (emWidth > o.maxWidth) { emWidth = o.maxWidth; }
                else if (emWidth < o.minWidth) { emWidth = o.minWidth; }
                emWidth += 'em'; $ul.css('width', emWidth); $LIs.css({ 'float': liFloat, 'width': '100%', 'white-space': 'normal' }).each(function() { var $childUl = $('>ul', this); var offsetDirection = $childUl.css('left') !== undefined ? 'left' : 'right'; $childUl.css(offsetDirection, emWidth); });
            });
        });
    }; $.fn.supersubs.defaults = { minWidth: 9, maxWidth: 25, extraWidth: 0 };
})(jQuery);

// 
//  jquery.preloadImages.js
//  html+css
//  
//  Created by Rafael Vega on 2010-02-09.
//  Copyright 2010 Studiocom. All rights reserved.
// 
//  Usage: 
//
//  $.preloadImages(['path/to/img1.jpg','path/to/img2.jpg']);
(function($) { $.preloadImages = function(imagesArray) { for (var i = 0; i < imagesArray.length; i++) { var img = $('<img />').attr('src', imagesArray[i]); } }; })(jQuery);

/*
* jQuery validation plug-in 1.6
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
* Copyright (c) 2006 - 2008 Jörn Zaefferer
*
* $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*/
(function($) {
    $.extend($.fn, { validate: function(options) { if (!this.length) { options && options.debug && window.console && console.warn("nothing selected, can't validate, returning nothing"); return; } var validator = $.data(this[0], 'validator'); if (validator) { return validator; } validator = new $.validator(options, this[0]); $.data(this[0], 'validator', validator); if (validator.settings.onsubmit) { this.find("input, button").filter(".cancel").click(function() { validator.cancelSubmit = true; }); if (validator.settings.submitHandler) { this.find("input, button").filter(":submit").click(function() { validator.submitButton = this; }); } this.submit(function(event) { if (validator.settings.debug) event.preventDefault(); function handle() { if (validator.settings.submitHandler) { if (validator.submitButton) { var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm); } validator.settings.submitHandler.call(validator, validator.currentForm); if (validator.submitButton) { hidden.remove(); } return false; } return true; } if (validator.cancelSubmit) { validator.cancelSubmit = false; return handle(); } if (validator.form()) { if (validator.pendingRequest) { validator.formSubmitted = true; return false; } return handle(); } else { validator.focusInvalid(); return false; } }); } return validator; }, valid: function() { if ($(this[0]).is('form')) { return this.validate().form(); } else { var valid = true; var validator = $(this[0].form).validate(); this.each(function() { valid &= validator.element(this); }); return valid; } }, removeAttrs: function(attributes) { var result = {}, $element = this; $.each(attributes.split(/\s/), function(index, value) { result[value] = $element.attr(value); $element.removeAttr(value); }); return result; }, rules: function(command, argument) { var element = this[0]; if (command) { var settings = $.data(element.form, 'validator').settings; var staticRules = settings.rules; var existingRules = $.validator.staticRules(element); switch (command) { case "add": $.extend(existingRules, $.validator.normalizeRule(argument)); staticRules[element.name] = existingRules; if (argument.messages) settings.messages[element.name] = $.extend(settings.messages[element.name], argument.messages); break; case "remove": if (!argument) { delete staticRules[element.name]; return existingRules; } var filtered = {}; $.each(argument.split(/\s/), function(index, method) { filtered[method] = existingRules[method]; delete existingRules[method]; }); return filtered; } } var data = $.validator.normalizeRules($.extend({}, $.validator.metadataRules(element), $.validator.classRules(element), $.validator.attributeRules(element), $.validator.staticRules(element)), element); if (data.required) { var param = data.required; delete data.required; data = $.extend({ required: param }, data); } return data; } }); $.extend($.expr[":"], { blank: function(a) { return !$.trim("" + a.value); }, filled: function(a) { return !!$.trim("" + a.value); }, unchecked: function(a) { return !a.checked; } }); $.validator = function(options, form) { this.settings = $.extend({}, $.validator.defaults, options); this.currentForm = form; this.init(); }; $.validator.format = function(source, params) { if (arguments.length == 1) return function() { var args = $.makeArray(arguments); args.unshift(source); return $.validator.format.apply(this, args); }; if (arguments.length > 2 && params.constructor != Array) { params = $.makeArray(arguments).slice(1); } if (params.constructor != Array) { params = [params]; } $.each(params, function(i, n) { source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n); }); return source; }; $.extend($.validator, { defaults: { messages: {}, groups: {}, rules: {}, errorClass: "error", validClass: "valid", errorElement: "label", focusInvalid: true, errorContainer: $([]), errorLabelContainer: $([]), onsubmit: true, ignore: [], ignoreTitle: false, onfocusin: function(element) { this.lastActive = element; if (this.settings.focusCleanup && !this.blockFocusCleanup) { this.settings.unhighlight && this.settings.unhighlight.call(this, element, this.settings.errorClass, this.settings.validClass); this.errorsFor(element).hide(); } }, onfocusout: function(element) { if (!this.checkable(element) && (element.name in this.submitted || !this.optional(element))) { this.element(element); } }, onkeyup: function(element) { if (element.name in this.submitted || element == this.lastElement) { this.element(element); } }, onclick: function(element) { if (element.name in this.submitted) this.element(element); else if (element.parentNode.name in this.submitted) this.element(element.parentNode) }, highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); } }, setDefaults: function(settings) { $.extend($.validator.defaults, settings); }, messages: { required: "This field is required.", remote: "Please fix this field.", email: "Please enter a valid email address.", url: "Please enter a valid URL.", date: "Please enter a valid date.", dateISO: "Please enter a valid date (ISO).", number: "Please enter a valid number.", digits: "Please enter only digits.", creditcard: "Please enter a valid credit card number.", equalTo: "Please enter the same value again.", accept: "Please enter a value with a valid extension.", maxlength: $.validator.format("Please enter no more than {0} characters."), minlength: $.validator.format("Please enter at least {0} characters."), rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."), range: $.validator.format("Please enter a value between {0} and {1}."), max: $.validator.format("Please enter a value less than or equal to {0}."), min: $.validator.format("Please enter a value greater than or equal to {0}.") }, autoCreateRanges: false, prototype: { init: function() { this.labelContainer = $(this.settings.errorLabelContainer); this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm); this.containers = $(this.settings.errorContainer).add(this.settings.errorLabelContainer); this.submitted = {}; this.valueCache = {}; this.pendingRequest = 0; this.pending = {}; this.invalid = {}; this.reset(); var groups = (this.groups = {}); $.each(this.settings.groups, function(key, value) { $.each(value.split(/\s/), function(index, name) { groups[name] = key; }); }); var rules = this.settings.rules; $.each(rules, function(key, value) { rules[key] = $.validator.normalizeRule(value); }); function delegate(event) { var validator = $.data(this[0].form, "validator"); validator.settings["on" + event.type] && validator.settings["on" + event.type].call(validator, this[0]); } $(this.currentForm).delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", delegate).delegate("click", ":radio, :checkbox, select, option", delegate); if (this.settings.invalidHandler) $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler); }, form: function() { this.checkForm(); $.extend(this.submitted, this.errorMap); this.invalid = $.extend({}, this.errorMap); if (!this.valid()) $(this.currentForm).triggerHandler("invalid-form", [this]); this.showErrors(); return this.valid(); }, checkForm: function() { this.prepareForm(); for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) { this.check(elements[i]); } return this.valid(); }, element: function(element) { element = this.clean(element); this.lastElement = element; this.prepareElement(element); this.currentElements = $(element); var result = this.check(element); if (result) { delete this.invalid[element.name]; } else { this.invalid[element.name] = true; } if (!this.numberOfInvalids()) { this.toHide = this.toHide.add(this.containers); } this.showErrors(); return result; }, showErrors: function(errors) { if (errors) { $.extend(this.errorMap, errors); this.errorList = []; for (var name in errors) { this.errorList.push({ message: errors[name], element: this.findByName(name)[0] }); } this.successList = $.grep(this.successList, function(element) { return !(element.name in errors); }); } this.settings.showErrors ? this.settings.showErrors.call(this, this.errorMap, this.errorList) : this.defaultShowErrors(); }, resetForm: function() { if ($.fn.resetForm) $(this.currentForm).resetForm(); this.submitted = {}; this.prepareForm(); this.hideErrors(); this.elements().removeClass(this.settings.errorClass); }, numberOfInvalids: function() { return this.objectLength(this.invalid); }, objectLength: function(obj) { var count = 0; for (var i in obj) count++; return count; }, hideErrors: function() { this.addWrapper(this.toHide).hide(); }, valid: function() { return this.size() == 0; }, size: function() { return this.errorList.length; }, focusInvalid: function() { if (this.settings.focusInvalid) { try { $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus(); } catch (e) { } } }, findLastActive: function() { var lastActive = this.lastActive; return lastActive && $.grep(this.errorList, function(n) { return n.element.name == lastActive.name; }).length == 1 && lastActive; }, elements: function() { var validator = this, rulesCache = {}; return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function() { !this.name && validator.settings.debug && window.console && console.error("%o has no name assigned", this); if (this.name in rulesCache || !validator.objectLength($(this).rules())) return false; rulesCache[this.name] = true; return true; }); }, clean: function(selector) { return $(selector)[0]; }, errors: function() { return $(this.settings.errorElement + "." + this.settings.errorClass, this.errorContext); }, reset: function() { this.successList = []; this.errorList = []; this.errorMap = {}; this.toShow = $([]); this.toHide = $([]); this.currentElements = $([]); }, prepareForm: function() { this.reset(); this.toHide = this.errors().add(this.containers); }, prepareElement: function(element) { this.reset(); this.toHide = this.errorsFor(element); }, check: function(element) {
        element = this.clean(element); if (this.checkable(element)) { element = this.findByName(element.name)[0]; } var rules = $(element).rules(); var dependencyMismatch = false; for (method in rules) {
            var rule = { method: method, parameters: rules[method] }; try { var result = $.validator.methods[method].call(this, element.value.replace(/\r/g, ""), element, rule.parameters); if (result == "dependency-mismatch") { dependencyMismatch = true; continue; } dependencyMismatch = false; if (result == "pending") { this.toHide = this.toHide.not(this.errorsFor(element)); return; } if (!result) { this.formatAndAdd(element, rule); return false; } } catch (e) {
                this.settings.debug && window.console && console.log("exception occured when checking element " + element.id
+ ", check the '" + rule.method + "' method", e); throw e;
            } 
        } if (dependencyMismatch) return; if (this.objectLength(rules)) this.successList.push(element); return true;
    }, customMetaMessage: function(element, method) { if (!$.metadata) return; var meta = this.settings.meta ? $(element).metadata()[this.settings.meta] : $(element).metadata(); return meta && meta.messages && meta.messages[method]; }, customMessage: function(name, method) { var m = this.settings.messages[name]; return m && (m.constructor == String ? m : m[method]); }, findDefined: function() { for (var i = 0; i < arguments.length; i++) { if (arguments[i] !== undefined) return arguments[i]; } return undefined; }, defaultMessage: function(element, method) { return this.findDefined(this.customMessage(element.name, method), this.customMetaMessage(element, method), !this.settings.ignoreTitle && element.title || undefined, $.validator.messages[method], "<strong>Warning: No message defined for " + element.name + "</strong>"); }, formatAndAdd: function(element, rule) { var message = this.defaultMessage(element, rule.method), theregex = /\$?\{(\d+)\}/g; if (typeof message == "function") { message = message.call(this, rule.parameters, element); } else if (theregex.test(message)) { message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters); } this.errorList.push({ message: message, element: element }); this.errorMap[element.name] = message; this.submitted[element.name] = message; }, addWrapper: function(toToggle) { if (this.settings.wrapper) toToggle = toToggle.add(toToggle.parent(this.settings.wrapper)); return toToggle; }, defaultShowErrors: function() { for (var i = 0; this.errorList[i]; i++) { var error = this.errorList[i]; this.settings.highlight && this.settings.highlight.call(this, error.element, this.settings.errorClass, this.settings.validClass); this.showLabel(error.element, error.message); } if (this.errorList.length) { this.toShow = this.toShow.add(this.containers); } if (this.settings.success) { for (var i = 0; this.successList[i]; i++) { this.showLabel(this.successList[i]); } } if (this.settings.unhighlight) { for (var i = 0, elements = this.validElements(); elements[i]; i++) { this.settings.unhighlight.call(this, elements[i], this.settings.errorClass, this.settings.validClass); } } this.toHide = this.toHide.not(this.toShow); this.hideErrors(); this.addWrapper(this.toShow).show(); }, validElements: function() { return this.currentElements.not(this.invalidElements()); }, invalidElements: function() { return $(this.errorList).map(function() { return this.element; }); }, showLabel: function(element, message) { var label = this.errorsFor(element); if (label.length) { label.removeClass().addClass(this.settings.errorClass); label.attr("generated") && label.html(message); } else { label = $("<" + this.settings.errorElement + "/>").attr({ "for": this.idOrName(element), generated: true }).addClass(this.settings.errorClass).html(message || ""); if (this.settings.wrapper) { label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent(); } if (!this.labelContainer.append(label).length) this.settings.errorPlacement ? this.settings.errorPlacement(label, $(element)) : label.insertAfter(element); } if (!message && this.settings.success) { label.text(""); typeof this.settings.success == "string" ? label.addClass(this.settings.success) : this.settings.success(label); } this.toShow = this.toShow.add(label); }, errorsFor: function(element) { var name = this.idOrName(element); return this.errors().filter(function() { return $(this).attr('for') == name }); }, idOrName: function(element) { return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name); }, checkable: function(element) { return /radio|checkbox/i.test(element.type); }, findByName: function(name) { var form = this.currentForm; return $(document.getElementsByName(name)).map(function(index, element) { return element.form == form && element.name == name && element || null; }); }, getLength: function(value, element) { switch (element.nodeName.toLowerCase()) { case 'select': return $("option:selected", element).length; case 'input': if (this.checkable(element)) return this.findByName(element.name).filter(':checked').length; } return value.length; }, depend: function(param, element) { return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true; }, dependTypes: { "boolean": function(param, element) { return param; }, "string": function(param, element) { return !!$(param, element.form).length; }, "function": function(param, element) { return param(element); } }, optional: function(element) { return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch"; }, startRequest: function(element) { if (!this.pending[element.name]) { this.pendingRequest++; this.pending[element.name] = true; } }, stopRequest: function(element, valid) { this.pendingRequest--; if (this.pendingRequest < 0) this.pendingRequest = 0; delete this.pending[element.name]; if (valid && this.pendingRequest == 0 && this.formSubmitted && this.form()) { $(this.currentForm).submit(); this.formSubmitted = false; } else if (!valid && this.pendingRequest == 0 && this.formSubmitted) { $(this.currentForm).triggerHandler("invalid-form", [this]); this.formSubmitted = false; } }, previousValue: function(element) { return $.data(element, "previousValue") || $.data(element, "previousValue", { old: null, valid: true, message: this.defaultMessage(element, "remote") }); } 
    }, classRuleSettings: { required: { required: true }, email: { email: true }, url: { url: true }, date: { date: true }, dateISO: { dateISO: true }, dateDE: { dateDE: true }, number: { number: true }, numberDE: { numberDE: true }, digits: { digits: true }, creditcard: { creditcard: true} }, addClassRules: function(className, rules) { className.constructor == String ? this.classRuleSettings[className] = rules : $.extend(this.classRuleSettings, className); }, classRules: function(element) { var rules = {}; var classes = $(element).attr('class'); classes && $.each(classes.split(' '), function() { if (this in $.validator.classRuleSettings) { $.extend(rules, $.validator.classRuleSettings[this]); } }); return rules; }, attributeRules: function(element) { var rules = {}; var $element = $(element); for (method in $.validator.methods) { var value = $element.attr(method); if (value) { rules[method] = value; } } if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) { delete rules.maxlength; } return rules; }, metadataRules: function(element) { if (!$.metadata) return {}; var meta = $.data(element.form, 'validator').settings.meta; return meta ? $(element).metadata()[meta] : $(element).metadata(); }, staticRules: function(element) { var rules = {}; var validator = $.data(element.form, 'validator'); if (validator.settings.rules) { rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {}; } return rules; }, normalizeRules: function(rules, element) { $.each(rules, function(prop, val) { if (val === false) { delete rules[prop]; return; } if (val.param || val.depends) { var keepRule = true; switch (typeof val.depends) { case "string": keepRule = !!$(val.depends, element.form).length; break; case "function": keepRule = val.depends.call(element, element); break; } if (keepRule) { rules[prop] = val.param !== undefined ? val.param : true; } else { delete rules[prop]; } } }); $.each(rules, function(rule, parameter) { rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter; }); $.each(['minlength', 'maxlength', 'min', 'max'], function() { if (rules[this]) { rules[this] = Number(rules[this]); } }); $.each(['rangelength', 'range'], function() { if (rules[this]) { rules[this] = [Number(rules[this][0]), Number(rules[this][1])]; } }); if ($.validator.autoCreateRanges) { if (rules.min && rules.max) { rules.range = [rules.min, rules.max]; delete rules.min; delete rules.max; } if (rules.minlength && rules.maxlength) { rules.rangelength = [rules.minlength, rules.maxlength]; delete rules.minlength; delete rules.maxlength; } } if (rules.messages) { delete rules.messages } return rules; }, normalizeRule: function(data) { if (typeof data == "string") { var transformed = {}; $.each(data.split(/\s/), function() { transformed[this] = true; }); data = transformed; } return data; }, addMethod: function(name, method, message) { $.validator.methods[name] = method; $.validator.messages[name] = message != undefined ? message : $.validator.messages[name]; if (method.length < 3) { $.validator.addClassRules(name, $.validator.normalizeRule(name)); } }, methods: { required: function(value, element, param) { if (!this.depend(param, element)) return "dependency-mismatch"; switch (element.nodeName.toLowerCase()) { case 'select': var val = $(element).val(); return val && val.length > 0; case 'input': if (this.checkable(element)) return this.getLength(value, element) > 0; default: return $.trim(value).length > 0; } }, remote: function(value, element, param) { if (this.optional(element)) return "dependency-mismatch"; var previous = this.previousValue(element); if (!this.settings.messages[element.name]) this.settings.messages[element.name] = {}; previous.originalMessage = this.settings.messages[element.name].remote; this.settings.messages[element.name].remote = previous.message; param = typeof param == "string" && { url: param} || param; if (previous.old !== value) { previous.old = value; var validator = this; this.startRequest(element); var data = {}; data[element.name] = value; $.ajax($.extend(true, { url: param, mode: "abort", port: "validate" + element.name, dataType: "json", data: data, success: function(response) { validator.settings.messages[element.name].remote = previous.originalMessage; var valid = response === true; if (valid) { var submitted = validator.formSubmitted; validator.prepareElement(element); validator.formSubmitted = submitted; validator.successList.push(element); validator.showErrors(); } else { var errors = {}; var message = (previous.message = response || validator.defaultMessage(element, "remote")); errors[element.name] = $.isFunction(message) ? message(value) : message; validator.showErrors(errors); } previous.valid = valid; validator.stopRequest(element, valid); } }, param)); return "pending"; } else if (this.pending[element.name]) { return "pending"; } return previous.valid; }, minlength: function(value, element, param) { return this.optional(element) || this.getLength($.trim(value), element) >= param; }, maxlength: function(value, element, param) { return this.optional(element) || this.getLength($.trim(value), element) <= param; }, rangelength: function(value, element, param) { var length = this.getLength($.trim(value), element); return this.optional(element) || (length >= param[0] && length <= param[1]); }, min: function(value, element, param) { return this.optional(element) || value >= param; }, max: function(value, element, param) { return this.optional(element) || value <= param; }, range: function(value, element, param) { return this.optional(element) || (value >= param[0] && value <= param[1]); }, email: function(value, element) { return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value); }, url: function(value, element) { return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); }, date: function(value, element) { return this.optional(element) || !/Invalid|NaN/.test(new Date(value)); }, dateISO: function(value, element) { return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value); }, number: function(value, element) { return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); }, digits: function(value, element) { return this.optional(element) || /^\d+$/.test(value); }, creditcard: function(value, element) { if (this.optional(element)) return "dependency-mismatch"; if (/[^0-9-]+/.test(value)) return false; var nCheck = 0, nDigit = 0, bEven = false; value = value.replace(/\D/g, ""); for (var n = value.length - 1; n >= 0; n--) { var cDigit = value.charAt(n); var nDigit = parseInt(cDigit, 10); if (bEven) { if ((nDigit *= 2) > 9) nDigit -= 9; } nCheck += nDigit; bEven = !bEven; } return (nCheck % 10) == 0; }, accept: function(value, element, param) { param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif"; return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i")); }, equalTo: function(value, element, param) { var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() { $(element).valid(); }); return value == target.val(); } }
    }); $.format = $.validator.format;
})(jQuery); ; (function($) { var ajax = $.ajax; var pendingRequests = {}; $.ajax = function(settings) { settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings)); var port = settings.port; if (settings.mode == "abort") { if (pendingRequests[port]) { pendingRequests[port].abort(); } return (pendingRequests[port] = ajax.apply(this, arguments)); } return ajax.apply(this, arguments); }; })(jQuery); ; (function($) { $.each({ focus: 'focusin', blur: 'focusout' }, function(original, fix) { $.event.special[fix] = { setup: function() { if ($.browser.msie) return false; this.addEventListener(original, $.event.special[fix].handler, true); }, teardown: function() { if ($.browser.msie) return false; this.removeEventListener(original, $.event.special[fix].handler, true); }, handler: function(e) { arguments[0] = $.event.fix(e); arguments[0].type = fix; return $.event.handle.apply(this, arguments); } }; }); $.extend($.fn, { delegate: function(type, delegate, handler) { return this.bind(type, function(event) { var target = $(event.target); if (target.is(delegate)) { return handler.apply(target, arguments); } }); }, triggerEvent: function(type, target) { return this.triggerHandler(type, [$.event.fix({ type: type, target: target })]); } }) })(jQuery);

/*
Copyright (c) 2009 Happyworm Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Author: Mark J Panaghiston
Version: 0.2.5.beta
Documentation: www.happyworm.com/jquery/jplayer
*/

(function($) {
    $.jPlayerCount = 0;

    var methods = {
        jPlayer: function(options) {
            $.jPlayerCount++;

            var config = {
                ready: null,
                cssPrefix: "jqjp",
                swfPath: "js",
                volume: 80,
                oggSupport: false,
                position: "absolute",
                width: 0,
                height: 0,
                top: 0,
                left: 0,
                quality: "high",
                bgcolor: "#ffffff"
            };
            $.extend(config, options);

            var configWithoutOptions = {
                id: $(this).attr("id"),
                swf: config.swfPath + ((config.swfPath != "") ? "/" : "") + "Jplayer.swf",
                fid: config.cssPrefix + "_flash_" + $.jPlayerCount,
                aid: config.cssPrefix + "_audio_" + $.jPlayerCount,
                hid: config.cssPrefix + "_force_" + $.jPlayerCount,
                i: $.jPlayerCount
            };
            $.extend(config, configWithoutOptions);

            $.fn["jPlayerReady" + config.i] = config.ready;

            $(this).prepend('<audio id="' + config.aid + '"></audio>'); // Begin check for HTML5 <audio>
            var audioArray = $("#" + config.aid).get();

            var configForAudioFormat = {
                canPlayMP3: Boolean((audioArray[0].canPlayType) ? (("" != audioArray[0].canPlayType("audio/mpeg")) && ("no" != audioArray[0].canPlayType("audio/mpeg"))) : false),
                canPlayOGG: Boolean((audioArray[0].canPlayType) ? (("" != audioArray[0].canPlayType("audio/ogg")) && ("no" != audioArray[0].canPlayType("audio/ogg"))) : false),
                audio: audioArray[0]
            };
            $.extend(config, configForAudioFormat);

            var configForHtmlAudio = {
                html5: Boolean((config.oggSupport) ? ((config.canPlayOGG) ? true : config.canPlayMP3) : config.canPlayMP3)
            };
            $.extend(config, configForHtmlAudio);

            $(this).data("jPlayer.config", config);

            var events = {
                setButtons: function(e, playing) {
                    var playId = $(this).data("jPlayer.cssId.play");
                    var pauseId = $(this).data("jPlayer.cssId.pause");
                    var prefix = $(this).data("jPlayer.config").cssPrefix;

                    if (playId != null && pauseId != null) {
                        if (playing) {
                            var style = $(this).data("jPlayer.cssDisplay.pause");
                            $("#" + playId).css("display", "none");
                            $("#" + pauseId).css("display", style);
                        } else {
                            var style = $(this).data("jPlayer.cssDisplay.play");
                            $("#" + playId).css("display", style);
                            $("#" + pauseId).css("display", "none");
                        }
                    }
                }
            };

            var eventsForFlash = {
                setFile: function(e, f) {
                    var fid = $(this).data("jPlayer.config").fid;
                    var m = $(this).data("jPlayer.getMovie")(fid);
                    m.fl_setFile_mp3(f.mp3);
                    $(this).trigger("jPlayer.setButtons", false);
                },
                play: function(e) {
                    var fid = $(this).data("jPlayer.config").fid;
                    var m = $(this).data("jPlayer.getMovie")(fid);
                    var r = m.fl_play_mp3();
                    if (r) {
                        $(this).trigger("jPlayer.setButtons", true);
                    }
                },
                pause: function(e) {
                    var fid = $(this).data("jPlayer.config").fid;
                    var m = $(this).data("jPlayer.getMovie")(fid);
                    var r = m.fl_pause_mp3();
                    if (r) {
                        $(this).trigger("jPlayer.setButtons", false);
                    }
                },
                stop: function(e) {
                    var fid = $(this).data("jPlayer.config").fid;
                    var m = $(this).data("jPlayer.getMovie")(fid);
                    var r = m.fl_stop_mp3();
                    if (r) {
                        $(this).trigger("jPlayer.setButtons", false);
                    }
                },
                playHead: function(e, p) {
                    var fid = $(this).data("jPlayer.config").fid;
                    var m = $(this).data("jPlayer.getMovie")(fid);
                    var r = m.fl_play_head_mp3(p);
                    if (r) {
                        $(this).trigger("jPlayer.setButtons", true);
                    }
                },
                playHeadTime: function(e, t) {
                    var fid = $(this).data("jPlayer.config").fid;
                    var m = $(this).data("jPlayer.getMovie")(fid);
                    var r = m.fl_play_head_time_mp3(t);
                    if (r) {
                        $(this).trigger("jPlayer.setButtons", true);
                    }
                },
                volume: function(e, v) {
                    $(this).data("jPlayer.config").volume = v;
                    var fid = $(this).data("jPlayer.config").fid;
                    var m = $(this).data("jPlayer.getMovie")(fid);
                    m.fl_volume_mp3(v);
                }
            };

            var eventsForHtmlAudio = {
                setFile: function(e, f) {
                    $("#" + $(this).data("jPlayer.config").aid).remove();
                    $(this).prepend('<audio id="' + $(this).data("jPlayer.config").aid + '"></audio>');
                    var audioArray = $("#" + $(this).data("jPlayer.config").aid).get();
                    $(this).data("jPlayer.config").audio = audioArray[0];
                    $(this).data("jPlayer.config").audio.volume = $(this).data("jPlayer.config").volume / 100;

                    if ($(this).data("jPlayer.config").oggSupport && $(this).data("jPlayer.config").canPlayOGG) {
                        $(this).data("jPlayer.config").audio.src = f.ogg;
                    } else {
                        $(this).data("jPlayer.config").audio.src = f.mp3;
                    }
                    $(this).trigger("jPlayer.setButtons", false);
                },
                play: function(e) {
                    $(this).data("jPlayer.config").audio.play();
                    $(this).trigger("jPlayer.setButtons", true);

                    clearInterval($(this).data("jPlayer.interval.jPlayerController"));
                    $(this).data("jPlayer.interval.jPlayerController", window.setInterval($(this).jPlayerController, 50, $(this), false));
                },
                pause: function(e) {
                    $(this).data("jPlayer.config").audio.pause();
                    $(this).trigger("jPlayer.setButtons", false);
                    clearInterval($(this).data("jPlayer.interval.jPlayerController"));
                },
                stop: function(e) {
                    $(this).data("jPlayer.config").audio.currentTime = 0;
                    $(this).trigger("jPlayer.pause");
                    $(this).jPlayerController($(this), true); // With override true
                },
                playHead: function(e, p) {
                    $(this).data("jPlayer.config").audio.currentTime = ($(this).data("jPlayer.config").audio.buffered) ? p * $(this).data("jPlayer.config").audio.buffered.end() / 100 : p * $(this).data("jPlayer.config").audio.duration / 100;
                    $(this).trigger("jPlayer.play");
                },
                playHeadTime: function(e, t) {
                    $(this).data("jPlayer.config").audio.currentTime = t / 1000;
                    $(this).trigger("jPlayer.play");
                },
                volume: function(e, v) {
                    $(this).data("jPlayer.config").volume = v;
                    $(this).data("jPlayer.config").audio.volume = v / 100;
                    $(this).jPlayerVolume(v);
                }
            };

            if (config.html5) {
                $.extend(events, eventsForHtmlAudio);
            } else {
                $.extend(events, eventsForFlash);
            }

            for (var event in events) {
                var e = "jPlayer." + event;
                $(this).unbind(e);
                $(this).bind(e, events[event]);
            }

            var getMovie = function(fid) {
                return document[fid];
            };
            $(this).data("jPlayer.getMovie", getMovie);

            // Function checkForFlash adapted from FlashReplace by Robert Nyman
            // http://code.google.com/p/flashreplace/
            var checkForFlash = function(version) {
                var flashIsInstalled = false;
                var flash;
                if (window.ActiveXObject) {
                    try {
                        flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));
                        flashIsInstalled = true;
                    }
                    catch (e) {
                        // Throws an error if the version isn't available			
                    }
                }
                else if (navigator.plugins && navigator.mimeTypes.length > 0) {
                    flash = navigator.plugins["Shockwave Flash"];
                    if (flash) {
                        var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1");
                        if (flashVersion >= version) {
                            flashIsInstalled = true;
                        }
                    }
                }
                return flashIsInstalled;
            };

            if (!config.html5) {
                if (checkForFlash(8)) {
                    if ($.browser.msie) {
                        var html_obj = '<object id="' + config.fid + '"';
                        html_obj += ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
                        html_obj += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"';
                        html_obj += ' type="application/x-shockwave-flash"';
                        html_obj += ' width="' + config.width + '" height="' + config.height + '">';
                        html_obj += '</object>';

                        var obj_param = new Array();
                        obj_param[0] = '<param name="movie" value="' + config.swf + '" />';
                        obj_param[1] = '<param name="quality" value="high" />';
                        obj_param[2] = '<param name="FlashVars" value="id=' + escape(config.id) + '&fid=' + escape(config.fid) + '&vol=' + config.volume + '" />';
                        obj_param[3] = '<param name="allowScriptAccess" value="always" />';
                        obj_param[4] = '<param name="bgcolor" value="' + config.bgcolor + '" />';

                        var ie_dom = document.createElement(html_obj);
                        for (var i = 0; i < obj_param.length; i++) {
                            ie_dom.appendChild(document.createElement(obj_param[i]));
                        }
                        $(this).html(ie_dom);
                    } else {
                        var html_embed = '<embed name="' + config.fid + '" id="' + config.fid + '" src="' + config.swf + '"';
                        html_embed += ' width="' + config.width + '" height="' + config.height + '" bgcolor="' + config.bgcolor + '"';
                        html_embed += ' quality="high" FlashVars="id=' + escape(config.id) + '&fid=' + escape(config.fid) + '&vol=' + config.volume + '"';
                        html_embed += ' allowScriptAccess="always"';
                        html_embed += ' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
                        $(this).html(html_embed);
                    }

                } else {
                    $(this).html("<p>Flash 8 or above is not installed. <a href='http://get.adobe.com/flashplayer'>Get Flash!</a></p>");
                }
            }

            var html_hidden = '<div id="' + config.hid + '"></div>';
            $(this).append(html_hidden);

            $(this).css({ 'position': config.position, 'top': config.top, 'left': config.left });
            $("#" + config.hid).css({ 'text-indent': '-9999px' });

            if (config.html5) { // Emulate initial flash calls after 100ms
                var self = $(this);
                window.setTimeout(function() {
                    self.volume(config.volume);
                    self.jPlayerReady();
                }, 100);
            }

            return $(this);
        },
        setFile: function(f1, f2) {
            var f = { mp3: f1, ogg: f2 };
            $(this).trigger("jPlayer.setFile", f);
            return $(this);
        },
        play: function() {
            $(this).trigger("jPlayer.play");
            return $(this);
        },
        pause: function() {
            $(this).trigger("jPlayer.pause");
            return $(this);
        },
        stop: function() {
            $(this).trigger("jPlayer.stop");
            return $(this);
        },
        playHead: function(p) {
            $(this).trigger("jPlayer.playHead", p);
            return $(this);
        },
        playHeadTime: function(t) {
            $(this).trigger("jPlayer.playHeadTime", t);
            return $(this);
        },
        volume: function(v) {
            $(this).trigger("jPlayer.volume", v);
            return $(this);
        },
        jPlayerId: function(fn, id) {
            if (id != null) {
                var isValid = eval("$(this)." + fn);
                if (isValid != null) {
                    $(this).data("jPlayer.cssId." + fn, id);
                    var jPlayerId = $(this).data("jPlayer.config").id;
                    eval("var myHandler = function(e) { $(\"#" + jPlayerId + "\")." + fn + "(e); return false; }");
                    $("#" + id).click(myHandler).hover($(this).jPlayerRollOver, $(this).jPlayerRollOut).data("jPlayerId", jPlayerId);

                    var display = $("#" + id).css("display");
                    $(this).data("jPlayer.cssDisplay." + fn, display);

                    if (fn == "pause") {
                        $("#" + id).css("display", "none");
                    }
                } else {
                    alert("Unknown function assigned in: jPlayerId( fn=" + fn + ", id=" + id + " )");
                }
            } else {
                id = $(this).data("jPlayer.cssId." + fn);
                if (id != null) {
                    return id;
                } else {
                    alert("Unknown function id requested: jPlayerId( fn=" + fn + " )");
                    return false;
                }
            }
            return $(this);
        },
        loadBar: function(e) { // Handles clicks on the loadBar
            var lbId = $(this).data("jPlayer.cssId.loadBar");
            if (lbId != null) {
                var offset = $("#" + lbId).offset();
                var x = e.pageX - offset.left;
                var w = $("#" + lbId).width();
                var p = 100 * x / w;
                $(this).playHead(p);
            }
        },
        playBar: function(e) { // Handles clicks on the playBar
            $(this).loadBar(e);
        },
        onProgressChange: function(fn) {
            $.fn["jPlayerOnProgressChange" + $(this).data("jPlayer.config").i] = fn;
            return $(this);
        },
        jPlayerOnProgressChange: function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) { // Called from Flash
            var lbId = $(this).data("jPlayer.cssId.loadBar");
            if (lbId != null) {
                $("#" + lbId).width(loadPercent + "%");
            }
            var pbId = $(this).data("jPlayer.cssId.playBar");
            if (pbId != null) {
                $("#" + pbId).width(playedPercentRelative + "%");
            }

            //$(this)["jPlayerOnProgressChange" + $(this).data("jPlayer.config").i](loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime);
            $(this).jPlayerForceUpdate();
            return true;
        },
        jPlayerController: function(self, override) { // For HTML5 interval.
            var playedTime = 0;
            var totalTime = 0;
            var playedPercentAbsolute = 0;
            var loadPercent = 0;
            var playedPercentRelative = 0;

            if (self.data("jPlayer.config").audio.readyState >= 1) {
                playedTime = self.data("jPlayer.config").audio.currentTime * 1000; // milliSeconds
                totalTime = self.data("jPlayer.config").audio.duration * 1000; // milliSeconds
                playedPercentAbsolute = 100 * playedTime / totalTime;
                loadPercent = (self.data("jPlayer.config").audio.buffered) ? 100 * self.data("jPlayer.config").audio.buffered.end() / self.data("jPlayer.config").audio.duration : 100;
                playedPercentRelative = (self.data("jPlayer.config").audio.buffered) ? 100 * self.data("jPlayer.config").audio.currentTime / self.data("jPlayer.config").audio.buffered.end() : playedPercentAbsolute;
            }

            if (override) {
                self.jPlayerOnProgressChange(loadPercent, 0, 0, 0, totalTime);
            } else {
                self.jPlayerOnProgressChange(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime);

                if (self.data("jPlayer.config").audio.ended) {
                    clearInterval(self.data("jPlayer.interval.jPlayerController"));
                    self.jPlayerOnSoundComplete();
                }
            }
        },
        volumeMin: function() {
            $(this).volume(0);
            return $(this);
        },
        volumeMax: function() {
            $(this).volume(100);
            return $(this);
        },
        volumeBar: function(e) { // Handles clicks on the volumeBar
            var vbId = $(this).data("jPlayer.cssId.volumeBar");
            if (vbId != null) {
                var offset = $("#" + vbId).offset();
                var x = e.pageX - offset.left;
                var w = $("#" + vbId).width();
                var p = 100 * x / w;
                $(this).volume(p);
            }
        },
        volumeBarValue: function(e) { // Handles clicks on the volumeBarValue
            $(this).volumeBar(e);
        },
        jPlayerVolume: function(v) { // Called from Flash
            var vbvId = $(this).data("jPlayer.cssId.volumeBarValue");
            if (vbvId != null) {
                $("#" + vbvId).width(v + "%");
                $(this).jPlayerForceUpdate();
                return true;
            }
        },
        onSoundComplete: function(fn) {
            $.fn["jPlayerOnSoundComplete" + $(this).data("jPlayer.config").i] = fn;
            return $(this);
        },
        jPlayerOnSoundComplete: function() { // Called from Flash
            $(this).trigger("jPlayer.setButtons", false);
            $(this)["jPlayerOnSoundComplete" + $(this).data("jPlayer.config").i]();
            return true;
        },
        jPlayerBufferState: function(b) { // Called from Flash
            var lbId = $(this).data("jPlayer.cssId.loadBar");
            if (lbId != null) {
                var prefix = $(this).data("jPlayer.config").cssPrefix;
                if (b) {
                    $("#" + lbId).addClass(prefix + "_buffer");
                } else {
                    $("#" + lbId).removeClass(prefix + "_buffer");
                }
                return true;
            } else {
                return false;
            }
        },
        bufferMsg: function() {
            // Empty: Initialized to enable jPlayerId() to work.
            // See jPlayerBufferMsg() for code.
        },
        jPlayerBufferMsg: function(msg) { // Called from Flash
            var bmId = $(this).data("jPlayer.cssId.bufferMsg");
            if (bmId != null) {
                $("#" + bmId).html(msg);
                return true;
            } else {
                return false;
            }
        },
        jPlayerForceUpdate: function() { // For Safari and Chrome
            var hid = $(this).data("jPlayer.config").hid;
            $("#" + hid).html(Math.random());
        },
        jPlayerRollOver: function() {
            var jPlayerId = $(this).data("jPlayerId");
            var prefix = $("#" + jPlayerId).data("jPlayer.config").cssPrefix;
            $(this).addClass(prefix + "_hover");
        },
        jPlayerRollOut: function() {
            var jPlayerId = $(this).data("jPlayerId");
            var prefix = $("#" + jPlayerId).data("jPlayer.config").cssPrefix;
            $(this).removeClass(prefix + "_hover");
        },
        jPlayerReady: function() { // Called from Flash
            $(this)["jPlayerReady" + $(this).data("jPlayer.config").i]();
        },
        jPlayerGetInfo: function(info) {
            return $(this).data("jPlayer.config")[info];
        }
    };

    $.each(methods, function(i) {
        $.fn[i] = this;
    });
})(jQuery);

/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
*       used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
*                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
*                             If set to null or omitted, the cookie will be a session cookie and will not be retained
*                             when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
*                        require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
