new version
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 5 Sep 2014 17:08:14 +0000 (13:08 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 5 Sep 2014 17:08:14 +0000 (13:08 -0400)
wp-content/themes/headway/library/blocks/blocks.php
wp-content/themes/headway/library/common/application.php
wp-content/themes/headway/library/common/compiler.php
wp-content/themes/headway/library/visual-editor/scripts-min/app.js
wp-content/themes/headway/style.css

index 8ec4ddd..983dcd0 100644 (file)
@@ -630,7 +630,7 @@ class HeadwayBlocks {
                        if ( $where != 'grid' ) {
 
                                $block_classes[] = 'block-mirroring-' . $mirrored_block['id'];
-                               $block_classes[] = 'block-original-' . HeadwayBlocksData::get_legacy_id( $block );
+                               $block_classes[] = 'block-original-' . HeadwayBlocksData::get_legacy_id( $block['original'] );
 
                        }
 
index f0b5d7e..221ffeb 100644 (file)
@@ -26,7 +26,7 @@ class Headway {
                                
                /* Define simple constants */
                define('THEME_FRAMEWORK', 'headway');
-               define('HEADWAY_VERSION', '3.7.9');
+               define('HEADWAY_VERSION', '3.7.10');
 
                /* Define directories */
                define('HEADWAY_DIR', headway_change_to_unix_path(TEMPLATEPATH));
index ca42aeb..0988d25 100644 (file)
@@ -51,7 +51,8 @@ class HeadwayCompiler {
                        'footer-js' => true,
                        'enqueue' => true,
                        'require-hard-flush' => false,
-                       'iframe-cache' => false
+                       'iframe-cache' => false,
+                       'output-inline' => false
                );
                
                $args = array_merge($defaults, $args);
index 78decd7..9f7f4c4 100644 (file)
@@ -1 +1 @@
-function ITStylesheet(e,t){return"undefined"!=typeof e.document&&(this.document=e.document,delete e.document),this.property_dom_names={},this.property_standard_names={},this.converted_rgb_values={},this.args="undefined"!=typeof e?e:{},this.action="undefined"!=typeof t?t:"load",this.init=function(){"find"===this.action?this._find_stylesheet():this._load_stylesheet()},this._load_stylesheet=function(){e=this.args;var t;"undefined"!=typeof e.href?(t=this.document.createElement("link"),t.href=e.href,this.type="link"):(t=this.document.createElement("style"),this.type="style"),t.type="text/css","undefined"!=typeof e.title&&(t.title=e.title),"undefined"!=typeof e.rel&&(t.rel=e.rel),"undefined"!=typeof e.media&&(t.media=e.media),"undefined"!=typeof e.href&&"undefined"==typeof e.rel&&(t.rel="stylesheet");var n="";"undefined"!=typeof e.content&&(n=e.content,delete e.content);var r=Math.floor(Math.random()*1e3)+1;this.$stylesheet_node=jQuery(t).insertBefore($i("style#live-css-holder")).addClass("ITStylesheet").attr("id","itstylesheet-"+r),this.stylesheet_node=this.$stylesheet_node[0];var i=this;jQuery.each(this.document.styleSheets,function(e,t){if(typeof t.ownerNode.id=="undefined"||!t.ownerNode.id||t.ownerNode.id!="itstylesheet-"+r)return;return i.stylesheet=t,!1}),this._find_rules(),""!==n&&this.set_rules(n)},this._find_stylesheet=function(){e=this.args;for(var t=0;t<this.document.styleSheets.length;t++){if("undefined"!=typeof e.href&&typeof this.document.styleSheets[t].href=="string"&&this.document.styleSheets[t].href.indexOf(e.href)===-1)continue;if("undefined"!=typeof e.title&&e.title!==this.document.styleSheets[t].title)continue;if("undefined"!=typeof e.rel&&e.rel!==this.document.styleSheets[t].rel)continue;if("undefined"!=typeof e.media&&e.media!==this.document.styleSheets[t].media)continue;if("undefined"!=typeof e.type&&e.type!==this.document.styleSheets[t].type)continue;if("undefined"!=typeof e.disabled&&e.disabled!==this.document.styleSheets[t].disabled)continue;this.type="link",this.stylesheet=this.document.styleSheets[t],this._find_rules();break}},this._find_rules=function(){if("undefined"==typeof this.stylesheet)return;this.stylesheet.cssRules?this.rules=this.stylesheet.cssRules:this.rules=this.stylesheet.rules},this._get_style_from_declarations=function(e){var t="";for(property in e)t+=property+":"+e[property]+"; ";return t},this._get_rules_obj_from_string=function(e){var t={},n=e.match(/\s*[^{;]+\s*{\s*[^{}]+\s*}/g);if(-1===n)return t;for(var r=0;r<n.length;r++){var i=n[r].match(/\s*([^{;]+)\s*{\s*([^{}]+)\s*}/);t[i[1]]=i[2]}return t},this._get_property_dom_name=function(e){if("undefined"!=typeof this.property_dom_names[e])return this.property_dom_names[e];var t=e.split("-"),n=t.shift();while(t.length>0){var r=t.shift();r=r.charAt(0).toUpperCase()+r.substr(1),n+=r}return this.property_dom_names[e]=n,n},this._get_property_standard_name=function(e){if("undefined"!=typeof this.property_standard_names[e])return this.property_standard_names[e];var t=e;return"padding-right-value"===e?t="padding-right":"padding-left-value"===e?t="padding-left":"margin-right-value"===e?t="margin-right":"margin-left-value"===e&&(t="margin-left"),this.property_standard_names[e]=t,t},this._delete_rule_at_index=function(e){this.stylesheet.deleteRule?this.stylesheet.deleteRule(e):this.stylesheet.removeRule(e)},this._get_stylesheet_rules=function(e){return e.cssRules?e.cssRules:e.rules},this._get_stylesheet_rules_object=function(e){var t=this._get_stylesheet_rules(e),n={},r=[];for(var i=0;i<t.length;i++)n[t[i].selectorText]=this._get_rule_declarations_object(t[i]),r.push(t[i].selectorText);r.sort();var s={};for(var i=0;i<r.length;i++)s[r[i]]=n[r[i]];return s},this._get_rule_declarations_object=function(e){var t={},n;e.style?n=e.style:n=e;var r=[];for(var i=0;i<n.length;i++)r.push(n[i]);r.sort();for(var i=0;i<r.length;i++){var s=this._get_property_standard_name(r[i]);"undefined"!=typeof n[s]?t[s]=n[s]:t[s]=n[this._get_property_dom_name(s)]}return t},this.get_rule_index=function(e){if("undefined"==typeof e)return!1;indexes=new Array,this.rules||this._find_rules();if(!this.rules)return!1;if("undefined"!=typeof this.rules[e])return e;for(var t=0;t<this.rules.length;t++)typeof this.rules[t].selectorText=="string"&&this.rules[t].selectorText.toLowerCase()==e.toLowerCase()&&indexes.push(t);return indexes.length!==0?indexes[indexes.length-1]:!1},this.get_rule=function(e){if("undefined"==typeof e)return!1;var t=this.get_rule_index(e);return!1===t||"undefined"==typeof this.rules[t]?!1:this.rules[t]},this.add_rule=function(e,t){return this.update_rule(e,t)},this.update_rule=function(e,t,n){if("undefined"==typeof this.rules||"undefined"==typeof e)return!1;"undefined"==typeof t&&(t={}),"undefined"==typeof n&&(n=!1);if(n)var r=e.split(",");else var r=new Array(e);var i=[];for(var s=0;s<r.length;s++){var o=r[s];if("undefined"==typeof o)continue;var u=this.get_rule(o);try{if(!1===u){var a=this.rules.length;string_declarations="string"==typeof t?t:this._get_style_from_declarations(t),this.stylesheet.addRule?this.stylesheet.addRule(o,string_declarations,a):this.stylesheet.insertRule(o+" {"+string_declarations+"}",a),u=this.rules[a]}else for(property in t)u.style.setAttribute?u.style.setAttribute(property,t[property]):u.style.setProperty(property,t[property],null);i.push(u)}catch(f){}}return i},this.delete_all_rules=function(){while(this.rules.length>0)this._delete_rule_at_index(0)},this.delete_rule=function(e){var t=this.get_rule_index(e);return!1===t?!1:(this._delete_rule_at_index(t),!0)},this.delete_rule_property=function(e,t){var n={};n[t]=null,this.update_rule(e,n)},this._convert_rgb_to_hex=function(e){if("undefined"!=typeof this.converted_rgb_values[e])return this.converted_rgb_values[e];var t=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e),n=parseInt(t[1]),r=parseInt(t[2]),i=parseInt(t[3]),s=i|r<<8|n<<16;hex=s.toString(16).toUpperCase();while(hex.length<6)hex="0"+hex;return this.converted_rgb_values[e]="#"+hex,"#"+hex},this.get_stylesheet_text=function(){var e=this._get_stylesheet_rules_object(this.stylesheet),t="",n=/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)/;for(selector in e){var r="";for(property in e[selector]){var i=e[selector][property];if("undefined"==typeof i)continue;n.test(i)&&(i=this._convert_rgb_to_hex(i)),r+="      "+property+": "+i+";\n"}if(""===r)continue;""!==t&&(t+="\n"),t+=selector+" {\n"+r+"}"}return t},this.get_computed_style=function(e){return window.getComputedStyle?window.getComputedStyle(e,""):e.currentStyle},this.set_rules=function(e){this.delete_all_rules(),"string"==typeof e&&(e=this._get_rules_obj_from_string(e));for(selector in e)this.update_rule(selector,e[selector])},this.init(),!0}define("util.misc",["jquery"],function(e){updateQueryStringParameter=function(e,t,n){var r=new RegExp("([?|&])"+t+"=.*?(&|$)","i"),i=e.indexOf("?")!==-1?"&":"?";return e.match(r)?e.replace(r,"$1"+t+"="+n+"$2"):e+i+t+"="+n},jQuery.fn.reverse=[].reverse,Number.prototype.toNearest=function(e){return Math.round(this/e)*e},Math._round=Math.round,Math.round=function(e,t){t=Math.abs(parseInt(t))||0;var n=Math.pow(10,t);return Math._round(e*n)/n},String.prototype.repeatStr=function(e){return e<=0?"":Array.prototype.join.call({length:e+1},this)},String.prototype.capitalize=function(){return this.replace(/(^|\s)([a-z])/g,function(e,t,n){return t+n.toUpperCase()})},hwBoolean=function(e){if(typeof e=="boolean")return e;if(typeof e=="undefined")return!1;if(typeof e=="number")return e===1?!0:e===0?!1:null;if(e===null)return!1;if(typeof e=="string"){var t=e.split(/\b/g);return t[0]==="1"||t[0]==="true"?!0:t[0]==="0"||t[0]==="false"?!1:null}return null},Number.prototype.toBool=function(){return this===1?!0:this===0?!1:null},String.prototype.toBool=function(){var e=this.split(/\b/g);return e[0]==="1"||e[0]==="true"?!0:e[0]==="0"||e[0]==="false"?!1:null},String.prototype.escapeHTML=function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}}),define("util.loader",["jquery","util.misc"],function(e){createCog=function(t,n,r,i,s){if(e(t).length===0||e(t).find(".cog-container:visible").length)return!1;var r=typeof r=="undefined"?!1:r,o='<div class="cog-container"><div class="cog-bottom-left"></div><div class="cog-top-right"></div></div>';return r?t.append(o):t.html(o),typeof s!="undefined"&&t.find(".cog-container").css({opacity:s}),!0},changeTitle=function(t){return e("title").text(t)},startTitleActivityIndicator=function(){return typeof titleActivityIndicatorInstance=="number"?!1:(titleActivityIndicatorInstance=window.setInterval(titleActivityIndicator,500),titleActivityIndicatorSavedTitle=e("title").text(),!0)},stopTitleActivityIndicator=function(){return typeof titleActivityIndicatorInstance!="number"?!1:(window.clearInterval(titleActivityIndicatorInstance),changeTitle(titleActivityIndicatorSavedTitle),delete titleActivityIndicatorCounter,delete titleActivityIndicatorSavedTitle,delete titleActivityIndicatorInstance,!0)},titleActivityIndicator=function(){typeof titleActivityIndicatorCounter=="undefined"&&(titleActivityIndicatorCounter=0,titleActivityIndicatorCounterPos=!0),titleActivityIndicatorCounterPos===!0?++titleActivityIndicatorCounter:--titleActivityIndicatorCounter,titleActivityIndicatorCounter===3?titleActivityIndicatorCounterPos=!1:titleActivityIndicatorCounter===0&&(titleActivityIndicatorCounterPos=!0);var e=titleActivityIndicatorSavedTitle+".".repeatStr(titleActivityIndicatorCounter);changeTitle(e)}}),function(){var DEBUG=!0;(function(undefined){var window=this||(0,eval)("this"),document=window.document,navigator=window.navigator,jQuery=window.jQuery,JSON=window.JSON;(function(e){if(typeof require=="function"&&typeof exports=="object"&&typeof module=="object"){var t=module.exports||exports;e(t)}else typeof define=="function"&&define.amd?define("ko",["exports"],e):e(window.ko={})})(function(e){function r(e,t){var r=e===null||typeof e in n;return r?e===t:!1}function i(e,t){var n;return function(){n||(n=setTimeout(function(){n=undefined,e()},t))}}function s(e,t){var n;return function(){clearTimeout(n),n=setTimeout(e,t)}}function o(e){var n=this;return e&&t.utils.objectForEach(e,function(e,r){var i=t.extenders[e];typeof i=="function"&&(n=i(n,r)||n)}),n}function d(e){t.bindingHandlers[e]={init:function(n,r,i,s,o){var u=function(){var t={};return t[e]=r(),t};return t.bindingHandlers.event.init.call(this,n,u,i,s,o)}}}function g(e,n,r,i){t.bindingHandlers[e]={init:function(e,s,o,u,a){var f,l;return t.computed(function(){var o=t.utils.unwrapObservable(s()),u=!r!=!o,c=!l,h=c||n||u!==f;h&&(c&&t.computedContext.getDependenciesCount()&&(l=t.utils.cloneNodes(t.virtualElements.childNodes(e),!0)),u?(c||t.virtualElements.setDomNodeChildren(e,t.utils.cloneNodes(l)),t.applyBindingsToDescendants(i?i(a,o):a,e)):t.virtualElements.emptyNode(e),f=u)},null,{disposeWhenNodeIsRemoved:e}),{controlsDescendantBindings:!0}}},t.expressionRewriting.bindingRewriteValidators[e]=!1,t.virtualElements.allowedBindings[e]=!0}var t=typeof e!="undefined"?e:{};t.exportSymbol=function(e,n){var r=e.split("."),i=t;for(var s=0;s<r.length-1;s++)i=i[r[s]];i[r[r.length-1]]=n},t.exportProperty=function(e,t,n){e[t]=n},t.version="3.1.0",t.exportSymbol("version",t.version),t.utils=function(){function e(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])}function n(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function r(e,t){return e.__proto__=t,e}function h(e,n){if(t.utils.tagNameLower(e)!=="input"||!e.type)return!1;if(n.toLowerCase()!="click")return!1;var r=e.type;return r=="checkbox"||r=="radio"}var i={__proto__:[]}instanceof Array,s={},o={},u=navigator&&/Firefox\/2/i.test(navigator.userAgent)?"KeyboardEvent":"UIEvents";s[u]=["keyup","keydown","keypress"],s.MouseEvents=["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave"],e(s,function(e,t){if(t.length)for(var n=0,r=t.length;n<r;n++)o[t[n]]=e});var a={propertychange:!0},f=document&&function(){var e=3,t=document.createElement("div"),n=t.getElementsByTagName("i");while(t.innerHTML="<!--[if gt IE "+ ++e+"]><i></i><![endif]-->",n[0]);return e>4?e:undefined}(),l=f===6,c=f===7;return{fieldsIncludedWithJsonPost:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],arrayForEach:function(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)},arrayIndexOf:function(e,t){if(typeof Array.prototype.indexOf=="function")return Array.prototype.indexOf.call(e,t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},arrayFirst:function(e,t,n){for(var r=0,i=e.length;r<i;r++)if(t.call(n,e[r],r))return e[r];return null},arrayRemoveItem:function(e,n){var r=t.utils.arrayIndexOf(e,n);r>0?e.splice(r,1):r===0&&e.shift()},arrayGetDistinctValues:function(e){e=e||[];var n=[];for(var r=0,i=e.length;r<i;r++)t.utils.arrayIndexOf(n,e[r])<0&&n.push(e[r]);return n},arrayMap:function(e,t){e=e||[];var n=[];for(var r=0,i=e.length;r<i;r++)n.push(t(e[r],r));return n},arrayFilter:function(e,t){e=e||[];var n=[];for(var r=0,i=e.length;r<i;r++)t(e[r],r)&&n.push(e[r]);return n},arrayPushAll:function(e,t){if(t instanceof Array)e.push.apply(e,t);else for(var n=0,r=t.length;n<r;n++)e.push(t[n]);return e},addOrRemoveItem:function(e,n,r){var i=t.utils.arrayIndexOf(t.utils.peekObservable(e),n);i<0?r&&e.push(n):r||e.splice(i,1)},canSetPrototype:i,extend:n,setPrototypeOf:r,setPrototypeOfOrExtend:i?r:n,objectForEach:e,objectMap:function(e,t){if(!e)return e;var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r],r,e));return n},emptyDomNode:function(e){while(e.firstChild)t.removeNode(e.firstChild)},moveCleanedNodesToContainerElement:function(e){var n=t.utils.makeArray(e),r=document.createElement("div");for(var i=0,s=n.length;i<s;i++)r.appendChild(t.cleanNode(n[i]));return r},cloneNodes:function(e,n){for(var r=0,i=e.length,s=[];r<i;r++){var o=e[r].cloneNode(!0);s.push(n?t.cleanNode(o):o)}return s},setDomNodeChildren:function(e,n){t.utils.emptyDomNode(e);if(n)for(var r=0,i=n.length;r<i;r++)e.appendChild(n[r])},replaceDomNodes:function(e,n){var r=e.nodeType?[e]:e;if(r.length>0){var i=r[0],s=i.parentNode;for(var o=0,u=n.length;o<u;o++)s.insertBefore(n[o],i);for(var o=0,u=r.length;o<u;o++)t.removeNode(r[o])}},fixUpContinuousNodeArray:function(e,t){if(e.length){t=t.nodeType===8&&t.parentNode||t;while(e.length&&e[0].parentNode!==t)e.shift();if(e.length>1){var n=e[0],r=e[e.length-1];e.length=0;while(n!==r){e.push(n),n=n.nextSibling;if(!n)return}e.push(r)}}return e},setOptionNodeSelectionState:function(e,t){f<7?e.setAttribute("selected",t):e.selected=t},stringTrim:function(e){return e===null||e===undefined?"":e.trim?e.trim():e.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},stringTokenize:function(e,n){var r=[],i=(e||"").split(n);for(var s=0,o=i.length;s<o;s++){var u=t.utils.stringTrim(i[s]);u!==""&&r.push(u)}return r},stringStartsWith:function(e,t){return e=e||"",t.length>e.length?!1:e.substring(0,t.length)===t},domNodeIsContainedBy:function(e,t){if(e===t)return!0;if(e.nodeType===11)return!1;if(t.contains)return t.contains(e.nodeType===3?e.parentNode:e);if(t.compareDocumentPosition)return(t.compareDocumentPosition(e)&16)==16;while(e&&e!=t)e=e.parentNode;return!!e},domNodeIsAttachedToDocument:function(e){return t.utils.domNodeIsContainedBy(e,e.ownerDocument.documentElement)},anyDomNodeIsAttachedToDocument:function(e){return!!t.utils.arrayFirst(e,t.utils.domNodeIsAttachedToDocument)},tagNameLower:function(e){return e&&e.tagName&&e.tagName.toLowerCase()},registerEventHandler:function(e,n,r){var i=f&&a[n];if(!i&&jQuery)jQuery(e).bind(n,r);else if(!i&&typeof e.addEventListener=="function")e.addEventListener(n,r,!1);else{if(typeof e.attachEvent=="undefined")throw new Error("Browser doesn't support addEventListener or attachEvent");var s=function(t){r.call(e,t)},o="on"+n;e.attachEvent(o,s),t.utils.domNodeDisposal.addDisposeCallback(e,function(){e.detachEvent(o,s)})}},triggerEvent:function(e,t){if(!e||!e.nodeType)throw new Error("element must be a DOM node when calling triggerEvent");var n=h(e,t);if(jQuery&&!n)jQuery(e).trigger(t);else if(typeof document.createEvent=="function"){if(typeof e.dispatchEvent!="function")throw new Error("The supplied element doesn't support dispatchEvent");var r=o[t]||"HTMLEvents",i=document.createEvent(r);i.initEvent(t,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,e),e.dispatchEvent(i)}else if(n&&e.click)e.click();else{if(typeof e.fireEvent=="undefined")throw new Error("Browser doesn't support triggering events");e.fireEvent("on"+t)}},unwrapObservable:function(e){return t.isObservable(e)?e():e},peekObservable:function(e){return t.isObservable(e)?e.peek():e},toggleDomNodeCssClass:function(e,n,r){if(n){var i=/\S+/g,s=e.className.match(i)||[];t.utils.arrayForEach(n.match(i),function(e){t.utils.addOrRemoveItem(s,e,r)}),e.className=s.join(" ")}},setTextContent:function(e,n){var r=t.utils.unwrapObservable(n);if(r===null||r===undefined)r="";var i=t.virtualElements.firstChild(e);!i||i.nodeType!=3||t.virtualElements.nextSibling(i)?t.virtualElements.setDomNodeChildren(e,[e.ownerDocument.createTextNode(r)]):i.data=r,t.utils.forceRefresh(e)},setElementName:function(e,t){e.name=t;if(f<=7)try{e.mergeAttributes(document.createElement("<input name='"+e.name+"'/>"),!1)}catch(n){}},forceRefresh:function(e){if(f>=9){var t=e.nodeType==1?e:e.parentNode;t.style&&(t.style.zoom=t.style.zoom)}},ensureSelectElementIsRenderedCorrectly:function(e){if(f){var t=e.style.width;e.style.width=0,e.style.width=t}},range:function(e,n){e=t.utils.unwrapObservable(e),n=t.utils.unwrapObservable(n);var r=[];for(var i=e;i<=n;i++)r.push(i);return r},makeArray:function(e){var t=[];for(var n=0,r=e.length;n<r;n++)t.push(e[n]);return t},isIe6:l,isIe7:c,ieVersion:f,getFormFields:function(e,n){var r=t.utils.makeArray(e.getElementsByTagName("input")).concat(t.utils.makeArray(e.getElementsByTagName("textarea"))),i=typeof n=="string"?function(e){return e.name===n}:function(e){return n.test(e.name)},s=[];for(var o=r.length-1;o>=0;o--)i(r[o])&&s.push(r[o]);return s},parseJson:function(e){if(typeof e=="string"){e=t.utils.stringTrim(e);if(e)return JSON&&JSON.parse?JSON.parse(e):(new Function("return "+e))()}return null},stringifyJson:function(e,n,r){if(!JSON||!JSON.stringify)throw new Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js");return JSON.stringify(t.utils.unwrapObservable(e),n,r)},postJson:function(n,r,i){i=i||{};var s=i.params||{},o=i.includeFields||this.fieldsIncludedWithJsonPost,u=n;if(typeof n=="object"&&t.utils.tagNameLower(n)==="form"){var a=n;u=a.action;for(var f=o.length-1;f>=0;f--){var l=t.utils.getFormFields(a,o[f]);for(var c=l.length-1;c>=0;c--)s[l[c].name]=l[c].value}}r=t.utils.unwrapObservable(r);var h=document.createElement("form");h.style.display="none",h.action=u,h.method="post";for(var p in r){var d=document.createElement("input");d.name=p,d.value=t.utils.stringifyJson(t.utils.unwrapObservable(r[p])),h.appendChild(d)}e(s,function(e,t){var n=document.createElement("input");n.name=e,n.value=t,h.appendChild(n)}),document.body.appendChild(h),i.submitter?i.submitter(h):h.submit(),setTimeout(function(){h.parentNode.removeChild(h)},0)}}}(),t.exportSymbol("utils",t.utils),t.exportSymbol("utils.arrayForEach",t.utils.arrayForEach),t.exportSymbol("utils.arrayFirst",t.utils.arrayFirst),t.exportSymbol("utils.arrayFilter",t.utils.arrayFilter),t.exportSymbol("utils.arrayGetDistinctValues",t.utils.arrayGetDistinctValues),t.exportSymbol("utils.arrayIndexOf",t.utils.arrayIndexOf),t.exportSymbol("utils.arrayMap",t.utils.arrayMap),t.exportSymbol("utils.arrayPushAll",t.utils.arrayPushAll),t.exportSymbol("utils.arrayRemoveItem",t.utils.arrayRemoveItem),t.exportSymbol("utils.extend",t.utils.extend),t.exportSymbol("utils.fieldsIncludedWithJsonPost",t.utils.fieldsIncludedWithJsonPost),t.exportSymbol("utils.getFormFields",t.utils.getFormFields),t.exportSymbol("utils.peekObservable",t.utils.peekObservable),t.exportSymbol("utils.postJson",t.utils.postJson),t.exportSymbol("utils.parseJson",t.utils.parseJson),t.exportSymbol("utils.registerEventHandler",t.utils.registerEventHandler),t.exportSymbol("utils.stringifyJson",t.utils.stringifyJson),t.exportSymbol("utils.range",t.utils.range),t.exportSymbol("utils.toggleDomNodeCssClass",t.utils.toggleDomNodeCssClass),t.exportSymbol("utils.triggerEvent",t.utils.triggerEvent),t.exportSymbol("utils.unwrapObservable",t.utils.unwrapObservable),t.exportSymbol("utils.objectForEach",t.utils.objectForEach),t.exportSymbol("utils.addOrRemoveItem",t.utils.addOrRemoveItem),t.exportSymbol("unwrap",t.utils.unwrapObservable),Function.prototype.bind||(Function.prototype.bind=function(e){var t=this,n=Array.prototype.slice.call(arguments),e=n.shift();return function(){return t.apply(e,n.concat(Array.prototype.slice.call(arguments)))}}),t.utils.domData=new function(){function r(r,i){var s=r[t],o=s&&s!=="null"&&n[s];if(!o){if(!i)return undefined;s=r[t]="ko"+e++,n[s]={}}return n[s]}var e=0,t="__ko__"+(new Date).getTime(),n={};return{get:function(e,t){var n=r(e,!1);return n===undefined?undefined:n[t]},set:function(e,t,n){if(n===undefined&&r(e,!1)===undefined)return;var i=r(e,!0);i[t]=n},clear:function(e){var r=e[t];return r?(delete n[r],e[t]=null,!0):!1},nextKey:function(){return e++ +t}}},t.exportSymbol("utils.domData",t.utils.domData),t.exportSymbol("utils.domData.clear",t.utils.domData.clear),t.utils.domNodeDisposal=new function(){function i(n,r){var i=t.utils.domData.get(n,e);return i===undefined&&r&&(i=[],t.utils.domData.set(n,e,i)),i}function s(n){t.utils.domData.set(n,e,undefined)}function o(e){var n=i(e,!1);if(n){n=n.slice(0);for(var s=0;s<n.length;s++)n[s](e)}t.utils.domData.clear(e),t.utils.domNodeDisposal.cleanExternalData(e),r[e.nodeType]&&u(e)}function u(e){var t,n=e.firstChild;while(t=n)n=t.nextSibling,t.nodeType===8&&o(t)}var e=t.utils.domData.nextKey(),n={1:!0,8:!0,9:!0},r={1:!0,9:!0};return{addDisposeCallback:function(e,t){if(typeof t!="function")throw new Error("Callback must be a function");i(e,!0).push(t)},removeDisposeCallback:function(e,n){var r=i(e,!1);r&&(t.utils.arrayRemoveItem(r,n),r.length==0&&s(e))},cleanNode:function(e){if(n[e.nodeType]){o(e);if(r[e.nodeType]){var i=[];t.utils.arrayPushAll(i,e.getElementsByTagName("*"));for(var s=0,u=i.length;s<u;s++)o(i[s])}}return e},removeNode:function(e){t.cleanNode(e),e.parentNode&&e.parentNode.removeChild(e)},cleanExternalData:function(e){jQuery&&typeof jQuery["cleanData"]=="function"&&jQuery.cleanData([e])}}},t.cleanNode=t.utils.domNodeDisposal.cleanNode,t.removeNode=t.utils.domNodeDisposal.removeNode,t.exportSymbol("cleanNode",t.cleanNode),t.exportSymbol("removeNode",t.removeNode),t.exportSymbol("utils.domNodeDisposal",t.utils.domNodeDisposal),t.exportSymbol("utils.domNodeDisposal.addDisposeCallback",t.utils.domNodeDisposal.addDisposeCallback),t.exportSymbol("utils.domNodeDisposal.removeDisposeCallback",t.utils.domNodeDisposal.removeDisposeCallback),function(){function n(e){var n=t.utils.stringTrim(e).toLowerCase(),r=document.createElement("div"),i=n.match(/^<(thead|tbody|tfoot)/)&&[1,"<table>","</table>"]||!n.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!n.indexOf("<td")||!n.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||[0,"",""],s="ignored<div>"+i[1]+e+i[2]+"</div>";typeof window["innerShiv"]=="function"?r.appendChild(window.innerShiv(s)):r.innerHTML=s;while(i[0]--)r=r.lastChild;return t.utils.makeArray(r.lastChild.childNodes)}function r(e){if(jQuery.parseHTML)return jQuery.parseHTML(e)||[];var t=jQuery.clean([e]);if(t&&t[0]){var n=t[0];while(n.parentNode&&n.parentNode.nodeType!==11)n=n.parentNode;n.parentNode&&n.parentNode.removeChild(n)}return t}var e=/^(\s*)<!--(.*?)-->/;t.utils.parseHtmlFragment=function(e){return jQuery?r(e):n(e)},t.utils.setHtml=function(e,n){t.utils.emptyDomNode(e),n=t.utils.unwrapObservable(n);if(n!==null&&n!==undefined){typeof n!="string"&&(n=n.toString());if(jQuery)jQuery(e).html(n);else{var r=t.utils.parseHtmlFragment(n);for(var i=0;i<r.length;i++)e.appendChild(r[i])}}}}(),t.exportSymbol("utils.parseHtmlFragment",t.utils.parseHtmlFragment),t.exportSymbol("utils.setHtml",t.utils.setHtml),t.memoization=function(){function n(){return((1+Math.random())*4294967296|0).toString(16).substring(1)}function r(){return n()+n()}function i(e,n){if(!e)return;if(e.nodeType==8){var r=t.memoization.parseMemoText(e.nodeValue);r!=null&&n.push({domNode:e,memoId:r})}else if(e.nodeType==1)for(var s=0,o=e.childNodes,u=o.length;s<u;s++)i(o[s],n)}var e={};return{memoize:function(t){if(typeof t!="function")throw new Error("You can only pass a function to ko.memoization.memoize()");var n=r();return e[n]=t,"<!--[ko_memo:"+n+"]-->"},unmemoize:function(t,n){var r=e[t];if(r===undefined)throw new Error("Couldn't find any memo with ID "+t+". Perhaps it's already been unmemoized.");try{return r.apply(null,n||[]),!0}finally{delete e[t]}},unmemoizeDomNodeAndDescendants:function(e,n){var r=[];i(e,r);for(var s=0,o=r.length;s<o;s++){var u=r[s].domNode,a=[u];n&&t.utils.arrayPushAll(a,n),t.memoization.unmemoize(r[s].memoId,a),u.nodeValue="",u.parentNode&&u.parentNode.removeChild(u)}},parseMemoText:function(e){var t=e.match(/^\[ko_memo\:(.*?)\]$/);return t?t[1]:null}}}(),t.exportSymbol("memoization",t.memoization),t.exportSymbol("memoization.memoize",t.memoization.memoize),t.exportSymbol("memoization.unmemoize",t.memoization.unmemoize),t.exportSymbol("memoization.parseMemoText",t.memoization.parseMemoText),t.exportSymbol("memoization.unmemoizeDomNodeAndDescendants",t.memoization.unmemoizeDomNodeAndDescendants),t.extenders={throttle:function(e,n){e.throttleEvaluation=n;var r=null;return t.dependentObservable({read:e,write:function(t){clearTimeout(r),r=setTimeout(function(){e(t)},n)}})},rateLimit:function(e,t){var n,r,o;typeof t=="number"?n=t:(n=t.timeout,r=t.method),o=r=="notifyWhenChangesStop"?s:i,e.limit(function(e){return o(e,n)})},notify:function(e,t){e.equalityComparer=t=="always"?null:r}};var n={"undefined":1,"boolean":1,number:1,string:1};t.exportSymbol("extenders",t.extenders),t.subscription=function(e,n,r){this.target=e,this.callback=n,this.disposeCallback=r,this.isDisposed=!1,t.exportProperty(this,"dispose",this.dispose)},t.subscription.prototype.dispose=function(){this.isDisposed=!0,this.disposeCallback()},t.subscribable=function(){t.utils.setPrototypeOfOrExtend(this,t.subscribable.fn),this._subscriptions={}};var u="change",a={subscribe:function(e,n,r){var i=this;r=r||u;var s=n?e.bind(n):e,o=new t.subscription(i,s,function(){t.utils.arrayRemoveItem(i._subscriptions[r],o)});return i.peek&&i.peek(),i._subscriptions[r]||(i._subscriptions[r]=[]),i._subscriptions[r].push(o),o},notifySubscribers:function(e,n){n=n||u;if(this.hasSubscriptionsForEvent(n))try{t.dependencyDetection.begin();for(var r=this._subscriptions[n].slice(0),i=0,s;s=r[i];++i)s.isDisposed||s.callback(e)}finally{t.dependencyDetection.end()}},limit:function(e){var n=this,r=t.isObservable(n),i,s,o,a="beforeChange";n._origNotifySubscribers||(n._origNotifySubscribers=n.notifySubscribers,n.notifySubscribers=function(e,t){!t||t===u?n._rateLimitedChange(e):t===a?n._rateLimitedBeforeChange(e):n._origNotifySubscribers(e,t)});var f=e(function(){r&&o===n&&(o=n()),i=!1,n.isDifferent(s,o)&&n._origNotifySubscribers(s=o)});n._rateLimitedChange=function(e){i=!0,o=e,f()},n._rateLimitedBeforeChange=function(e){i||(s=e,n._origNotifySubscribers(e,a))}},hasSubscriptionsForEvent:function(e){return this._subscriptions[e]&&this._subscriptions[e].length},getSubscriptionsCount:function(){var e=0;return t.utils.objectForEach(this._subscriptions,function(t,n){e+=n.length}),e},isDifferent:function(e,t){return!this.equalityComparer||!this.equalityComparer(e,t)},extend:o};t.exportProperty(a,"subscribe",a.subscribe),t.exportProperty(a,"extend",a.extend),t.exportProperty(a,"getSubscriptionsCount",a.getSubscriptionsCount),t.utils.canSetPrototype&&t.utils.setPrototypeOf(a,Function.prototype),t.subscribable.fn=a,t.isSubscribable=function(e){return e!=null&&typeof e.subscribe=="function"&&typeof e["notifySubscribers"]=="function"},t.exportSymbol("subscribable",t.subscribable),t.exportSymbol("isSubscribable",t.isSubscribable),t.computedContext=t.dependencyDetection=function(){function i(){return++r}function s(t){e.push(n),n=t}function o(){n=e.pop()}var e=[],n,r=0;return{begin:s,end:o,registerDependency:function(e){if(n){if(!t.isSubscribable(e))throw new Error("Only subscribable things can act as dependencies");n.callback(e,e._id||(e._id=i()))}},ignore:function(e,t,n){try{return s(),e.apply(t,n||[])}finally{o()}},getDependenciesCount:function(){if(n)return n.computed.getDependenciesCount()},isInitial:function(){if(n)return n.isInitial}}}(),t.exportSymbol("computedContext",t.computedContext),t.exportSymbol("computedContext.getDependenciesCount",t.computedContext.getDependenciesCount),t.exportSymbol("computedContext.isInitial",t.computedContext.isInitial),t.observable=function(e){function r(){return arguments.length>0?(r.isDifferent(n,arguments[0])&&(r.valueWillMutate(),n=arguments[0],DEBUG&&(r._latestValue=n),r.valueHasMutated()),this):(t.dependencyDetection.registerDependency(r),n)}var n=e;return t.subscribable.call(r),t.utils.setPrototypeOfOrExtend(r,t.observable.fn),DEBUG&&(r._latestValue=n),r.peek=function(){return n},r.valueHasMutated=function(){r.notifySubscribers(n)},r.valueWillMutate=function(){r.notifySubscribers(n,"beforeChange")},t.exportProperty(r,"peek",r.peek),t.exportProperty(r,"valueHasMutated",r.valueHasMutated),t.exportProperty(r,"valueWillMutate",r.valueWillMutate),r},t.observable.fn={equalityComparer:r};var f=t.observable.protoProperty="__ko_proto__";t.observable.fn[f]=t.observable,t.utils.canSetPrototype&&t.utils.setPrototypeOf(t.observable.fn,t.subscribable.fn),t.hasPrototype=function(e,n){return e===null||e===undefined||e[f]===undefined?!1:e[f]===n?!0:t.hasPrototype(e[f],n)},t.isObservable=function(e){return t.hasPrototype(e,t.observable)},t.isWriteableObservable=function(e){return typeof e=="function"&&e[f]===t.observable?!0:typeof e=="function"&&e[f]===t.dependentObservable&&e.hasWriteFunction?!0:!1},t.exportSymbol("observable",t.observable),t.exportSymbol("isObservable",t.isObservable),t.exportSymbol("isWriteableObservable",t.isWriteableObservable),t.observableArray=function(e){e=e||[];if(typeof e=="object"&&"length"in e){var n=t.observable(e);return t.utils.setPrototypeOfOrExtend(n,t.observableArray.fn),n.extend({trackArrayChanges:!0})}throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.")},t.observableArray.fn={remove:function(e){var n=this.peek(),r=[],i=typeof e=="function"&&!t.isObservable(e)?e:function(t){return t===e};for(var s=0;s<n.length;s++){var o=n[s];i(o)&&(r.length===0&&this.valueWillMutate(),r.push(o),n.splice(s,1),s--)}return r.length&&this.valueHasMutated(),r},removeAll:function(e){if(e===undefined){var n=this.peek(),r=n.slice(0);return this.valueWillMutate(),n.splice(0,n.length),this.valueHasMutated(),r}return e?this.remove(function(n){return t.utils.arrayIndexOf(e,n)>=0}):[]},destroy:function(e){var n=this.peek(),r=typeof e=="function"&&!t.isObservable(e)?e:function(t){return t===e};this.valueWillMutate();for(var i=n.length-1;i>=0;i--){var s=n[i];r(s)&&(n[i]._destroy=!0)}this.valueHasMutated()},destroyAll:function(e){return e===undefined?this.destroy(function(){return!0}):e?this.destroy(function(n){return t.utils.arrayIndexOf(e,n)>=0}):[]},indexOf:function(e){var n=this();return t.utils.arrayIndexOf(n,e)},replace:function(e,t){var n=this.indexOf(e);n>=0&&(this.valueWillMutate(),this.peek()[n]=t,this.valueHasMutated())}},t.utils.arrayForEach(["pop","push","reverse","shift","sort","splice","unshift"],function(e){t.observableArray.fn[e]=function(){var t=this.peek();this.valueWillMutate(),this.cacheDiffForKnownOperation(t,e,arguments);var n=t[e].apply(t,arguments);return this.valueHasMutated(),n}}),t.utils.arrayForEach(["slice"],function(e){t.observableArray.fn[e]=function(){var t=this();return t[e].apply(t,arguments)}}),t.utils.canSetPrototype&&t.utils.setPrototypeOf(t.observableArray.fn,t.observable.fn),t.exportSymbol("observableArray",t.observableArray);var l="arrayChange";t.extenders.trackArrayChanges=function(e){function o(){if(n)return;n=!0;var t=e.notifySubscribers;e.notifySubscribers=function(e,n){return(!n||n===u)&&++i,t.apply(this,arguments)};var s=[].concat(e.peek()||[]);r=null,e.subscribe(function(t){t=[].concat(t||[]);if(e.hasSubscriptionsForEvent(l)){var n=a(s,t);n.length&&e.notifySubscribers(n,l)}s=t,r=null,i=0})}function a(e,n){if(!r||i>1)r=t.utils.compareArrays(e,n,{sparse:!0});return r}if(e.cacheDiffForKnownOperation)return;var n=!1,r=null,i=0,s=e.subscribe;e.subscribe=e.subscribe=function(e,t,n){return n===l&&o(),s.apply(this,arguments)},e.cacheDiffForKnownOperation=function(e,s,o){function c(e,t,n){return u[u.length]={status:e,value:t,index:n}}if(!n||i)return;var u=[],a=e.length,f=o.length,l=0;switch(s){case"push":l=a;case"unshift":for(var h=0;h<f;h++)c("added",o[h],l+h);break;case"pop":l=a-1;case"shift":a&&c("deleted",e[l],l);break;case"splice":var p=Math.min(Math.max(0,o[0]<0?a+o[0]:o[0]),a),d=f===1?a:Math.min(p+(o[1]||0),a),v=p+f-2,m=Math.max(d,v),g=[],y=[];for(var h=p,b=2;h<m;++h,++b)h<d&&y.push(c("deleted",e[h],h)),h<v&&g.push(c("added",o[b],h));t.utils.findMovesInArrayComparison(y,g);break;default:return}r=u}},t.computed=t.dependentObservable=function(e,n,r){function l(e,t){S[t]||(S[t]=e.subscribe(h),++x)}function c(){a=!0,t.utils.objectForEach(S,function(e,t){t.dispose()}),S={},x=0,s=!1}function h(){var e=d.throttleEvaluation;e&&e>=0?(clearTimeout(T),T=setTimeout(p,e)):d._evalRateLimited?d._evalRateLimited():p()}function p(){if(o)return;if(a)return;if(w&&w()){if(!u){E();return}}else u=!1;o=!0;try{var e=S,r=x;t.dependencyDetection.begin({callback:function(t,n){a||(r&&e[n]?(S[n]=e[n],++x,delete e[n],--r):l(t,n))},computed:d,isInitial:!x}),S={},x=0;try{var c=n?f.call(n):f()}finally{t.dependencyDetection.end(),r&&t.utils.objectForEach(e,function(e,t){t.dispose()}),s=!1}d.isDifferent(i,c)&&(d.notifySubscribers(i,"beforeChange"),i=c,DEBUG&&(d._latestValue=i),(!d._evalRateLimited||d.throttleEvaluation)&&d.notifySubscribers(i))}finally{o=!1}x||E()}function d(){if(arguments.length>0){if(typeof g!="function")throw new Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");return g.apply(n,arguments),this}return s&&p(),t.dependencyDetection.registerDependency(d),i}function v(){return s&&!x&&p(),i}function m(){return s||x>0}var i,s=!0,o=!1,u=!1,a=!1,f=e;f&&typeof f=="object"?(r=f,f=r.read):(r=r||{},f||(f=r.read));if(typeof f!="function")throw new Error("Pass a function that returns the value of the ko.computed");var g=r.write,y=r.disposeWhenNodeIsRemoved||r.disposeWhenNodeIsRemoved||null,b=r.disposeWhen||r.disposeWhen,w=b,E=c,S={},x=0,T=null;n||(n=r.owner),t.subscribable.call(d),t.utils.setPrototypeOfOrExtend(d,t.dependentObservable.fn),d.peek=v,d.getDependenciesCount=function(){return x},d.hasWriteFunction=typeof r.write=="function",d.dispose=function(){E()},d.isActive=m;var N=d.limit;return d.limit=function(e){N.call(d,e),d._evalRateLimited=function(){d._rateLimitedBeforeChange(i),s=!0,d._rateLimitedChange(d)}},t.exportProperty(d,"peek",d.peek),t.exportProperty(d,"dispose",d.dispose),t.exportProperty(d,"isActive",d.isActive),t.exportProperty(d,"getDependenciesCount",d.getDependenciesCount),y&&(u=!0,y.nodeType&&(w=function(){return!t.utils.domNodeIsAttachedToDocument(y)||b&&b()})),r.deferEvaluation!==!0&&p(),y&&m()&&y.nodeType&&(E=function(){t.utils.domNodeDisposal.removeDisposeCallback(y,E),c()},t.utils.domNodeDisposal.addDisposeCallback(y,E)),d},t.isComputed=function(e){return t.hasPrototype(e,t.dependentObservable)};var c=t.observable.protoProperty;t.dependentObservable[c]=t.observable,t.dependentObservable.fn={equalityComparer:r},t.dependentObservable.fn[c]=t.dependentObservable,t.utils.canSetPrototype&&t.utils.setPrototypeOf(t.dependentObservable.fn,t.subscribable.fn),t.exportSymbol("dependentObservable",t.dependentObservable),t.exportSymbol("computed",t.dependentObservable),t.exportSymbol("isComputed",t.isComputed),function(){function n(e,t,s){s=s||new i,e=t(e);var o=typeof e=="object"&&e!==null&&e!==undefined&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof Number)&&!(e instanceof Boolean);if(!o)return e;var u=e instanceof Array?[]:{};return s.save(e,u),r(e,function(r){var i=t(e[r]);switch(typeof i){case"boolean":case"number":case"string":case"function":u[r]=i;break;case"object":case"undefined":var o=s.get(i);u[r]=o!==undefined?o:n(i,t,s)}}),u}function r(e,t){if(e instanceof Array){for(var n=0;n<e.length;n++)t(n);typeof e["toJSON"]=="function"&&t("toJSON")}else for(var r in e)t(r)}function i(){this.keys=[],this.values=[]}var e=10;t.toJS=function(r){if(arguments.length==0)throw new Error("When calling ko.toJS, pass the object you want to convert.");return n(r,function(n){for(var r=0;t.isObservable(n)&&r<e;r++)n=n();return n})},t.toJSON=function(e,n,r){var i=t.toJS(e);return t.utils.stringifyJson(i,n,r)},i.prototype={constructor:i,save:function(e,n){var r=t.utils.arrayIndexOf(this.keys,e);r>=0?this.values[r]=n:(this.keys.push(e),this.values.push(n))},get:function(e){var n=t.utils.arrayIndexOf(this.keys,e);return n>=0?this.values[n]:undefined}}}(),t.exportSymbol("toJS",t.toJS),t.exportSymbol("toJSON",t.toJSON),function(){var e="__ko__hasDomDataOptionValue__";t.selectExtensions={readValue:function(n){switch(t.utils.tagNameLower(n)){case"option":if(n[e]===!0)return t.utils.domData.get(n,t.bindingHandlers.options.optionValueDomDataKey);return t.utils.ieVersion<=7?n.getAttributeNode("value")&&n.getAttributeNode("value").specified?n.value:n.text:n.value;case"select":return n.selectedIndex>=0?t.selectExtensions.readValue(n.options[n.selectedIndex]):undefined;default:return n.value}},writeValue:function(n,r,i){switch(t.utils.tagNameLower(n)){case"option":switch(typeof r){case"string":t.utils.domData.set(n,t.bindingHandlers.options.optionValueDomDataKey,undefined),e in n&&delete n[e],n.value=r;break;default:t.utils.domData.set(n,t.bindingHandlers.options.optionValueDomDataKey,r),n[e]=!0,n.value=typeof r=="number"?r:""}break;case"select":if(r===""||r===null)r=undefined;var s=-1;for(var o=0,u=n.options.length,a;o<u;++o){a=t.selectExtensions.readValue(n.options[o]);if(a==r||a==""&&r===undefined){s=o;break}}if(i||s>=0||r===undefined&&n.size>1)n.selectedIndex=s;break;default:if(r===null||r===undefined)r="";n.value=r}}}}(),t.exportSymbol("selectExtensions",t.selectExtensions),t.exportSymbol("selectExtensions.readValue",t.selectExtensions.readValue),t.exportSymbol("selectExtensions.writeValue",t.selectExtensions.writeValue),t.expressionRewriting=function(){function r(r){if(t.utils.arrayIndexOf(e,r)>=0)return!1;var i=r.match(n);return i===null?!1:i[1]?"Object("+i[1]+")"+i[2]:r}function p(e){var n=t.utils.stringTrim(e);n.charCodeAt(0)===123&&(n=n.slice(1,-1));var r=[],i=n.match(l),s,o,u=0;if(i){i.push(",");for(var a=0,f;f=i[a];++a){var p=f.charCodeAt(0);if(p===44){if(u<=0){s&&r.push(o?{key:s,value:o.join("")}:{unknown:s}),s=o=u=0;continue}}else if(p===58){if(!o)continue}else if(p===47&&a&&f.length>1){var d=i[a-1].match(c);d&&!h[d[0]]&&(n=n.substr(n.indexOf(f)+1),i=n.match(l),i.push(","),a=-1,f="/")}else if(p===40||p===123||p===91)++u;else if(p===41||p===125||p===93)--u;else if(!s&&!o){s=p===34||p===39?f.slice(1,-1):f;continue}o?o.push(f):o=[f]}}return r}function v(e,n){function i(e,n){function f(t){return t&&t.preprocess?n=t.preprocess(n,e,i):!0}var a;if(!f(t.getBindingHandler(e)))return;d[e]&&(a=r(n))&&o.push("'"+e+"':function(_z){"+a+"=_z}"),u&&(n="function(){return "+n+" }"),s.push("'"+e+"':"+n)}n=n||{};var s=[],o=[],u=n.valueAccessors,a=typeof e=="string"?p(e):e;return t.utils.arrayForEach(a,function(e){i(e.key||e.unknown,e.value)}),o.length&&i("_ko_property_writers","{"+o.join(",")+" }"),s.join(",")}var e=["true","false","null","undefined"],n=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,i='"(?:[^"\\\\]|\\\\.)*"',s="'(?:[^'\\\\]|\\\\.)*'",o="/(?:[^/\\\\]|\\\\.)*/w*",u=",\"'{}()/:[\\]",a="[^\\s:,/][^"+u+"]*[^\\s"+u+"]",f="[^\\s]",l=RegExp(i+"|"+s+"|"+o+"|"+a+"|"+f,"g"),c=/[\])"'A-Za-z0-9_$]+$/,h={"in":1,"return":1,"typeof":1},d={};return{bindingRewriteValidators:[],twoWayBindings:d,parseObjectLiteral:p,preProcessBindings:v,keyValueArrayContainsKey:function(e,t){for(var n=0;n<e.length;n++)if(e[n]["key"]==t)return!0;return!1},writeValueToProperty:function(e,n,r,i,s){if(!e||!t.isObservable(e)){var o=n.get("_ko_property_writers");o&&o[r]&&o[r](i)}else t.isWriteableObservable(e)&&(!s||e.peek()!==i)&&e(i)}}}(),t.exportSymbol("expressionRewriting",t.expressionRewriting),t.exportSymbol("expressionRewriting.bindingRewriteValidators",t.expressionRewriting.bindingRewriteValidators),t.exportSymbol("expressionRewriting.parseObjectLiteral",t.expressionRewriting.parseObjectLiteral),t.exportSymbol("expressionRewriting.preProcessBindings",t.expressionRewriting.preProcessBindings),t.exportSymbol("expressionRewriting._twoWayBindings",t.expressionRewriting.twoWayBindings),t.exportSymbol("jsonExpressionRewriting",t.expressionRewriting),t.exportSymbol("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",t.expressionRewriting.preProcessBindings),function(){function s(t){return t.nodeType==8&&n.test(e?t.text:t.nodeValue)}function o(t){return t.nodeType==8&&r.test(e?t.text:t.nodeValue)}function u(e,t){var n=e,r=1,i=[];while(n=n.nextSibling){if(o(n)){r--;if(r===0)return i}i.push(n),s(n)&&r++}if(!t)throw new Error("Cannot find closing comment tag to match: "+e.nodeValue);return null}function a(e,t){var n=u(e,t);return n?n.length>0?n[n.length-1].nextSibling:e.nextSibling:null}function f(e){var t=e.firstChild,n=null;if(t)do if(n)n.push(t);else if(s(t)){var r=a(t,!0);r?t=r:n=[t]}else o(t)&&(n=[t]);while(t=t.nextSibling);return n}var e=document&&document.createComment("test").text==="<!--test-->",n=e?/^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,r=e?/^<!--\s*\/ko\s*-->$/:/^\s*\/ko\s*$/,i={ul:!0,ol:!0};t.virtualElements={allowedBindings:{},childNodes:function(e){return s(e)?u(e):e.childNodes},emptyNode:function(e){if(!s(e))t.utils.emptyDomNode(e);else{var n=t.virtualElements.childNodes(e);for(var r=0,i=n.length;r<i;r++)t.removeNode(n[r])}},setDomNodeChildren:function(e,n){if(!s(e))t.utils.setDomNodeChildren(e,n);else{t.virtualElements.emptyNode(e);var r=e.nextSibling;for(var i=0,o=n.length;i<o;i++)r.parentNode.insertBefore(n[i],r)}},prepend:function(e,t){s(e)?e.parentNode.insertBefore(t,e.nextSibling):e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)},insertAfter:function(e,n,r){r?s(e)?e.parentNode.insertBefore(n,r.nextSibling):r.nextSibling?e.insertBefore(n,r.nextSibling):e.appendChild(n):t.virtualElements.prepend(e,n)},firstChild:function(e){return s(e)?!e.nextSibling||o(e.nextSibling)?null:e.nextSibling:e.firstChild},nextSibling:function(e){return s(e)&&(e=a(e)),e.nextSibling&&o(e.nextSibling)?null:e.nextSibling},hasBindingValue:s,virtualNodeBindingValue:function(t){var r=(e?t.text:t.nodeValue).match(n);return r?r[1]:null},normaliseVirtualElementDomStructure:function(e){if(!i[t.utils.tagNameLower(e)])return;var n=e.firstChild;if(n)do if(n.nodeType===1){var r=f(n);if(r){var s=n.nextSibling;for(var o=0;o<r.length;o++)s?e.insertBefore(r[o],s):e.appendChild(r[o])}}while(n=n.nextSibling)}}}(),t.exportSymbol("virtualElements",t.virtualElements),t.exportSymbol("virtualElements.allowedBindings",t.virtualElements.allowedBindings),t.exportSymbol("virtualElements.emptyNode",t.virtualElements.emptyNode),t.exportSymbol("virtualElements.insertAfter",t.virtualElements.insertAfter),t.exportSymbol("virtualElements.prepend",t.virtualElements.prepend),t.exportSymbol("virtualElements.setDomNodeChildren",t.virtualElements.setDomNodeChildren),function(){function n(e,t,n){var i=e+(n&&n.valueAccessors||"");return t[i]||(t[i]=r(e,n))}function r(e,n){var r=t.expressionRewriting.preProcessBindings(e,n),i="with($context){with($data||{}){return{"+r+"}}}";return new Function("$context","$element",i)}var e="data-bind";t.bindingProvider=function(){this.bindingCache={}},t.utils.extend(t.bindingProvider.prototype,{nodeHasBindings:function(n){switch(n.nodeType){case 1:return n.getAttribute(e)!=null;case 8:return t.virtualElements.hasBindingValue(n);default:return!1}},getBindings:function(e,t){var n=this.getBindingsString(e,t);return n?this.parseBindingsString(n,t,e):null},getBindingAccessors:function(e,t){var n=this.getBindingsString(e,t);return n?this.parseBindingsString(n,t,e,{valueAccessors:!0}):null},getBindingsString:function(n,r){switch(n.nodeType){case 1:return n.getAttribute(e);case 8:return t.virtualElements.virtualNodeBindingValue(n);default:return null}},parseBindingsString:function(e,t,r,i){try{var s=n(e,this.bindingCache,i);return s(t,r)}catch(o){throw o.message="Unable to parse bindings.\nBindings value: "+e+"\nMessage: "+o.message,o}}}),t.bindingProvider.instance=new t.bindingProvider}(),t.exportSymbol("bindingProvider",t.bindingProvider),function(){function n(e){return function(){return e}}function r(e){return e()}function i(e){return t.utils.objectMap(t.dependencyDetection.ignore(e),function(t,n){return function(){return e()[n]}})}function s(e,r,s){return typeof e=="function"?i(e.bind(null,r,s)):t.utils.objectMap(e,n)}function o(e,t){return i(this.getBindings.bind(this,e,t))}function u(e){var n=t.virtualElements.allowedBindings[e];if(!n)throw new Error("The binding '"+e+"' cannot be used with virtual elements")}function a(e,n,r){var i,s=t.virtualElements.firstChild(n),o=t.bindingProvider.instance,u=o.preprocessNode;if(u){while(i=s)s=t.virtualElements.nextSibling(i),u.call(o,i);s=t.virtualElements.firstChild(n)}while(i=s)s=t.virtualElements.nextSibling(i),f(e,i,r)}function f(n,r,i){var s=!0,o=r.nodeType===1;o&&t.virtualElements.normaliseVirtualElementDomStructure(r);var u=o&&i||t.bindingProvider.instance.nodeHasBindings(r);u&&(s=h(r,null,n,i).shouldBindDescendants),s&&!e[t.utils.tagNameLower(r)]&&a(n,r,!o)}function c(e){var n=[],r={},i=[];return t.utils.objectForEach(e,function s(o){if(!r[o]){var u=t.getBindingHandler(o);u&&(u.after&&(i.push(o),t.utils.arrayForEach(u.after,function(n){if(e[n]){if(t.utils.arrayIndexOf(i,n)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+i.join(", "));s(n)}}),i.length--),n.push({key:o,handler:u})),r[o]=!0}}),n}function h(e,n,i,s){var a=t.utils.domData.get(e,l);if(!n){if(a)throw Error("You cannot apply bindings multiple times to the same element.");t.utils.domData.set(e,l,!0)}!a&&s&&t.storedBindingContextForNode(e,i);var f;if(n&&typeof n!="function")f=n;else{var h=t.bindingProvider.instance,p=h.getBindingAccessors||o,d=t.dependentObservable(function(){return f=n?n(i,e):p.call(h,e,i),f&&i._subscribable&&i._subscribable(),f},null,{disposeWhenNodeIsRemoved:e});if(!f||!d.isActive())d=null}var v;if(f){var m=d?function(e){return function(){return r(d()[e])}}:function(e){return f[e]};function g(){return t.utils.objectMap(d?d():f,r)}g.get=function(e){return f[e]&&r(m(e))},g.has=function(e){return e in f};var y=c(f);t.utils.arrayForEach(y,function(n){var r=n.handler.init,s=n.handler.update,o=n.key;e.nodeType===8&&u(o);try{typeof r=="function"&&t.dependencyDetection.ignore(function(){var t=r(e,m(o),g,i.$data,i);if(t&&t.controlsDescendantBindings){if(v!==undefined)throw new Error("Multiple bindings ("+v+" and "+o+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");v=o}}),typeof s=="function"&&t.dependentObservable(function(){s(e,m(o),g,i.$data,i)},null,{disposeWhenNodeIsRemoved:e})}catch(a){throw a.message='Unable to process binding "'+o+": "+f[o]+'"\nMessage: '+a.message,a}})}return{shouldBindDescendants:v===undefined}}function d(e){return e&&e instanceof t.bindingContext?e:new t.bindingContext(e)}t.bindingHandlers={};var e={script:!0};t.getBindingHandler=function(e){return t.bindingHandlers[e]},t.bindingContext=function(e,n,r,i){function s(){var s=a?e():e,o=t.utils.unwrapObservable(s);return n?(n._subscribable&&n._subscribable(),t.utils.extend(u,n),l&&(u._subscribable=l)):(u.$parents=[],u.$root=o,u.ko=t),u.$rawData=s,u.$data=o,r&&(u[r]=o),i&&i(u,n,o),u.$data}function o(){return f&&!t.utils.anyDomNodeIsAttachedToDocument(f)}var u=this,a=typeof e=="function"&&!t.isObservable(e),f,l=t.dependentObservable(s,null,{disposeWhen:o,disposeWhenNodeIsRemoved:!0});l.isActive()&&(u._subscribable=l,l.equalityComparer=null,f=[],l._addNode=function(e){f.push(e),t.utils.domNodeDisposal.addDisposeCallback(e,function(e){t.utils.arrayRemoveItem(f,e),f.length||(l.dispose(),u._subscribable=l=undefined)})})},t.bindingContext.prototype.createChildContext=function(e,n,r){return new t.bindingContext(e,this,n,function(e,t){e.$parentContext=t,e.$parent=t.$data,e.$parents=(t.$parents||[]).slice(0),e.$parents.unshift(e.$parent),r&&r(e)})},t.bindingContext.prototype.extend=function(e){return new t.bindingContext(this._subscribable||this.$data,this,null,function(n,r){n.$rawData=r.$rawData,t.utils.extend(n,typeof e=="function"?e():e)})};var l=t.utils.domData.nextKey(),p=t.utils.domData.nextKey();t.storedBindingContextForNode=function(e,n){if(arguments.length!=2)return t.utils.domData.get(e,p);t.utils.domData.set(e,p,n),n._subscribable&&n._subscribable._addNode(e)},t.applyBindingAccessorsToNode=function(e,n,r){return e.nodeType===1&&t.virtualElements.normaliseVirtualElementDomStructure(e),h(e,n,d(r),!0)},t.applyBindingsToNode=function(e,n,r){var i=d(r);return t.applyBindingAccessorsToNode(e,s(n,i,e),i)},t.applyBindingsToDescendants=function(e,t){(t.nodeType===1||t.nodeType===8)&&a(d(e),t,!0)},t.applyBindings=function(e,t){!jQuery&&window.jQuery&&(jQuery=window.jQuery);if(t&&t.nodeType!==1&&t.nodeType!==8)throw new Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");t=t||window.document.body,f(d(e),t,!0)},t.contextFor=function(e){switch(e.nodeType){case 1:case 8:var n=t.storedBindingContextForNode(e);if(n)return n;if(e.parentNode)return t.contextFor(e.parentNode)}return undefined},t.dataFor=function(e){var n=t.contextFor(e);return n?n.$data:undefined},t.exportSymbol("bindingHandlers",t.bindingHandlers),t.exportSymbol("applyBindings",t.applyBindings),t.exportSymbol("applyBindingsToDescendants",t.applyBindingsToDescendants),t.exportSymbol("applyBindingAccessorsToNode",t.applyBindingAccessorsToNode),t.exportSymbol("applyBindingsToNode",t.applyBindingsToNode),t.exportSymbol("contextFor",t.contextFor),t.exportSymbol("dataFor",t.dataFor)}();var h={"class":"className","for":"htmlFor"};t.bindingHandlers.attr={update:function(e,n,r){var i=t.utils.unwrapObservable(n())||{};t.utils.objectForEach(i,function(n,r){r=t.utils.unwrapObservable(r);var i=r===!1||r===null||r===undefined;i&&e.removeAttribute(n),t.utils.ieVersion<=8&&n in h?(n=h[n],i?e.removeAttribute(n):e[n]=r):i||e.setAttribute(n,r.toString()),n==="name"&&t.utils.setElementName(e,i?"":r.toString())})}},function(){t.bindingHandlers.checked={after:["value","attr"],init:function(e,n,r){function i(){return r.has("checkedValue")?t.utils.unwrapObservable(r.get("checkedValue")):e.value}function s(){var s=e.checked,o=c?i():s;if(t.computedContext.isInitial())return;if(a&&!s)return;var u=t.dependencyDetection.ignore(n);f?l!==o?(s&&(t.utils.addOrRemoveItem(u,o,!0),t.utils.addOrRemoveItem(u,l,!1)),l=o):t.utils.addOrRemoveItem(u,o,s):t.expressionRewriting.writeValueToProperty(u,r,"checked",o,!0)}function o(){var r=t.utils.unwrapObservable(n());f?e.checked=t.utils.arrayIndexOf(r,i())>=0:u?e.checked=r:e.checked=i()===r}var u=e.type=="checkbox",a=e.type=="radio";if(!u&&!a)return;var f=u&&t.utils.unwrapObservable(n())instanceof Array,l=f?i():undefined,c=a||f;a&&!e.name&&t.bindingHandlers.uniqueName.init(e,function(){return!0}),t.computed(s,null,{disposeWhenNodeIsRemoved:e}),t.utils.registerEventHandler(e,"click",s),t.computed(o,null,{disposeWhenNodeIsRemoved:e})}},t.expressionRewriting.twoWayBindings.checked=!0,t.bindingHandlers.checkedValue={update:function(e,n){e.value=t.utils.unwrapObservable(n())}}}();var p="__ko__cssValue";t.bindingHandlers.css={update:function(e,n){var r=t.utils.unwrapObservable(n());typeof r=="object"?t.utils.objectForEach(r,function(n,r){r=t.utils.unwrapObservable(r),t.utils.toggleDomNodeCssClass(e,n,r)}):(r=String(r||""),t.utils.toggleDomNodeCssClass(e,e[p],!1),e[p]=r,t.utils.toggleDomNodeCssClass(e,r,!0))}},t.bindingHandlers.enable={update:function(e,n){var r=t.utils.unwrapObservable(n());r&&e.disabled?e.removeAttribute("disabled"):!r&&!e.disabled&&(e.disabled=!0)}},t.bindingHandlers.disable={update:function(e,n){t.bindingHandlers.enable.update(e,function(){return!t.utils.unwrapObservable(n())})}},t.bindingHandlers.event={init:function(e,n,r,i,s){var o=n()||{};t.utils.objectForEach(o,function(o){typeof o=="string"&&t.utils.registerEventHandler(e,o,function(e){var u,a=n()[o];if(!a)return;try{var f=t.utils.makeArray(arguments);i=s.$data,f.unshift(i),u=a.apply(i,f)}finally{u!==!0&&(e.preventDefault?e.preventDefault():e.returnValue=!1)}var l=r.get(o+"Bubble")!==!1;l||(e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation())})})}},t.bindingHandlers.foreach={makeTemplateValueAccessor:function(e){return function(){var n=e(),r=t.utils.peekObservable(n);return!r||typeof r.length=="number"?{foreach:n,templateEngine:t.nativeTemplateEngine.instance}:(t.utils.unwrapObservable(n),{foreach:r.data,as:r.as,includeDestroyed:r.includeDestroyed,afterAdd:r.afterAdd,beforeRemove:r.beforeRemove,afterRender:r.afterRender,beforeMove:r.beforeMove,afterMove:r.afterMove,templateEngine:t.nativeTemplateEngine.instance})}},init:function(e,n,r,i,s){return t.bindingHandlers.template.init(e,t.bindingHandlers.foreach.makeTemplateValueAccessor(n))},update:function(e,n,r,i,s){return t.bindingHandlers.template.update(e,t.bindingHandlers.foreach.makeTemplateValueAccessor(n),r,i,s)}},t.expressionRewriting.bindingRewriteValidators.foreach=!1,t.virtualElements.allowedBindings.foreach=!0;var v="__ko_hasfocusUpdating",m="__ko_hasfocusLastValue";t.bindingHandlers.hasfocus={init:function(e,n,r){var i=function(i){e[v]=!0;var s=e.ownerDocument;if("activeElement"in s){var o;try{o=s.activeElement}catch(u){o=s.body}i=o===e}var a=n();t.expressionRewriting.writeValueToProperty(a,r,"hasfocus",i,!0),e[m]=i,e[v]=!1},s=i.bind(null,!0),o=i.bind(null,!1);t.utils.registerEventHandler(e,"focus",s),t.utils.registerEventHandler(e,"focusin",s),t.utils.registerEventHandler(e,"blur",o),t.utils.registerEventHandler(e,"focusout",o)},update:function(e,n){var r=!!t.utils.unwrapObservable(n());!e[v]&&e[m]!==r&&(r?e.focus():e.blur(),t.dependencyDetection.ignore(t.utils.triggerEvent,null,[e,r?"focusin":"focusout"]))}},t.expressionRewriting.twoWayBindings.hasfocus=!0,t.bindingHandlers.hasFocus=t.bindingHandlers.hasfocus,t.expressionRewriting.twoWayBindings.hasFocus=!0,t.bindingHandlers.html={init:function(){return{controlsDescendantBindings:!0}},update:function(e,n){t.utils.setHtml(e,n())}},g("if"),g("ifnot",!1,!0),g("with",!0,!1,function(e,t){return e.createChildContext(t)});var y={};t.bindingHandlers.options={init:function(e){if(t.utils.tagNameLower(e)!=="select")throw new Error("options binding applies only to SELECT elements");while(e.length>0)e.remove(0);return{controlsDescendantBindings:!0}},update:function(e,n,r){function i(){return t.utils.arrayFilter(e.options,function(e){return e.selected})}function p(e,t,n){var r=typeof t;return r=="function"?t(e):r=="string"?e[t]:n}function v(n,i,s){s.length&&(h=s[0].selected?[t.selectExtensions.readValue(s[0])]:[],d=!0);var o=e.ownerDocument.createElement("option");if(n===y)t.utils.setTextContent(o,r.get("optionsCaption")),t.selectExtensions.writeValue(o,undefined);else{var u=p(n,r.get("optionsValue"),n);t.selectExtensions.writeValue(o,t.utils.unwrapObservable(u));var a=p(n,r.get("optionsText"),u);t.utils.setTextContent(o,a)}return[o]}function m(n,r){if(h.length){var i=t.utils.arrayIndexOf(h,t.selectExtensions.readValue(r[0]))>=0;t.utils.setOptionNodeSelectionState(r[0],i),d&&!i&&t.dependencyDetection.ignore(t.utils.triggerEvent,null,[e,"change"])}}var s=e.length==0,o=!s&&e.multiple?e.scrollTop:null,u=t.utils.unwrapObservable(n()),a=r.get("optionsIncludeDestroyed"),f={},l,c,h;e.multiple?h=t.utils.arrayMap(i(),t.selectExtensions.readValue):h=e.selectedIndex>=0?[t.selectExtensions.readValue(e.options[e.selectedIndex])]:[],u&&(typeof u.length=="undefined"&&(u=[u]),c=t.utils.arrayFilter(u,function(e){return a||e===undefined||e===null||!t.utils.unwrapObservable(e._destroy)}),r.has("optionsCaption")&&(l=t.utils.unwrapObservable(r.get("optionsCaption")),l!==null&&l!==undefined&&c.unshift(y)));var d=!1;f.beforeRemove=function(t){e.removeChild(t)};var g=m;r.has("optionsAfterRender")&&(g=function(e,n){m(e,n),t.dependencyDetection.ignore(r.get("optionsAfterRender"),null,[n[0],e!==y?e:undefined])}),t.utils.setDomNodeChildrenFromArrayMapping(e,c,v,f,g),t.dependencyDetection.ignore(function(){if(r.get("valueAllowUnset")&&r.has("value"))t.selectExtensions.writeValue(e,t.utils.unwrapObservable(r.get("value")),!0);else{var n;e.multiple?n=h.length&&i().length<h.length:n=h.length&&e.selectedIndex>=0?t.selectExtensions.readValue(e.options[e.selectedIndex])!==h[0]:h.length||e.selectedIndex>=0,n&&t.utils.triggerEvent(e,"change")}}),t.utils.ensureSelectElementIsRenderedCorrectly(e),o&&Math.abs(o-e.scrollTop)>20&&(e.scrollTop=o)}},t.bindingHandlers.options.optionValueDomDataKey=t.utils.domData.nextKey(),t.bindingHandlers.selectedOptions={after:["options","foreach"],init:function(e,n,r){t.utils.registerEventHandler(e,"change",function(){var i=n(),s=[];t.utils.arrayForEach(e.getElementsByTagName("option"),function(e){e.selected&&s.push(t.selectExtensions.readValue(e))}),t.expressionRewriting.writeValueToProperty(i,r,"selectedOptions",s)})},update:function(e,n){if(t.utils.tagNameLower(e)!="select")throw new Error("values binding applies only to SELECT elements");var r=t.utils.unwrapObservable(n());r&&typeof r.length=="number"&&t.utils.arrayForEach(e.getElementsByTagName("option"),function(e){var n=t.utils.arrayIndexOf(r,t.selectExtensions.readValue(e))>=0;t.utils.setOptionNodeSelectionState(e,n)})}},t.expressionRewriting.twoWayBindings.selectedOptions=!0,t.bindingHandlers.style={update:function(e,n){var r=t.utils.unwrapObservable(n()||{});t.utils.objectForEach(r,function(n,r){r=t.utils.unwrapObservable(r),e.style[n]=r||""})}},t.bindingHandlers.submit={init:function(e,n,r,i,s){if(typeof n()!="function")throw new Error("The value for a submit binding must be a function");t.utils.registerEventHandler(e,"submit",function(t){var r,i=n();try{r=i.call(s.$data,e)}finally{r!==!0&&(t.preventDefault?t.preventDefault():t.returnValue=!1)}})}},t.bindingHandlers.text={init:function(){return{controlsDescendantBindings:!0}},update:function(e,n){t.utils.setTextContent(e,n())}},t.virtualElements.allowedBindings.text=!0,t.bindingHandlers.uniqueName={init:function(e,n){if(n()){var r="ko_unique_"+ ++t.bindingHandlers.uniqueName.currentIndex;t.utils.setElementName(e,r)}}},t.bindingHandlers.uniqueName.currentIndex=0,t.bindingHandlers.value={after:["options","foreach"],init:function(e,n,r){var i=["change"],s=r.get("valueUpdate"),o=!1;s&&(typeof s=="string"&&(s=[s]),t.utils.arrayPushAll(i,s),i=t.utils.arrayGetDistinctValues(i));var u=function(){o=!1;var i=n(),s=t.selectExtensions.readValue(e);t.expressionRewriting.writeValueToProperty(i,r,"value",s)},a=t.utils.ieVersion&&e.tagName.toLowerCase()=="input"&&e.type=="text"&&e.autocomplete!="off"&&(!e.form||e.form.autocomplete!="off");a&&t.utils.arrayIndexOf(i,"propertychange")==-1&&(t.utils.registerEventHandler(e,"propertychange",function(){o=!0}),t.utils.registerEventHandler(e,"focus",function(){o=!1}),t.utils.registerEventHandler(e,"blur",function(){o&&u()})),t.utils.arrayForEach(i,function(n){var r=u;t.utils.stringStartsWith(n,"after")&&(r=function(){setTimeout(u,0)},n=n.substring("after".length)),t.utils.registerEventHandler(e,n,r)})},update:function(e,n,r){var i=t.utils.unwrapObservable(n()),s=t.selectExtensions.readValue(e),o=i!==s;if(o)if(t.utils.tagNameLower(e)==="select"){var u=r.get("valueAllowUnset"),a=function(){t.selectExtensions.writeValue(e,i,u)};a(),!u&&i!==t.selectExtensions.readValue(e)?t.dependencyDetection.ignore(t.utils.triggerEvent,null,[e,"change"]):setTimeout(a,0)}else t.selectExtensions.writeValue(e,i)}},t.expressionRewriting.twoWayBindings.value=!0,t.bindingHandlers.visible={update:function(e,n){var r=t.utils.unwrapObservable(n()),i=e.style.display!="none";r&&!i?e.style.display="":!r&&i&&(e.style.display="none")}},d("click"),t.templateEngine=function(){},t.templateEngine.prototype.renderTemplateSource=function(e,t,n){throw new Error("Override renderTemplateSource")},t.templateEngine.prototype.createJavaScriptEvaluatorBlock=function(e){throw new Error("Override createJavaScriptEvaluatorBlock")},t.templateEngine.prototype.makeTemplateSource=function(e,n){if(typeof e=="string"){n=n||document;var r=n.getElementById(e);if(!r)throw new Error("Cannot find template with ID "+e);return new t.templateSources.domElement(r)}if(e.nodeType==1||e.nodeType==8)return new t.templateSources.anonymousTemplate(e);throw new Error("Unknown template type: "+e)},t.templateEngine.prototype.renderTemplate=function(e,t,n,r){var i=this.makeTemplateSource(e,r);return this.renderTemplateSource(i,t,n)},t.templateEngine.prototype.isTemplateRewritten=function(e,t){return this.allowTemplateRewriting===!1?!0:this.makeTemplateSource(e,t).data("isRewritten")},t.templateEngine.prototype.rewriteTemplate=function(e,t,n){var r=this.makeTemplateSource(e,n),i=t(r.text());r.text(i),r.data("isRewritten",!0)},t.exportSymbol("templateEngine",t.templateEngine),t.templateRewriting=function(){function r(e){var n=t.expressionRewriting.bindingRewriteValidators;for(var r=0;r<e.length;r++){var i=e[r].key;if(n.hasOwnProperty(i)){var s=n[i];if(typeof s=="function"){var o=s(e[r].value);if(o)throw new Error(o)}else if(!s)throw new Error("This template engine does not support the '"+i+"' binding within its templates")}}}function i(e,n,i,s){var o=t.expressionRewriting.parseObjectLiteral(e);r(o);var u=t.expressionRewriting.preProcessBindings(o,{valueAccessors:!0}),a="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+u+" } })()},'"+i.toLowerCase()+"')";return s.createJavaScriptEvaluatorBlock(a)+n}var e=/(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,n=/<!--\s*ko\b\s*([\s\S]*?)\s*-->/g;return{ensureTemplateIsRewritten:function(e,n,r){n.isTemplateRewritten(e,r)||n.rewriteTemplate(e,function(e){return t.templateRewriting.memoizeBindingAttributeSyntax(e,n)},r)},memoizeBindingAttributeSyntax:function(t,r){return t.replace(e,function(){return i(arguments[4],arguments[1],arguments[2],r)}).replace(n,function(){return i(arguments[1],"<!-- ko -->","#comment",r)})},applyMemoizedBindingsToNextSibling:function(e,n){return t.memoization.memoize(function(r,i){var s=r.nextSibling;s&&s.nodeName.toLowerCase()===n&&t.applyBindingAccessorsToNode(s,e,i)})}}}(),t.exportSymbol("__tr_ambtns",t.templateRewriting.applyMemoizedBindingsToNextSibling),function(){t.templateSources={},t.templateSources.domElement=function(e){this.domElement=e},t.templateSources.domElement.prototype.text=function(){var e=t.utils.tagNameLower(this.domElement),n=e==="script"?"text":e==="textarea"?"value":"innerHTML";if(arguments.length==0)return this.domElement[n];var r=arguments[0];n==="innerHTML"?t.utils.setHtml(this.domElement,r):this.domElement[n]=r};var e=t.utils.domData.nextKey()+"_";t.templateSources.domElement.prototype.data=function(n){if(arguments.length===1)return t.utils.domData.get(this.domElement,e+n);t.utils.domData.set(this.domElement,e+n,arguments[1])};var n=t.utils.domData.nextKey();t.templateSources.anonymousTemplate=function(e){this.domElement=e},t.templateSources.anonymousTemplate.prototype=new t.templateSources.domElement,t.templateSources.anonymousTemplate.prototype.constructor=t.templateSources.anonymousTemplate,t.templateSources.anonymousTemplate.prototype.text=function(){if(arguments.length==0){var e=t.utils.domData.get(this.domElement,n)||{};return e.textData===undefined&&e.containerData&&(e.textData=e.containerData.innerHTML),e.textData}var r=arguments[0];t.utils.domData.set(this.domElement,n,{textData:r})},t.templateSources.domElement.prototype.nodes=function(){if(arguments.length==0){var e=t.utils.domData.get(this.domElement,n)||{};return e.containerData}var r=arguments[0];t.utils.domData.set(this.domElement,n,{containerData:r})},t.exportSymbol("templateSources",t.templateSources),t.exportSymbol("templateSources.domElement",t.templateSources.domElement),t.exportSymbol("templateSources.anonymousTemplate",t.templateSources.anonymousTemplate)}(),function(){function n(e,n,r){var i,s=e,o=t.virtualElements.nextSibling(n);while(s&&(i=s)!==o)s=t.virtualElements.nextSibling(i),r(i,s)}function r(e,r){if(e.length){var i=e[0],s=e[e.length-1],o=i.parentNode,u=t.bindingProvider.instance,a=u.preprocessNode;if(a){n(i,s,function(e,t){var n=e.previousSibling,r=a.call(u,e);r&&(e===i&&(i=r[0]||t),e===s&&(s=r[r.length-1]||n))}),e.length=0;if(!i)return;i===s?e.push(i):(e.push(i,s),t.utils.fixUpContinuousNodeArray(e,o))}n(i,s,function(e){(e.nodeType===1||e.nodeType===8)&&t.applyBindings(r,e)}),n(i,s,function(e){(e.nodeType===1||e.nodeType===8)&&t.memoization.unmemoizeDomNodeAndDescendants(e,[r])}),t.utils.fixUpContinuousNodeArray(e,o)}}function i(e){return e.nodeType?e:e.length>0?e[0]:null}function s(n,s,o,u,a){a=a||{};var f=n&&i(n),l=f&&f.ownerDocument,c=a.templateEngine||e;t.templateRewriting.ensureTemplateIsRewritten(o,c,l);var h=c.renderTemplate(o,u,a,l);if(typeof h.length!="number"||h.length>0&&typeof h[0].nodeType!="number")throw new Error("Template engine must return an array of DOM nodes");var p=!1;switch(s){case"replaceChildren":t.virtualElements.setDomNodeChildren(n,h),p=!0;break;case"replaceNode":t.utils.replaceDomNodes(n,h),p=!0;break;case"ignoreTargetNode":break;default:throw new Error("Unknown renderMode: "+s)}return p&&(r(h,u),a.afterRender&&t.dependencyDetection.ignore(a.afterRender,null,[h,u.$data])),h}function u(e,n){var r=t.utils.domData.get(e,o);r&&typeof r.dispose=="function"&&r.dispose(),t.utils.domData.set(e,o,n&&n.isActive()?n:undefined)}var e;t.setTemplateEngine=function(n){if(!(n==undefined||n instanceof t.templateEngine))throw new Error("templateEngine must inherit from ko.templateEngine");e=n},t.renderTemplate=function(n,r,o,u,a){o=o||{};if((o["templateEngine"]||e)==undefined)throw new Error("Set a template engine before calling renderTemplate");a=a||"replaceChildren";if(u){var f=i(u),l=function(){return!f||!t.utils.domNodeIsAttachedToDocument(f)},c=f&&a=="replaceNode"?f.parentNode:f;return t.dependentObservable(function(){var e=r&&r instanceof t.bindingContext?r:new t.bindingContext(t.utils.unwrapObservable(r)),l=t.isObservable(n)?n():typeof n=="function"?n(e.$data,e):n,c=s(u,a,l,e,o);a=="replaceNode"&&(u=c,f=i(u))},null,{disposeWhen:l,disposeWhenNodeIsRemoved:c})}return t.memoization.memoize(function(e){t.renderTemplate(n,r,o,e,"replaceNode")})},t.renderTemplateForEach=function(e,n,i,o,u){var a,f=function(t,n){a=u.createChildContext(t,i.as,function(e){e.$index=n});var r=typeof e=="function"?e(t,a):e;return s(null,"ignoreTargetNode",r,a,i)},l=function(e,t,n){r(t,a),i.afterRender&&i.afterRender(t,e)};return t.dependentObservable(function(){var e=t.utils.unwrapObservable(n)||[];typeof e.length=="undefined"&&(e=[e]);var r=t.utils.arrayFilter(e,function(e){return i.includeDestroyed||e===undefined||e===null||!t.utils.unwrapObservable(e._destroy)});t.dependencyDetection.ignore(t.utils.setDomNodeChildrenFromArrayMapping,null,[o,r,f,i,l])},null,{disposeWhenNodeIsRemoved:o})};var o=t.utils.domData.nextKey();t.bindingHandlers.template={init:function(e,n){var r=t.utils.unwrapObservable(n());if(typeof r=="string"||r.name)t.virtualElements.emptyNode(e);else{var i=t.virtualElements.childNodes(e),s=t.utils.moveCleanedNodesToContainerElement(i);(new t.templateSources.anonymousTemplate(e)).nodes(s)}return{controlsDescendantBindings:!0}},update:function(e,n,r,i,s){var o=n(),a,f=t.utils.unwrapObservable(o),l=!0,c=null,h;typeof f=="string"?(h=o,f={}):(h=f.name,"if"in f&&(l=t.utils.unwrapObservable(f["if"])),l&&"ifnot"in f&&(l=!t.utils.unwrapObservable(f.ifnot)),a=t.utils.unwrapObservable(f.data));if("foreach"in f){var p=l&&f.foreach||[];c=t.renderTemplateForEach(h||e,p,f,e,s)}else if(!l)t.virtualElements.emptyNode(e);else{var d="data"in f?s.createChildContext(a,f.as):s;c=t.renderTemplate(h||e,d,f,e)}u(e,c)}},t.expressionRewriting.bindingRewriteValidators.template=function(e){var n=t.expressionRewriting.parseObjectLiteral(e);return n.length==1&&n[0].unknown?null:t.expressionRewriting.keyValueArrayContainsKey(n,"name")?null:"This template engine does not support anonymous templates nested within its templates"},t.virtualElements.allowedBindings.template=!0}(),t.exportSymbol("setTemplateEngine",t.setTemplateEngine),t.exportSymbol("renderTemplate",t.renderTemplate),t.utils.findMovesInArrayComparison=function(e,t,n){if(e.length&&t.length){var r,i,s,o,u;for(r=i=0;(!n||r<n)&&(o=e[i]);++i){for(s=0;u=t[s];++s)if(o.value===u.value){o.moved=u.index,u.moved=o.index,t.splice(s,1),r=s=0;break}r+=s}}},t.utils.compareArrays=function(){function r(t,r,s){return s=typeof s=="boolean"?{dontLimitMoves:s}:s||{},t=t||[],r=r||[],t.length<=r.length?i(t,r,e,n,s):i(r,t,n,e,s)}function i(e,n,r,i,s){var o=Math.min,u=Math.max,a=[],f,l=e.length,c,h=n.length,p=h-l||1,d=l+h+1,v,m,g,y;for(f=0;f<=l;f++){m=v,a.push(v=[]),g=o(h,f+p),y=u(0,f-1);for(c=y;c<=g;c++)if(!c)v[c]=f+1;else if(!f)v[c]=c+1;else if(e[f-1]===n[c-1])v[c]=m[c-1];else{var b=m[c]||d,w=v[c-1]||d;v[c]=o(b,w)+1}}var E=[],S,x=[],T=[];for(f=l,c=h;f||c;)S=a[f][c]-1,c&&S===a[f][c-1]?x.push(E[E.length]={status:r,value:n[--c],index:c}):f&&S===a[f-1][c]?T.push(E[E.length]={status:i,value:e[--f],index:f}):(--c,--f,s.sparse||E.push({status:"retained",value:n[c]}));return t.utils.findMovesInArrayComparison(x,T,l*10),E.reverse()}var e="added",n="deleted";return r}(),t.exportSymbol("utils.compareArrays",t.utils.compareArrays),function(){function e(e,n,r,i,s){var o=[],u=t.dependentObservable(function(){var u=n(r,s,t.utils.fixUpContinuousNodeArray(o,e))||[];o.length>0&&(t.utils.replaceDomNodes(o,u),i&&t.dependencyDetection.ignore(i,null,[r,u,s])),o.length=0,t.utils.arrayPushAll(o,u)},null,{disposeWhenNodeIsRemoved:e,disposeWhen:function(){return!t.utils.anyDomNodeIsAttachedToDocument(o)}});return{mappedNodes:o,dependentObservable:u.isActive()?u:undefined}}var n=t.utils.domData.nextKey();t.utils.setDomNodeChildrenFromArrayMapping=function(r,i,s,o,u){function E(e,n){w=f[n],d!==n&&(y[e]=w),w.indexObservable(d++),t.utils.fixUpContinuousNodeArray(w.mappedNodes,r),h.push(w),m.push(w)}function S(e,n){if(e)for(var r=0,i=n.length;r<i;r++)n[r]&&t.utils.arrayForEach(n[r].mappedNodes,function(t){e(t,r,n[r].arrayEntry)})}i=i||[],o=o||{};var a=t.utils.domData.get(r,n)===undefined,f=t.utils.domData.get(r,n)||[],l=t.utils.arrayMap(f,function(e){return e.arrayEntry}),c=t.utils.compareArrays(l,i,o.dontLimitMoves),h=[],p=0,d=0,v=[],m=[],g=[],y=[],b=[],w;for(var x=0,T,N;T=c[x];x++){N=T.moved;switch(T.status){case"deleted":N===undefined&&(w=f[p],w.dependentObservable&&w.dependentObservable.dispose(),v.push.apply(v,t.utils.fixUpContinuousNodeArray(w.mappedNodes,r)),o.beforeRemove&&(g[x]=w,m.push(w))),p++;break;case"retained":E(x,p++);break;case"added":N!==undefined?E(x,N):(w={arrayEntry:T.value,indexObservable:t.observable(d++)},h.push(w),m.push(w),a||(b[x]=w))}}S(o.beforeMove,y),t.utils.arrayForEach(v,o.beforeRemove?t.cleanNode:t.removeNode);for(var x=0,C=t.virtualElements.firstChild(r),k,L;w=m[x];x++){w.mappedNodes||t.utils.extend(w,e(r,s,w.arrayEntry,u,w.indexObservable));for(var A=0;L=w.mappedNodes[A];C=L.nextSibling,k=L,A++)L!==C&&t.virtualElements.insertAfter(r,L,k);!w.initialized&&u&&(u(w.arrayEntry,w.mappedNodes,w.indexObservable),w.initialized=!0)}S(o.beforeRemove,g),S(o.afterMove,y),S(o.afterAdd,b),t.utils.domData.set(r,n,h)}}(),t.exportSymbol("utils.setDomNodeChildrenFromArrayMapping",t.utils.setDomNodeChildrenFromArrayMapping),t.nativeTemplateEngine=function(){this.allowTemplateRewriting=!1},t.nativeTemplateEngine.prototype=new t.templateEngine,t.nativeTemplateEngine.prototype.constructor=t.nativeTemplateEngine,t.nativeTemplateEngine.prototype.renderTemplateSource=function(e,n,r){var i=!(t.utils.ieVersion<9),s=i?e.nodes:null,o=s?e.nodes():null;if(o)return t.utils.makeArray(o.cloneNode(!0).childNodes);var u=e.text();return t.utils.parseHtmlFragment(u)},t.nativeTemplateEngine.instance=new t.nativeTemplateEngine,t.setTemplateEngine(t.nativeTemplateEngine.instance),t.exportSymbol("nativeTemplateEngine",t.nativeTemplateEngine),function(){t.jqueryTmplTemplateEngine=function(){function t(){if(e<2)throw new Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.")}function n(e,t,n){return jQuery.tmpl(e,t,n)}var e=this.jQueryTmplVersion=function(){if(!jQuery||!jQuery.tmpl)return 0;try{if(jQuery.tmpl.tag.tmpl.open.toString().indexOf("__")>=0)return 2}catch(e){}return 1}();this.renderTemplateSource=function(e,r,i){i=i||{},t();var s=e.data("precompiled");if(!s){var o=e.text()||"";o="{{ko_with $item.koBindingContext}}"+o+"{{/ko_with}}",s=jQuery.template(null,o),e.data("precompiled",s)}var u=[r.$data],a=jQuery.extend({koBindingContext:r},i.templateOptions),f=n(s,u,a);return f.appendTo(document.createElement("div")),jQuery.fragments={},f},this.createJavaScriptEvaluatorBlock=function(e){return"{{ko_code ((function() { return "+e+" })()) }}"},this.addTemplate=function(e,t){document.write("<script type='text/html' id='"+e+"'>"+t+"<"+"/script>")},e>0&&(jQuery.tmpl.tag.ko_code={open:"__.push($1 || '');"},jQuery.tmpl.tag.ko_with={open:"with($1) {",close:"} "})},t.jqueryTmplTemplateEngine.prototype=new t.templateEngine,t.jqueryTmplTemplateEngine.prototype.constructor=t.jqueryTmplTemplateEngine;var e=new t.jqueryTmplTemplateEngine;e.jQueryTmplVersion>0&&t.setTemplateEngine(e),t.exportSymbol("jqueryTmplTemplateEngine",t.jqueryTmplTemplateEngine)}()})})()}(),function(e,t){function n(t,n){var i,s,o,u=t.nodeName.toLowerCase();return"area"===u?(i=t.parentNode,s=i.name,t.href&&s&&"map"===i.nodeName.toLowerCase()?(o=e("img[usemap=#"+s+"]")[0],!!o&&r(o)):!1):(/input|select|textarea|button|object/.test(u)?!t.disabled:"a"===u?t.href||n:n)&&r(t)}function r(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var i=0,s=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"1.10.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(t){return function(n,r){return"number"==typeof n?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),r&&r.call(t)},n)}):t.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var t;return t=e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(n){if(n!==t)return this.css("zIndex",n);if(this.length)for(var r,i,s=e(this[0]);s.length&&s[0]!==document;){if(r=s.css("position"),("absolute"===r||"relative"===r||"fixed"===r)&&(i=parseInt(s.css("zIndex"),10),!isNaN(i)&&0!==i))return i;s=s.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++i)})},removeUniqueId:function(){return this.each(function(){s.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return n(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var r=e.attr(t,"tabindex"),i=isNaN(r);return(i||r>=0)&&n(t,!i)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(n,r){function i(t,n,r,i){return e.each(s,function(){n-=parseFloat(e.css(t,"padding"+this))||0,r&&(n-=parseFloat(e.css(t,"border"+this+"Width"))||0),i&&(n-=parseFloat(e.css(t,"margin"+this))||0)}),n}var s="Width"===r?["Left","Right"]:["Top","Bottom"],o=r.toLowerCase(),u={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?u["inner"+r].call(this):this.each(function(){e(this).css(o,i(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return"number"!=typeof t?u["outer"+r].call(this,t):this.each(function(){e(this).css(o,i(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(n){return arguments.length?t.call(this,e.camelCase(n)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in document.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,n,r){var i,s=e.ui[t].prototype;for(i in r)s.plugins[i]=s.plugins[i]||[],s.plugins[i].push([n,r[i]])},call:function(e,t,n){var r,i=e.plugins[t];if(i&&e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType)for(r=0;i.length>r;r++)e.options[i[r][0]]&&i[r][1].apply(e.element,n)}},hasScroll:function(t,n){if("hidden"===e(t).css("overflow"))return!1;var r=n&&"left"===n?"scrollLeft":"scrollTop",i=!1;return t[r]>0?!0:(t[r]=1,i=t[r]>0,t[r]=0,i)}})}(jQuery),function(e,t){var n=0,r=Array.prototype.slice,i=e.cleanData;e.cleanData=function(t){for(var n,r=0;null!=(n=t[r]);r++)try{e(n).triggerHandler("remove")}catch(s){}i(t)},e.widget=function(n,r,i){var s,o,u,a,f={},l=n.split(".")[0];n=n.split(".")[1],s=l+"-"+n,i||(i=r,r=e.Widget),e.expr[":"][s.toLowerCase()]=function(t){return!!e.data(t,s)},e[l]=e[l]||{},o=e[l][n],u=e[l][n]=function(e,n){return this._createWidget?(arguments.length&&this._createWidget(e,n),t):new u(e,n)},e.extend(u,o,{version:i.version,_proto:e.extend({},i),_childConstructors:[]}),a=new r,a.options=e.widget.extend({},a.options),e.each(i,function(n,i){return e.isFunction(i)?(f[n]=function(){var e=function(){return r.prototype[n].apply(this,arguments)},t=function(e){return r.prototype[n].apply(this,e)};return function(){var n,r=this._super,s=this._superApply;return this._super=e,this._superApply=t,n=i.apply(this,arguments),this._super=r,this._superApply=s,n}}(),t):(f[n]=i,t)}),u.prototype=e.widget.extend(a,{widgetEventPrefix:o?a.widgetEventPrefix:n},f,{constructor:u,namespace:l,widgetName:n,widgetFullName:s}),o?(e.each(o._childConstructors,function(t,n){var r=n.prototype;e.widget(r.namespace+"."+r.widgetName,u,n._proto)}),delete o._childConstructors):r._childConstructors.push(u),e.widget.bridge(n,u)},e.widget.extend=function(n){for(var i,o,u=r.call(arguments,1),a=0,f=u.length;f>a;a++)for(i in u[a])o=u[a][i],u[a].hasOwnProperty(i)&&o!==t&&(n[i]=e.isPlainObject(o)?e.isPlainObject(n[i])?e.widget.extend({},n[i],o):e.widget.extend({},o):o);return n},e.widget.bridge=function(n,i){var o=i.prototype.widgetFullName||n;e.fn[n]=function(u){var f="string"==typeof u,l=r.call(arguments,1),c=this;return u=!f&&l.length?e.widget.extend.apply(null,[u].concat(l)):u,f?this.each(function(){var r,i=e.data(this,o);return i?e.isFunction(i[u])&&"_"!==u.charAt(0)?(r=i[u].apply(i,l),r!==i&&r!==t?(c=r&&r.jquery?c.pushStack(r.get()):r,!1):t):e.error("no such method '"+u+"' for "+n+" widget instance"):e.error("cannot call methods on "+n+" prior to initialization; "+"attempted to call method '"+u+"'")}):this.each(function(){var t=e.data(this,o);t?t.option(u||{})._init():e.data(this,o,new i(u,this))}),c}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,r){r=e(r||this.defaultElement||this)[0],this.element=e(r),this.uuid=n++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),r!==this&&(e.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===r&&this.destroy()}}),this.document=e(r.style?r.ownerDocument:r.document||r),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(n,r){var i,s,o,u=n;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof n)if(u={},i=n.split("."),n=i.shift(),i.length){for(s=u[n]=e.widget.extend({},this.options[n]),o=0;i.length-1>o;o++)s[i[o]]=s[i[o]]||{},s=s[i[o]];if(n=i.pop(),r===t)return s[n]===t?null:s[n];s[n]=r}else{if(r===t)return this.options[n]===t?null:this.options[n];u[n]=r}return this._setOptions(u),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!t).attr("aria-disabled",t),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(n,r,i){var s,o=this;"boolean"!=typeof n&&(i=r,r=n,n=!1),i?(r=s=e(r),this.bindings=this.bindings.add(r)):(i=r,r=this.element,s=this.widget()),e.each(i,function(i,u){function f(){return n||o.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof u?o[u]:u).apply(o,arguments):t}"string"!=typeof u&&(f.guid=u.guid=u.guid||f.guid||e.guid++);var l=i.match(/^(\w+)\s*(.*)$/),c=l[1]+o.eventNamespace,h=l[2];h?s.delegate(h,c,f):r.bind(c,f)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function n(){return("string"==typeof e?r[e]:e).apply(r,arguments)}var r=this;return setTimeout(n,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,n,r){var i,s,o=this.options[t];if(r=r||{},n=e.Event(n),n.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),n.target=this.element[0],s=n.originalEvent)for(i in s)i in n||(n[i]=s[i]);return this.element.trigger(n,r),!(e.isFunction(o)&&o.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,n){e.Widget.prototype["_"+t]=function(r,i,s){"string"==typeof i&&(i={effect:i});var o,u=i?i===!0||"number"==typeof i?n:i.effect||n:t;i=i||{},"number"==typeof i&&(i={duration:i}),o=!e.isEmptyObject(i),i.complete=s,i.delay&&r.delay(i.delay),o&&e.effects&&e.effects.effect[u]?r[t](i):u!==t&&r[u]?r[u](i.duration,i.easing,s):r.queue(function(n){e(this)[t](),s&&s.call(r[0]),n()})}})}(jQuery),function(e,t){var n=!1;e(document).mouseup(function(){n=!1}),e.widget("ui.mouse",{version:"1.10.0",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(n){if(!0===e.data(n.target,t.widgetName+".preventClickEvent"))return e.removeData(n.target,t.widgetName+".preventClickEvent"),n.stopImmediatePropagation(),!1}),this.document.mouseup(function(e){n=!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&e(this.document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var r=this,i=t.which===1,s=typeof this.options.cancel=="string"&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;if(!i||s||!this._mouseCapture(t))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){r.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)){this._mouseStarted=this._mouseStart(t)!==!1;if(!this._mouseStarted)return t.preventDefault(),!0}return!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return r._mouseMove(e)},this._mouseUpDelegate=function(e){return r._mouseUp(e)},e(this.document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),n=!0,!0},_mouseMove:function(t){return e.ui.ie&&(!document.documentMode||document.documentMode<9)&&!t.button?this._mouseUp(t):this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return e(this.document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(jQuery),function(e,t){function n(e,t,n){return[parseInt(e[0],10)*(p.test(e[0])?t/100:1),parseInt(e[1],10)*(p.test(e[1])?n/100:1)]}function r(t,n){return parseInt(e.css(t,n),10)||0}function i(t){var n=t[0];return n.nodeType===9?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:e.isWindow(n)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:n.preventDefault?{width:0,height:0,offset:{top:n.pageY,left:n.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()}}e.ui=e.ui||{};var s,o=Math.max,u=Math.abs,a=Math.round,f=/left|center|right/,l=/top|center|bottom/,c=/[\+\-]\d+%?/,h=/^\w+/,p=/%$/,d=e.fn.position;e.position={scrollbarWidth:function(){if(s!==t)return s;var n,r,i=e("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),o=i.children()[0];return e("body").append(i),n=o.offsetWidth,i.css("overflow","scroll"),r=o.offsetWidth,n===r&&(r=i[0].clientWidth),i.remove(),s=n-r},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width<t.element[0].scrollWidth,s=r==="scroll"||r==="auto"&&t.height<t.element[0].scrollHeight;return{width:i?e.position.scrollbarWidth():0,height:s?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var n=e(t||window),r=e.isWindow(n[0]);return{element:n,isWindow:r,offset:n.offset()||{left:0,top:0},scrollLeft:n.scrollLeft(),scrollTop:n.scrollTop(),width:r?n.width():n.outerWidth(),height:r?n.height():n.outerHeight()}}},e.fn.position=function(t){if(!t||!t.of)return d.apply(this,arguments);t=e.extend({},t);var s,p,v,m,g,y,b=e(t.of),w=e.position.getWithinInfo(t.within),E=e.position.getScrollInfo(w),S=(t.collision||"flip").split(" "),x={};return y=i(b),b[0].preventDefault&&(t.at="left top"),p=y.width,v=y.height,m=y.offset,g=e.extend({},m),e.each(["my","at"],function(){var e=(t[this]||"").split(" "),n,r;e.length===1&&(e=f.test(e[0])?e.concat(["center"]):l.test(e[0])?["center"].concat(e):["center","center"]),e[0]=f.test(e[0])?e[0]:"center",e[1]=l.test(e[1])?e[1]:"center",n=c.exec(e[0]),r=c.exec(e[1]),x[this]=[n?n[0]:0,r?r[0]:0],t[this]=[h.exec(e[0])[0],h.exec(e[1])[0]]}),S.length===1&&(S[1]=S[0]),t.at[0]==="right"?g.left+=p:t.at[0]==="center"&&(g.left+=p/2),t.at[1]==="bottom"?g.top+=v:t.at[1]==="center"&&(g.top+=v/2),s=n(x.at,p,v),g.left+=s[0],g.top+=s[1],this.each(function(){var i,f,l=e(this),c=l.outerWidth(),h=l.outerHeight(),d=r(this,"marginLeft"),y=r(this,"marginTop"),T=c+d+r(this,"marginRight")+E.width,N=h+y+r(this,"marginBottom")+E.height,C=e.extend({},g),k=n(x.my,l.outerWidth(),l.outerHeight());t.my[0]==="right"?C.left-=c:t.my[0]==="center"&&(C.left-=c/2),t.my[1]==="bottom"?C.top-=h:t.my[1]==="center"&&(C.top-=h/2),C.left+=k[0],C.top+=k[1],e.support.offsetFractions||(C.left=a(C.left),C.top=a(C.top)),i={marginLeft:d,marginTop:y},e.each(["left","top"],function(n,r){e.ui.position[S[n]]&&e.ui.position[S[n]][r](C,{targetWidth:p,targetHeight:v,elemWidth:c,elemHeight:h,collisionPosition:i,collisionWidth:T,collisionHeight:N,offset:[s[0]+k[0],s[1]+k[1]],my:t.my,at:t.at,within:w,elem:l})}),t.using&&(f=function(e){var n=m.left-C.left,r=n+p-c,i=m.top-C.top,s=i+v-h,a={target:{element:b,left:m.left,top:m.top,width:p,height:v},element:{element:l,left:C.left,top:C.top,width:c,height:h},horizontal:r<0?"left":n>0?"right":"center",vertical:s<0?"top":i>0?"bottom":"middle"};p<c&&u(n+r)<p&&(a.horizontal="center"),v<h&&u(i+s)<v&&(a.vertical="middle"),o(u(n),u(r))>o(u(i),u(s))?a.important="horizontal":a.important="vertical",t.using.call(this,e,a)}),l.offset(e.extend(C,{using:f}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,r=n.isWindow?n.scrollLeft:n.offset.left,i=n.width,s=e.left-t.collisionPosition.marginLeft,u=r-s,a=s+t.collisionWidth-i-r,f;t.collisionWidth>i?u>0&&a<=0?(f=e.left+u+t.collisionWidth-i-r,e.left+=u-f):a>0&&u<=0?e.left=r:u>a?e.left=r+i-t.collisionWidth:e.left=r:u>0?e.left+=u:a>0?e.left-=a:e.left=o(e.left-s,e.left)},top:function(e,t){var n=t.within,r=n.isWindow?n.scrollTop:n.offset.top,i=t.within.height,s=e.top-t.collisionPosition.marginTop,u=r-s,a=s+t.collisionHeight-i-r,f;t.collisionHeight>i?u>0&&a<=0?(f=e.top+u+t.collisionHeight-i-r,e.top+=u-f):a>0&&u<=0?e.top=r:u>a?e.top=r+i-t.collisionHeight:e.top=r:u>0?e.top+=u:a>0?e.top-=a:e.top=o(e.top-s,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,i=n.width,s=n.isWindow?n.scrollLeft:n.offset.left,o=e.left-t.collisionPosition.marginLeft,a=o-s,f=o+t.collisionWidth-i-s,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-i-r;if(p<0||p<u(a))e.left+=l+c+h}else if(f>0){d=e.left-t.collisionPosition.marginLeft+l+c+h-s;if(d>0||u(d)<f)e.left+=l+c+h}},top:function(e,t){var n=t.within,r=n.offset.top+n.scrollTop,i=n.height,s=n.isWindow?n.scrollTop:n.offset.top,o=e.top-t.collisionPosition.marginTop,a=o-s,f=o+t.collisionHeight-i-s,l=t.my[1]==="top",c=l?-t.elemHeight:t.my[1]==="bottom"?t.elemHeight:0,h=t.at[1]==="top"?t.targetHeight:t.at[1]==="bottom"?-t.targetHeight:0,p=-2*t.offset[1],d,v;a<0?(v=e.top+c+h+p+t.collisionHeight-i-r,e.top+c+h+p>a&&(v<0||v<u(a))&&(e.top+=c+h+p)):f>0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-s,e.top+c+h+p>f&&(d>0||u(d)<f)&&(e.top+=c+h+p))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,n,r,i,s,o=document.getElementsByTagName("body")[0],u=document.createElement("div");t=document.createElement(o?"div":"body"),r={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},o&&e.extend(r,{position:"absolute",left:"-1000px",top:"-1000px"});for(s in r)t.style[s]=r[s];t.appendChild(u),n=o||document.documentElement,n.insertBefore(t,n.firstChild),u.style.cssText="position: absolute; left: 10.7432222px;",i=e(u).offset().left,e.support.offsetFractions=i>10&&i<11,t.innerHTML="",n.removeChild(t)}()}(jQuery),function(e,t){e.widget("ui.draggable",e.ui.mouse,{version:"1.10.2",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){this.options.helper==="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var n=this.options;return this.helper||n.disabled||e(t.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(t),this.handle?(e(n.iframeFix===!0?"iframe":n.iframeFix).each(function(){e("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var n=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,n.cursorAt&&this._adjustOffsetFromHelper(n.cursorAt),n.containment&&this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,n){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute");if(!n){var r=this._uiHash();if(this._trigger("drag",t,r)===!1)return this._mouseUp({}),!1;this.position=r.position}if(!this.options.axis||this.options.axis!=="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!=="x")this.helper[0].style.top=this.position.top+"px";return e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var n,r=this,i=!1,s=!1;e.ui.ddmanager&&!this.options.dropBehaviour&&(s=e.ui.ddmanager.drop(this,t)),this.dropped&&(s=this.dropped,this.dropped=!1),n=this.element[0];while(n&&(n=n.parentNode))n===this.document.get(0)&&(i=!0);return!i&&this.options.helper==="original"?!1:(this.options.revert==="invalid"&&!s||this.options.revert==="valid"&&s||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){r._trigger("stop",t)!==!1&&r._clear()}):this._trigger("stop",t)!==!1&&this._clear(),!1)},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){return this.options.handle?!!e(t.target).closest(this.element.find(this.options.handle)).length:!0},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t])):n.helper==="clone"?this.element.clone().removeAttr("id"):this.element;return r.parents("body").length||r.appendTo(n.appendTo==="parent"?this.element[0].parentNode:n.appendTo),r[0]!==this.element[0]&&!/(fixed|absolute)/.test(r.css("position"))&&r.css("position","absolute"),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition==="absolute"&&this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()==="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition==="relative"){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,n,r,i=this.options;i.containment==="parent"&&(i.containment=this.helper[0].parentNode);if(i.containment==="document"||i.containment==="window")this.containment=[i.containment==="document"?0:e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,i.containment==="document"?0:e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(i.containment==="document"?0:e(window).scrollLeft())+e(i.containment==="document"?document:window).width()-this.helperProportions.width-this.margins.left,(i.containment==="document"?0:e(window).scrollTop())+(e(i.containment==="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(i.containment)&&i.containment.constructor!==Array){n=e(i.containment),r=n[0];if(!r)return;t=e(r).css("overflow")!=="hidden",this.containment=[(parseInt(e(r).css("borderLeftWidth"),10)||0)+(parseInt(e(r).css("paddingLeft"),10)||0),(parseInt(e(r).css("borderTopWidth"),10)||0)+(parseInt(e(r).css("paddingTop"),10)||0),(t?Math.max(r.scrollWidth,r.offsetWidth):r.offsetWidth)-(parseInt(e(r).css("borderRightWidth"),10)||0)-(parseInt(e(r).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(r.scrollHeight,r.offsetHeight):r.offsetHeight)-(parseInt(e(r).css("borderBottomWidth"),10)||0)-(parseInt(e(r).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=n}else i.containment.constructor===Array&&(this.containment=i.containment)},_convertPositionTo:function(t,n){n||(n=this.position);var r=t==="absolute"?1:-1,i=this.cssPosition!=="absolute"||this.scrollParent[0]!==document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,s=/(html|body)/i.test(i[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():s?0:i.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():s?0:i.scrollLeft())*r}},_generatePosition:function(t){var n,r,i,s,o=this.options,u=this.cssPosition!=="absolute"||this.scrollParent[0]!==document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(u[0].tagName),f=t.pageX,l=t.pageY;return this.originalPosition&&(this.containment&&(this.relative_container?(r=this.relative_container.offset(),n=[this.containment[0]+r.left,this.containment[1]+r.top,this.containment[2]+r.left,this.containment[3]+r.top]):n=this.containment,t.pageX-this.offset.click.left<n[0]&&(f=n[0]+this.offset.click.left),t.pageY-this.offset.click.top<n[1]&&(l=n[1]+this.offset.click.top),t.pageX-this.offset.click.left>n[2]&&(f=n[2]+this.offset.click.left),t.pageY-this.offset.click.top>n[3]&&(l=n[3]+this.offset.click.top)),o.grid&&(i=o.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY,l=n?i-this.offset.click.top>=n[1]||i-this.offset.click.top>n[3]?i:i-this.offset.click.top>=n[1]?i-o.grid[1]:i+o.grid[1]:i,s=o.grid[0]?this.originalPageX+Math.round((f-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX,f=n?s-this.offset.click.left>=n[0]||s-this.offset.click.left>n[2]?s:s-this.offset.click.left>=n[0]?s-o.grid[0]:s+o.grid[0]:s)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():a?0:u.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():a?0:u.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!==this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(t,n,r){return r=r||this._uiHash(),e.ui.plugin.call(this,t,[n,r]),t==="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,n,r)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,n){var r=e(this).data("ui-draggable"),i=r.options,s=e.extend({},n,{item:r.element});r.sortables=[],e(i.connectToSortable).each(function(){var n=e.data(this,"ui-sortable");n&&!n.options.disabled&&(r.sortables.push({instance:n,shouldRevert:n.options.revert}),n.refreshPositions(),n._trigger("activate",t,s))})},stop:function(t,n){var r=e(this).data("ui-draggable"),i=e.extend({},n,{item:r.element});e.each(r.sortables,function(){this.instance.isOver?(this.instance.isOver=0,r.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,r.options.helper==="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,i))})},drag:function(t,n){var r=e(this).data("ui-draggable"),i=this;e.each(r.sortables,function(){var s=!1,o=this;this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(s=!0,e.each(r.sortables,function(){return this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this!==o&&this.instance._intersectsWith(this.instance.containerCache)&&e.contains(o.instance.element[0],this.instance.element[0])&&(s=!1),s})),s?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(i).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return n.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=r.offset.click.top,this.instance.offset.click.left=r.offset.click.left,this.instance.offset.parent.left-=r.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=r.offset.parent.top-this.instance.offset.parent.top,r._trigger("toSortable",t),r.dropped=this.instance.element,r.currentItem=r.element,this.instance.fromOutside=r),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),r._trigger("fromSortable",t),r.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(){var t=e("body"),n=e(this).data("ui-draggable").options;t.css("cursor")&&(n._cursor=t.css("cursor")),t.css("cursor",n.cursor)},stop:function(){var t=e(this).data("ui-draggable").options;t._cursor&&e("body").css("cursor",t._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,n){var r=e(n.helper),i=e(this).data("ui-draggable").options;r.css("opacity")&&(i._opacity=r.css("opacity")),r.css("opacity",i.opacity)},stop:function(t,n){var r=e(this).data("ui-draggable").options;r._opacity&&e(n.helper).css("opacity",r._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(){var t=e(this).data("ui-draggable");t.scrollParent[0]!==document&&t.scrollParent[0].tagName!=="HTML"&&(t.overflowOffset=t.scrollParent.offset())},drag:function(t){var n=e(this).data("ui-draggable"),r=n.options,i=!1;if(n.scrollParent[0]!==document&&n.scrollParent[0].tagName!=="HTML"){if(!r.axis||r.axis!=="x")n.overflowOffset.top+n.scrollParent[0].offsetHeight-t.pageY<r.scrollSensitivity?n.scrollParent[0].scrollTop=i=n.scrollParent[0].scrollTop+r.scrollSpeed:t.pageY-n.overflowOffset.top<r.scrollSensitivity&&(n.scrollParent[0].scrollTop=i=n.scrollParent[0].scrollTop-r.scrollSpeed);if(!r.axis||r.axis!=="y")n.overflowOffset.left+n.scrollParent[0].offsetWidth-t.pageX<r.scrollSensitivity?n.scrollParent[0].scrollLeft=i=n.scrollParent[0].scrollLeft+r.scrollSpeed:t.pageX-n.overflowOffset.left<r.scrollSensitivity&&(n.scrollParent[0].scrollLeft=i=n.scrollParent[0].scrollLeft-r.scrollSpeed)}else{if(!r.axis||r.axis!=="x")t.pageY-e(document).scrollTop()<r.scrollSensitivity?i=e(document).scrollTop(e(document).scrollTop()-r.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<r.scrollSensitivity&&(i=e(document).scrollTop(e(document).scrollTop()+r.scrollSpeed));if(!r.axis||r.axis!=="y")t.pageX-e(document).scrollLeft()<r.scrollSensitivity?i=e(document).scrollLeft(e(document).scrollLeft()-r.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<r.scrollSensitivity&&(i=e(document).scrollLeft(e(document).scrollLeft()+r.scrollSpeed))}i!==!1&&e.ui.ddmanager&&!r.dropBehaviour&&e.ui.ddmanager.prepareOffsets(n,t)}}),e.ui.plugin.add("draggable","snap",{start:function(){var t=e(this).data("ui-draggable"),n=t.options;t.snapElements=[],e(n.snap.constructor!==String?n.snap.items||":data(ui-draggable)":n.snap).each(function(){var n=e(this),r=n.offset();this!==t.element[0]&&t.snapElements.push({item:this,width:n.outerWidth(),height:n.outerHeight(),top:r.top,left:r.left})})},drag:function(t,n){var r,i,s,o,u,a,f,l,c,h,p=e(this).data("ui-draggable"),d=p.options,v=d.snapTolerance,m=n.offset.left,g=m+p.helperProportions.width,y=n.offset.top,b=y+p.helperProportions.height;for(c=p.snapElements.length-1;c>=0;c--){u=p.snapElements[c].left,a=u+p.snapElements[c].width,f=p.snapElements[c].top,l=f+p.snapElements[c].height;if(!(u-v<m&&m<a+v&&f-v<y&&y<l+v||u-v<m&&m<a+v&&f-v<b&&b<l+v||u-v<g&&g<a+v&&f-v<y&&y<l+v||u-v<g&&g<a+v&&f-v<b&&b<l+v)){p.snapElements[c].snapping&&p.options.snap.release&&p.options.snap.release.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=!1;continue}d.snapMode!=="inner"&&(r=Math.abs(f-b)<=v,i=Math.abs(l-y)<=v,s=Math.abs(u-g)<=v,o=Math.abs(a-m)<=v,r&&(n.position.top=p._convertPositionTo("relative",{top:f-p.helperProportions.height,left:0}).top-p.margins.top),i&&(n.position.top=p._convertPositionTo("relative",{top:l,left:0}).top-p.margins.top),s&&(n.position.left=p._convertPositionTo("relative",{top:0,left:u-p.helperProportions.width}).left-p.margins.left),o&&(n.position.left=p._convertPositionTo("relative",{top:0,left:a}).left-p.margins.left)),h=r||i||s||o,d.snapMode!=="outer"&&(r=Math.abs(f-y)<=v,i=Math.abs(l-b)<=v,s=Math.abs(u-m)<=v,o=Math.abs(a-g)<=v,r&&(n.position.top=p._convertPositionTo("relative",{top:f,left:0}).top-p.margins.top),i&&(n.position.top=p._convertPositionTo("relative",{top:l-p.helperProportions.height,left:0}).top-p.margins.top),s&&(n.position.left=p._convertPositionTo("relative",{top:0,left:u}).left-p.margins.left),o&&(n.position.left=p._convertPositionTo("relative",{top:0,left:a-p.helperProportions.width}).left-p.margins.left)),!p.snapElements[c].snapping&&(r||i||s||o||h)&&p.options.snap.snap&&p.options.snap.snap.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=r||i||s||o||h}}}),e.ui.plugin.add("draggable","stack",{start:function(){var t,n=this.data("ui-draggable").options,r=e.makeArray(e(n.stack)).sort(function(t,n){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(n).css("zIndex"),10)||0)});if(!r.length)return;t=parseInt(e(r[0]).css("zIndex"),10)||0,e(r).each(function(n){e(this).css("zIndex",t+n)}),this.css("zIndex",t+r.length)}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,n){var r=e(n.helper),i=e(this).data("ui-draggable").options;r.css("zIndex")&&(i._zIndex=r.css("zIndex")),r.css("zIndex",i.zIndex)},stop:function(t,n){var r=e(this).data("ui-draggable").options;r._zIndex&&e(n.helper).css("zIndex",r._zIndex)}})}(jQuery),function(e,t){function n(e,t,n){return e>t&&e<t+n}e.widget("ui.droppable",{version:"1.10.1",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t=this.options,n=t.accept;this.isover=!1,this.isout=!0,this.accept=e.isFunction(n)?n:function(e){return e.is(n)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},e.ui.ddmanager.droppables[t.scope]=e.ui.ddmanager.droppables[t.scope]||[],e.ui.ddmanager.droppables[t.scope].push(this),t.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){var t=0,n=e.ui.ddmanager.droppables[this.options.scope];for(;t<n.length;t++)n[t]===this&&n.splice(t,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,n){t==="accept"&&(this.accept=e.isFunction(n)?n:function(e){return e.is(n)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),n&&this._trigger("activate",t,this.ui(n))},_deactivate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),n&&this._trigger("deactivate",t,this.ui(n))},_over:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]===this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(n)))},_out:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]===this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(n)))},_drop:function(t,n){var r=n||e.ui.ddmanager.current,i=!1;return!r||(r.currentItem||r.element)[0]===this.element[0]?!1:(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var n=e.data(this,"ui-droppable");if(n.options.greedy&&!n.options.disabled&&n.options.scope===r.options.scope&&n.accept.call(n.element[0],r.currentItem||r.element)&&e.ui.intersect(r,e.extend(n,{offset:n.element.offset()}),n.options.tolerance,t))return i=!0,!1}),i?!1:this.accept.call(this.element[0],r.currentItem||r.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(r)),this.element):!1)},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(e,t,r,i){if(!t.offset)return!1;var s,o,u=(e.positionAbs||e.position.absolute).left,a=u+e.helperProportions.width,f=(e.positionAbs||e.position.absolute).top,l=f+e.helperProportions.height,c=t.offset.left,h=c+t.proportions.width,p=t.offset.top,d=p+t.proportions.height;switch(r){case"fit":return c<=u&&a<=h&&p<=f&&l<=d;case"intersect":return c<u+e.helperProportions.width/2&&a-e.helperProportions.width/2<h&&p<f+e.helperProportions.height/2&&l-e.helperProportions.height/2<d;case"pointer":return s=i.pageX,o=i.pageY,n(o,p,t.proportions.height)&&n(s,c,t.proportions.width);case"touch":return(f>=p&&f<=d||l>=p&&l<=d||f<p&&l>d)&&(u>=c&&u<=h||a>=c&&a<=h||u<c&&a>h);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,n){var r,i,s=e.ui.ddmanager.droppables[t.options.scope]||[],o=n?n.type:null,u=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();e:for(r=0;r<s.length;r++){if(s[r].options.disabled||t&&!s[r].accept.call(s[r].element[0],t.currentItem||t.element))continue;for(i=0;i<u.length;i++)if(u[i]===s[r].element[0]){s[r].proportions.height=0;continue e}s[r].visible=s[r].element.css("display")!=="none";if(!s[r].visible)continue;o==="mousedown"&&s[r]._activate.call(s[r],n),s[r].offset=s[r].element.offset(),s[r].proportions={width:s[r].element[0].offsetWidth,height:s[r].element[0].offsetHeight}}},drop:function(t,n){var r=!1;return e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance,n)&&(r=this._drop.call(this,n)||r),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,n))}),r},dragStart:function(t,n){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)})},drag:function(t,n){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,n),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var r,i,s,o=e.ui.intersect(t,this,this.options.tolerance,n),u=!o&&this.isover?"isout":o&&!this.isover?"isover":null;if(!u)return;this.options.greedy&&(i=this.options.scope,s=this.element.parents(":data(ui-droppable)").filter(function(){return e.data(this,"ui-droppable").options.scope===i}),s.length&&(r=e.data(s[0],"ui-droppable"),r.greedyChild=u==="isover")),r&&u==="isover"&&(r.isover=!1,r.isout=!0,r._out.call(r,n)),this[u]=!0,this[u==="isout"?"isover":"isout"]=!1,this[u==="isover"?"_over":"_out"].call(this,n),r&&u==="isout"&&(r.isout=!1,r.isover=!0,r._over.call(r,n))})},dragStop:function(t,n){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)}}}(jQuery),function(e,t){function n(e){return parseInt(e,10)||0}function r(e){return!isNaN(parseInt(e,10))}e.widget("ui.resizable",e.ui.mouse,{version:"1.10.0",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_create:function(){var t,n,r,i,s,o=this,u=this.options;this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!u.aspectRatio,aspectRatio:u.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:u.helper||u.ghost||u.animate?u.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.data("ui-resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=u.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor===String){this.handles==="all"&&(this.handles="n,e,s,w,se,sw,ne,nw"),t=this.handles.split(","),this.handles={};for(n=0;n<t.length;n++)r=e.trim(t[n]),s="ui-resizable-"+r,i=e("<div class='ui-resizable-handle "+s+"'></div>"),i.css({zIndex:u.zIndex}),"se"===r&&i.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[r]=".ui-resizable-"+r,this.element.append(i)}this._renderAxis=function(t){var n,r,i,s;t=t||this.element;for(n in this.handles){this.handles[n].constructor===String&&(this.handles[n]=e(this.handles[n],this.element).show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(r=e(this.handles[n],this.element),s=/sw|ne|nw|se|n|s/.test(n)?r.outerHeight():r.outerWidth(),i=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join(""),t.css(i,s),this._proportionallyResize());if(!e(this.handles[n]).length)continue}},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){o.resizing||(this.className&&(i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),o.axis=i&&i[1]?i[1]:"se")}),u.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){if(u.disabled)return;e(this).removeClass("ui-resizable-autohide"),o._handles.show()}).mouseleave(function(){if(u.disabled)return;o.resizing||(e(this).addClass("ui-resizable-autohide"),o._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,n=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(n(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),n(this.originalElement),this},_mouseCapture:function(t){var n,r,i=!1;for(n in this.handles){r=e(this.handles[n])[0];if(r===t.target||e.contains(r,t.target))i=!0}return!this.options.disabled&&i},_mouseStart:function(t){var r,i,s,o=this.options,u=this.element.position(),a=this.element;return this.resizing=!0,/absolute/.test(a.css("position"))?a.css({position:"absolute",top:a.css("top"),left:a.css("left")}):a.is(".ui-draggable")&&a.css({position:"absolute",top:u.top,left:u.left}),this._renderProxy(),r=n(this.helper.css("left")),i=n(this.helper.css("top")),o.containment&&(r+=e(o.containment).scrollLeft()||0,i+=e(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:r,top:i},this.size=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.originalPosition={left:r,top:i},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio=typeof o.aspectRatio=="number"?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,s=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor",s==="auto"?this.axis+"-resize":s),a.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var n,r=this.helper,i={},s=this.originalMousePosition,o=this.axis,u=this.position.top,a=this.position.left,f=this.size.width,l=this.size.height,c=t.pageX-s.left||0,h=t.pageY-s.top||0,p=this._change[o];if(!p)return!1;n=p.apply(this,[t,c,h]),this._updateVirtualBoundaries(t.shiftKey);if(this._aspectRatio||t.shiftKey)n=this._updateRatio(n,t);return n=this._respectSize(n,t),this._updateCache(n),this._propagate("resize",t),this.position.top!==u&&(i.top=this.position.top+"px"),this.position.left!==a&&(i.left=this.position.left+"px"),this.size.width!==f&&(i.width=this.size.width+"px"),this.size.height!==l&&(i.height=this.size.height+"px"),r.css(i),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(i)||this._trigger("resize",t,this.ui()),!1},_mouseStop:function(t){this.resizing=!1;var n,r,i,s,o,u,a,f=this.options,l=this;return this._helper&&(n=this._proportionallyResizeElements,r=n.length&&/textarea/i.test(n[0].nodeName),i=r&&e.ui.hasScroll(n[0],"left")?0:l.sizeDiff.height,s=r?0:l.sizeDiff.width,o={width:l.helper.width()-s,height:l.helper.height()-i},u=parseInt(l.element.css("left"),10)+(l.position.left-l.originalPosition.left)||null,a=parseInt(l.element.css("top"),10)+(l.position.top-l.originalPosition.top)||null,f.animate||this.element.css(e.extend(o,{top:a,left:u})),l.helper.height(l.size.height),l.helper.width(l.size.width),this._helper&&!f.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t,n,i,s,o,u=this.options;o={minWidth:r(u.minWidth)?u.minWidth:0,maxWidth:r(u.maxWidth)?u.maxWidth:Infinity,minHeight:r(u.minHeight)?u.minHeight:0,maxHeight:r(u.maxHeight)?u.maxHeight:Infinity};if(this._aspectRatio||e)t=o.minHeight*this.aspectRatio,i=o.minWidth/this.aspectRatio,n=o.maxHeight*this.aspectRatio,s=o.maxWidth/this.aspectRatio,t>o.minWidth&&(o.minWidth=t),i>o.minHeight&&(o.minHeight=i),n<o.maxWidth&&(o.maxWidth=n),s<o.maxHeight&&(o.maxHeight=s);this._vBoundaries=o},_updateCache:function(e){this.offset=this.helper.offset(),r(e.left)&&(this.position.left=e.left),r(e.top)&&(this.position.top=e.top),r(e.height)&&(this.size.height=e.height),r(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=this.position,n=this.size,i=this.axis;return r(e.height)?e.width=e.height*this.aspectRatio:r(e.width)&&(e.height=e.width/this.aspectRatio),i==="sw"&&(e.left=t.left+(n.width-e.width),e.top=null),i==="nw"&&(e.top=t.top+(n.height-e.height),e.left=t.left+(n.width-e.width)),e},_respectSize:function(e){var t=this._vBoundaries,n=this.axis,i=r(e.width)&&t.maxWidth&&t.maxWidth<e.width,s=r(e.height)&&t.maxHeight&&t.maxHeight<e.height,o=r(e.width)&&t.minWidth&&t.minWidth>e.width,u=r(e.height)&&t.minHeight&&t.minHeight>e.height,a=this.originalPosition.left+this.originalSize.width,f=this.position.top+this.size.height,l=/sw|nw|w/.test(n),c=/nw|ne|n/.test(n);return o&&(e.width=t.minWidth),u&&(e.height=t.minHeight),i&&(e.width=t.maxWidth),s&&(e.height=t.maxHeight),o&&l&&(e.left=a-t.minWidth),i&&l&&(e.left=a-t.maxWidth),u&&c&&(e.top=f-t.minHeight),s&&c&&(e.top=f-t.maxHeight),!e.width&&!e.height&&!e.left&&e.top?e.top=null:!e.width&&!e.height&&!e.top&&e.left&&(e.left=null),e},_proportionallyResize:function(){if(!this._proportionallyResizeElements.length)return;var e,t,n,r,i,s=this.helper||this.element;for(e=0;e<this._proportionallyResizeElements.length;e++){i=this._proportionallyResizeElements[e];if(!this.borderDif){this.borderDif=[],n=[i.css("borderTopWidth"),i.css("borderRightWidth"),i.css("borderBottomWidth"),i.css("borderLeftWidth")],r=[i.css("paddingTop"),i.css("paddingRight"),i.css("paddingBottom"),i.css("paddingLeft")];for(t=0;t<n.length;t++)this.borderDif[t]=(parseInt(n[t],10)||0)+(parseInt(r[t],10)||0)}i.css({height:s.height()-this.borderDif[0]-this.borderDif[2]||0,width:s.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var t=this.element,n=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||e("<div style='overflow:hidden;'></div>"),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++n.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var n=this.originalSize,r=this.originalPosition;return{left:r.left+t,width:n.width-t}},n:function(e,t,n){var r=this.originalSize,i=this.originalPosition;return{top:i.top+n,height:r.height-n}},s:function(e,t,n){return{height:this.originalSize.height+n}},se:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},sw:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,n,r]))},ne:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},nw:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,n,r]))}},_propagate:function(t,n){e.ui.plugin.call(this,t,[n,this.ui()]),t!=="resize"&&this._trigger(t,n,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var n=e(this).data("ui-resizable"),r=n.options,i=n._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),o=s&&e.ui.hasScroll(i[0],"left")?0:n.sizeDiff.height,u=s?0:n.sizeDiff.width,a={width:n.size.width-u,height:n.size.height-o},f=parseInt(n.element.css("left"),10)+(n.position.left-n.originalPosition.left)||null,l=parseInt(n.element.css("top"),10)+(n.position.top-n.originalPosition.top)||null;n.element.animate(e.extend(a,l&&f?{top:l,left:f}:{}),{duration:r.animateDuration,easing:r.animateEasing,step:function(){var r={width:parseInt(n.element.css("width"),10),height:parseInt(n.element.css("height"),10),top:parseInt(n.element.css("top"),10),left:parseInt(n.element.css("left"),10)};i&&i.length&&e(i[0]).css({width:r.width,height:r.height}),n._updateCache(r),n._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var t,r,i,s,o,u,a,f=e(this).data("ui-resizable"),l=f.options,c=f.element,h=l.containment,p=h instanceof e?h.get(0):/parent/.test(h)?c.parent().get(0):h;if(!p)return;f.containerElement=e(p),/document/.test(h)||h===document?(f.containerOffset={left:0,top:0},f.containerPosition={left:0,top:0},f.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(t=e(p),r=[],e(["Top","Right","Left","Bottom"]).each(function(e,i){r[e]=n(t.css("padding"+i))}),f.containerOffset=t.offset(),f.containerPosition=t.position(),f.containerSize={height:t.innerHeight()-r[3],width:t.innerWidth()-r[1]},i=f.containerOffset,s=f.containerSize.height,o=f.containerSize.width,u=e.ui.hasScroll(p,"left")?p.scrollWidth:o,a=e.ui.hasScroll(p)?p.scrollHeight:s,f.parentData={element:p,left:i.left,top:i.top,width:u,height:a})},resize:function(t){var n,r,i,s,o=e(this).data("ui-resizable"),u=o.options,a=o.containerOffset,f=o.position,l=o._aspectRatio||t.shiftKey,c={top:0,left:0},h=o.containerElement;h[0]!==document&&/static/.test(h.css("position"))&&(c=a),f.left<(o._helper?a.left:0)&&(o.size.width=o.size.width+(o._helper?o.position.left-a.left:o.position.left-c.left),l&&(o.size.height=o.size.width/o.aspectRatio),o.position.left=u.helper?a.left:0),f.top<(o._helper?a.top:0)&&(o.size.height=o.size.height+(o._helper?o.position.top-a.top:o.position.top),l&&(o.size.width=o.size.height*o.aspectRatio),o.position.top=o._helper?a.top:0),o.offset.left=o.parentData.left+o.position.left,o.offset.top=o.parentData.top+o.position.top,n=Math.abs((o._helper?o.offset.left-c.left:o.offset.left-c.left)+o.sizeDiff.width),r=Math.abs((o._helper?o.offset.top-c.top:o.offset.top-a.top)+o.sizeDiff.height),i=o.containerElement.get(0)===o.element.parent().get(0),s=/relative|absolute/.test(o.containerElement.css("position")),i&&s&&(n-=o.parentData.left),n+o.size.width>=o.parentData.width&&(o.size.width=o.parentData.width-n,l&&(o.size.height=o.size.width/o.aspectRatio)),r+o.size.height>=o.parentData.height&&(o.size.height=o.parentData.height-r,l&&(o.size.width=o.size.height*o.aspectRatio))},stop:function(){var t=e(this).data("ui-resizable"),n=t.options,r=t.containerOffset,i=t.containerPosition,s=t.containerElement,o=e(t.helper),u=o.offset(),a=o.outerWidth()-t.sizeDiff.width,f=o.outerHeight()-t.sizeDiff.height;t._helper&&!n.animate&&/relative/.test(s.css("position"))&&e(this).css({left:u.left-i.left-r.left,width:a,height:f}),t._helper&&!n.animate&&/static/.test(s.css("position"))&&e(this).css({left:u.left-i.left-r.left,width:a,height:f})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).data("ui-resizable"),n=t.options,r=function(t){e(t).each(function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};typeof n.alsoResize=="object"&&!n.alsoResize.parentNode?n.alsoResize.length?(n.alsoResize=n.alsoResize[0],r(n.alsoResize)):e.each(n.alsoResize,function(e){r(e)}):r(n.alsoResize)},resize:function(t,n){var r=e(this).data("ui-resizable"),i=r.options,s=r.originalSize,o=r.originalPosition,u={height:r.size.height-s.height||0,width:r.size.width-s.width||0,top:r.position.top-o.top||0,left:r.position.left-o.left||0},a=function(t,r){e(t).each(function(){var t=e(this),i=e(this).data("ui-resizable-alsoresize"),s={},o=r&&r.length?r:t.parents(n.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var n=(i[t]||0)+(u[t]||0);n&&n>=0&&(s[t]=n||null)}),t.css(s)})};typeof i.alsoResize=="object"&&!i.alsoResize.nodeType?e.each(i.alsoResize,function(e,t){a(e,t)}):a(i.alsoResize)},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).data("ui-resizable"),n=t.options,r=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:r.height,width:r.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof n.ghost=="string"?n.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).data("ui-resizable");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).data("ui-resizable");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t=e(this).data("ui-resizable"),n=t.options,r=t.size,i=t.originalSize,s=t.originalPosition,o=t.axis,u=typeof n.grid=="number"?[n.grid,n.grid]:n.grid,a=u[0]||1,f=u[1]||1,l=Math.round((r.width-i.width)/a)*a,c=Math.round((r.height-i.height)/f)*f,h=i.width+l,p=i.height+c,d=n.maxWidth&&n.maxWidth<h,v=n.maxHeight&&n.maxHeight<p,m=n.minWidth&&n.minWidth>h,g=n.minHeight&&n.minHeight>p;n.grid=u,m&&(h+=a),g&&(p+=f),d&&(h-=a),v&&(p-=f),/^(se|s|e)$/.test(o)?(t.size.width=h,t.size.height=p):/^(ne)$/.test(o)?(t.size.width=h,t.size.height=p,t.position.top=s.top-c):/^(sw)$/.test(o)?(t.size.width=h,t.size.height=p,t.position.left=s.left-l):(t.size.width=h,t.size.height=p,t.position.top=s.top-c,t.position.left=s.left-l)}})}(jQuery),function(e){function t(e,t,n){return e>t&&t+n>e}function n(e){return/left|right/.test(e.css("float"))||/inline|table-cell/.test(e.css("display"))}e.widget("ui.sortable",e.ui.mouse,{version:"1.10.2",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===e.axis||n(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,n){"disabled"===t?(this.options[t]=n,this.widget().toggleClass("ui-sortable-disabled",!!n)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,n){var r=null,i=!1,s=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(t),e(t.target).parents().each(function(){return e.data(this,s.widgetName+"-item")===s?(r=e(this),!1):undefined}),e.data(t.target,s.widgetName+"-item")===s&&(r=e(t.target)),r?!this.options.handle||n||(e(this.options.handle,r).find("*").addBack().each(function(){this===t.target&&(i=!0)}),i)?(this.currentItem=r,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(t,n,r){var i,s,o=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),o.containment&&this._setContainment(),o.cursor&&"auto"!==o.cursor&&(s=this.document.find("body"),this.storedCursor=s.css("cursor"),s.css("cursor",o.cursor),this.storedStylesheet=e("<style>*{ cursor: "+o.cursor+" !important; }</style>").appendTo(s)),o.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",o.opacity)),o.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",o.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!r)for(i=this.containers.length-1;i>=0;i--)this.containers[i]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!o.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){var n,r,i,s,o=this.options,u=!1;for(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<o.scrollSensitivity?this.scrollParent[0].scrollTop=u=this.scrollParent[0].scrollTop+o.scrollSpeed:t.pageY-this.overflowOffset.top<o.scrollSensitivity&&(this.scrollParent[0].scrollTop=u=this.scrollParent[0].scrollTop-o.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<o.scrollSensitivity?this.scrollParent[0].scrollLeft=u=this.scrollParent[0].scrollLeft+o.scrollSpeed:t.pageX-this.overflowOffset.left<o.scrollSensitivity&&(this.scrollParent[0].scrollLeft=u=this.scrollParent[0].scrollLeft-o.scrollSpeed)):(t.pageY-e(document).scrollTop()<o.scrollSensitivity?u=e(document).scrollTop(e(document).scrollTop()-o.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<o.scrollSensitivity&&(u=e(document).scrollTop(e(document).scrollTop()+o.scrollSpeed)),t.pageX-e(document).scrollLeft()<o.scrollSensitivity?u=e(document).scrollLeft(e(document).scrollLeft()-o.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<o.scrollSensitivity&&(u=e(document).scrollLeft(e(document).scrollLeft()+o.scrollSpeed))),u!==!1&&e.ui.ddmanager&&!o.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t)),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),n=this.items.length-1;n>=0;n--)if(r=this.items[n],i=r.item[0],s=this._intersectsWithPointer(r),s&&r.instance===this.currentContainer&&i!==this.currentItem[0]&&this.placeholder[1===s?"next":"prev"]()[0]!==i&&!e.contains(this.placeholder[0],i)&&("semi-dynamic"===this.options.type?!e.contains(this.element[0],i):!0)){if(this.direction=1===s?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(r))break;this._rearrange(t,r),this._trigger("change",t,this._uiHash());break}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,n){if(t){if(e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t),this.options.revert){var r=this,i=this.placeholder.offset(),s=this.options.axis,o={};s&&"x"!==s||(o.left=i.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),s&&"y"!==s||(o.top=i.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,e(this.helper).animate(o,parseInt(this.options.revert,10)||500,function(){r._clear(t)})}else this._clear(t,n);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},e(n).each(function(){var n=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[\-=_](.+)/);n&&r.push((t.key||n[1]+"[]")+"="+(t.key&&t.expression?n[1]:n[2]))}),!r.length&&t.key&&r.push(t.key+"="),r.join("&")},toArray:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},n.each(function(){r.push(e(t.item||this).attr(t.attribute||"id")||"")}),r},_intersectsWith:function(e){var t=this.positionAbs.left,n=t+this.helperProportions.width,r=this.positionAbs.top,i=r+this.helperProportions.height,s=e.left,o=s+e.width,u=e.top,a=u+e.height,f=this.offset.click.top,l=this.offset.click.left,c=r+f>u&&a>r+f&&t+l>s&&o>t+l;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?c:t+this.helperProportions.width/2>s&&o>n-this.helperProportions.width/2&&r+this.helperProportions.height/2>u&&a>i-this.helperProportions.height/2},_intersectsWithPointer:function(e){var n="x"===this.options.axis||t(this.positionAbs.top+this.offset.click.top,e.top,e.height),r="y"===this.options.axis||t(this.positionAbs.left+this.offset.click.left,e.left,e.width),i=n&&r,s=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return i?this.floating?o&&"right"===o||"down"===s?2:1:s&&("down"===s?2:1):!1},_intersectsWithSides:function(e){var n=t(this.positionAbs.top+this.offset.click.top,e.top+e.height/2,e.height),r=t(this.positionAbs.left+this.offset.click.left,e.left+e.width/2,e.width),i=this._getDragVerticalDirection(),s=this._getDragHorizontalDirection();return this.floating&&s?"right"===s&&r||"left"===s&&!r:i&&("down"===i&&n||"up"===i&&!n)},_getDragVerticalDirection:function(){var e=this.positionAbs.top-this.lastPositionAbs.top;return 0!==e&&(e>0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return 0!==e&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor===String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var n,r,i,s,o=[],u=[],a=this._connectWith();if(a&&t)for(n=a.length-1;n>=0;n--)for(i=e(a[n]),r=i.length-1;r>=0;r--)s=e.data(i[r],this.widgetFullName),s&&s!==this&&!s.options.disabled&&u.push([e.isFunction(s.options.items)?s.options.items.call(s.element):e(s.options.items,s.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),s]);for(u.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),n=u.length-1;n>=0;n--)u[n][0].each(function(){o.push(this)});return e(o)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var n=0;t.length>n;n++)if(t[n]===e.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var n,r,i,s,o,u,a,f,l=this.items,c=[[e.isFunction(this.options.items)?this.options.items.call(this.element[0],t,{item:this.currentItem}):e(this.options.items,this.element),this]],h=this._connectWith();if(h&&this.ready)for(n=h.length-1;n>=0;n--)for(i=e(h[n]),r=i.length-1;r>=0;r--)s=e.data(i[r],this.widgetFullName),s&&s!==this&&!s.options.disabled&&(c.push([e.isFunction(s.options.items)?s.options.items.call(s.element[0],t,{item:this.currentItem}):e(s.options.items,s.element),s]),this.containers.push(s));for(n=c.length-1;n>=0;n--)for(o=c[n][1],u=c[n][0],r=0,f=u.length;f>r;r++)a=e(u[r]),a.data(this.widgetName+"-item",o),l.push({item:a,instance:o,width:0,height:0,left:0,top:0})},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var n,r,i,s;for(n=this.items.length-1;n>=0;n--)r=this.items[n],r.instance!==this.currentContainer&&this.currentContainer&&r.item[0]!==this.currentItem[0]||(i=this.options.toleranceElement?e(this.options.toleranceElement,r.item):r.item,t||(r.width=i.outerWidth(),r.height=i.outerHeight()),s=i.offset(),r.left=s.left,r.top=s.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(n=this.containers.length-1;n>=0;n--)s=this.containers[n].element.offset(),this.containers[n].containerCache.left=s.left,this.containers[n].containerCache.top=s.top,this.containers[n].containerCache.width=this.containers[n].element.outerWidth(),this.containers[n].containerCache.height=this.containers[n].element.outerHeight();return this},_createPlaceholder:function(t){t=t||this;var n,r=t.options;r.placeholder&&r.placeholder.constructor!==String||(n=r.placeholder,r.placeholder={element:function(){var r=t.currentItem[0].nodeName.toLowerCase(),s=e(t.document[0].createElement(r)).addClass(n||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===r?s.append("<td colspan='99'>&#160;</td>"):"img"===r&&s.attr("src",t.currentItem.attr("src")),n||s.css("visibility","hidden"),s},update:function(e,o){(!n||r.forcePlaceholderSize)&&(o.height()||o.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),o.width()||o.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10)))}}),t.placeholder=e(r.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),r.placeholder.update(t,t.placeholder)},_contactContainers:function(r){var s,o,u,a,f,l,c,h,p,d,v=null,m=null;for(s=this.containers.length-1;s>=0;s--)if(!e.contains(this.currentItem[0],this.containers[s].element[0]))if(this._intersectsWith(this.containers[s].containerCache)){if(v&&e.contains(this.containers[s].element[0],v.element[0]))continue;v=this.containers[s],m=s}else this.containers[s].containerCache.over&&(this.containers[s]._trigger("out",r,this._uiHash(this)),this.containers[s].containerCache.over=0);if(v)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",r,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(u=1e4,a=null,d=v.floating||n(this.currentItem),f=d?"left":"top",l=d?"width":"height",c=this.positionAbs[f]+this.offset.click[f],o=this.items.length-1;o>=0;o--)e.contains(this.containers[m].element[0],this.items[o].item[0])&&this.items[o].item[0]!==this.currentItem[0]&&(!d||t(this.positionAbs.top+this.offset.click.top,this.items[o].top,this.items[o].height))&&(h=this.items[o].item.offset()[f],p=!1,Math.abs(h-c)>Math.abs(h+this.items[o][l]-c)&&(p=!0,h+=this.items[o][l]),u>Math.abs(h-c)&&(u=Math.abs(h-c),a=this.items[o],this.direction=p?"up":"down"));if(!a&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[m])return;a?this._rearrange(r,a,null,!0):this._rearrange(r,null,this.containers[m].element,!0),this._trigger("change",r,this._uiHash()),this.containers[m]._trigger("change",r,this._uiHash(this)),this.currentContainer=this.containers[m],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[m]._trigger("over",r,this._uiHash(this)),this.containers[m].containerCache.over=1}},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t,this.currentItem])):"clone"===n.helper?this.currentItem.clone():this.currentItem;return r.parents("body").length||e("parent"!==n.appendTo?n.appendTo:this.currentItem[0].parentNode)[0].appendChild(r[0]),r[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!r[0].style.width||n.forceHelperSize)&&r.width(this.currentItem.width()),(!r[0].style.height||n.forceHelperSize)&&r.height(this.currentItem.height()),r},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&e.ui.ie)&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,n,r,i=this.options;"parent"===i.containment&&(i.containment=this.helper[0].parentNode),("document"===i.containment||"window"===i.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e("document"===i.containment?document:window).width()-this.helperProportions.width-this.margins.left,(e("document"===i.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(i.containment)||(t=e(i.containment)[0],n=e(i.containment).offset(),r="hidden"!==e(t).css("overflow"),this.containment=[n.left+(parseInt(e(t).css("borderLeftWidth"),10)||0)+(parseInt(e(t).css("paddingLeft"),10)||0)-this.margins.left,n.top+(parseInt(e(t).css("borderTopWidth"),10)||0)+(parseInt(e(t).css("paddingTop"),10)||0)-this.margins.top,n.left+(r?Math.max(t.scrollWidth,t.offsetWidth):t.offsetWidth)-(parseInt(e(t).css("borderLeftWidth"),10)||0)-(parseInt(e(t).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,n.top+(r?Math.max(t.scrollHeight,t.offsetHeight):t.offsetHeight)-(parseInt(e(t).css("borderTopWidth"),10)||0)-(parseInt(e(t).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(t,n){n||(n=this.position);var r="absolute"===t?1:-1,i="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,s=/(html|body)/i.test(i[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():s?0:i.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():s?0:i.scrollLeft())*r}},_generatePosition:function(t){var n,r,i=this.options,s=t.pageX,o=t.pageY,u="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(u[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(s=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top)),i.grid&&(n=this.originalPageY+Math.round((o-this.originalPageY)/i.grid[1])*i.grid[1],o=this.containment?n-this.offset.click.top>=this.containment[1]&&n-this.offset.click.top<=this.containment[3]?n:n-this.offset.click.top>=this.containment[1]?n-i.grid[1]:n+i.grid[1]:n,r=this.originalPageX+Math.round((s-this.originalPageX)/i.grid[0])*i.grid[0],s=this.containment?r-this.offset.click.left>=this.containment[0]&&r-this.offset.click.left<=this.containment[2]?r:r-this.offset.click.left>=this.containment[0]?r-i.grid[0]:r+i.grid[0]:r)),{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():a?0:u.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():a?0:u.scrollLeft())}},_rearrange:function(e,t,n,r){n?n[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var i=this.counter;this._delay(function(){i===this.counter&&this.refreshPositions(!r)})},_clear:function(e,t){this.reverting=!1;var n,r=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(n in this._storedCSS)("auto"===this._storedCSS[n]||"static"===this._storedCSS[n])&&(this._storedCSS[n]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!t&&r.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||t||r.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(t||(r.push(function(e){this._trigger("remove",e,this._uiHash())}),r.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),r.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),n=this.containers.length-1;n>=0;n--)t||r.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[n])),this.containers[n].containerCache.over&&(r.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[n])),this.containers[n].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!t){for(this._trigger("beforeStop",e,this._uiHash()),n=0;r.length>n;n++)r[n].call(this,e);this._trigger("stop",e,this._uiHash())}return this.fromOutside=!1,!1}if(t||this._trigger("beforeStop",e,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!t){for(n=0;r.length>n;n++)r[n].call(this,e);this._trigger("stop",e,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){e.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(t){var n=t||this;return{helper:n.helper,placeholder:n.placeholder||e([]),position:n.position,originalPosition:n.originalPosition,offset:n.positionAbs,item:n.currentItem,sender:t?t.element:null}}})}(jQuery),function(e,t){function n(){return++i}function r(e){return e.hash.length>1&&decodeURIComponent(e.href.replace(s,""))===decodeURIComponent(location.href.replace(s,""))}var i=0,s=/#.*$/;e.widget("ui.tabs",{version:"1.10.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var t=this,n=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",n.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs(),n.active=this._initialActive(),e.isArray(n.disabled)&&(n.disabled=e.unique(n.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(n.active):e(),this._refresh(),this.active.length&&this.load(n.active)},_initialActive:function(){var n=this.options.active,r=this.options.collapsible,i=location.hash.substring(1);return null===n&&(i&&this.tabs.each(function(r,s){return e(s).attr("aria-controls")===i?(n=r,!1):t}),null===n&&(n=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===n||-1===n)&&(n=this.tabs.length?0:!1)),n!==!1&&(n=this.tabs.index(this.tabs.eq(n)),-1===n&&(n=r?!1:0)),!r&&n===!1&&this.anchors.length&&(n=0),n},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(n){var r=e(this.document[0].activeElement).closest("li"),i=this.tabs.index(r),s=!0;if(!this._handlePageNav(n)){switch(n.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:i++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:s=!1,i--;break;case e.ui.keyCode.END:i=this.anchors.length-1;break;case e.ui.keyCode.HOME:i=0;break;case e.ui.keyCode.SPACE:return n.preventDefault(),clearTimeout(this.activating),this._activate(i),t;case e.ui.keyCode.ENTER:return n.preventDefault(),clearTimeout(this.activating),this._activate(i===this.options.active?!1:i),t;default:return}n.preventDefault(),clearTimeout(this.activating),i=this._focusNextTab(i,s),n.ctrlKey||(r.attr("aria-selected","false"),this.tabs.eq(i).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",i)},this.delay))}},_panelKeydown:function(t){this._handlePageNav(t)||t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(n){return n.altKey&&n.keyCode===e.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):n.altKey&&n.keyCode===e.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):t},_findNextTab:function(t,n){function r(){return t>i&&(t=0),0>t&&(t=i),t}for(var i=this.tabs.length-1;-1!==e.inArray(r(),this.options.disabled);)t=n?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,n){return"active"===e?(this._activate(n),t):"disabled"===e?(this._setupDisabled(n),t):(this._super(e,n),"collapsible"===e&&(this.element.toggleClass("ui-tabs-collapsible",n),n||this.options.active!==!1||this._activate(0)),"event"===e&&this._setupEvents(n),"heightStyle"===e&&this._setupHeightStyle(n),t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+n()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,n=this.tablist.children(":has(a[href])");t.disabled=e.map(n.filter(".ui-state-disabled"),function(e){return n.index(e)}),this._processTabs(),t.active!==!1&&this.anchors.length?this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active):(t.active=!1,this.active=e()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(n,i){var s,o,u,a=e(i).uniqueId().attr("id"),f=e(i).closest("li"),l=f.attr("aria-controls");r(i)?(s=i.hash,o=t.element.find(t._sanitizeSelector(s))):(u=t._tabId(f),s="#"+u,o=t.element.find(s),o.length||(o=t._createPanel(u),o.insertAfter(t.panels[n-1]||t.tablist)),o.attr("aria-live","polite")),o.length&&(t.panels=t.panels.add(o)),l&&f.data("ui-tabs-aria-controls",l),f.attr({"aria-controls":s.substring(1),"aria-labelledby":a}),o.attr("aria-labelledby",a)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("<div>").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var n,r=0;n=this.tabs[r];r++)t===!0||-1!==e.inArray(r,t)?e(n).addClass("ui-state-disabled").attr("aria-disabled","true"):e(n).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var n={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,n),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var n,r=this.element.parent();"fill"===t?(n=r.height(),n-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var t=e(this),r=t.css("position");"absolute"!==r&&"fixed"!==r&&(n-=t.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){n-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,n-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===t&&(n=0,this.panels.each(function(){n=Math.max(n,e(this).height("").height())}).height(n))},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i.closest("li"),o=s[0]===r[0],u=o&&n.collapsible,a=u?e():this._getPanelForTab(s),f=r.length?this._getPanelForTab(r):e(),l={oldTab:r,oldPanel:f,newTab:u?e():s,newPanel:a};t.preventDefault(),s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||o&&!n.collapsible||this._trigger("beforeActivate",t,l)===!1||(n.active=u?!1:this.tabs.index(s),this.active=o?e():s,this.xhr&&this.xhr.abort(),f.length||a.length||e.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,l))},_toggle:function(t,n){function r(){s.running=!1,s._trigger("activate",t,n)}function i(){n.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),o.length&&s.options.show?s._show(o,s.options.show,r):(o.show(),r())}var s=this,o=n.newPanel,u=n.oldPanel;this.running=!0,u.length&&this.options.hide?this._hide(u,this.options.hide,function(){n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i()}):(n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u.hide(),i()),u.attr({"aria-expanded":"false","aria-hidden":"true"}),n.oldTab.attr("aria-selected","false"),o.length&&u.length?n.oldTab.attr("tabIndex",-1):o.length&&this.tabs.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),o.attr({"aria-expanded":"true","aria-hidden":"false"}),n.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var n,r=this._findActive(t);r[0]!==this.active[0]&&(r.length||(r=this.active),n=r.find(".ui-tabs-anchor")[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop}))},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return"string"==typeof e&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),n=t.data("ui-tabs-aria-controls");n?t.attr("aria-controls",n).removeData("ui-tabs-aria-controls"):t.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(n){var r=this.options.disabled;r!==!1&&(n===t?r=!1:(n=this._getIndex(n),r=e.isArray(r)?e.map(r,function(e){return e!==n?e:null}):e.map(this.tabs,function(e,t){return t!==n?t:null})),this._setupDisabled(r))},disable:function(n){var r=this.options.disabled;if(r!==!0){if(n===t)r=!0;else{if(n=this._getIndex(n),-1!==e.inArray(n,r))return;r=e.isArray(r)?e.merge([n],r).sort():[n]}this._setupDisabled(r)}},load:function(t,n){t=this._getIndex(t);var i=this,s=this.tabs.eq(t),o=s.find(".ui-tabs-anchor"),u=this._getPanelForTab(s),a={tab:s,panel:u};r(o[0])||(this.xhr=e.ajax(this._ajaxSettings(o,n,a)),this.xhr&&"canceled"!==this.xhr.statusText&&(s.addClass("ui-tabs-loading"),u.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){u.html(e),i._trigger("load",n,a)},1)}).complete(function(e,t){setTimeout(function(){"abort"===t&&i.panels.stop(!1,!0),s.removeClass("ui-tabs-loading"),u.removeAttr("aria-busy"),e===i.xhr&&delete i.xhr},1)})))},_ajaxSettings:function(t,n,r){var i=this;return{url:t.attr("href"),beforeSend:function(t,s){return i._trigger("beforeLoad",n,e.extend({jqXHR:t,ajaxSettings:s},r))}}},_getPanelForTab:function(t){var n=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+n))}})}(jQuery),function(e,t){var n=5;e.widget("ui.slider",e.ui.mouse,{version:"1.10.0",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},_create:function(){var t,n,r=this.options,i=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),s="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",o=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"),this.range=e([]),r.range&&(r.range===!0&&(r.values?r.values.length&&r.values.length!==2?r.values=[r.values[0],r.values[0]]:e.isArray(r.values)&&(r.values=r.values.slice(0)):r.values=[this._valueMin(),this._valueMin()]),this.range=e("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(r.range==="min"||r.range==="max"?" ui-slider-range-"+r.range:""))),n=r.values&&r.values.length||1;for(t=i.length;t<n;t++)o.push(s);this.handles=i.add(e(o.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(e){e.preventDefault()}).mouseenter(function(){r.disabled||e(this).addClass("ui-state-hover")}).mouseleave(function(){e(this).removeClass("ui-state-hover")}).focus(function(){r.disabled?e(this).blur():(e(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),e(this).addClass("ui-state-focus"))}).blur(function(){e(this).removeClass("ui-state-focus")}),this.handles.each(function(t){e(this).data("ui-slider-handle-index",t)}),this._setOption("disabled",r.disabled),this._on(this.handles,this._handleEvents),this._refreshValue(),this._animateOff=!1},_destroy:function(){this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(t){var n,r,i,s,o,u,a,f,l=this,c=this.options;return c.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),n={x:t.pageX,y:t.pageY},r=this._normValueFromMouse(n),i=this._valueMax()-this._valueMin()+1,this.handles.each(function(t){var n=Math.abs(r-l.values(t));if(i>n||i===n&&(t===l._lastChangedValue||l.values(t)===c.min))i=n,s=e(this),o=t}),u=this._start(t,o),u===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,s.addClass("ui-state-active").focus(),a=s.offset(),f=!e(t.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=f?{left:0,top:0}:{left:t.pageX-a.left-s.width()/2,top:t.pageY-a.top-s.height()/2-(parseInt(s.css("borderTopWidth"),10)||0)-(parseInt(s.css("borderBottomWidth"),10)||0)+(parseInt(s.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,r),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},n=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,n),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,n,r,i,s;return this.orientation==="horizontal"?(t=this.elementSize.width,n=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,n=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),r=n/t,r>1&&(r=1),r<0&&(r=0),this.orientation==="vertical"&&(r=1-r),i=this._valueMax()-this._valueMin(),s=this._valueMin()+r*i,this._trimAlignValue(s)},_start:function(e,t){var n={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("start",e,n)},_slide:function(e,t,n){var r,i,s;this.options.values&&this.options.values.length?(r=this.values(t?0:1),this.options.values.length===2&&this.options.range===!0&&(t===0&&n>r||t===1&&n<r)&&(n=r),n!==this.values(t)&&(i=this.values(),i[t]=n,s=this._trigger("slide",e,{handle:this.handles[t],value:n,values:i}),r=this.values(t?0:1),s!==!1&&this.values(t,n,!0))):n!==this.value()&&(s=this._trigger("slide",e,{handle:this.handles[t],value:n}),s!==!1&&this.value(n))},_stop:function(e,t){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("stop",e,n)},_change:function(e,t){if(!this._keySliding&&!this._mouseSliding){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._lastChangedValue=t,this._trigger("change",e,n)}},value:function(e){if(arguments.length){this.options.value=this._trimAlignValue(e),this._refreshValue(),this._change(null,0);return}return this._value()},values:function(t,n){var r,i,s;if(arguments.length>1){this.options.values[t]=this._trimAlignValue(n),this._refreshValue(),this._change(null,t);return}if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();r=this.options.values,i=arguments[0];for(s=0;s<r.length;s+=1)r[s]=this._trimAlignValue(i[s]),this._change(null,s);this._refreshValue()},_setOption:function(t,n){var r,i=0;e.isArray(this.options.values)&&(i=this.options.values.length),e.Widget.prototype._setOption.apply(this,arguments);switch(t){case"disabled":n?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.prop("disabled",!0)):this.handles.prop("disabled",!1);break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":this._animateOff=!0,this._refreshValue();for(r=0;r<i;r+=1)this._change(null,r);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1}},_value:function(){var e=this.options.value;return e=this._trimAlignValue(e),e},_values:function(e){var t,n,r;if(arguments.length)return t=this.options.values[e],t=this._trimAlignValue(t),t;n=this.options.values.slice();for(r=0;r<n.length;r+=1)n[r]=this._trimAlignValue(n[r]);return n},_trimAlignValue:function(e){if(e<=this._valueMin())return this._valueMin();if(e>=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,n=(e-this._valueMin())%t,r=e-n;return Math.abs(n)*2>=t&&(r+=n>0?t:-t),parseFloat(r.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,n,r,i,s,o=this.options.range,u=this.options,a=this,f=this._animateOff?!1:u.animate,l={};this.options.values&&this.options.values.length?this.handles.each(function(r){n=(a.values(r)-a._valueMin())/(a._valueMax()-a._valueMin())*100,l[a.orientation==="horizontal"?"left":"bottom"]=n+"%",e(this).stop(1,1)[f?"animate":"css"](l,u.animate),a.options.range===!0&&(a.orientation==="horizontal"?(r===0&&a.range.stop(1,1)[f?"animate":"css"]({left:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({width:n-t+"%"},{queue:!1,duration:u.animate})):(r===0&&a.range.stop(1,1)[f?"animate":"css"]({bottom:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({height:n-t+"%"},{queue:!1,duration:u.animate}))),t=n}):(r=this.value(),i=this._valueMin(),s=this._valueMax(),n=s!==i?(r-i)/(s-i)*100:0,l[this.orientation==="horizontal"?"left":"bottom"]=n+"%",this.handle.stop(1,1)[f?"animate":"css"](l,u.animate),o==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[f?"animate":"css"]({width:n+"%"},u.animate),o==="max"&&this.orientation==="horizontal"&&this.range[f?"animate":"css"]({width:100-n+"%"},{queue:!1,duration:u.animate}),o==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[f?"animate":"css"]({height:n+"%"},u.animate),o==="max"&&this.orientation==="vertical"&&this.range[f?"animate":"css"]({height:100-n+"%"},{queue:!1,duration:u.animate}))},_handleEvents:{keydown:function(t){var r,i,s,o,u=e(t.target).data("ui-slider-handle-index");switch(t.keyCode){case e.ui.keyCode.HOME:case e.ui.keyCode.END:case e.ui.keyCode.PAGE_UP:case e.ui.keyCode.PAGE_DOWN:case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:t.preventDefault();if(!this._keySliding){this._keySliding=!0,e(t.target).addClass("ui-state-active"),r=this._start(t,u);if(r===!1)return}}o=this.options.step,this.options.values&&this.options.values.length?i=s=this.values(u):i=s=this.value();switch(t.keyCode){case e.ui.keyCode.HOME:s=this._valueMin();break;case e.ui.keyCode.END:s=this._valueMax();break;case e.ui.keyCode.PAGE_UP:s=this._trimAlignValue(i+(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.PAGE_DOWN:s=this._trimAlignValue(i-(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:if(i===this._valueMax())return;s=this._trimAlignValue(i+o);break;case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(i===this._valueMin())return;s=this._trimAlignValue(i-o)}this._slide(t,u,s)},keyup:function(t){var n=e(t.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(t,n),this._change(t,n),e(t.target).removeClass("ui-state-active"))}}})}(jQuery),define("jqueryUI",function(){}),define("modules/layout-selector",["jquery","ko","jqueryUI"],function(e,t){loadLayoutSelector=function(t){createCog(e("#layout-selector-pages")),createCog(e("#layout-selector-templates")),e.ajax(Headway.ajaxURL,{type:"POST",async:!0,data:{action:"headway_visual_editor",method:"get_layout_selector_pages",security:Headway.security,currentLayout:Headway.currentLayout,mode:Headway.mode},success:function(n,r){e("#layout-selector-pages").html(n),typeof t=="function"&&t.call()}}),e.ajax(Headway.ajaxURL,{type:"POST",async:!0,data:{action:"headway_visual_editor",method:"get_layout_selector_templates",security:Headway.security,currentLayout:Headway.currentLayout,mode:Headway.mode},success:function(t,n){e("#layout-selector-templates").html(t)}})},showLayoutSelector=function(){return e("div#layout-selector-select").addClass("layout-selector-visible"),e("div#layout-selector").css({left:e("div#layout-selector-select-content").offset().left}),e(document).bind("mousedown",hideLayoutSelector),Headway.iframe.contents().bind("mousedown",hideLayoutSelector),e("div#layout-selector-select")},hideLayoutSelector=function(t){if(t&&(e(t.target).is("#layout-selector-select")||e(t.target).parents("#layout-selector-select").length===1))return;return e("div#layout-selector-select").removeClass("layout-selector-visible"),e(document).unbind("mousedown",hideLayoutSelector),Headway.iframe.contents().unbind("mousedown",hideLayoutSelector),e("div#layout-selector-select")},toggleLayoutSelector=function(){e("div#layout-selector-select").hasClass("layout-selector-visible")?hideLayoutSelector(!1):showLayoutSelector()},switchToLayout=function(t,n,r){typeof t=="object"&&!t.hasClass("layout")&&(t=t.find("> span.layout"));if(t.length!==1)return!1;changeTitle("Visual Editor: Loading"),startTitleActivityIndicator();var i=t,s=i.attr("data-layout-id"),o=Headway.mode=="grid"?Headway.homeURL:i.attr("data-layout-url"),u=i.find("strong").text();e(".layout-selected","div#layout-selector").removeClass("layout-selected"),i.parent("li").addClass("layout-selected"),Headway.currentLayout=s,Headway.currentLayoutName=u,Headway.currentLayoutTemplate=!1,Headway.currentLayoutCustomized=!1,Headway.switchedToLayout=!0,Headway.currentLayoutCustomized=i.parents("li.layout-item").first().hasClass("layout-item-customized")||i.parents("#layout-selector-templates-container").length;var a=i.find(".status-template").data("template-id");typeof a!="undefined"&&a!="none"&&(Headway.currentLayoutTemplate=a,Headway.currentLayoutTemplateName=e('span.layout[data-layout-id="template-'+a+'"]').find(".template-name").text()),window.history.pushState("","",Headway.homeURL+"/?visual-editor=true&visual-editor-mode="+Headway.mode+"&ve-layout="+Headway.currentLayout);if(typeof n=="undefined"||n==1){if(typeof r=="undefined"||r==1)headwayIframeLoadNotification="Switched to <em>"+Headway.currentLayoutName+"</em>";loadIframe(Headway.instance.iframeCallback,o)}return!0};var n={init:function(){loadLayoutSelector(),n.bind()},bind:function(){var t=e("div#layout-selector");e("div#layout-selector-select-content").click(function(){return toggleLayoutSelector(),!1}),t.tabs(),t.delegate("span.edit","click",function(t){return typeof allowVECloseSwitch!="undefined"&&allowVECloseSwitch===!1&&!confirm("You have unsaved changes, are you sure you want to switch layouts?")?!1:(showIframeLoadingOverlay(),switchToLayout(e(this).parents("span.layout")),hideLayoutSelector(),t.preventDefault(),e(this).parents("span.layout"))}),t.delegate("span.revert","click",function(t){if(!confirm("Are you sure you wish to reset this layout?  All blocks and content will be removed from this layout.\n\nPlease note: Any block that is mirroring a block on this layout will also lose its settings."))return!1;var n=e(this).parents("span.layout"),r=n.attr("data-layout-id"),i=n.find("strong").text();showIframeLoadingOverlay(),changeTitle("Visual Editor: Reverting "+i),startTitleActivityIndicator(),n.parent().removeClass("layout-item-customized");var s=e(n.parents(".layout-item-customized:not(.layout-selected)")[0]),o=s.find("> span.layout").attr("data-layout-id"),u=e(e("div#layout-selector-pages > ul > li.layout-item-customized")[0]),a=u.find("> span.layout").attr("data-layout-id"),f=o?s:u,l=o?o:a;if(typeof l=="undefined"||!l)l=Headway.frontPage=="posts"?"index":"front_page",f=e('div#layout-selector-pages > ul > li > span[data-layout-id="'+l+'"]').parent();return switchToLayout(f,!0,!1),e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"revert_layout",layout_to_revert:r},function(e){e==="success"?showNotification({id:"layout-reverted",message:"<em>"+i+"</em> successfully reverted!",success:!0}):showErrorNotification({id:"error-could-not-revert-layout",message:"Error: Could not revert layout."})}),!1}),t.delegate("span#add-template","click",function(t){var n=e("#template-name-input").val();return e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"add_template",layout:Headway.currentLayout,template_name:n},function(t){if(typeof t=="undefined"||!t)return showErrorNotification({id:"error-could-not-add-template",message:"Error: Could not add shared template."}),!1;var n=e('<li class="layout-item">                                             <span data-layout-id="template-'+t.id+'" class="layout layout-template">                                                        <strong class="template-name">'+t.name+'</strong>                                                                                                               <span class="delete-template" title="Delete Shared Layout">Delete</span>                                                                                                                <span class="status status-currently-editing">Currently Editing</span>                                                                                                                                                                  <span class="rename-template button layout-selector-button" title="Rename Shared Layout">Rename</span>                                                  <span class="assign-template button layout-selector-button">Use Layout</span>                                                   <span class="edit button layout-selector-button">Edit</span>                                            </span>                                 </li>');n.appendTo("div#layout-selector-templates ul"),e("li#no-templates:visible","div#layout-selector").hide(),showNotification({id:"template-added",message:"Shared layout added!",success:!0}),e("#template-name-input").val("")},"json"),!1}),t.delegate("span.delete-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent(),i=r.attr("data-layout-id"),s=i.replace("template-",""),o=r.find("strong").text();return confirm("Are you sure you wish to delete this template?")?(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"delete_template",template_to_delete:s},function(t){if(typeof t=="undefined"||t=="failure"||t!="success")return showErrorNotification({id:"error-could-not-deleted-template",message:"Error: Could not delete shared layout."}),!1;n.remove(),e("span.layout-template","div#layout-selector").length===0&&e("li#no-templates","div#layout-selector").show(),showNotification({id:"template-deleted",message:"Shared Layout: <em>"+o+"</em> successfully deleted!",success:!0});if(i===Headway.currentLayout){var r=Headway.frontPage=="posts"?"index":"front_page";switchToLayout(e('div#layout-selector span.layout[data-layout-id="'+r+'"]'),!0,!1)}}),!1):!1}),t.delegate("span.assign-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent().attr("data-layout-id").replace("template-","");return Headway.currentLayout.indexOf("template-")===0?(alert("You cannot assign a shared layout to another shared layout."),!1):(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"assign_template",template:r,layout:Headway.currentLayout},function(t){if(typeof t=="undefined"||t=="failure")return showErrorNotification({id:"error-could-not-assign-template",message:"Error: Could not assign shared layout."}),!1;e("li.layout-selected","div#layout-selector").removeClass("layout-item-customized"),e("li.layout-selected","div#layout-selector").addClass("layout-item-template-used"),e("li.layout-selected > span.status-template","div#layout-selector").text(t),showIframeLoadingOverlay(),changeTitle("Visual Editor: Assigning Shared Layout"),startTitleActivityIndicator(),Headway.currentLayoutTemplate="template-"+r,Headway.currentLayoutTemplateName=e('span.layout[data-layout-id="template-'+r+'"]').find(".template-name").text(),headwayIframeLoadNotification="Shared layout assigned successfully!",loadIframe(Headway.instance.iframeCallback)}),!1)}),t.delegate("span.rename-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent().attr("data-layout-id"),i=e(this).siblings(".template-name"),s=i.text(),o=prompt("Please enter new Shared Layout name",s);return e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"rename_layout_template",layout:r,newName:o},function(e){return typeof e=="undefined"||e=="failure"?(showErrorNotification({id:"error-could-not-rename-layout-template",message:"Error: Could not rename shared layout."}),!1):(i.text(o),!0)}),!1}),t.delegate("span.remove-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent().attr("data-layout-id");return confirm("Are you sure you want to remove the shared layout from "+n.find("> span.layout strong").text()+"?")?(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"remove_template_from_layout",layout:r},function(e){return typeof e=="undefined"||e=="failure"?(showErrorNotification({id:"error-could-not-remove-template-from-layout",message:"Error: Could not remove shared layout from layout."}),!1):(n.removeClass("layout-item-template-used"),e==="customized"&&n.addClass("layout-item-customized"),r==Headway.currentLayout?(showIframeLoadingOverlay(),changeTitle("Visual Editor: Removing Shared Layout From Layout"),startTitleActivityIndicator(),Headway.currentLayoutTemplate=!1,headwayIframeLoadNotification="Shared Layout removed from layout successfully!",loadIframe(Headway.instance.iframeCallback),!0):!0)}),!1):!1}),t.delegate("span","click",function(t){e(this).hasClass("layout-open")?(e(this).removeClass("layout-open"),e(this).siblings("ul").hide()):(e(this).addClass("layout-open"),e(this).siblings("ul").show())})}};return n}),jQuery.cookie=function(e,t,n){if(arguments.length>1&&String(t)!=="[object Object]"){n=jQuery.extend({},n);if(t===null||t===undefined)n.expires=-1;if(typeof n.expires=="number"){var r=n.expires,i=n.expires=new Date;i.setDate(i.getDate()+r)}return t=String(t),document.cookie=[encodeURIComponent(e),"=",n.raw?t:encodeURIComponent(t),n.expires?"; expires="+n.expires.toUTCString():"",n.path?"; path="+n.path:"",n.domain?"; domain="+n.domain:"",n.secure?"; secure":""].join("")}n=t||{};var s,o=n.raw?function(e){return e}:decodeURIComponent;return(s=(new RegExp("(?:^|; )"+encodeURIComponent(e)+"=([^;]*)")).exec(document.cookie))?o(s[1]):null},define("deps/jquery.cookie",function(){}),!function(e,t,n){!function(e){"function"==typeof define&&define.amd?define("qtip",["jquery"],e):jQuery&&!jQuery.fn.qtip&&e(jQuery)}(function(r){function i(e,t,n,i){this.id=n,this.target=e,this.tooltip=D,this.elements={target:e},this._id=V+"-"+n,this.timers={img:{}},this.options=t,this.plugins={},this.cache={event:{},target:r(),disabled:_,attr:i,onTooltip:_,lastClass:""},this.rendered=this.destroyed=this.disabled=this.waiting=this.hiddenDuringWait=this.positioning=this.triggering=_}function s(e){return e===D||"object"!==r.type(e)}function o(e){return!(r.isFunction(e)||e&&e.attr||e.length||"object"===r.type(e)&&(e.jquery||e.then))}function u(e){var t,n,i,u;return s(e)?_:(s(e.metadata)&&(e.metadata={type:e.metadata}),"content"in e&&(t=e.content,s(t)||t.jquery||t.done?t=e.content={text:n=o(t)?_:t}:n=t.text,"ajax"in t&&(i=t.ajax,u=i&&i.once!==_,delete t.ajax,t.text=function(e,t){var s=n||r(this).attr(t.options.content.attr)||"Loading...",o=r.ajax(r.extend({},i,{context:t})).then(i.success,D,i.error).then(function(e){return e&&u&&t.set("content.text",e),e},function(e,n,r){t.destroyed||0===e.status||t.set("content.text",n+": "+r)});return u?s:(t.set("content.text",s),o)}),"title"in t&&(s(t.title)||(t.button=t.title.button,t.title=t.title.text),o(t.title||_)&&(t.title=_))),"position"in e&&s(e.position)&&(e.position={my:e.position,at:e.position}),"show"in e&&s(e.show)&&(e.show=e.show.jquery?{target:e.show}:e.show===M?{ready:M}:{event:e.show}),"hide"in e&&s(e.hide)&&(e.hide=e.hide.jquery?{target:e.hide}:{event:e.hide}),"style"in e&&s(e.style)&&(e.style={classes:e.style}),r.each(X,function(){this.sanitize&&this.sanitize(e)}),e)}function f(e,t){for(var n,r=0,i=e,s=t.split(".");i=i[s[r++]];)r<s.length&&(n=i);return[n||e,s.pop()]}function l(e,t){var n,r,i;for(n in this.checks)for(r in this.checks[n])(i=(new RegExp(r,"i")).exec(e))&&(t.push(i),("builtin"===n||this.plugins[n])&&this.checks[n][r].apply(this.plugins[n]||this,t))}function h(e){return K.concat("").join(e?"-"+e+" ":" ")}function p(n){return n&&{type:n.type,pageX:n.pageX,pageY:n.pageY,target:n.target,relatedTarget:n.relatedTarget,scrollX:n.scrollX||e.pageXOffset||t.body.scrollLeft||t.documentElement.scrollLeft,scrollY:n.scrollY||e.pageYOffset||t.body.scrollTop||t.documentElement.scrollTop}||{}}function d(e,t){return t>0?setTimeout(r.proxy(e,this),t):(e.call(this),void 0)}function v(e){return this.tooltip.hasClass(nt)?_:(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this.timers.show=d.call(this,function(){this.toggle(M,e)},this.options.show.delay),void 0)}function m(e){if(this.tooltip.hasClass(nt))return _;var t=r(e.relatedTarget),n=t.closest(Q)[0]===this.tooltip[0],i=t[0]===this.options.show.target[0];if(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this!==t[0]&&"mouse"===this.options.position.target&&n||this.options.hide.fixed&&/mouse(out|leave|move)/.test(e.type)&&(n||i))try{e.preventDefault(),e.stopImmediatePropagation()}catch(s){}else this.timers.hide=d.call(this,function(){this.toggle(_,e)},this.options.hide.delay,this)}function g(e){return this.tooltip.hasClass(nt)||!this.options.hide.inactive?_:(clearTimeout(this.timers.inactive),this.timers.inactive=d.call(this,function(){this.hide(e)},this.options.hide.inactive),void 0)}function y(e){this.rendered&&this.tooltip[0].offsetWidth>0&&this.reposition(e)}function w(e,n,i){r(t.body).delegate(e,(n.split?n:n.join(ft+" "))+ft,function(){var e=C.api[r.attr(this,J)];e&&!e.disabled&&i.apply(e,arguments)})}function E(e,n,s){var o,a,f,l,c,h=r(t.body),p=e[0]===t?h:e,d=e.metadata?e.metadata(s.metadata):D,v="html5"===s.metadata.type&&d?d[s.metadata.name]:D,m=e.data(s.metadata.name||"qtipopts");try{m="string"==typeof m?r.parseJSON(m):m}catch(g){}if(l=r.extend(M,{},C.defaults,s,"object"==typeof m?u(m):D,u(v||d)),a=l.position,l.id=n,"boolean"==typeof l.content.text){if(f=e.attr(l.content.attr),l.content.attr===_||!f)return _;l.content.text=f}if(a.container.length||(a.container=h),a.target===_&&(a.target=p),l.show.target===_&&(l.show.target=p),l.show.solo===M&&(l.show.solo=a.container.closest("body")),l.hide.target===_&&(l.hide.target=p),l.position.viewport===M&&(l.position.viewport=a.container),a.container=a.container.eq(0),a.at=new L(a.at,M),a.my=new L(a.my),e.data(V))if(l.overwrite)e.qtip("destroy",!0);else if(l.overwrite===_)return _;return e.attr($,n),l.suppress&&(c=e.attr("title"))&&e.removeAttr("title").attr(it,c).attr("title",""),o=new i(e,l,n,!!f),e.data(V,o),e.one("remove.qtip-"+n+" removeqtip.qtip-"+n,function(){var e;(e=r(this).data(V))&&e.destroy(!0)}),o}function S(e){return e.charAt(0).toUpperCase()+e.slice(1)}function x(e,t){var r,i,s=t.charAt(0).toUpperCase()+t.slice(1),o=(t+" "+wt.join(s+" ")+s).split(" "),u=0;if(bt[t])return e.css(bt[t]);for(;r=o[u++];)if((i=e.css(r))!==n)return bt[t]=r,i}function T(e,t){return Math.ceil(parseFloat(x(e,t)))}function N(e,t){this._ns="tip",this.options=t,this.offset=t.offset,this.size=[t.width,t.height],this.init(this.qtip=e)}var C,k,L,A,O,M=!0,_=!1,D=null,P="x",H="y",B="width",j="height",F="top",I="left",q="bottom",R="right",U="center",z="flipinvert",W="shift",X={},V="qtip",$="data-hasqtip",J="data-qtip-id",K=["ui-widget","ui-tooltip"],Q="."+V,G="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),Y=V+"-fixed",Z=V+"-default",et=V+"-focus",tt=V+"-hover",nt=V+"-disabled",rt="_replacedByqTip",it="oldtitle",st={ie:function(){for(var e=3,n=t.createElement("div");(n.innerHTML="<!--[if gt IE "+ ++e+"]><i></i><![endif]-->")&&n.getElementsByTagName("i")[0];);return e>4?e:0/0}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||_};k=i.prototype,k._when=function(e){return r.when.apply(r,e)},k.render=function(e){if(this.rendered||this.destroyed)return this;var t,n=this,i=this.options,s=this.cache,o=this.elements,u=i.content.text,a=i.content.title,f=i.content.button,l=i.position,c=("."+this._id+" ",[]);return r.attr(this.target[0],"aria-describedby",this._id),this.tooltip=o.tooltip=t=r("<div/>",{id:this._id,"class":[V,Z,i.style.classes,V+"-pos-"+i.position.my.abbrev()].join(" "),width:i.style.width||"",height:i.style.height||"",tracking:"mouse"===l.target&&l.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":_,"aria-describedby":this._id+"-content","aria-hidden":M}).toggleClass(nt,this.disabled).attr(J,this.id).data(V,this).appendTo(l.container).append(o.content=r("<div />",{"class":V+"-content",id:this._id+"-content","aria-atomic":M})),this.rendered=-1,this.positioning=M,a&&(this._createTitle(),r.isFunction(a)||c.push(this._updateTitle(a,_))),f&&this._createButton(),r.isFunction(u)||c.push(this._updateContent(u,_)),this.rendered=M,this._setWidget(),r.each(X,function(e){var t;"render"===this.initialize&&(t=this(n))&&(n.plugins[e]=t)}),this._unassignEvents(),this._assignEvents(),this._when(c).then(function(){n._trigger("render"),n.positioning=_,n.hiddenDuringWait||!i.show.ready&&!e||n.toggle(M,s.event,_),n.hiddenDuringWait=_}),C.api[this.id]=this,this},k.destroy=function(e){function t(){if(!this.destroyed){this.destroyed=M;var e=this.target,t=e.attr(it);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove(),r.each(this.plugins,function(){this.destroy&&this.destroy()}),clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this._unassignEvents(),e.removeData(V).removeAttr(J).removeAttr($).removeAttr("aria-describedby"),this.options.suppress&&t&&e.attr("title",t).removeAttr(it),this._unbind(e),this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=D,delete C.api[this.id]}}return this.destroyed?this.target:(e===M&&"hide"!==this.triggering||!this.rendered?t.call(this):(this.tooltip.one("tooltiphidden",r.proxy(t,this)),!this.triggering&&this.hide()),this.target)},A=k.checks={builtin:{"^id$":function(e,t,n,i){var s=n===M?C.nextid:n,o=V+"-"+s;s!==_&&s.length>0&&!r("#"+o).length?(this._id=o,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):e[t]=i},"^prerender":function(e,t,n){n&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(e,t,n){this._updateContent(n)},"^content.attr$":function(e,t,n,r){this.options.content.text===this.target.attr(r)&&this._updateContent(this.target.attr(n))},"^content.title$":function(e,t,n){return n?(n&&!this.elements.title&&this._createTitle(),this._updateTitle(n),void 0):this._removeTitle()},"^content.button$":function(e,t,n){this._updateButton(n)},"^content.title.(text|button)$":function(e,t,n){this.set("content."+t,n)},"^position.(my|at)$":function(e,t,n){"string"==typeof n&&(e[t]=new L(n,"at"===t))},"^position.container$":function(e,t,n){this.rendered&&this.tooltip.appendTo(n)},"^show.ready$":function(e,t,n){n&&(!this.rendered&&this.render(M)||this.toggle(M))},"^style.classes$":function(e,t,n,r){this.rendered&&this.tooltip.removeClass(r).addClass(n)},"^style.(width|height)":function(e,t,n){this.rendered&&this.tooltip.css(t,n)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(e,t,n){this.rendered&&this.tooltip.toggleClass(Z,!!n)},"^events.(render|show|move|hide|focus|blur)$":function(e,t,n){this.rendered&&this.tooltip[(r.isFunction(n)?"":"un")+"bind"]("tooltip"+t,n)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(this.rendered){var e=this.options.position;this.tooltip.attr("tracking","mouse"===e.target&&e.adjust.mouse),this._unassignEvents(),this._assignEvents()}}}},k.get=function(e){if(this.destroyed)return this;var t=f(this.options,e.toLowerCase()),n=t[0][t[1]];return n.precedance?n.string():n};var ot=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,ut=/^prerender|show\.ready/i;k.set=function(e,t){if(this.destroyed)return this;var n,i=this.rendered,s=_,o=this.options;return this.checks,"string"==typeof e?(n=e,e={},e[n]=t):e=r.extend({},e),r.each(e,function(t,n){if(i&&ut.test(t))return delete e[t],void 0;var u,l=f(o,t.toLowerCase());u=l[0][l[1]],l[0][l[1]]=n&&n.nodeType?r(n):n,s=ot.test(t)||s,e[t]=[l[0],l[1],n,u]}),u(o),this.positioning=M,r.each(e,r.proxy(l,this)),this.positioning=_,this.rendered&&this.tooltip[0].offsetWidth>0&&s&&this.reposition("mouse"===o.position.target?D:this.cache.event),this},k._update=function(e,t){var n=this,i=this.cache;return this.rendered&&e?(r.isFunction(e)&&(e=e.call(this.elements.target,i.event,this)||""),r.isFunction(e.then)?(i.waiting=M,e.then(function(e){return i.waiting=_,n._update(e,t)},D,function(e){return n._update(e,t)})):e===_||!e&&""!==e?_:(e.jquery&&e.length>0?t.empty().append(e.css({display:"block",visibility:"visible"})):t.html(e),this._waitForContent(t).then(function(e){e.images&&e.images.length&&n.rendered&&n.tooltip[0].offsetWidth>0&&n.reposition(i.event,!e.length)}))):_},k._waitForContent=function(e){var t=this.cache;return t.waiting=M,(r.fn.imagesLoaded?e.imagesLoaded():r.Deferred().resolve([])).done(function(){t.waiting=_}).promise()},k._updateContent=function(e,t){this._update(e,this.elements.content,t)},k._updateTitle=function(e,t){this._update(e,this.elements.title,t)===_&&this._removeTitle(_)},k._createTitle=function(){var e=this.elements,t=this._id+"-title";e.titlebar&&this._removeTitle(),e.titlebar=r("<div />",{"class":V+"-titlebar "+(this.options.style.widget?h("header"):"")}).append(e.title=r("<div />",{id:t,"class":V+"-title","aria-atomic":M})).insertBefore(e.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(e){r(this).toggleClass("ui-state-active ui-state-focus","down"===e.type.substr(-4))}).delegate(".qtip-close","mouseover mouseout",function(e){r(this).toggleClass("ui-state-hover","mouseover"===e.type)}),this.options.content.button&&this._createButton()},k._removeTitle=function(e){var t=this.elements;t.title&&(t.titlebar.remove(),t.titlebar=t.title=t.button=D,e!==_&&this.reposition())},k.reposition=function(n,i){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=M;var s,o,u=this.cache,f=this.tooltip,l=this.options.position,c=l.target,h=l.my,p=l.at,d=l.viewport,v=l.container,m=l.adjust,g=m.method.split(" "),y=f.outerWidth(_),w=f.outerHeight(_),E=0,S=0,x=f.css("position"),T={left:0,top:0},N=f[0].offsetWidth>0,C=n&&"scroll"===n.type,k=r(e),L=v[0].ownerDocument,A=this.mouse;if(r.isArray(c)&&2===c.length)p={x:I,y:F},T={left:c[0],top:c[1]};else if("mouse"===c)p={x:I,y:F},!A||!A.pageX||!m.mouse&&n&&n.pageX?n&&n.pageX||((!m.mouse||this.options.show.distance)&&u.origin&&u.origin.pageX?n=u.origin:(!n||n&&("resize"===n.type||"scroll"===n.type))&&(n=u.event)):n=A,"static"!==x&&(T=v.offset()),L.body.offsetWidth!==(e.innerWidth||L.documentElement.clientWidth)&&(o=r(t.body).offset()),T={left:n.pageX-T.left+(o&&o.left||0),top:n.pageY-T.top+(o&&o.top||0)},m.mouse&&C&&A&&(T.left-=(A.scrollX||0)-k.scrollLeft(),T.top-=(A.scrollY||0)-k.scrollTop());else{if("event"===c?n&&n.target&&"scroll"!==n.type&&"resize"!==n.type?u.target=r(n.target):n.target||(u.target=this.elements.target):"event"!==c&&(u.target=r(c.jquery?c:this.elements.target)),c=u.target,c=r(c).eq(0),0===c.length)return this;c[0]===t||c[0]===e?(E=st.iOS?e.innerWidth:c.width(),S=st.iOS?e.innerHeight:c.height(),c[0]===e&&(T={top:(d||c).scrollTop(),left:(d||c).scrollLeft()})):X.imagemap&&c.is("area")?s=X.imagemap(this,c,p,X.viewport?g:_):X.svg&&c&&c[0].ownerSVGElement?s=X.svg(this,c,p,X.viewport?g:_):(E=c.outerWidth(_),S=c.outerHeight(_),T=c.offset()),s&&(E=s.width,S=s.height,o=s.offset,T=s.position),T=this.reposition.offset(c,T,v),(st.iOS>3.1&&st.iOS<4.1||st.iOS>=4.3&&st.iOS<4.33||!st.iOS&&"fixed"===x)&&(T.left-=k.scrollLeft(),T.top-=k.scrollTop()),(!s||s&&s.adjustable!==_)&&(T.left+=p.x===R?E:p.x===U?E/2:0,T.top+=p.y===q?S:p.y===U?S/2:0)}return T.left+=m.x+(h.x===R?-y:h.x===U?-y/2:0),T.top+=m.y+(h.y===q?-w:h.y===U?-w/2:0),X.viewport?(T.adjusted=X.viewport(this,T,l,E,S,y,w),o&&T.adjusted.left&&(T.left+=o.left),o&&T.adjusted.top&&(T.top+=o.top)):T.adjusted={left:0,top:0},this._trigger("move",[T,d.elem||d],n)?(delete T.adjusted,i===_||!N||isNaN(T.left)||isNaN(T.top)||"mouse"===c||!r.isFunction(l.effect)?f.css(T):r.isFunction(l.effect)&&(l.effect.call(f,this,r.extend({},T)),f.queue(function(e){r(this).css({opacity:"",height:""}),st.ie&&this.style.removeAttribute("filter"),e()})),this.positioning=_,this):this},k.reposition.offset=function(e,n,i){function s(e,t){n.left+=t*e.scrollLeft(),n.top+=t*e.scrollTop()}if(!i[0])return n;var o,u,a,f,l=r(e[0].ownerDocument),c=!!st.ie&&"CSS1Compat"!==t.compatMode,h=i[0];do"static"!==(u=r.css(h,"position"))&&("fixed"===u?(a=h.getBoundingClientRect(),s(l,-1)):(a=r(h).position(),a.left+=parseFloat(r.css(h,"borderLeftWidth"))||0,a.top+=parseFloat(r.css(h,"borderTopWidth"))||0),n.left-=a.left+(parseFloat(r.css(h,"marginLeft"))||0),n.top-=a.top+(parseFloat(r.css(h,"marginTop"))||0),o||"hidden"===(f=r.css(h,"overflow"))||"visible"===f||(o=r(h)));while(h=h.offsetParent);return o&&(o[0]!==l[0]||c)&&s(o,1),n};var at=(L=k.reposition.Corner=function(e,t){e=(""+e).replace(/([A-Z])/," $1").replace(/middle/gi,U).toLowerCase(),this.x=(e.match(/left|right/i)||e.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(e.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase(),this.forceY=!!t;var n=e.charAt(0);this.precedance="t"===n||"b"===n?H:P}).prototype;at.invert=function(e,t){this[e]=this[e]===I?R:this[e]===R?I:t||this[e]},at.string=function(){var e=this.x,t=this.y;return e===t?e:this.precedance===H||this.forceY&&"center"!==t?t+" "+e:e+" "+t},at.abbrev=function(){var e=this.string().split(" ");return e[0].charAt(0)+(e[1]&&e[1].charAt(0)||"")},at.clone=function(){return new L(this.string(),this.forceY)},k.toggle=function(e,n){var i=this.cache,s=this.options,o=this.tooltip;if(n){if(/over|enter/.test(n.type)&&/out|leave/.test(i.event.type)&&s.show.target.add(n.target).length===s.show.target.length&&o.has(n.relatedTarget).length)return this;i.event=p(n)}if(this.waiting&&!e&&(this.hiddenDuringWait=M),!this.rendered)return e?this.render(1):this;if(this.destroyed||this.disabled)return this;var u,a,f,l=e?"show":"hide",c=this.options[l],h=(this.options[e?"hide":"show"],this.options.position),d=this.options.content,v=this.tooltip.css("width"),m=this.tooltip.is(":visible"),g=e||1===c.target.length,y=!n||c.target.length<2||i.target[0]===n.target;return(typeof e).search("boolean|number")&&(e=!m),u=!o.is(":animated")&&m===e&&y,a=u?D:!!this._trigger(l,[90]),this.destroyed?this:(a!==_&&e&&this.focus(n),!a||u?this:(r.attr(o[0],"aria-hidden",!e),e?(i.origin=p(this.mouse),r.isFunction(d.text)&&this._updateContent(d.text,_),r.isFunction(d.title)&&this._updateTitle(d.title,_),!O&&"mouse"===h.target&&h.adjust.mouse&&(r(t).bind("mousemove."+V,this._storeMouse),O=M),v||o.css("width",o.outerWidth(_)),this.reposition(n,arguments[2]),v||o.css("width",""),c.solo&&("string"==typeof c.solo?r(c.solo):r(Q,c.solo)).not(o).not(c.target).qtip("hide",r.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete i.origin,O&&!r(Q+'[tracking="true"]:visible',c.solo).not(o).length&&(r(t).unbind("mousemove."+V),O=_),this.blur(n)),f=r.proxy(function(){e?(st.ie&&o[0].style.removeAttribute("filter"),o.css("overflow",""),"string"==typeof c.autofocus&&r(this.options.show.autofocus,o).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):o.css({display:"",visibility:"",opacity:"",left:"",top:""}),this._trigger(e?"visible":"hidden")},this),c.effect===_||g===_?(o[l](),f()):r.isFunction(c.effect)?(o.stop(1,1),c.effect.call(o,this),o.queue("fx",function(e){f(),e()})):o.fadeTo(90,e?1:0,f),e&&c.target.trigger("qtip-"+this.id+"-inactive"),this))},k.show=function(e){return this.toggle(M,e)},k.hide=function(e){return this.toggle(_,e)},k.focus=function(e){if(!this.rendered||this.destroyed)return this;var t=r(Q),n=this.tooltip,i=parseInt(n[0].style.zIndex,10),s=C.zindex+t.length;return n.hasClass(et)||this._trigger("focus",[s],e)&&(i!==s&&(t.each(function(){this.style.zIndex>i&&(this.style.zIndex=this.style.zIndex-1)}),t.filter("."+et).qtip("blur",e)),n.addClass(et)[0].style.zIndex=s),this},k.blur=function(e){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass(et),this._trigger("blur",[this.tooltip.css("zIndex")],e),this)},k.disable=function(e){return this.destroyed?this:("toggle"===e?e=this.rendered?!this.tooltip.hasClass(nt):!this.disabled:"boolean"!=typeof e&&(e=M),this.rendered&&this.tooltip.toggleClass(nt,e).attr("aria-disabled",e),this.disabled=!!e,this)},k.enable=function(){return this.disable(_)},k._createButton=function(){var e=this,t=this.elements,n=t.tooltip,i=this.options.content.button,s="string"==typeof i,o=s?i:"Close tooltip";t.button&&t.button.remove(),t.button=i.jquery?i:r("<a />",{"class":"qtip-close "+(this.options.style.widget?"":V+"-icon"),title:o,"aria-label":o}).prepend(r("<span />",{"class":"ui-icon ui-icon-close",html:"&times;"})),t.button.appendTo(t.titlebar||n).attr("role","button").click(function(t){return n.hasClass(nt)||e.hide(t),_})},k._updateButton=function(e){if(!this.rendered)return _;var t=this.elements.button;e?this._createButton():t.remove()},k._setWidget=function(){var e=this.options.style.widget,t=this.elements,n=t.tooltip,r=n.hasClass(nt);n.removeClass(nt),nt=e?"ui-state-disabled":"qtip-disabled",n.toggleClass(nt,r),n.toggleClass("ui-helper-reset "+h(),e).toggleClass(Z,this.options.style.def&&!e),t.content&&t.content.toggleClass(h("content"),e),t.titlebar&&t.titlebar.toggleClass(h("header"),e),t.button&&t.button.toggleClass(V+"-icon",!e)},k._storeMouse=function(e){(this.mouse=p(e)).type="mousemove"},k._bind=function(e,t,n,i,s){var o="."+this._id+(i?"-"+i:"");t.length&&r(e).bind((t.split?t:t.join(o+" "))+o,r.proxy(n,s||this))},k._unbind=function(e,t){r(e).unbind("."+this._id+(t?"-"+t:""))};var ft="."+V;r(function(){w(Q,["mouseenter","mouseleave"],function(e){var t="mouseenter"===e.type,n=r(e.currentTarget),i=r(e.relatedTarget||e.target),s=this.options;t?(this.focus(e),n.hasClass(Y)&&!n.hasClass(nt)&&clearTimeout(this.timers.hide)):"mouse"===s.position.target&&s.hide.event&&s.show.target&&!i.closest(s.show.target[0]).length&&this.hide(e),n.toggleClass(tt,t)}),w("["+J+"]",G,g)}),k._trigger=function(e,t,n){var i=r.Event("tooltip"+e);return i.originalEvent=n&&r.extend({},n)||this.cache.event||D,this.triggering=e,this.tooltip.trigger(i,[this].concat(t||[])),this.triggering=_,!i.isDefaultPrevented()},k._bindEvents=function(e,t,n,i,s,o){if(i.add(n).length===i.length){var u=[];t=r.map(t,function(t){var n=r.inArray(t,e);return n>-1?(u.push(e.splice(n,1)[0]),void 0):t}),u.length&&this._bind(n,u,function(e){var t=this.rendered?this.tooltip[0].offsetWidth>0:!1;(t?o:s).call(this,e)})}this._bind(n,e,s),this._bind(i,t,o)},k._assignInitialEvents=function(e){function t(e){return this.disabled||this.destroyed?_:(this.cache.event=p(e),this.cache.target=e?r(e.target):[n],clearTimeout(this.timers.show),this.timers.show=d.call(this,function(){this.render("object"==typeof e||i.show.ready)},i.show.delay),void 0)}var i=this.options,s=i.show.target,o=i.hide.target,u=i.show.event?r.trim(""+i.show.event).split(" "):[],a=i.hide.event?r.trim(""+i.hide.event).split(" "):[];/mouse(over|enter)/i.test(i.show.event)&&!/mouse(out|leave)/i.test(i.hide.event)&&a.push("mouseleave"),this._bind(s,"mousemove",function(e){this._storeMouse(e),this.cache.onTarget=M}),this._bindEvents(u,a,s,o,t,function(){clearTimeout(this.timers.show)}),(i.show.ready||i.prerender)&&t.call(this,e)},k._assignEvents=function(){var n=this,i=this.options,s=i.position,o=this.tooltip,u=i.show.target,f=i.hide.target,l=s.container,c=s.viewport,h=r(t),p=(r(t.body),r(e)),d=i.show.event?r.trim(""+i.show.event).split(" "):[],w=i.hide.event?r.trim(""+i.hide.event).split(" "):[];r.each(i.events,function(e,t){n._bind(o,"toggle"===e?["tooltipshow","tooltiphide"]:["tooltip"+e],t,null,o)}),/mouse(out|leave)/i.test(i.hide.event)&&"window"===i.hide.leave&&this._bind(h,["mouseout","blur"],function(e){/select|option/.test(e.target.nodeName)||e.relatedTarget||this.hide(e)}),i.hide.fixed?f=f.add(o.addClass(Y)):/mouse(over|enter)/i.test(i.show.event)&&this._bind(f,"mouseleave",function(){clearTimeout(this.timers.show)}),(""+i.hide.event).indexOf("unfocus")>-1&&this._bind(l.closest("html"),["mousedown","touchstart"],function(e){var t=r(e.target),n=this.rendered&&!this.tooltip.hasClass(nt)&&this.tooltip[0].offsetWidth>0,i=t.parents(Q).filter(this.tooltip[0]).length>0;t[0]===this.target[0]||t[0]===this.tooltip[0]||i||this.target.has(t[0]).length||!n||this.hide(e)}),"number"==typeof i.hide.inactive&&(this._bind(u,"qtip-"+this.id+"-inactive",g),this._bind(f.add(o),C.inactiveEvents,g,"-inactive")),this._bindEvents(d,w,u,f,v,m),this._bind(u.add(o),"mousemove",function(e){if("number"==typeof i.hide.distance){var t=this.cache.origin||{},n=this.options.hide.distance,r=Math.abs;(r(e.pageX-t.pageX)>=n||r(e.pageY-t.pageY)>=n)&&this.hide(e)}this._storeMouse(e)}),"mouse"===s.target&&s.adjust.mouse&&(i.hide.event&&this._bind(u,["mouseenter","mouseleave"],function(e){this.cache.onTarget="mouseenter"===e.type}),this._bind(h,"mousemove",function(e){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(nt)&&this.tooltip[0].offsetWidth>0&&this.reposition(e)})),(s.adjust.resize||c.length)&&this._bind(r.event.special.resize?c:p,"resize",y),s.adjust.scroll&&this._bind(p.add(s.container),"scroll",y)},k._unassignEvents=function(){var n=[this.options.show.target[0],this.options.hide.target[0],this.rendered&&this.tooltip[0],this.options.position.container[0],this.options.position.viewport[0],this.options.position.container.closest("html")[0],e,t];this._unbind(r([]).pushStack(r.grep(n,function(e){return"object"==typeof e})))},C=r.fn.qtip=function(e,t,i){var s=(""+e).toLowerCase(),o=D,a=r.makeArray(arguments).slice(1),f=a[a.length-1],l=this[0]?r.data(this[0],V):D;return!arguments.length&&l||"api"===s?l:"string"==typeof e?(this.each(function(){var e=r.data(this,V);if(!e)return M;if(f&&f.timeStamp&&(e.cache.event=f),!t||"option"!==s&&"options"!==s)e[s]&&e[s].apply(e,a);else{if(i===n&&!r.isPlainObject(t))return o=e.get(t),_;e.set(t,i)}}),o!==D?o:this):"object"!=typeof e&&arguments.length?void 0:(l=u(r.extend(M,{},e)),this.each(function(e){var t,n;return n=r.isArray(l.id)?l.id[e]:l.id,n=!n||n===_||n.length<1||C.api[n]?C.nextid++:n,t=E(r(this),n,l),t===_?M:(C.api[n]=t,r.each(X,function(){"initialize"===this.initialize&&this(t)}),t._assignInitialEvents(f),void 0)}))},r.qtip=i,C.api={},r.each({attr:function(e,t){if(this.length){var n=this[0],i="title",s=r.data(n,"qtip");if(e===i&&s&&"object"==typeof s&&s.options.suppress)return arguments.length<2?r.attr(n,it):(s&&s.options.content.attr===i&&s.cache.attr&&s.set("content.text",t),this.attr(it,t))}return r.fn["attr"+rt].apply(this,arguments)},clone:function(e){var t=(r([]),r.fn["clone"+rt].apply(this,arguments));return e||t.filter("["+it+"]").attr("title",function(){return r.attr(this,it)}).removeAttr(it),t}},function(e,t){if(!t||r.fn[e+rt])return M;var n=r.fn[e+rt]=r.fn[e];r.fn[e]=function(){return t.apply(this,arguments)||n.apply(this,arguments)}}),r.ui||(r["cleanData"+rt]=r.cleanData,r.cleanData=function(e){for(var t,n=0;(t=r(e[n])).length;n++)if(t.attr($))try{t.triggerHandler("removeqtip")}catch(i){}r["cleanData"+rt].apply(this,arguments)}),C.version="2.2.0",C.nextid=0,C.inactiveEvents=G,C.zindex=15e3,C.defaults={prerender:_,id:_,overwrite:M,suppress:M,content:{text:M,attr:"title",title:_,button:_},position:{my:"top left",at:"bottom right",target:_,container:_,viewport:_,adjust:{x:0,y:0,mouse:M,scroll:M,resize:M,method:"flipinvert flipinvert"},effect:function(e,t){r(this).animate(t,{duration:200,queue:_})}},show:{target:_,event:"mouseenter",effect:M,delay:90,solo:_,ready:_,autofocus:_},hide:{target:_,event:"mouseleave",effect:M,delay:0,fixed:_,inactive:_,leave:"window",distance:_},style:{classes:"",widget:_,width:_,height:_,def:M},events:{render:D,move:D,show:D,hide:D,toggle:D,visible:D,hidden:D,focus:D,blur:D}};var lt,ct="margin",ht="border",pt="color",dt="background-color",vt="transparent",mt=" !important",gt=!!t.createElement("canvas").getContext,yt=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,bt={},wt=["Webkit","O","Moz","ms"];if(gt)var Et=e.devicePixelRatio||1,St=function(){var e=t.createElement("canvas").getContext("2d");return e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1}(),xt=Et/St;else var Tt=function(e,t,n){return"<qtipvml:"+e+' xmlns="urn:schemas-microsoft.com:vml" class="qtip-vml" '+(t||"")+' style="behavior: url(#default#VML); '+(n||"")+'" />'};r.extend(N.prototype,{init:function(e){var t,n;n=this.element=e.elements.tip=r("<div />",{"class":V+"-tip"}).prependTo(e.tooltip),gt?(t=r("<canvas />").appendTo(this.element)[0].getContext("2d"),t.lineJoin="miter",t.miterLimit=1e5,t.save()):(t=Tt("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(t+t),e._bind(r("*",n).add(n),["click","mousedown"],function(e){e.stopPropagation()},this._ns)),e._bind(e.tooltip,"tooltipmove",this.reposition,this._ns,this),this.create()},_swapDimensions:function(){this.size[0]=this.options.height,this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width,this.size[1]=this.options.height},_useTitle:function(e){var t=this.qtip.elements.titlebar;return t&&(e.y===F||e.y===U&&this.element.position().top+this.size[1]/2+this.options.offset<t.outerHeight(M))},_parseCorner:function(e){var t=this.qtip.options.position.my;return e===_||t===_?e=_:e===M?e=new L(t.string()):e.string||(e=new L(e),e.fixed=M),e},_parseWidth:function(e,t,n){var r=this.qtip.elements,i=ht+S(t)+"Width";return(n?T(n,i):T(r.content,i)||T(this._useTitle(e)&&r.titlebar||r.content,i)||T(r.tooltip,i))||0},_parseRadius:function(e){var t=this.qtip.elements,n=ht+S(e.y)+S(e.x)+"Radius";return st.ie<9?0:T(this._useTitle(e)&&t.titlebar||t.content,n)||T(t.tooltip,n)||0},_invalidColour:function(e,t,n){var r=e.css(t);return!r||n&&r===e.css(n)||yt.test(r)?_:r},_parseColours:function(e){var t=this.qtip.elements,n=this.element.css("cssText",""),i=ht+S(e[e.precedance])+S(pt),s=this._useTitle(e)&&t.titlebar||t.content,o=this._invalidColour,u=[];return u[0]=o(n,dt)||o(s,dt)||o(t.content,dt)||o(t.tooltip,dt)||n.css(dt),u[1]=o(n,i,pt)||o(s,i,pt)||o(t.content,i,pt)||o(t.tooltip,i,pt)||t.tooltip.css(i),r("*",n).add(n).css("cssText",dt+":"+vt+mt+";"+ht+":0"+mt+";"),u},_calculateSize:function(e){var t,n,r,i=e.precedance===H,s=this.options.width,o=this.options.height,u="c"===e.abbrev(),a=(i?s:o)*(u?.5:1),f=Math.pow,l=Math.round,c=Math.sqrt(f(a,2)+f(o,2)),h=[this.border/a*c,this.border/o*c];return h[2]=Math.sqrt(f(h[0],2)-f(this.border,2)),h[3]=Math.sqrt(f(h[1],2)-f(this.border,2)),t=c+h[2]+h[3]+(u?0:h[0]),n=t/c,r=[l(n*s),l(n*o)],i?r:r.reverse()},_calculateTip:function(e,t,n){n=n||1,t=t||this.size;var r=t[0]*n,i=t[1]*n,s=Math.ceil(r/2),o=Math.ceil(i/2),u={br:[0,0,r,i,r,0],bl:[0,0,r,0,0,i],tr:[0,i,r,0,r,i],tl:[0,0,0,i,r,i],tc:[0,i,s,0,r,i],bc:[0,0,r,0,s,i],rc:[0,0,r,o,0,i],lc:[r,0,r,i,0,o]};return u.lt=u.br,u.rt=u.bl,u.lb=u.tr,u.rb=u.tl,u[e.abbrev()]},_drawCoords:function(e,t){e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(t[2],t[3]),e.lineTo(t[4],t[5]),e.closePath()},create:function(){var e=this.corner=(gt||st.ie)&&this._parseCorner(this.options.corner);return(this.enabled=!!this.corner&&"c"!==this.corner.abbrev())&&(this.qtip.cache.corner=e.clone(),this.update()),this.element.toggle(this.enabled),this.corner},update:function(t,n){if(!this.enabled)return this;var i,s,o,u,f,l,c,h,p=this.qtip.elements,d=this.element,v=d.children(),m=this.options,g=this.size,y=m.mimic,b=Math.round;t||(t=this.qtip.cache.corner||this.corner),y===_?y=t:(y=new L(y),y.precedance=t.precedance,"inherit"===y.x?y.x=t.x:"inherit"===y.y?y.y=t.y:y.x===y.y&&(y[t.precedance]=t[t.precedance])),s=y.precedance,t.precedance===P?this._swapDimensions():this._resetDimensions(),i=this.color=this._parseColours(t),i[1]!==vt?(h=this.border=this._parseWidth(t,t[t.precedance]),m.border&&1>h&&!yt.test(i[1])&&(i[0]=i[1]),this.border=h=m.border!==M?m.border:h):this.border=h=0,c=this.size=this._calculateSize(t),d.css({width:c[0],height:c[1],lineHeight:c[1]+"px"}),l=t.precedance===H?[b(y.x===I?h:y.x===R?c[0]-g[0]-h:(c[0]-g[0])/2),b(y.y===F?c[1]-g[1]:0)]:[b(y.x===I?c[0]-g[0]:0),b(y.y===F?h:y.y===q?c[1]-g[1]-h:(c[1]-g[1])/2)],gt?(o=v[0].getContext("2d"),o.restore(),o.save(),o.clearRect(0,0,6e3,6e3),u=this._calculateTip(y,g,xt),f=this._calculateTip(y,this.size,xt),v.attr(B,c[0]*xt).attr(j,c[1]*xt),v.css(B,c[0]).css(j,c[1]),this._drawCoords(o,f),o.fillStyle=i[1],o.fill(),o.translate(l[0]*xt,l[1]*xt),this._drawCoords(o,u),o.fillStyle=i[0],o.fill()):(u=this._calculateTip(y),u="m"+u[0]+","+u[1]+" l"+u[2]+","+u[3]+" "+u[4]+","+u[5]+" xe",l[2]=h&&/^(r|b)/i.test(t.string())?8===st.ie?2:1:0,v.css({coordsize:c[0]+h+" "+(c[1]+h),antialias:""+(y.string().indexOf(U)>-1),left:l[0]-l[2]*Number(s===P),top:l[1]-l[2]*Number(s===H),width:c[0]+h,height:c[1]+h}).each(function(e){var t=r(this);t[t.prop?"prop":"attr"]({coordsize:c[0]+h+" "+(c[1]+h),path:u,fillcolor:i[0],filled:!!e,stroked:!e}).toggle(!!h||!!e),!e&&t.html(Tt("stroke",'weight="'+2*h+'px" color="'+i[1]+'" miterlimit="1000" joinstyle="miter"'))})),e.opera&&setTimeout(function(){p.tip.css({display:"inline-block",visibility:"visible"})},1),n!==_&&this.calculate(t,c)},calculate:function(e,t){if(!this.enabled)return _;var n,i,s=this,o=this.qtip.elements,u=this.element,a=this.options.offset,f=(o.tooltip.hasClass("ui-widget"),{});return e=e||this.corner,n=e.precedance,t=t||this._calculateSize(e),i=[e.x,e.y],n===P&&i.reverse(),r.each(i,function(r,i){var u,l,h;i===U?(u=n===H?I:F,f[u]="50%",f[ct+"-"+u]=-Math.round(t[n===H?0:1]/2)+a):(u=s._parseWidth(e,i,o.tooltip),l=s._parseWidth(e,i,o.content),h=s._parseRadius(e),f[i]=Math.max(-s.border,r?l:a+(h>u?h:-u)))}),f[e[n]]-=t[n===P?0:1],u.css({margin:"",top:"",bottom:"",left:"",right:""}).css(f),f},reposition:function(e,t,r){function i(e,t,n,r,i){e===W&&f.precedance===t&&l[r]&&f[n]!==U?f.precedance=f.precedance===P?H:P:e!==W&&l[r]&&(f[t]=f[t]===U?l[r]>0?r:i:f[t]===r?i:r)}function s(e,t,i){f[e]===U?m[ct+"-"+t]=v[e]=o[ct+"-"+t]-l[t]:(u=o[i]!==n?[l[t],-o[t]]:[-l[t],o[t]],(v[e]=Math.max(u[0],u[1]))>u[0]&&(r[t]-=l[t],v[t]=_),m[o[i]!==n?i:t]=v[e])}if(this.enabled){var o,u,a=t.cache,f=this.corner.clone(),l=r.adjusted,h=t.options.position.adjust.method.split(" "),p=h[0],d=h[1]||h[0],v={left:_,top:_,x:0,y:0},m={};this.corner.fixed!==M&&(i(p,P,H,I,R),i(d,H,P,F,q),f.string()===a.corner.string()||a.cornerTop===l.top&&a.cornerLeft===l.left||this.update(f,_)),o=this.calculate(f),o.right!==n&&(o.left=-o.right),o.bottom!==n&&(o.top=-o.bottom),o.user=this.offset,(v.left=p===W&&!!l.left)&&s(P,I,R),(v.top=d===W&&!!l.top)&&s(H,F,q),this.element.css(m).toggle(!(v.x&&v.y||f.x===U&&v.y||f.y===U&&v.x)),r.left-=o.left.charAt?o.user:p!==W||v.top||!v.left&&!v.top?o.left+this.border:0,r.top-=o.top.charAt?o.user:d!==W||v.left||!v.left&&!v.top?o.top+this.border:0,a.cornerLeft=l.left,a.cornerTop=l.top,a.corner=f.clone()}},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns),this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}}),lt=X.tip=function(e){return new N(e,e.options.style.tip)},lt.initialize="render",lt.sanitize=function(e){if(e.style&&"tip"in e.style){var t=e.style.tip;"object"!=typeof t&&(t=e.style.tip={corner:t}),/string|boolean/i.test(typeof t.corner)||(t.corner=M)}},A.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create(),this.qtip.reposition()},"^style.tip.(height|width)$":function(e){this.size=[e.width,e.height],this.update(),this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}},r.extend(M,C.defaults,{style:{tip:{corner:M,mimic:_,width:6,height:6,border:M,offset:0}}}),X.viewport=function(n,r,i,s,o,u,f){function l(e,t,n,i,s,o,u,a,f){var l=r[s],c=x[e],p=T[e],b=n===W,E=c===s?f:c===o?-f:-f/2,S=p===s?a:p===o?-a:-a/2,N=y[s]+w[s]-(v?0:d[s]),C=N-l,k=l+f-(u===B?m:g)-N,L=E-(x.precedance===e||c===x[t]?S:0)-(p===U?a/2:0);return b?(L=(c===s?1:-1)*E,r[s]+=C>0?C:k>0?-k:0,r[s]=Math.max(-d[s]+w[s],l-L,Math.min(Math.max(-d[s]+w[s]+(u===B?m:g),l+L),r[s],"center"===c?l-E:1e9))):(i*=n===z?2:0,C>0&&(c!==s||k>0)?(r[s]-=L+i,h.invert(e,s)):k>0&&(c!==o||C>0)&&(r[s]-=(c===U?-L:L)+i,h.invert(e,o)),r[s]<y&&-r[s]>k&&(r[s]=l,h=x.clone())),r[s]-l}var c,h,p,d,v,m,g,y,w,E=i.target,S=n.elements.tooltip,x=i.my,T=i.at,N=i.adjust,C=N.method.split(" "),k=C[0],L=C[1]||C[0],A=i.viewport,O=i.container,M=n.cache,D={left:0,top:0};return A.jquery&&E[0]!==e&&E[0]!==t.body&&"none"!==N.method?(d=O.offset()||D,v="static"===O.css("position"),c="fixed"===S.css("position"),m=A[0]===e?A.width():A.outerWidth(_),g=A[0]===e?A.height():A.outerHeight(_),y={left:c?0:A.scrollLeft(),top:c?0:A.scrollTop()},w=A.offset()||D,("shift"!==k||"shift"!==L)&&(h=x.clone()),D={left:"none"!==k?l(P,H,k,N.x,I,R,B,s,u):0,top:"none"!==L?l(H,P,L,N.y,F,q,j,o,f):0},h&&M.lastClass!==(p=V+"-pos-"+h.abbrev())&&S.removeClass(n.cache.lastClass).addClass(n.cache.lastClass=p),D):D}})}(window,document),define("util.tooltips",["jquery","qtip"],function(e){setupTooltips=function(t){typeof t=="undefined"&&(t=!1);if(Headway.disableTooltips==1||Headway.touch)return e("div.tooltip-button").hide(),!1;var n={style:{classes:"qtip-headway"},show:{delay:10,solo:!0,event:"mouseenter"},position:{my:"bottom left",at:"top center",viewport:e(window),effect:!1},hide:{effect:!1}};if(t=="iframe"){n.position.container=Headway.iframe.contents().find("body"),n.position.viewport=e("#iframe-container");var r=$i}else var r=e;r("div.tooltip-button:not([data-hasqtip]), .tooltip:not([data-hasqtip])").qtip(n),r(".tooltip-bottom-right:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"bottom right",at:"top center"}})),r(".tooltip-top-right:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"top right",at:"bottom center"}})),r(".tooltip-top-left:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"top left",at:"bottom center"},show:{delay:750}})),r(".tooltip-left:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"left center",at:"right center"}})),r(".tooltip-right:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"right center",at:"left center"}})),r(".tooltip-top:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"top center",at:"bottom center"}}));var i=function(){if($i(".qtip:visible").length===0||typeof iframeScrollTooltipRepositionFloodTimeout!="undefined")return;iframeScrollTooltipRepositionFloodTimeout=setTimeout(function(){$i(".qtip:visible").qtip("reposition"),delete iframeScrollTooltipRepositionFloodTimeout},400)};Headway.iframe.contents().unbind("scroll",i),Headway.iframe.contents().bind("scroll",i)},repositionTooltips=function(){$i(".qtip:visible").qtip("reposition")}}),function(e,t,n){function m(e,t,n){if(e.addEventListener){e.addEventListener(t,n,!1);return}e.attachEvent("on"+t,n)}function g(e){if(e.type=="keypress"){var t=String.fromCharCode(e.which);return e.shiftKey||(t=t.toLowerCase()),t}return r[e.which]?r[e.which]:i[e.which]?i[e.which]:String.fromCharCode(e.which).toLowerCase()}function y(e,t){return e.sort().join(",")===t.sort().join(",")}function b(e){e=e||{};var t=!1,n;for(n in l){if(e[n]){t=!0;continue}l[n]=0}t||(d=!1)}function w(e,t,n,r,i,s){var o,u,f=[],c=n.type;if(!a[e])return[];c=="keyup"&&k(e)&&(t=[e]);for(o=0;o<a[e].length;++o){u=a[e][o];if(!r&&u.seq&&l[u.seq]!=u.level)continue;if(c!=u.action)continue;if(c=="keypress"&&!n.metaKey&&!n.ctrlKey||y(t,u.modifiers)){var h=!r&&u.combo==i,p=r&&u.seq==r&&u.level==s;(h||p)&&a[e].splice(o,1),f.push(u)}}return f}function E(e){var t=[];return e.shiftKey&&t.push("shift"),e.altKey&&t.push("alt"),e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),t}function S(e){if(e.preventDefault){e.preventDefault();return}e.returnValue=!1}function x(e){if(e.stopPropagation){e.stopPropagation();return}e.cancelBubble=!0}function T(e,t,n,r){if(B.stopCallback(t,t.target||t.srcElement,n,r))return;e(t,n)===!1&&(S(t),x(t))}function N(e,t,n){var r=w(e,t,n),i,s={},o=0,u=!1;for(i=0;i<r.length;++i)r[i].seq&&(o=Math.max(o,r[i].level));for(i=0;i<r.length;++i){if(r[i].seq){if(r[i].level!=o)continue;u=!0,s[r[i].seq]=1,T(r[i].callback,n,r[i].combo,r[i].seq);continue}u||T(r[i].callback,n,r[i].combo)}var a=n.type=="keypress"&&p;n.type==d&&!k(e)&&!a&&b(s),p=u&&n.type=="keydown"}function C(e){typeof e.which!="number"&&(e.which=e.keyCode);var t=g(e);if(!t)return;if(e.type=="keyup"&&h===t){h=!1;return}B.handleKey(t,E(e),e)}function k(e){return e=="shift"||e=="ctrl"||e=="alt"||e=="meta"}function L(){clearTimeout(c),c=setTimeout(b,1e3)}function A(){if(!u){u={};for(var e in r){if(e>95&&e<112)continue;r.hasOwnProperty(e)&&(u[r[e]]=e)}}return u}function O(e,t,n){return n||(n=A()[e]?"keydown":"keypress"),n=="keypress"&&t.length&&(n="keydown"),n}function M(e,t,n,r){function i(t){return function(){d=t,++l[e],L()}}function s(t){T(n,t,e),r!=="keyup"&&(h=g(t)),setTimeout(b,10)}l[e]=0;for(var o=0;o<t.length;++o){var u=o+1===t.length,a=u?s:i(r||D(t[o+1]).action);P(t[o],a,r,e,o)}}function _(e){return e==="+"?["+"]:e.split("+")}function D(e,t){var n,r,i,u=[];n=_(e);for(i=0;i<n.length;++i)r=n[i],o[r]&&(r=o[r]),t&&t!="keypress"&&s[r]&&(r=s[r],u.push("shift")),k(r)&&u.push(r);return t=O(r,u,t),{key:r,modifiers:u,action:t}}function P(e,t,n,r,i){f[e+":"+n]=t,e=e.replace(/\s+/g," ");var s=e.split(" "),o;if(s.length>1){M(e,s,t,n);return}o=D(e,n),a[o.key]=a[o.key]||[],w(o.key,o.modifiers,{type:o.action},r,e,i),a[o.key][r?"unshift":"push"]({callback:t,modifiers:o.modifiers,action:o.action,seq:r,level:i,combo:e})}function H(e,t,n){for(var r=0;r<e.length;++r)P(e[r],t,n)}var r={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},i={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},s={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},o={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},u,a={},f={},l={},c,h=!1,p=!1,d=!1;for(var v=1;v<20;++v)r[111+v]="f"+v;for(v=0;v<=9;++v)r[v+96]=v;m(t,"keypress",C),m(t,"keydown",C),m(t,"keyup",C);var B={bind:function(e,t,n){return e=e instanceof Array?e:[e],H(e,t,n),this},unbind:function(e,t){return B.bind(e,function(){},t)},trigger:function(e,t){return f[e+":"+t]&&f[e+":"+t]({},e),this},reset:function(){return a={},f={},this},stopCallback:function(e,t){return(" "+t.className+" ").indexOf(" mousetrap ")>-1?!1:t.tagName=="INPUT"||t.tagName=="SELECT"||t.tagName=="TEXTAREA"||t.isContentEditable},bindEventsTo:function(e){e==n&&(e=t),m(e,"keypress",C),m(e,"keydown",C),m(e,"keyup",C)},handleKey:N};e.Mousetrap=B,typeof define=="function"&&define.amd&&define("deps/mousetrap",B)}(window,document),Mousetrap=function(e){var t={},n=e.stopCallback;return e.stopCallback=function(e,r,i,s){return t[i]||t[s]?!1:n(e,r,i)},e.bindGlobal=function(n,r,i){e.bind(n,r,i);if(n instanceof Array){for(var s=0;s<n.length;s++)t[n[s]]=!0;return}t[n]=!0},e}(Mousetrap),define("helper.ace",["jquery","deps/mousetrap"],function(e,t){Headway.aceEditors={};var n={init:function(){window.onunload=function(){e.each(Headway.aceEditors,function(e,t){typeof t.window!="undefined"&&!t.window.closed&&t.window.close()})}},showEditor:function(e,t,r,i){if(typeof Headway.aceEditors[e]!="undefined"&&!Headway.aceEditors[e].window.closed)return Headway.aceEditors[e].window.focus(),Headway.aceEditors[e];var s={width:750,height:550};return s.left=screen.width/2-s.width/2,s.top=screen.height/2-s.height/2,Headway.aceEditors[e]={window:window.open(Headway.homeURL+"/?headway-trigger=ace-editor&mode="+t,e,"width="+s.width+",height="+s.height+",top="+s.top+",left="+s.left,!0)},Headway.aceEditors[e].window.focus(),n.bindEditor(e,t,r,i),Headway.aceEditors[e]},bindEditor:function(n,r,i,s){var o=Headway.aceEditors[n].window;return e(o).bind("load",function(){t.bindEventsTo(o.document);var u=o.ace,a=Headway.headwayURL+"/library/visual-editor/"+Headway.scriptFolder+"/deps/ace/";u.config.set("basePath",a),u.config.set("modePath",a),u.config.set("workerPath",a),u.config.set("themePath",a),Headway.aceEditors[n].editor=u.edit(e(o.document).contents().find("#ace-editor").get(0)),Headway.aceEditors[n].editorSession=Headway.aceEditors[n].editor.getSession(),Headway.aceEditors[n].editor.setTheme("ace/theme/textmate"),Headway.aceEditors[n].editorSession.setMode("ace/mode/"+r),Headway.aceEditors[n].editor.setShowPrintMargin(!1),Headway.aceEditors[n].editor.setValue(i),Headway.aceEditors[n].editor.gotoLine(0),Headway.aceEditors[n].editor.focus(),Headway.aceEditors[n].editorSession.on("change",function(e){return s(Headway.aceEditors[n].editor)})})}};return n.init(),n}),function($){function Colorpicker(){this._mainDivId=mainDivId,this._colorDivClass=colorDivClass,this._defaults={showAnim:!0,duration:200,color:"FFFFFF",allowNull:!1,realtime:!0,invertControls:!0,controlStyle:"simple",swatches:!0,alpha:!1,alphaHex:!1,beforeShow:null,onClose:null,onSelect:null,onAddSwatch:null,onDeleteSwatch:null}}function extendRemove(e,t){$.extend(e,t);for(var n in t)if(t[n]==null||t[n]==undefined)e[n]=t[n];return e}function isset(e){return e!==undefined}var PROP_NAME="css3colorpicker",mainDivId="css3colorpicker-div",colorDivClass="color",cpDiv=$('<div id="'+mainDivId+'"></div>');cpDiv.swatchContainer=$('<div id="'+mainDivId+'-swatchContainer"></div>'),cpDiv.swatches=$('<div id="'+mainDivId+'-swatches"></div>'),cpDiv.addSwatchButton=$('<div id="'+mainDivId+'-add-swatch-button" title="Add Current Color to Swatches" class="tooltip"></div>'),cpDiv.colorDiv=$('<div id="'+mainDivId+'-color" title="Choose Color and Close Color Picker" class="tooltip"></div>'),cpDiv.oldColorDiv=$('<div id="'+mainDivId+'-colorOld" title="Revert to Previous Color" class="tooltip"></div>'),cpDiv.d1Div=$('<div id="'+mainDivId+'-1d"></div>'),cpDiv.d1Div.control=$('<div id="'+mainDivId+'-1dControl"></div>'),cpDiv.d1Div.colorDiv=$('<div id="'+mainDivId+'-1dColor"></div>'),cpDiv.d1Div.gradientDiv=$('<div id="'+mainDivId+'-1dGradient"></div>'),cpDiv.d2Div=$('<div id="'+mainDivId+'-2d"></div>'),cpDiv.d2Div.control=$('<div id="'+mainDivId+'-2dControl"></div>'),cpDiv.d2Div.colorDiv=$('<div id="'+mainDivId+'-2dColor"></div>'),cpDiv.d2Div.gradientDiv=$('<div id="'+mainDivId+'-2dGradient"></div>'),cpDiv.alphaDiv=$('<div id="'+mainDivId+'-alpha"></div>'),cpDiv.alphaDiv.control=$('<div id="'+mainDivId+'-alphaControl"></div>'),cpDiv.inputContainerHSB=$('<ul id="'+mainDivId+'-inputContainer-hsv" class="css3colorpicker-inputContainer"></ul>'),cpDiv.inputContainerRGBA=$('<ul id="'+mainDivId+'-inputContainer-rgba" class="css3colorpicker-inputContainer"></ul>'),cpDiv.inputContainerHex=$('<ul id="'+mainDivId+'-inputContainer-hex" class="css3colorpicker-inputContainer"></ul>'),cpDiv.inputs={h:$('<input type="text" data-mode="h" id="'+mainDivId+'-h"/>'),s:$('<input type="text" data-mode="s" id="'+mainDivId+'-s"/>'),v:$('<input type="text" data-mode="v" id="'+mainDivId+'-v"/>'),r:$('<input type="text" id="'+mainDivId+'-r"/>'),g:$('<input type="text" id="'+mainDivId+'-g"/>'),b:$('<input type="text" id="'+mainDivId+'-b"/>'),a:$('<input type="text" id="'+mainDivId+'-a"/>'),hex:$('<input type="text" id="'+mainDivId+'-hex" maxlength="8" />')},cpDiv.append($('<div id="'+mainDivId+'-container"></div>').append($('<div id="'+mainDivId+'-colorContainer"></div>').append(cpDiv.colorDiv,cpDiv.oldColorDiv),cpDiv.d1Div.append(cpDiv.d1Div.colorDiv,cpDiv.d1Div.gradientDiv,cpDiv.d1Div.control),cpDiv.d2Div.append(cpDiv.d2Div.colorDiv,cpDiv.d2Div.gradientDiv,cpDiv.d2Div.control),cpDiv.alphaDiv.append(cpDiv.alphaDiv.control),cpDiv.inputContainerHSB.append($("<li>H <span>&deg;</span></li>").append(cpDiv.inputs.h),$("<li>S <span>%</span></li>").append(cpDiv.inputs.s),$("<li>B <span>%</span></li>").append(cpDiv.inputs.v)),cpDiv.inputContainerRGBA.append($("<li>R </li>").append(cpDiv.inputs.r),$("<li>G </li>").append(cpDiv.inputs.g),$("<li>B </li>").append(cpDiv.inputs.b),$('<li class="alpha">A <span>%</span></li>').append(cpDiv.inputs.a)),cpDiv.inputContainerHex.append($("<li># </li>").append(cpDiv.inputs.hex))),cpDiv.swatchContainer.append(cpDiv.swatches,cpDiv.addSwatchButton)),$.extend(Colorpicker.prototype,{cpDiv:cpDiv,mode:"h",markerClassName:"hasColorpicker",controlsClassPrefix:"controls-",minLum:50,swatches:[],swatchLimit:15,setDefaults:function(e){return extendRemove(this._defaults,e||{}),this},_setMode:function(e){["h","s","v"].indexOf(e)>=0&&(this.cpDiv.removeClass("mode-"+this.mode),this.cpDiv.addClass("mode-"+e),this.mode=e,$.colorpicker._updateMaps(),$.colorpicker._updateControls())},refresh:function(){return this._updateColorpicker(!0),this},color:function(e){this.r=0,this.g=0,this.b=0,this.a=1,this.h=0,this.s=0,this.v=0,this.l=0,this.hex="",this.hexa="",this.rgb="rgb(0,0,0)",this.rgba="rgba(0,0,0,1)",this._a=1,this._h=0,this._s=0,this._v=0,this.setRgb=function(e,t,n,r){this.isNull=!1,this.r=Math.max(0,Math.min(255,Math.round(e))),this.g=Math.max(0,Math.min(255,Math.round(t))),this.b=Math.max(0,Math.min(255,Math.round(n))),this._a=isset(r)?Math.max(0,Math.min(100,parseFloat(r))):this._a||100,this.a=Math.round(this._a);var i=$.colorpicker.rgbToHsv(this);this._h=i.h,this._s=i.s,this._v=i.v,this.h=Math.round(i.h),this.s=Math.round(i.s),this.v=Math.round(i.v),this.l=$.colorpicker.rgbToLum(this),this.hex=$.colorpicker.rgbToHex(this),this.hexa=$.colorpicker.rgbToHex(this),this.rgb="rgb("+this.r+","+this.g+","+this.b+")",this.rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/100+")"},this.setHsv=function(e,t,n,r){this.isNull=!1,this._h=Math.max(0,Math.min(360,parseFloat(e))),this._s=Math.max(0,Math.min(100,parseFloat(t))),this._v=Math.max(0,Math.min(100,parseFloat(n))),this.h=Math.round(this._h),this.s=Math.round(this._s),this.v=Math.round(this._v),this._a=isset(r)?Math.max(0,Math.min(100,parseFloat(r))):this._a||100,this.a=Math.round(this._a);var i=$.colorpicker.hsvToRgb(this);this.r=Math.round(i.r),this.g=Math.round(i.g),this.b=Math.round(i.b),this.l=$.colorpicker.rgbToLum(this),this.hex=$.colorpicker.rgbToHex(i),this.hexa=$.colorpicker.rgbToHex(i),this.rgb="rgb("+this.r+","+this.g+","+this.b+")",this.rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/100+")"},this.setHex=function(e){this.isNull=!1,this.hexa=$.colorpicker.validateHex(e),this.hex=$.colorpicker.validateHex(e);var t=$.colorpicker.hexToRgb(this.hexa);this.r=t.r,this.g=t.g,this.b=t.b,this._a=t.a,this.a=Math.round(t.a);var n=$.colorpicker.rgbToHsv(t);this._h=n.h,this._s=n.s,this._v=n.v,this.h=Math.round(n.h),this.s=Math.round(n.s),this.v=Math.round(n.v),this.l=$.colorpicker.rgbToLum(this),this.rgb="rgb("+this.r+","+this.g+","+this.b+")",this.rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/100+")"};if(e)if("hexa"in e)this.setHex(e.hexa);else if("hex"in e)this.setHex(e.hex);else if("rgb"in e){var t=e.rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(0?\.?\d+))?\)/i);if(t){var n=100;typeof t[4]!="undefined"&&(n*=t[4]),this.setRgb(t[1],t[2],t[3],n)}}else"r"in e?this.setRgb(e.r,e.g,e.b,e.a):"h"in e&&this.setHsv(e.h,e.s,e.v,e.a);return this},_attachColorpicker:function(target,settings){var input=$(target);if(input.hasClass(this.markerClassName))return;input.addClass(this._colorDivClass).addClass(this.markerClassName),target.id||(this.uuid+=1,target.id="cp"+this.uuid);var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("color:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var inst=this._newInst(input);inst.settings=$.extend({},settings||{},inlineSettings||{}),this._get(inst,"alpha")?input.addClass("alpha")[inst.settings.alphaHex?"addClass":"removeClass"]("alphaHex"):input.removeClass("alpha").removeClass("alphaHex"),this._setColor(inst,input.val()||input.data("color")||this._get(inst,"color"),!0);var swatches=this._get(inst,"swatches");swatches&&this.addSwatch(swatches),input.is("input")&&input.focus(function(){$.colorpicker._showColorpicker(target)}).keyup(function(){$.colorpicker._setColor(inst,this.value),$.colorpicker._updateColorpicker()}).bind("setData.colorpicker",function(e,t,n){inst.settings[t]=n}).bind("getData.colorpicker",function(e,t){return $.colorpicker._get(inst,t)}),input.click(function(){$.colorpicker._showColorpicker(target)}).bind("refresh",function(){var e=$(this),t=$.colorpicker._getInst(this);$.colorpicker._setColor(t,input.val()||input.data("color")||$.colorpicker._get(t,"color").hexa,!0),$.colorpicker._updateColorpicker()})},_setColor:function(e,t,n){if(!t||t.isNull)t=new $.colorpicker.color({hex:this._defaults.color}),t.isNull=this._get(e,"allowNull");if(typeof t=="string"||typeof t=="number")t.match(/^rgb/)?t=new $.colorpicker.color({rgb:t}):t=new $.colorpicker.color({hex:t});e.settings.color=new $.colorpicker.color({hex:t.hexa}),this._isDragging||(e.color=new $.colorpicker.color({hex:t.hexa})),e.color.isNull=e.settings.color.isNull=t.isNull,this._updateTarget(e,n);if(!this._isLastColor(t)){e.lastColor=t.isNull?null:t.hexa;var r=this._get(e,"onSelect");typeof r=="function"&&r(t.isNull?null:t,e)}},_newInst:function(e){var t=e[0].id.replace(/([^F-Za-z0-9_-])/g,"\\\\$1"),n={id:t,input:e,cpDiv:cpDiv,color:new $.colorpicker.color,lastColor:null};return e.data(PROP_NAME,n),n},_checkExternalClick:function(e){if(!$.colorpicker._curInst)return;var t=$(e.target);t[0].id!=$.colorpicker._mainDivId&&!t.is('label[for="'+$.colorpicker._curInst.input[0].id+'"]')&&t.parents("#"+$.colorpicker._mainDivId).length==0&&!t.hasClass($.colorpicker.markerClassName)&&$.colorpicker._hideColorpicker()},_optionColorpicker:function(e,t,n){var r=this._getInst(e),i=!1;if(arguments.length==2&&typeof t=="string")return t=="defaults"?$.extend({},$.colorpicker._defaults):r?t=="all"?$.extend({},r.settings):this._get(r,t):null;r&&this._curInst==r&&(this._hideColorpicker(e,!0),i=!0);var s=t||{};if(typeof t=="string"){s={};if(r&&t=="color"&&isset(n)){var o=n?new this.color({hex:n}):new this.color({hex:this._defaults.color});o.isNull=!n&&this._get(r,"allowNull"),n=o,this._setColor(r,n,!0),this.addSwatch(n,!0)}t=="swatches"&&n&&this.addSwatch(n),s[t]=n}r&&extendRemove(r.settings,s),i&&this._showColorpicker(e,!0)},_showColorpicker:function(e,t){e=e.target||e;var n=$(e);if(e.disabled)return;var r=$.colorpicker._getInst(e);this._curInst&&this._curInst!=r&&(this._triggerOnClose(),this.cpDiv.stop(!0,!0)),this._curInst=r,r.lastColor=r.color.isNull?null:r.color.hexa;var i=this._get(r,"alpha");$.colorpicker._updateColorpicker(),r.input.addClass("selected");var s=!t&&this._get(r,"showAnim"),o=this._get(r,"duration"),u=function(){$.colorpicker.cpDiv.addClass("visible")},a=$.colorpicker._get(r,"controlStyle").split(/\s+/);for(var f=0;f<a.length;f++)cpDiv.addClass(this.controlsClassPrefix+a[f]);cpDiv[i?"addClass":"removeClass"]("alphaOn"),cpDiv[this._get(r,"swatches")?"addClass":"removeClass"]("swatchesOn"),this.cpDiv.oldColorDiv.data("color",r.color.isNull?null:r.color.hexa).css("background-color",r.color[i?"rgba":"rgb"]);var l=this._get(r,"beforeShow");typeof l=="function"&&l(r.input,r),this._colorpickerShowing=!0,this.cpDiv[s?"fadeIn":"show"](s?o:null,u),s||u(),this._positionColorpicker()},_positionColorpicker:function(){var e=$.colorpicker._curInst.input,t=this.cpDiv,n=e.offset(),r=t.outerWidth(),i=t.defaultHeight+(this._get(this._getInst(e),"alpha")?t.alphaHeight:0)+(this._get(this._getInst(e),"swatches")?t.swatchHeight:0),s=$(window).width(),o=$(window).height(),u=10;i+=u,n.left+=e.outerWidth()+u,n.top+i>o&&(n.top=o-i),n.left+r>s&&(n.left=s-r),t.css({top:0,left:0}).offset(n)},_hideColorpicker:function(e,t){var n=this._curInst;if(!n||e&&n!=this._getInst(e))return;var r=function(){$.colorpicker._triggerOnClose(),$.colorpicker._curInst=null};if(this._colorpickerShowing){var i=!t&&this._get(n,"showAnim"),s=this._get(n,"duration");this.cpDiv[i?"fadeOut":"hide"](i?s:null,r),i||r(),this.cpDiv.removeClass("visible"),this._colorpickerShowing=!1;var o=this._get(n,"onClose");typeof o=="function"&&o(n.color,n)}else r()},_triggerOnClose:function(){var e=this._curInst;if(!e)return;e.input.removeClass("selected"),$.colorpicker.addSwatch(e.color,!0),this._setColor(e,e.color),cpDiv.removeClass(this.controlsClassPrefix+"invert");var t=$.colorpicker._get(e,"controlStyle").split(/\s+/);for(var n=0;n<t.length;n++)cpDiv.removeClass(this.controlsClassPrefix+t[n])},_updateColorpicker:function(e){var t=this._curInst;if(!t)return;var n=this._get(t,"alpha");this.cpDiv.colorDiv.data("color",t.color.isNull?null:t.color.hexa).css("background-color",t.color[n?"rgba":"rgb"]),cpDiv.d2Div.control.css("background-color",t.color.rgb),$.colorpicker._updateInputs(e),$.colorpicker._updateMaps(),$.colorpicker._updateControls(),this._get(t,"realtime")&&this._setColor(t,t.color,e)},_updateTarget:function(e,t){var n=this._get(e,"alpha"),r=this._get(e,"alphaHex");e.color.isNull?e.input.parent().addClass("color-null"):e.input.css({backgroundColor:e.color[n?"rgba":"rgb"],color:e.color.l<$.colorpicker.minLum?"#fff":"#000"}).parent().removeClass("color-null"),e.input.data("color",e.color.isNull?null:e.color.hexa);if(t||!e.input.is(":focus")){var i=e.input.val()||"";e.color.isNull?e.input.val(""):e.input.val(i.indexOf("#")>=0?"#"+e.color[r?"hexa":"hex"]:e.color[r?"hexa":"hex"]),i!=e.input.val()&&e.input.trigger("change")}},_updateInputs:function(e){var t=this._curInst;if(!t)return;var n=this._get(t,"alphaHex");for(var r in this.cpDiv.inputs)r&&isset(t.color[r])&&(e||!this.cpDiv.inputs[r].is(":focus"))&&(r=="hex"?this.cpDiv.inputs[r].val(t.color.isNull?"":t.color[n?"hexa":r]):this.cpDiv.inputs[r].val(t.color[r]))},_updateMaps:function(){var e=this._curInst;if(!e)return;this.cpDiv.alphaDiv.css("background-color",e.color.rgb);switch(this.mode){case"h":this.cpDiv.d1Div.gradientDiv.css("background",""),this.cpDiv.d2Div.colorDiv.css("background-color",(new this.color({h:e.color.h,s:100,v:100})).rgb),this.cpDiv.d1Div.gradientDiv.css("opacity",1-e.color.v/100),this.cpDiv.d1Div.colorDiv.css("opacity",e.color.s/100),this.cpDiv.d2Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.gradientDiv.css("opacity",1);break;case"s":this.cpDiv.d1Div.colorDiv.css("background-color",(new this.color({h:e.color.h,s:100,v:100})).rgb),this.cpDiv.d1Div.gradientDiv.css("opacity",1-e.color.v/100),this.cpDiv.d1Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.colorDiv.css("opacity",e.color.s/100),this.cpDiv.d2Div.gradientDiv.css("opacity",1);break;case"v":this.cpDiv.d1Div.gradientDiv.css("background",""),this.cpDiv.d1Div.colorDiv.css("background-color",(new this.color({h:e.color.h,s:e.color.s,v:100})).rgb),this.cpDiv.d1Div.gradientDiv.css("opacity",1),this.cpDiv.d1Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.gradientDiv.css("opacity",1-e.color.v/100)}$.colorpicker._updateControl()},_updateControls:function(){if(!this._curInst||this._isDragging)return;var e=this._curInst,t,n,r,i;switch(this.mode){case"h":t=e.color._s*255/100,n=255-e.color._v*255/100,r=255-e.color._h*255/360,i=e.color._a*255/100;break;case"s":t=e.color._h*255/360,n=255-e.color._v*255/100,r=255-e.color._s*255/100,i=e.color._a*255/100;break;case"v":t=e.color._h*255/360,n=255-e.color._s*255/100,r=255-e.color._v*255/100,i=e.color._a*255/100}$.colorpicker._moveControl1d(r,!0),$.colorpicker._moveControl2d(t,n,!0),$.colorpicker._moveControlAlpha(i,!0)},_moveControl1d:function(e,t){if(!$.colorpicker._curInst)return;var n=$.colorpicker._curInst;cpDiv.d1Div.control.css({top:Math.max(0,Math.min(255,Math.round(e)))+"px"});if(!t){switch($.colorpicker.mode){case"h":e=360-e*360/256;break;case"s":case"v":e=100-e*100/256}n.color["_"+$.colorpicker.mode]=e,n.color.setHsv(n.color._h,n.color._s,n.color._v,n.color.a),$.colorpicker._updateColorpicker(!0)}},_moveControl2d:function(e,t,n){if(!$.colorpicker._curInst)return;var r=$.colorpicker._curInst;cpDiv.d2Div.control.css({left:Math.max(0,Math.min(255,Math.round(e)))+"px",top:Math.max(0,Math.min(255,Math.round(t)))+"px"});if(!n){switch($.colorpicker.mode){case"h":e=e*100/256,t=100-t*100/256,r.color._s=e,r.color._v=t;break;case"s":case"v":e=e*360/256,t=100-t*100/256,r.color._h=e,r.color[$.colorpicker.mode=="s"?"_v":"_s"]=t}r.color.setHsv(r.color._h,r.color._s,r.color._v,r.color.a),$.colorpicker._updateColorpicker(!0)}},_moveControlAlpha:function(e,t){if(!$.colorpicker._curInst)return;var n=$.colorpicker._curInst;cpDiv.alphaDiv.control.css({left:Math.max(0,Math.min(255,parseInt(e)))+"px"}),t||(e*=.390625,n.color.a=e,n.color.setHsv(n.color._h,n.color._s,n.color._v,n.color.a),$.colorpicker._updateColorpicker(!0))},_mousemoveControl1d:function(e){return $.colorpicker._moveControl1d(e.pageY-$.colorpicker.cpDiv.d1Div.offset().top),e.preventDefault(),!1},_mousemoveControl2d:function(e){var t=$.colorpicker.cpDiv.d2Div.offset();return $.colorpicker._moveControl2d(e.pageX-t.left,e.pageY-t.top),e.preventDefault(),!1},_mousemoveControlAlpha:function(e){return $.colorpicker._moveControlAlpha(e.pageX-$.colorpicker.cpDiv.alphaDiv.offset().left),e.preventDefault(),!1},_updateControl:function(){if(!this._curInst||!$.colorpicker._get(this._curInst,"invertControls"))return!1;this._curInst.color.l<$.colorpicker.minLum?cpDiv.addClass(this.controlsClassPrefix+"invert"):cpDiv.removeClass(this.controlsClassPrefix+"invert")},_submit:function(e,t){var n=this._curInst;if(!n)return;if(!isset(e))var e=n.color,r=e.isNull&&this._get(n,"allowNull");else if(!e){var r=this._get(n,"allowNull");e=this._defaults.color}typeof e=="string"||typeof e=="number"?(e=new this.color({hex:e}),this._get(n,"alpha")||(e.a=e._a=100)):e=new this.color({hex:e[this._get(n,"alpha")?"hexa":"hex"]}),e.isNull=r,this._isCurrentColor(e)?($.colorpicker._hideColorpicker(),t=!0):($.colorpicker._setColor(n,e,!0),$.colorpicker._updateColorpicker(!0)),$.colorpicker.addSwatch(e,t)},_isCurrentColor:function(e){var t=this._curInst;if(!t)return;if(!e||e.isNull)return t.settings.color.isNull&&t.color.isNull;if(typeof e=="string"||typeof e=="number")e=new this.color({hex:e});return this._get(t,"alpha")?e.hexa==t.settings.color.hexa&&e.hexa==t.color.hexa:e.hex==t.settings.color.hex&&e.hex==t.color.hex},_isLastColor:function(e){var t=this._curInst;if(!t)return;if(!e||e.isNull)return t.lastColor===null;var n=new this.color({hex:t.lastColor});if(typeof e=="string"||typeof e=="number")e=new this.color({hex:e});return this._get(t,"alpha")?e.hexa==n.hexa:e.hex==n.hex},addSwatch:function(e,t){var n=this._curInst;if(n&&!this._get(n,"swatches")||!e||e.isNull)return!1;if(typeof e=="string"||typeof e=="number")e=new this.color({hex:e});if(e.hexa){var r=this.swatches.indexOf(e.hexa);if(r<0){this.swatches.unshift(e.hexa);var i=$("<div/>").addClass("swatch").attr("title","Right-click to delete swatch").data("color",e.hexa).css({backgroundColor:e.rgb,width:0,opacity:0}).append($("<div/>").css("background",e.rgba));window.setTimeout(function(){i.css({width:"",opacity:1})},0),this.cpDiv.swatches.prepend(i)}else{if(t)return!1;this.swatches.splice(r,1),this.swatches.unshift(e.hexa),this.cpDiv.swatches.prepend(this.cpDiv.swatches.children().eq(r))}this.swatchLimit&&(this.swatches=this.swatches.slice(0,this.swatchLimit));var s=n?this._get(n,"onAddSwatch"):this._defaults.onAddSwatch;typeof s=="function"&&s(e,this.swatches)}else if(e.length&&e[0])for(var o=e.length-1;o>=0;o--)this.addSwatch(e[o]);return this},deleteSwatch:function(e){var e=$(e);if(typeof e!="object"||!e||!e.length)return!1;this.swatches.splice(this.swatches.indexOf(e.data("color")),1);var t=this._curInst,n=t?this._get(t,"onDeleteSwatch"):this._defaults.onDeleteSwatch;typeof n=="function"&&n(e.data("color"),this.swatches),e.remove()},clearSwatches:function(){return this.swatches=[],this.cpDiv.swatches.empty(),this},_useSwatch:function(e){return $.colorpicker._setColor($.colorpicker._curInst,$(this).data("color")),$.colorpicker._updateColorpicker(),e.preventDefault(),!1},_get:function(e,t){return isset(e.settings[t])?e.settings[t]:this._defaults[t]},_getInst:function(e){try{return $(e).data(PROP_NAME)}catch(t){throw"Missing instance data for this colorpicker"}},hexToRgb:function(e){e=this.validateHex(e);var t="00",n="00",r="00";return e.length==6&&(a="FF",t=e.substring(0,2),n=e.substring(2,4),r=e.substring(4,6)),e.length==8&&(a=e.substring(0,2),t=e.substring(2,4),n=e.substring(4,6),r=e.substring(6,8)),{r:this.hexToInt(t),g:this.hexToInt(n),b:this.hexToInt(r),a:100*this.hexToInt(a)/255}},_hexRegExp:/[a-f0-9]{0,2}([a-f0-9]{6})|[a-f0-9]?([a-f0-9]{3})/i,_hexaRegExp:/([a-f0-9]{8}|[a-f0-9]{6}|[a-f0-9]{4}|[a-f0-9]{3})/i,validateHex:function(e){return e?(e=(""+e).match(this._hexaRegExp),e=e?e[1]||e[2]:"00000000",e=e.toUpperCase(),e.length==3&&(e=e.split(""),e=[e[0],e[0],e[1],e[1],e[2],e[2]].join("")),e.length==4&&(e=e.split(""),e=[e[0],e[0],e[1],e[1],e[2],e[2],e[3],e[3]].join("")),e.length!=8&&(e="FF"+e),e.substring(0,2)=="FF"&&(e=e.substring(2,8)),e):!1},rgbToHex:function(e){var t=this.intToHex(Math.round(e.a*255/100));t=="FF"&&(t="");var n=this.intToHex(e.r)+this.intToHex(e.g)+this.intToHex(e.b);return t+n},intToHex:function(e){var t=parseInt(e).toString(16);return t.length==1&&(t="0"+t),t.toUpperCase()},hexToInt:function(e){return parseInt(e,16)},rgbToLum:function(e){return Math.abs(Math.round((.2126*e.r+.7152*e.g+.0722*e.b)/2.55))},rgbToHsv:function(e){var t=e.r/255,n=e.g/255,r=e.b/255;hsv={h:0,s:0,v:0,a:isset(e._a)?e._a:e.a};var i=0,s=0;return t>=n&&t>=r?(s=t,i=n>r?r:n):n>=r&&n>=t?(s=n,i=t>r?r:t):(s=r,i=n>t?t:n),hsv.v=s,hsv.s=s?(s-i)/s:0,hsv.s?(delta=s-i,t==s?hsv.h=(n-r)/delta:n==s?hsv.h=2+(r-t)/delta:hsv.h=4+(t-n)/delta,hsv.h=hsv.h*60,hsv.h<0&&(hsv.h+=360)):hsv.h=0,hsv.s=Math.abs(hsv.s*100),hsv.v=Math.abs(hsv.v*100),hsv},hsvToRgb:function(e){rgb={r:0,g:0,b:0,a:isset(e._a)?e._a:e.a};var t=isset(e._h)?e._h:e.h,n=isset(e._s)?e._s:e.s,r=isset(e._v)?e._v:e.v;if(n==0)r==0?rgb.r=rgb.g=rgb.b=0:rgb.r=rgb.g=rgb.b=Math.abs(r*255/100);else{t==360&&(t=0),t/=60,n/=100,r/=100;var i=parseInt(t),s=t-i,o=r*(1-n),u=r*(1-n*s),a=r*(1-n*(1-s));switch(i){case 0:rgb.r=r,rgb.g=a,rgb.b=o;break;case 1:rgb.r=u,rgb.g=r,rgb.b=o;break;case 2:rgb.r=o,rgb.g=r,rgb.b=a;break;case 3:rgb.r=o,rgb.g=u,rgb.b=r;break;case 4:rgb.r=a,rgb.g=o,rgb.b=r;break;case 5:rgb.r=r,rgb.g=o,rgb.b=u}rgb.r=Math.abs(Math.round(rgb.r*255)),rgb.g=Math.abs(Math.round(rgb.g*255)),rgb.b=Math.abs(Math.round(rgb.b*255))}return rgb}}),$.fn.colorpicker=function(e){if(!this.length)return this;if(!$.colorpicker.initialized){$(document).mousedown($.colorpicker._checkExternalClick).find("body").append($.colorpicker.cpDiv.hide()).find("#"+mainDivId+"-"+$.colorpicker.mode).closest("li").addClass("selected");for(var t in cpDiv.inputs)if(t){var n=$(cpDiv.inputs[t]);n.data("mode")&&n.focus(function(){var e=$(this);e.closest("li").addClass("selected").siblings(".selected").removeClass("selected"),$.colorpicker._setMode(e.data("mode"))}).closest("li").click(function(){$(this).find("input").focus()}),n.blur(function(){$.colorpicker._updateInputs()});switch(t){case"h":case"s":case"v":case"a":n.keydown(function(e){if(!$.colorpicker._curInst)return;var t=$(this),n=$.colorpicker._curInst;switch(e.keyCode){case 38:case 40:t.val(parseInt(t.val())+(e.shiftKey?10:1)*(e.keyCode==40?-1:1)),n.color.setHsv(cpDiv.inputs.h.val(),cpDiv.inputs.s.val(),cpDiv.inputs.v.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker(!0);break;case 13:$.colorpicker._submit();break;default:return}}).keyup(function(){if(!$.colorpicker._curInst)return;$.colorpicker._curInst.color.setHsv(cpDiv.inputs.h.val(),cpDiv.inputs.s.val(),cpDiv.inputs.v.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker()});break;case"r":case"g":case"b":n.keydown(function(e){if(!$.colorpicker._curInst)return;var t=$(this),n=$.colorpicker._curInst;switch(e.keyCode){case 38:case 40:t.val(parseInt(t.val())+(e.shiftKey?10:1)*(e.keyCode==40?-1:1)),n.color.setRgb(cpDiv.inputs.r.val(),cpDiv.inputs.g.val(),cpDiv.inputs.b.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker(!0);break;case 13:$.colorpicker._submit();break;default:return}}).keyup(function(){if(!$.colorpicker._curInst)return;$.colorpicker._curInst.color.setRgb(cpDiv.inputs.r.val(),cpDiv.inputs.g.val(),cpDiv.inputs.b.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker()});break;case"hex":n.keydown(function(e){if(!$.colorpicker._curInst)return;switch(e.keyCode){case 13:$.colorpicker._submit();break;default:return}}).keyup(function(){var e=$.colorpicker._curInst;if(!e)return;cpDiv.inputs.hex.val()?(e.color.setHex(cpDiv.inputs.hex.val()),$.colorpicker._updateColorpicker()):(e.color=new $.colorpicker.color({hex:$.colorpicker._defaults.color}),e.color.isNull=$.colorpicker._get(e,"allowNull"),$.colorpicker._updateColorpicker())})}}cpDiv.addSwatchButton.mousedown(function(e){$.colorpicker.addSwatch($.colorpicker._curInst.color)}),cpDiv.swatches.delegate(".swatch","click",function(e){var t=$.proxy($.colorpicker._useSwatch,this);t(e),e.preventDefault()}),cpDiv.swatches.delegate(".swatch","contextmenu",function(e){return confirm("Are you sure you wish to delete this swatch?")&&$.colorpicker.deleteSwatch(this),e.preventDefault(),!1}),cpDiv.oldColorDiv.mousedown($.colorpicker._useSwatch),cpDiv.colorDiv.mousedown(function(e){return $.colorpicker._submit($(this).data("color")),e.preventDefault(),!1}),cpDiv.defaultHeight=cpDiv.outerHeight(),cpDiv.addClass("swatchesOn"),cpDiv.swatchHeight=cpDiv.outerHeight()-cpDiv.defaultHeight,cpDiv.removeClass("swatchesOn").addClass("alphaOn"),cpDiv.alphaHeight=cpDiv.outerHeight()-cpDiv.defaultHeight,cpDiv.removeClass("alphaOn"),cpDiv.d1Div.mousedown(function(e){return $.colorpicker._isDragging=!0,$.colorpicker._mousemoveControl1d(e),$(document).bind("mousemove",$.colorpicker._mousemoveControl1d),!1}),cpDiv.d2Div.mousedown(function(e){return $.colorpicker._isDragging=!0,$.colorpicker._mousemoveControl2d(e),$(document).bind("mousemove",$.colorpicker._mousemoveControl2d),!1}),cpDiv.alphaDiv.mousedown(function(e){return $.colorpicker._isDragging=!0,$.colorpicker._mousemoveControlAlpha(e),$(document).bind("mousemove",$.colorpicker._mousemoveControlAlpha),!1}),$(document).mouseup(function(){return $(document).unbind("mousemove",$.colorpicker._mousemoveControl1d).unbind("mousemove",$.colorpicker._mousemoveControl2d).unbind("mousemove",$.colorpicker._mousemoveControlAlpha),$.colorpicker._isDragging=!1,!1}),$(window).resize(function(){$.colorpicker._colorpickerShowing&&$.colorpicker._positionColorpicker()}),$.colorpicker._setMode($.colorpicker.mode),$.colorpicker.initialized=!0}var r=Array.prototype.slice.call(arguments,1);return e=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.colorpicker["_"+e+"Colorpicker"].apply($.colorpicker,[this[0]].concat(r)):this.each(function(){typeof e=="string"?$.colorpicker["_"+e+"Colorpicker"].apply($.colorpicker,[this].concat(r)):$.colorpicker._attachColorpicker(this,e)})},$.colorpicker=new Colorpicker,$.colorpicker.initialized=!1,$.colorpicker.uuid=(new Date).getTime()}(jQuery),define("deps/colorpicker",function(){}),function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){if(e instanceof x)return e;if(!(this instanceof x))return new x(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.6.0";var T=x.each=x.forEach=function(e,t,r){if(e==null)return e;if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}else{var o=x.keys(e);for(var i=0,s=o.length;i<s;i++)if(t.call(r,e[o[i]],o[i],e)===n)return}return e};x.map=x.collect=function(e,t,n){var r=[];return e==null?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r.push(t.call(n,e,i,s))}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},x.filter=x.select=function(e,t,n){var r=[];return e==null?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&r.push(e)}),r)},x.reject=function(e,t,n){return x.filter(e,x.negate(t),n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return e==null?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return e==null?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};x.contains=x.include=function(e,t){return e==null?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,x.property(t))},x.where=function(e,t){return x.filter(e,x.matches(t))},x.findWhere=function(e,t){return x.find(e,x.matches(t))},x.max=function(e,t,n){var r=-Infinity,i=-Infinity,s,o;if(!t&&x.isArray(e))for(var u=0,a=e.length;u<a;u++)s=e[u],s>r&&(r=s);else T(e,function(e,s,u){o=t?t.call(n,e,s,u):e,o>i&&(r=e,i=o)});return r},x.min=function(e,t,n){var r=Infinity,i=Infinity,s,o;if(!t&&x.isArray(e))for(var u=0,a=e.length;u<a;u++)s=e[u],s<r&&(r=s);else T(e,function(e,s,u){o=t?t.call(n,e,s,u):e,o<i&&(r=e,i=o)});return r},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r},x.sample=function(e,t,n){return t==null||n?(e.length!==+e.length&&(e=x.values(e)),e[x.random(e.length-1)]):x.shuffle(e).slice(0,Math.max(0,t))};var k=function(e){return e==null?x.identity:x.isFunction(e)?e:x.property(e)};x.sortBy=function(e,t,n){return t=k(t),x.pluck(x.map(e,function(e,r,i){return{value:e,index:r,criteria:t.call(n,e,r,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index-t.index}),"value")};var L=function(e){return function(t,n,r){var i={};return n=k(n),T(t,function(s,o){var u=n.call(r,s,o,t);e(i,u,s)}),i}};x.groupBy=L(function(e,t,n){x.has(e,t)?e[t].push(n):e[t]=[n]}),x.indexBy=L(function(e,t,n){e[t]=n}),x.countBy=L(function(e,t){x.has(e,t)?e[t]++:e[t]=1}),x.sortedIndex=function(e,t,n,r){n=k(n);var i=n.call(r,t),s=0,o=e.length;while(s<o){var u=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return e==null?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return e==null?void 0:t==null||n?e[0]:t<0?[]:u.call(e,0,t)},x.initial=function(e,t,n){return u.call(e,0,e.length-(t==null||n?1:t))},x.last=function(e,t,n){return e==null?void 0:t==null||n?e[e.length-1]:u.call(e,Math.max(e.length-t,0))},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,t==null||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n,r){if(t&&x.every(e,x.isArray))return a.apply(r,e);for(var i=0,s=e.length;i<s;i++){var u=e[i];!x.isArray(u)&&!x.isArguments(u)?n||r.push(u):t?o.apply(r,u):A(u,t,n,r)}return r};x.flatten=function(e,t){return A(e,t,!1,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.partition=function(e,t,n){t=k(t);var r=[],i=[];return T(e,function(e){(t.call(n,e)?r:i).push(e)}),[r,i]},x.uniq=x.unique=function(e,t,n,r){if(e==null)return[];x.isFunction(t)&&(r=n,n=t,t=!1);var i=[],s=[];for(var o=0,u=e.length;o<u;o++){var a=e[o];n&&(a=n.call(r,a,o,e));if(t?!o||s!==a:!x.contains(s,a))t?s=a:s.push(a),i.push(e[o])}return i},x.union=function(){return x.uniq(A(arguments,!0,!0,[]))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.contains(t,e)})})},x.difference=function(e){var t=A(u.call(arguments,1),!0,!0,[]);return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){var e=x.max(x.pluck(arguments,"length").concat(0)),t=new Array(e);for(var n=0;n<e;n++)t[n]=x.pluck(arguments,""+n);return t},x.object=function(e,t){if(e==null)return{};var n={};for(var r=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(e==null)return-1;var r=0,i=e.length;if(n){if(typeof n!="number")return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;r<i;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(e==null)return-1;var r=n!=null;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);var i=r?n:e.length;while(i--)if(e[i]===t)return i;return-1},x.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=new Array(r);while(i<r)s[i++]=e,e+=n;return s};var O=function(){};x.bind=function(e,t){var n,r;if(S&&e.bind===S)return S.apply(e,u.call(arguments,1));if(!x.isFunction(e))throw new TypeError;return n=u.call(arguments,2),r=function(){if(this instanceof r){O.prototype=e.prototype;var i=new O;O.prototype=null;var s=e.apply(i,n.concat(u.call(arguments)));return Object(s)===s?s:i}return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){var n=0,r=t.slice();for(var i=0,s=r.length;i<s;i++)r[i]===x&&(r[i]=arguments[n++]);while(n<arguments.length)r.push(arguments[n++]);return e.apply(this,r)}},x.bindAll=function(e){var t=u.call(arguments,1);if(t.length===0)throw new Error("bindAll must be passed function names");return T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t,n){var r,i,s,o=null,u=0;n||(n={});var a=function(){u=n.leading===!1?0:x.now(),o=null,s=e.apply(r,i),r=i=null};return function(){var f=x.now();!u&&n.leading===!1&&(u=f);var l=t-(f-u);return r=this,i=arguments,l<=0||l>t?(clearTimeout(o),o=null,u=f,s=e.apply(r,i),r=i=null):!o&&n.trailing!==!1&&(o=setTimeout(a,l)),s}},x.debounce=function(e,t,n){var r,i,s,o,u,a=function(){var f=x.now()-o;f<t&&f>0?r=setTimeout(a,t-f):(r=null,n||(u=e.apply(s,i),s=i=null))};return function(){s=this,i=arguments,o=x.now();var f=n&&!r;return r||(r=setTimeout(a,t)),f&&(u=e.apply(s,i),s=i=null),u}},x.once=function(e){var t=!1,n;return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},x.wrap=function(e,t){return x.partial(t,e)},x.negate=function(e){return function(){return!e.apply(this,arguments)}},x.compose=function(){var e=arguments;return function(){var t=arguments;for(var n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},x.keys=function(e){if(!x.isObject(e))return[];if(E)return E(e);var t=[];for(var n in e)x.has(e,n)&&t.push(n);return t},x.values=function(e){var t=x.keys(e),n=t.length,r=new Array(n);for(var i=0;i<n;i++)r[i]=e[t[i]];return r},x.pairs=function(e){var t=x.keys(e),n=t.length,r=new Array(n);for(var i=0;i<n;i++)r[i]=[t[i],e[t[i]]];return r},x.invert=function(e){var t={},n=x.keys(e);for(var r=0,i=n.length;r<i;r++)t[e[n[r]]]=n[r];return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e,t,n){var i={};if(x.isFunction(t))for(var s in e){var o=e[s];t.call(n,o,s,e)&&(i[s]=o)}else{var f=a.apply(r,u.call(arguments,1));for(var l=0,c=f.length;l<c;l++){var s=f[l];s in e&&(i[s]=e[s])}}return i},x.omit=function(e,t,n){var i;return x.isFunction(t)?t=x.negate(t):(i=a.apply(r,u.call(arguments,1)),t=function(e,t){return!x.contains(i,t)}),x.pick(e,t,n)},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;var o=e.constructor,u=t.constructor;if(o!==u&&!(x.isFunction(o)&&o instanceof o&&x.isFunction(u)&&u instanceof u)&&"constructor"in e&&"constructor"in t)return!1;n.push(e),r.push(t);var a=0,l=!0;if(i=="[object Array]"){a=e.length,l=a==t.length;if(l)while(a--)if(!(l=M(e[a],t[a],n,r)))break}else{for(var c in e)if(x.has(e,c)){a++;if(!(l=x.has(t,c)&&M(e[c],t[c],n,r)))break}if(l){for(c in t)if(x.has(t,c)&&!(a--))break;l=!a}}return n.pop(),r.pop(),l};x.isEqual=function(e,t){return M(e,t,[],[])},x.isEmpty=function(e){if(e==null)return!0;if(x.isArray(e)||x.isString(e))return e.length===0;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&e.nodeType===1},x.isArray=w||function(e){return f.call(e)=="[object Array]"},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),typeof /./!="function"&&(x.isFunction=function(e){return typeof e=="function"}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||f.call(e)=="[object Boolean]"},x.isNull=function(e){return e===null},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.constant=function(e){return function(){return e}},x.noop=function(){},x.property=function(e){return function(t){return t[e]}},x.matches=function(e){return function(t){if(t===e)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0}},x.times=function(e,t,n){var r=Array(Math.max(0,e));for(var i=0;i<e;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return t==null&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},x.now=Date.now||function(){return(new Date).getTime()};var _={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};_.unescape=x.invert(_.escape);var D={escape:new RegExp("["+x.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+x.keys(_.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),x.result=function(e,t){if(e==null)return void 0;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(x,e))}})};var P=0;x.uniqueId=function(e){var t=++P+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n","   ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(j,function(e){return"\\"+B[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var F=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),typeof define=="function"&&define.amd&&define("underscore",[],function(){return x})}.call(this),define("util.image-uploader",["jquery","underscore"],function(e,t){openImageUploader=function(t){if(!boxExists("input-image")){isNaN(Headway.currentLayout)&&(iframePostID=0);var n={id:"input-image",title:"Select an image",description:"Upload or select an image",src:Headway.homeURL+"/?headway-trigger=media-uploader",load:function(){initiateImageUploader(t)},width:e(window).width()-200,height:e(window).height()-200,center:!0,draggable:!1,deleteWhenClosed:!0,blackOverlay:!0},r=createBox(n);e("#box-input-image").css({width:"auto",height:"auto",top:"70px",left:"70px",right:"70px",bottom:"70px",margin:0})}openBox("input-image")},initiateImageUploader=function(n){if(!e("#box-input-image iframe").length||typeof e("#box-input-image iframe")[0].contentWindow.wp=="undefined"||typeof e("#box-input-image iframe")[0].contentWindow.wp.media=="undefined"||typeof e("#box-input-image iframe")[0].contentWindow.wp.media()=="undefined")return setTimeout(function(){initiateImageUploader(n)},100);wpMedia=e("#box-input-image iframe")[0].contentWindow.wp.media;var r=parent.Headway.currentLayout.split("-");return t.first(r)=="single"&&!isNaN(t.last(r))&&(wpMedia.model.settings.post.id=t.last(r)),wpMedia.frames={file_frame:wpMedia({title:"",button:{text:"Use Image"},multiple:!1})},wpMedia.frames.file_frame.on("select",function(){attachment=wpMedia.frames.file_frame.state().get("selection").first().toJSON();if(typeof e=="undefined")var e=attachment.url;var t=e.split("/")[e.split("/").length-1];n(e,t),parent.closeBox("input-image",!0)}),wpMedia.frames.file_frame.on("escape",function(){parent.closeBox("input-image",!0)}),wpMedia.frames.file_frame.open()}}),define("modules/panel.inputs",["jquery","helper.ace","deps/colorpicker","util.image-uploader"],function($,aceHelper){handleInputTogglesInContainer=function(e){e.each(function(){$(this).find('[id*="input-"]').reverse().each(function(){handleInputToggle($(this))})})},handleInputToggle=function(e,t){if(!e||!e.length||typeof e.attr("data-toggle")=="undefined")return;var n=$.parseJSON(e.attr("data-toggle")),r=".panel";if(e.parents(".repeater-group").length)var r=".repeater-group";if(typeof t=="undefined")var t=e.val().toString();e.attr("type")=="checkbox"&&(e.is(":checked")?t="true":t="false");if(t&&n&&typeof n=="object"&&n.hasOwnProperty(t)){if(typeof n[t].show=="string"){var i=e.parents(r).find(n[t].show);i.show(),i.find("*[data-toggle]").not(e).each(function(){handleInputToggle($(this))})}else typeof n[t].show=="object"&&$.each(n[t].show,function(t,n){var i=e.parents(r).find(n).show();i.show(),i.find("*[data-toggle]").not(e).each(function(){handleInputToggle($(this))})});if(typeof n[t].hide=="string"){var s=e.parents(r).find(n[t].hide);s.find("*[data-toggle]").not(e).each(function(){handleInputToggleHideAll($(this))}),s.hide()}else typeof n[t].hide=="object"&&$.each(n[t].hide,function(t,n){var i=e.parents(r).find(n);i.find("*[data-toggle]").not(e).each(function(){handleInputToggleHideAll($(this))}),i.hide()})}},handleInputToggleHideAll=function(e){if(!e||!e.length||typeof e.attr("data-toggle")=="undefined")return;var t=$.parseJSON(e.attr("data-toggle")),n=".panel";if(e.parents(".input").parent().attr("class")==="repeater-group")var n=".repeater-group";$.each(t,function(t,r){if(typeof r.hide=="undefined"||!r.hide||!r.hide.length)return;if(typeof r.hide=="string"){var i=e.parents(n).find(r.hide);i.hide()}else typeof r.hide=="object"&&$.each(r.hide,function(t,r){var i=e.parents(n).find(r);i.hide()})})};var panelInputs={delegate:function(){var context="div#panel";$(context).delegate("div.input-select select","change",function(){dataHandleInput($(this));var e=$(this),t=$(this).val();handleInputToggle(e,t)}),$(context).delegate("div.input-text input","keyup blur",function(){dataHandleInput($(this))}),$(context).delegate("div.input-textarea textarea","keyup blur",function(){dataHandleInput($(this))}),$(context).delegate("div.input-textarea span.textarea-open","click",function(){var e=$(this).siblings(".textarea-container"),t=e.find("textarea"),n=$(this).parents(".input").offset();e.css({top:n.top-e.outerHeight(!0),left:n.left}),$("div.sub-tabs-content-container").css("overflow-y","hidden"),e.data("visible")!==!0?(e.show(),e.data("visible",!0),t.trigger("focus"),$(document).bind("mousedown",{textareaContainer:e},textareaClose),Headway.iframe.contents().bind("mousedown",{textareaContainer:e},textareaClose),$(window).bind("resize",{textareaContainer:e},textareaClose)):(e.hide(),e.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",textareaClose),Headway.iframe.contents().unbind("mousedown",textareaClose),$(window).unbind("resize",textareaClose))}),textareaClose=function(e){if($(e.target).parents("div.input-textarea div.input-right").length===1)return;var t=e.data.textareaContainer;t.hide(),t.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",textareaClose),Headway.iframe.contents().unbind("mousedown",textareaClose),$(window).unbind("resize",textareaClose)},$(context).delegate("div.input-code span.code-editor-open","click",function(){var e=$(this).siblings("textarea");aceHelper.showEditor(e.attr("id"),$(this).data("editor-mode"),e.val(),function(t){e.val(t.getValue()),dataHandleInput(e)})}),inputWYSIWYGChange=function(e){dataHandleInput(this.$element,this.get())},inputWYSIWYGTextareaChange=function(){dataHandleInput($(this))},$(context).delegate("div.input-wysiwyg span.wysiwyg-open","click",function(){var e=$(this).siblings(".wysiwyg-container"),t=$(this).parents(".input").offset(),n=t.top-e.outerHeight(!0);n<50&&(n=50),e.css({top:n,left:t.left}),$("div.sub-tabs-content-container").css("overflow-y","hidden");if(e.data("visible")!==!0){e.show(),e.css("marginLeft",""),e.data("visible",!0);if($("div#side-panel-container").length)var r=$("div#side-panel-container").outerWidth()-$("div#side-panel-container").css("right").replace("px","");else var r=0;var i=$(document).width()-r-(e.offset().left+e.width());i<0&&e.css("marginLeft",i-30);var s=function(){e.find("textarea").redactor({path:Headway.headwayURL+"/library/resources/redactor/",plugins:["fontcolor","fontsize"],buttons:["html","|","formatting","|","bold","italic","deleted","|","unorderedlist","orderedlist","outdent","indent","|","table","link","|","image","|","alignleft","aligncenter","alignright","|","horizontalrule"],allowedTags:["inline","code","span","div","label","a","br","p","b","i","del","strike","u","img","video","audio","iframe","object","embed","param","blockquote","mark","cite","small","ul","ol","li","hr","dl","dt","dd","sup","sub","big","pre","code","figure","figcaption","strong","em","table","tr","td","th","tbody","thead","tfoot","h1","h2","h3","h4","h5","h6","frame","frameset","script","hgroup","form","label","input","textarea","select","fieldset","legend"],iframe:!0,css:Headway.headwayURL+"/library/resources/redactor/css/redactor-iframe.css",changeCallback:inputWYSIWYGChange,blurCallback:inputWYSIWYGChange,imageUpload:Headway.ajaxURL+"?action=headway_visual_editor&method=redactor_upload_image&security="+Headway.security,convertDivs:!1}),e.find("textarea").bind("keyup",inputWYSIWYGTextareaChange),e.find("textarea").redactor("focusEnd"),e.data("setupRedactor",!0)};if($("body").data("loadedRedactor")!==!0){var o=$("<link>").attr({rel:"stylesheet",href:Headway.headwayURL+"/library/resources/redactor/css/redactor.css",type:"text/css",media:"screen"}).appendTo($("head")),u=jQuery.ajax({dataType:"script",cache:!0,url:Headway.headwayURL+"/library/resources/redactor/redactor.min.js"}),a=jQuery.ajax({dataType:"script",cache:!0,url:Headway.headwayURL+"/library/resources/redactor/fontcolor.js"}),f=jQuery.ajax({dataType:"script",cache:!0,url:Headway.headwayURL+"/library/resources/redactor/fontsize.js"});$.when(u,a,f).then(function(){s(),$("body").data("loadedRedactor",!0)})}else $("body").data("loadedRedactor")===!0&&e.data("setupRedactor")!==!0?s():e.find("textarea").redactor("focusEnd");$(document).bind("mousedown",{wysiwygContainer:e},wysiwygClose),Headway.iframe.contents().bind("mousedown",{wysiwygContainer:e},wysiwygClose),$(window).bind("resize",{wysiwygContainer:e},wysiwygClose)}else e.hide(),e.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",wysiwygClose),Headway.iframe.contents().unbind("mousedown",wysiwygClose),$(window).unbind("resize",wysiwygClose)}),wysiwygClose=function(e){if($(e.target).parents("div.input-wysiwyg div.input-right").length===1||$(e.target).parents(".redactor_dropdown").length===1||$(e.target).parents("#redactor_modal").length===1)return;var t=e.data.wysiwygContainer;t.hide(),t.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",wysiwygClose),Headway.iframe.contents().unbind("mousedown",wysiwygClose),$(window).unbind("resize",wysiwygClose)},$(context).delegate("div.input-integer input","focus",function(){typeof originalValues!="undefined"&&delete originalValues,originalValues=new Object,originalValues[$(this).attr("name")]=$(this).val()}),$(context).delegate("div.input-integer input","keyup blur",function(e){t=$(this).val();if(e.type=="keyup"&&t=="-")return;if(isNaN(t)){t=t.replace(/[^0-9]*/ig,"");if(t==="")var t=originalValues[$(this).attr("name")];$(this).val(t)}t.length>1&&t[0]==0&&(t=t.replace(/^[0]+/g,""),$(this).val(t)),dataHandleInput($(this),t)}),$(context).delegate("div.input-checkbox input","change",function(e){var t=$(this).parents(".input-checkbox").first(),n=t.find("input"),r=t.find("label"),i=n.is(":checked");return Headway.history.add({up:function(){n.val(i),n.prop("checked",i),dataHandleInput(n,i),handleInputToggle(n,i),n.trigger("blur")},down:function(){var e=!e;n.val(e),n.prop("checked",e),dataHandleInput(n,e),handleInputToggle(n,e),n.trigger("blur")}}),allowSaving(),e.preventDefault(),e.stopPropagation(),!1}),$(context).delegate("div.input-multi-select select","click",function(){dataHandleInput($(this))}),$(context).delegate("div.input-multi-select span.multi-select-open","click",function(){var e=$(this).siblings(".multi-select-container"),t=e.find("select"),n=$(this).parents(".input").offset();e.css({top:n.top-e.outerHeight(!0),left:n.left}),$("div.sub-tabs-content-container").css("overflow-y","hidden"),e.data("visible")!==!0?(e.show(),e.data("visible",!0),$(document).bind("mousedown",{multiSelectContainer:e},multiSelectClose),Headway.iframe.contents().bind("mousedown",{multiSelectContainer:e},multiSelectClose),$(window).bind("resize",{multiSelectContainer:e},multiSelectClose)):(e.hide(),e.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",multiSelectClose),Headway.iframe.contents().unbind("mousedown",multiSelectClose),$(window).unbind("resize",multiSelectClose))}),multiSelectClose=function(e){if($(e.target).parents("div.input-multi-select div.input-right").length===1)return;var t=e.data.multiSelectContainer;t.hide(),t.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",multiSelectClose),Headway.iframe.contents().unbind("mousedown",multiSelectClose),$(window).unbind("resize",multiSelectClose)},$(context).delegate("div.input-image span.button","click",function(){var e=this;openImageUploader(function(t,n){$(e).siblings("input").val(t),$(e).siblings("span.src").show().text(n),$(e).siblings("span.delete-image").show(),dataHandleInput($(e).siblings("input"),t,{action:"add"})})}),$(context).delegate("div.input-image span.delete-image","click",function(){if(!confirm("Are you sure you wish to remove this image?"))return!1;$(this).siblings(".src").hide(),$(this).hide(),$(this).siblings("input").val(""),dataHandleInput($(this).siblings("input"),"",{action:"delete"})}),updateRepeaterValues=function(e){var t={};return e.find("div.repeater-group:visible").each(function(e){var n={};$(this).find("select, input, textarea").each(function(){var e=$(this).val();$(this).is('[type="checkbox"]')&&!$(this).is(":checked")&&(e=!1),n[$(this).attr("name")]=e}),t[e]=n}),dataHandleInput(e.find("input.repeater-group-input"),t)},$(context).delegate("div.repeater .add-group","click",function(){var e=$(this).parents("div.repeater"),t=$(this).parents("div.repeater-group"),n=e.find(".repeater-group-template");if(e.hasClass("limit-met"))return;var r=n.clone().hide().removeClass("repeater-group-template");r.insertAfter(t).fadeIn(300),e.find(".repeater-group-single").removeClass("repeater-group-single");var i=e.data("repeater-limit");!isNaN(i)&&i>=1&&e.find("div.repeater-group:not(.repeater-group-template):visible").length==i&&e.addClass("limit-met"),updateRepeaterValues(e)}),$(context).delegate("div.repeater .remove-group","click",function(){if(!confirm("Are you sure?"))return;var e=$(this).parents("div.repeater"),t=$(this).parents("div.repeater-group");t.fadeOut(300,function(){e.find("div.repeater-group:visible").length===1&&e.find("div.repeater-group:visible").addClass("repeater-group-single");var t=e.data("repeater-limit");!isNaN(t)&&t>=1&&e.find("div.repeater-group:not(.repeater-group-template):visible").length<t&&e.removeClass("limit-met"),updateRepeaterValues(e)})}),$(context).delegate("div.input-colorpicker div.colorpicker-box","click",function(){$("div.sub-tabs-content-container").css("overflow-y","hidden");var input=$(this).parent().siblings("input"),inputVal=input.val();inputVal=="transparent"&&(inputVal="00FFFFFF");var colorpickerHandleVal=function(color,inst){var colorValue="#"+color.hex;if(color.a!=100)var colorValue=color.rgba;input.val(colorValue),dataHandleInput(input,colorValue);var callback=eval(input.attr("data-callback"));typeof callback=="function"&&callback({input:input,value:color.rgba,colorObj:color})};$(this).colorpicker({realtime:!0,alpha:!0,alphaHex:!0,allowNull:!1,swatches:typeof Headway.colorpickerSwatches=="object"&&Headway.colorpickerSwatches.length?Headway.colorpickerSwatches:!0,color:inputVal,showAnim:!1,beforeShow:function(e,t){showIframeOverlay()},onClose:function(e,t){colorpickerHandleVal(e,t),hideIframeOverlay(),$("div.sub-tabs-content-container").css("overflow-y","auto")},onSelect:function(e,t){colorpickerHandleVal(e,t)},onAddSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)},onDeleteSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)}}),$.colorpicker._showColorpicker($(this)),setupTooltips()}),$(context).delegate("div.input-button span.button","click",function(){dataHandleInput($(this))}),$(context).delegate("div.input-import-file span.button","click",function(){$(this).siblings('input[type="file"]').trigger("click")}),$(context).delegate('div.input-import-file input[type="file"]',"change",function(e){if(e.target.files[0].name.split(".").slice(-1)[0]!="json")return $(this).val(null),alert("Invalid Headway import file.  Please be sure that the Headway import file is a valid JSON formatted file.");$(this).siblings("span.src").show().text($(this).val().split(/(\\|\/)/g).pop()),$(this).siblings("span.delete-file").show(),dataHandleInput($(this))}),$(context).delegate("div.input-import-file .delete-file","click",function(){if(!confirm("Are you sure?"))return;$(this).fadeOut(100),$(this).siblings("span.src").fadeOut(100);var fileInput=$(this).siblings('input[type="file"]'),callback=eval(fileInput.attr("data-callback"));fileInput.val(null),dataHandleInput(fileInput)})},bind:function(e){if(typeof t=="undefined")var t="div#panel";$("div.input-slider div.input-slider-bar",t).each(function(){var e=this,t=parseInt($(this).parents(".input-slider").find("input.input-slider-bar-hidden").val()),n=parseInt($(this).attr("slider_min")),r=parseInt($(this).attr("slider_max")),i=parseInt($(this).attr("slider_interval")),s=$(this).siblings("div.input-slider-bar-text").find(".input-slider-bar-input"),o=function(e,t){Headway.history.add({up:function(){$(e).val(t),$(e).prev().text(t),$(e).parents(".input-slider").find(".input-slider-bar").slider("value",t),dataHandleInput($(e).parents(".input-slider").find("input.input-slider-bar-hidden"),t)},down:function(){var t=$(e).parents(".input-slider").find("input.input-slider-bar-hidden").data("value-original");$(e).val(t),$(e).prev().text(t),$(e).parents(".input-slider").find(".input-slider-bar").slider("value",t),dataHandleInput($(e).parents(".input-slider").find("input.input-slider-bar-hidden"),t)}})};$(this).slider({range:"min",value:t,min:n,max:r,step:i,start:function(e,t){$(this).parents(".input-slider").find("input.input-slider-bar-hidden").data("value-original",t.value)},slide:function(e,t){$(this).siblings("div.input-slider-bar-text").find(".input-slider-bar-input").val(t.value),$(this).parents(".input-slider").find("input.input-slider-bar-hidden").val(t.value),dataHandleInput($(this).parents(".input-slider").find("input.input-slider-bar-hidden"),t.value)},stop:function(e,t){o(s,t.value)}}),s.on("keydown",function(e){var t=e.charCode||e.keyCode||0;return t==8||t==9||t==46||t==110||t>=35&&t<=40||t>=48&&t<=57||t>=96&&t<=105}),s.on("focus",function(e){$(this).parents(".input-slider").find("input.input-slider-bar-hidden").data("value-original",$(this).val())}),s.on("keyup change",function(e){if(e.which===13)return;if(this.value<=r&&this.value>=n){var t=this;o(this,this.value)}}),s.on("blur",function(e){var t=this.value;this.value>r?t=r:this.value<n&&(t=n),o(this,t)})}),$(".repeater-sortable",t).sortable({items:".repeater-group",containment:"parent",forcePlaceholderSize:!0,handle:".sortable-handle",stop:function(){updateRepeaterValues($(this))}}),$(".repeater",t).each(function(){var e=$(this).data("repeater-limit");!isNaN(e)&&e>=1&&$(this).find("div.repeater-group:not(.repeater-group-template):visible").length>=e&&$(this).addClass("limit-met")})}};return panelInputs}),define("modules/panel",["jquery","jqueryUI","deps/jquery.cookie","util.tooltips","modules/panel.inputs"],function(e,t,n,r,i){selectTab=function(e,t){var n=t.find(".ui-tabs-nav"),r=n.find('li[aria-controls="'+e+'"] a').length?n.find('li[aria-controls="'+e+'"] a'):n.find('li[aria-controls="'+e+'-content"] a');return r.trigger("click")},addPanelTab=function(t,n,r,i,s,o){if(e('ul#panel-top li a[href="#'+t+'-tab"]').length!==0)return!1;if(typeof i=="undefined")var i=!1;if(typeof s=="undefined")var s=!1;if(typeof o=="undefined")var o=!1;var u=e('<li><a href="#'+t+'-tab">'+n+"</a></li>").appendTo("div#panel #panel-top"),a=e('<div id="'+t+'-tab"></div>').appendTo("div#panel"),f=u.find("a");e("div#panel").tabs("refresh"),e(f).bind("click",showPanel),showPanel(),e("body").removeClass("panel-empty"),a.addClass("panel");if(typeof r=="string")a.html(r);else{var l=r.url,c=r.data||!1,h=function(){typeof r.callback=="function"&&r.callback.call()};createCog(a,!0),c.mode=Headway.mode,e("div#panel div#"+t+"-tab").load(l,c,h)}return o&&a.addClass("panel-"+o),i&&f.parent().append('<span class="close">X</span>'),f.parent().addClass("tab-close-on-layout-switch"),u},removePanelTab=function(t){var t=t.replace("-tab","");return e("#"+t+"-tab").length===0?!1:(e("#panel").find("#"+t+"-tab").remove(),e("#panel-top").find('a[href="#'+t+'-tab"]').parent().remove(),e("#panel-top").find("li").length||e("body").addClass("panel-empty"),e("div#panel").tabs("refresh"))},removeLayoutSwitchPanels=function(){e("li.tab-close-on-layout-switch").each(function(){var t=e(this).find("a").attr("href").replace("#","");removePanelTab(t)})},togglePanel=function(){return e("div#panel").hasClass("panel-hidden")?showPanel():hidePanel()},hidePanel=function(){if(e("div#panel").hasClass("panel-hidden"))return!1;var t={bottom:-e("div#panel").height()},n={bottom:e("ul#panel-top").outerHeight()};return e("div#panel").css(t).addClass("panel-hidden"),e("div#iframe-container").css(n),setTimeout(repositionTooltips,400),e("body").addClass("panel-hidden"),e("ul#panel-top-right li#minimize span").text("^"),typeof $i=="function"&&$i(".block-selected").removeClass("block-selected block-hover"),e.cookie("hide-panel",!0),!0},showPanel=function(){if(!e("div#panel").hasClass("panel-hidden"))return!1;var t={bottom:0},n={bottom:e("div#panel").outerHeight()};return e("div#panel").css(t).removeClass("panel-hidden"),e("div#iframe-container").css(n),setTimeout(repositionTooltips,400),e("body").removeClass("panel-hidden"),e("ul#panel-top-right li#minimize span").text("g"),e("ul#panel-top > li.ui-state-active a").length&&$i("#"+e("ul#panel-top > li.ui-state-active a").attr("href").replace("#","").replace("-tab","")).addClass("block-selected block-hover"),e.cookie("hide-panel",!1),!0};var s={init:function(){i.delegate(),i.bind()},getPanelMaxHeight:function(){return e(window).height()-275},resizePanel:function(t,n){var r=e("div#panel"),i=r.find("ul#panel-top");if(typeof t=="undefined"||t==0)t=e("div#panel").height();t>s.getPanelMaxHeight()&&(t=s.getPanelMaxHeight()>o?s.getPanelMaxHeight():o),t<o&&(t=o);if(typeof n!="undefined"&&n&&t<s.getPanelMaxHeight())return;r.height(t);var u=r.hasClass("panel-hidden")?i.outerHeight():r.outerHeight(),a=r.hasClass("panel-hidden")?i.outerHeight()+e("div#layout-selector-tabs").height():r.outerHeight()+e("div#layout-selector-tabs").height();e("div#iframe-container").css({bottom:u}),r.hasClass("panel-hidden")&&e("div#panel").css({bottom:-e("div#panel").height()}),e.cookie("panel-height",r.height())}};e("ul#panel-top").find("li").length||e("body").addClass("panel-empty"),e("ul#panel-top").delegate("span.close","click",function(){var t=e(this).siblings("a").attr("href").replace("#","").replace("-tab","");return removePanelTab(t)}),e("div#panel").tabs({tabTemplate:"<li><a href='#{href}'>#{label}</a></li>",add:function(t,n,r){e(n.panel).append(r)},activate:function(t,n){var r=e(n.newTab).children("a").attr("href").replace("#","").replace("-tab","");$i(".block-selected").removeClass("block-selected block-hover"),r.indexOf("block-")===0&&$i("#"+r).addClass("block-selected block-hover")}}),e("ul#panel-top li a").on("click",showPanel),e("div.sub-tab").tabs();var o=120;return e(document).ready(function(){e.cookie("panel-height")&&s.resizePanel(e.cookie("panel-height"))}),e("div#panel").resizable({maxHeight:s.getPanelMaxHeight(),minHeight:120,handles:"n",resize:function(t,n){e(this).css({width:"100%",position:"fixed",bottom:0,top:""}),e("div#iframe-container").css({bottom:e("div#panel").outerHeight()}),showIframeOverlay()},start:function(){showIframeOverlay()},stop:function(){e.cookie("panel-height",e(this).height()),hideIframeOverlay()}}),e(window).bind("resize",function(t){if(t.target!=window)return;e("div#panel").resizable("option",{maxHeight:s.getPanelMaxHeight()}),s.resizePanel(!1,!0)}),e("div#panel-top-container").bind("dblclick",function(e){if(e.target.id!="panel-top-container")return!1;togglePanel()}),e("ul#panel-top-right li#minimize").bind("click",function(e){return togglePanel(),!1}),e.cookie("hide-panel")==="true"&&hidePanel(!0),s}),define("deps/itstylesheet",function(){}),define("util.saving",["jquery","util.loader"],function(e,t){save=function(){if(typeof isSavingAllowed=="undefined"||isSavingAllowed===!1)return!1;if(typeof currentlySaving!="undefined"&&currentlySaving===!0)return!1;currentlySaving=!0,savedTitle=e("title").text(),saveButton=e("span#save-button"),saveButton.text("Saving...").addClass("active").css("cursor","wait"),changeTitle("Visual Editor: Saving"),startTitleActivityIndicator();var t=e.param(GLOBALunsavedValues);e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"save_options",options:t,layout:Headway.currentLayout,mode:Headway.mode},function(t){delete currentlySaving;if(t==="0")return saveButton.stop(!0),saveButton.text("Save"),saveButton.removeClass("active"),saveButton.css("cursor","pointer"),showErrorNotification({id:"error-wordpress-authentication",message:'<strong>Notice!</strong><br /><br />Your WordPress authentication has expired and you must log in before you can save.<br /><br /><a href="'+Headway.adminURL+'" target="_blank">Click Here to log in</a>, then switch back to the window/tab the Visual Editor is in.',closeTimer:!1,closable:!0});if(typeof t.errors!="undefined"||typeof t!="object"&&t!="success"){saveButton.stop(!0),saveButton.text("Save"),saveButton.removeClass("active"),saveButton.css("cursor","pointer");var n="There was an error while saving.  Please try again";return typeof t.errors!="undefined"&&(n+="<br /><ul>",e.each(t.errors,function(e,t){n+="<li>"+t+"</li>"}),n+="</ul>"),showErrorNotification({id:"error-invalid-save-response",message:n,closeTimer:!1,closable:!0})}hideNotification("error-wordpress-authentication"),hideNotification("error-invalid-save-response"),saveButton.animate({boxShadow:"0 0 0 #7dd1e2"},350),setTimeout(function(){saveButton.css("boxShadow",""),saveButton.stop(!0),saveButton.text("Save"),saveButton.removeClass("active"),saveButton.css("cursor","pointer"),typeof t["block-id-mapping"]!="undefined"&&e.each(t["block-id-mapping"],function(t,n){var r=$i('.block[data-temp-id="'+t+'"]');r.attr("id","block-"+n).data("id",n).attr("data-id",n).removeAttr("data-temp-id").removeAttr("data-desired-id").removeData("duplicateOf").removeData("temp-id").removeData("desired-id"),updateBlockContentCover(r);if(e("#block-"+t+"-tab").length){var i=e("#block-"+t+"-tab").find(".sub-tabs .ui-tabs-active").attr("aria-controls");removePanelTab("block-"+t),openBlockOptions(r,i)}}),typeof t["wrapper-id-mapping"]!="undefined"&&e.each(t["wrapper-id-mapping"],function(t,n){var r=$i('.wrapper[data-temp-id="'+t+'"]');r.attr("id","wrapper-"+n).data("id",n).attr("data-id",n).removeData("temp-id").removeData("desired-id"),e("#wrapper-"+t+"-tab").length&&(removePanelTab("wrapper-"+t),openWrapperOptions(n))}),clearUnsavedValues(),typeof t.snapshot!="undefined"&&typeof t.snapshot.timestamp!="undefined"&&(showNotification({id:"snapshot-saved",message:"Snapshot automatically saved.",success:!0}),Headway.viewModels.snapshots.snapshots.unshift({id:t.snapshot.id,timestamp:t.snapshot.timestamp,comments:t.snapshot.comments})),e("li.layout-selected").addClass("layout-item-customized"),disallowSaving(),setTimeout(function(){stopTitleActivityIndicator(),changeTitle(savedTitle),showNotification({id:"saving-complete",message:"Saving Complete!",closeTimer:3500,success:!0})},150)},350),allowVEClose()})},clearUnsavedValues=function(){delete GLOBALunsavedValues},allowSaving=function(){if(Headway.mode=="grid"&&$i(".block").length===0||typeof Headway.overlappingBlocks!="undefined"&&Headway.overlappingBlocks)return disallowSaving();if(typeof isSavingAllowed!="undefined"&&isSavingAllowed===!0)return;return e("body").addClass("allow-saving"),isSavingAllowed=!0,prohibitVEClose(),!0},disallowSaving=function(){return isSavingAllowed=!1,e("body").removeClass("allow-saving"),(typeof Headway.overlappingBlocks=="undefined"||!Headway.overlappingBlocks)&&allowVEClose(),!0}}),function(e){typeof define=="function"&&define.amd?define("deps/jquery.ui.touchpunch",["jquery"],e):e(jQuery)}(function(e){function s(e){var t=window.pageXOffset,n=window.pageYOffset,r=e.clientX,i=e.clientY;if(e.pageY===0&&Math.floor(i)>Math.floor(e.pageY)||e.pageX===0&&Math.floor(r)>Math.floor(e.pageX))r-=t,i-=n;else if(i<e.pageY-n||r<e.pageX-t)r=e.pageX-t,i=e.pageY-n;return{clientX:r,clientY:i}}function o(e,n){if(!t&&e.originalEvent.touches&&e.originalEvent.touches.length>1||t&&!e.isPrimary)return;e.preventDefault();var r;t?r=e.originalEvent:e.originalEvent.changedTouches?r=e.originalEvent.changedTouches[0]:r=e,simulatedEvent=document.createEvent("MouseEvents"),coord=s(r),simulatedEvent.initMouseEvent(n,!0,!0,window,1,r.screenX,r.screenY,coord.clientX,coord.clientY,!1,!1,!1,!1,0,null),e.target.dispatchEvent(simulatedEvent)}var t=window.navigator.pointerEnabled||window.navigator.msPointerEnabled;e.support.touch=e.support.touch||(typeof Modernizr!="undefined"?Modernizr.touch:"ontouchend"in document||"createTouch"in document||t);if(!e.support.touch&&!navigator.msPointerEnabled)return;var n=e.ui.mouse.prototype,r=n._mouseInit,i;n._touchStart=function(e){var n=this;if(i||!t&&!n._mouseCapture(e.originalEvent.changedTouches[0]))return;i=!0,n._touchMoved=!1,o(e,"mouseover"),o(e,"mousemove"),o(e,"mousedown")},n._touchMove=function(e){if(!i)return;this._touchMoved=!0,o(e,"mousemove")},n._touchEnd=function(e){if(!i)return;o(e,"mouseup"),o(e,"mouseout"),this._touchMoved||o(e,"click"),i=!1},n._mouseInit=function(){var n=this;n.element.off("touchstart").off("touchmove").off("touchend"),t?n.element.on("pointerDown",e.proxy(n,"_touchStart")).on("pointerMove",e.proxy(n,"_touchMove")).on("pointerUp",e.proxy(n,"_touchEnd")).on("MSPointerDown",e.proxy(n,"_touchStart")).on("MSPointerMove",e.proxy(n,"_touchMove")).on("MSPointerUp",e.proxy(n,"_touchEnd")):(n.element.on(navigator.msPointerEnabled?"MSPointerDown":"touchstart",e.proxy(n,"_touchStart")).on(navigator.msPointerEnabled?"MSPointerMove":"touchmove",e.proxy(n,"_touchMove")).on(navigator.msPointerEnabled?"MSPointerUp":"touchend",e.proxy(n,"_touchEnd")),n.element.css({msTouchAction:"none"})),r.call(n)}}),function(e){function n(e){var n=jQuery(this);settings=jQuery.extend({},t,e.data);if(typeof n.data("events")!="undefined"&&typeof n.data("events").click!="undefined"){for(var r in n.data("events").click)if(n.data("events").click[r].namespace==""){var i=n.data("events").click[r].handler;n.data("taphold_click_handler",i),n.unbind("click",i);break}}else typeof settings.clickHandler=="function"&&n.data("taphold_click_handler",settings.clickHandler);n.data("taphold_triggered",!1),n.data("taphold_clicked",!1),n.data("taphold_cancelled",!1),n.data("taphold_timer",setTimeout(function(){!n.data("taphold_cancelled")&&!n.data("taphold_clicked")&&(n.trigger(jQuery.extend(e,jQuery.Event("taphold"))),n.data("taphold_triggered",!0))},settings.duration))}function r(e){var t=jQuery(this);if(t.data("taphold_cancelled"))return;clearTimeout(t.data("taphold_timer")),!t.data("taphold_triggered")&&!t.data("taphold_clicked")&&(typeof t.data("taphold_click_handler")=="function"&&t.data("taphold_click_handler")(jQuery.extend(e,jQuery.Event("click"))),t.data("taphold_clicked",!0))}function i(t){e(this).data("taphold_cancelled",!0)}var t={duration:1e3,clickHandler:null},s="ontouchstart"in window||"onmsgesturechange"in window,o=e.event.special.taphold={setup:function(t){e(this).bind(s?"touchstart":"mousedown",t,n).bind(s?"touchend":"mouseup",r).bind(s?"touchmove":"mouseleave",i)},teardown:function(t){e(this).unbind(s?"touchstart":"mousedown",n).unbind(s?"touchend":"mouseup",r).unbind(s?"touchmove":"mouseleave",i)}}}(jQuery),define("deps/jquery.taphold",function(){}),define("util.usability",["jquery","deps/mousetrap"],function(e,t){prohibitVEClose=function(){window.onbeforeunload=function(){return"You have unsaved changes.  Are you sure you wish to leave the Visual Editor?"},allowVECloseSwitch=!1},allowVEClose=function(){window.onbeforeunload=function(){return null},allowVECloseSwitch=!0},disableBadKeys=function(){var t=function(t){var n=e(t.target);if(t.which===8&&!n.is("input")&&!n.is("textarea")&&!n.hasClass("allow-backspace-key")&&!n.parents(".wysiwyg-container").length)return t.preventDefault(),!1;if(t.which===9&&!n.is("input")&&!n.is("textarea")&&!n.hasClass("allow-tab-key")&&!n.parents(".wysiwyg-container").length)return t.preventDefault(),!1;if(t.which==13&&!n.is("textarea")&&!n.hasClass("allow-enter-key")&&!n.parents(".wysiwyg-container").length)return t.preventDefault(),!1};e(document).bind("keypress",t),e(document).bind("keydown",t),$i("html").bind("keypress",t),$i("html").bind("keydown",t)},bindKeyShortcuts=function(){t.bindEventsTo($i("body").get(0));var n=function(t){if(!e(".qtip-tour").is(":visible"))return;e(document.body).qtip("hide")};t.bind("esc",n),t.bindGlobal(["ctrl+s","command+s"],function(e){return save(),!1}),t.bind(["ctrl+p","command+p"],function(e){return togglePanel(),!1}),t.bind("ctrl+l",toggleLayoutSelector),typeof designEditor!="undefined"&&typeof designEditor.processElementCopy=="function"&&(t.bind(["ctrl+c","command+c"],designEditor.processElementCopy),t.bind(["ctrl+v","command+v"],designEditor.processElementPaste),t.bind("ctrl+e",function(){boxOpen("live-css")?closeBox("live-css"):e("#open-live-css").trigger("click")}),t.bind("ctrl+i",toggleInspector),t.bind("tab",toggleDesignEditor))},Headway.touch&&require(["deps/jquery.ui.touchpunch","deps/jquery.taphold"],function(){})}),define("modules/iframe",["jquery","deps/itstylesheet","util.saving","util.usability","util.tooltips"],function(e,t,n){$i=function(t){return typeof Headway.iframe=="undefined"||typeof Headway.iframe.contents()=="undefined"?e():Headway.iframe.contents().find(t)},$iDocument=function(){return e(Headway.iframe.contents())},loadIframe=function(e,t){if(typeof t=="undefined"||!t)var t=Headway.homeURL;var n=Headway.iframe;startTitleActivityIndicator(),showIframeLoadingOverlay(),closeBox("grid-wizard"),iframeURL=t,iframeURL=updateQueryStringParameter(iframeURL,"ve-iframe","true"),iframeURL=updateQueryStringParameter(iframeURL,"ve-layout",Headway.currentLayout),iframeURL=updateQueryStringParameter(iframeURL,"ve-iframe-mode",Headway.mode),iframeURL=updateQueryStringParameter(iframeURL,"rand",Math.floor(Math.random()*100000001)),n.contents().find(".ui-headway-grid").length&&typeof n.contents().find(".ui-headway-grid").headwayGrid!="undefined"&&n.contents().find(".ui-headway-grid").headwayGrid("destroy"),n.contents().find("*").unbind().remove(),n[0].src=iframeURL,waitForIframeLoad(e,n)},waitForIframeLoad=function(e,t){if(typeof t=="undefined"||!t)var t=Headway.iframe;return typeof iframeTimeout=="undefined"&&(iframeTimeout=setTimeout(r.loadTimeout,4e4)),typeof t=="undefined"||t.contents().find("body.iframe-loaded").length!=1?setTimeout(function(){waitForIframeLoad(e,t)},100):(clearTimeout(iframeTimeout),r.loadCallback(e))},showIframeOverlay=function(){var t=e("div#iframe-overlay");t.show()},hideIframeOverlay=function(t){if(typeof t!="undefined"&&t==0)return e("div#iframe-overlay").hide();setTimeout(function(){e("div#iframe-overlay").hide()},250)},showIframeLoadingOverlay=function(){return e("div#iframe-container").css("overflow","hidden"),e("div#iframe-loading-overlay").css({top:e("div#iframe-container").scrollTop()}),e("div#iframe-loading-overlay").is(":visible")||(createCog(e("div#iframe-loading-overlay"),!0),e("div#iframe-loading-overlay").show()),e("div#iframe-loading-overlay")},hideIframeLoadingOverlay=function(){e("div#iframe-container").css("overflow","auto"),e("div#iframe-loading-overlay").hide().html("")};var r={init:function(){e(document).ready(function(){Headway.iframe=e("iframe#content"),r.bindFocusBlur()})},bindFocusBlur:function(){Headway.iframe.on("mouseleave",function(){e(this).trigger("blur"),$i("[data-hasqtip]").qtip("disable",!0)}),Headway.iframe.on("mouseenter mousedown",function(){if(e("textarea:focus, input:focus").length===1)return;$i("[data-hasqtip]").qtip("enable"),e(this).trigger("focus")})},loadCallback:function(t){return clearUnsavedValues(),typeof t=="function"&&t(),r.defaultLoadCallback(),r.stopFirefoxLoadingIndicator(),e("body").triggerHandler("headwayIframeLoad"),!0},defaultLoadCallback:function(){stopTitleActivityIndicator(),changeTitle("Visual Editor: "+Headway.currentLayoutName),e("span#current-layout").text(Headway.currentLayoutName),setupTooltips(),setupTooltips("iframe"),stylesheet=new ITStylesheet({document:Headway.iframe.contents()[0],href:Headway.homeURL+"/?headway-trigger=compiler&file=general-design-editor"},"find"),css=new ITStylesheet({document:Headway.iframe.contents()[0]},"load"),hideIframeOverlay(!1),Headway.currentLayoutTemplate&&(showIframeOverlay(),$i("body").prepend('<div id="no-edit-notice"><div><h1>To edit this layout, remove the shared layout from this layout.</h1></div></div>')),disableBadKeys(),bindKeyShortcuts(),$i("html, body").bind("keydown",function(t){e(document).trigger(t),t.stopPropagation()}),$i("html, body").bind("keypress",function(t){e(document).trigger(t),t.stopPropagation()}),$i("html, body").bind("keyup",function(t){e(document).trigger(t),t.stopPropagation()}),Headway.touch&&Headway.iframe.contents().find("body").css("-webkit-touch-callout","none"),Headway.iframe.contents().find("body").delegate('a, input[type="submit"], button',"click",function(t){if(e(this).hasClass("allow-click"))return;return t.preventDefault(),!1}),typeof headwayIframeLoadNotification!="undefined"&&(showNotification({id:"iframe-load-notification",message:headwayIframeLoadNotification,overwriteExisting:!0}),delete headwayIframeLoadNotification),removeLayoutSwitchPanels();var t=e('div#layout-selector span.layout[data-layout-id="'+Headway.currentLayout+'"]'),n=t.parent();!$i(".block").length&&(!Headway.currentLayoutCustomized||Headway.currentLayout.indexOf("template-")===0)&&!Headway.currentLayoutTemplate&&Headway.mode=="grid"?(hidePanel(),e(document).ready(function(){openBox("grid-wizard")})):closeBox("grid-wizard"),hideIframeLoadingOverlay()},loadTimeout:function(){iframeTimeout=!0,stopTitleActivityIndicator(),changeTitle("Visual Editor: Error!"),e("#iframe-container, #menu, #panel, #layout-selector-offset").hide(),alert("ERROR: There was a problem while loading the visual editor.\n\nYour browser will automatically refresh to attempt loading again."),document.location.reload(!0)},stopFirefoxLoadingIndicator:function(){if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){var e;e==null&&(e=document.createElement("iframe"),e.style.display="none"),document.body.appendChild(e),document.body.removeChild(e)}}};return r}),function(e,t,n){function s(t,n){this.name=r,this.el=t,this.$el=e(t),this.options=e.extend({},i,n),this.$document=e(this.$el[0].ownerDocument),this.$body=this.$document.find("body"),this.moveTrigger="MSPointerMove touchmove mousemove",this.startTrigger="MSPointerDown touchstart mousedown",this.stopTrigger="MSPointerUp touchend mouseup",this.startTriggerArray=this.startTrigger.split(" "),this.moveTriggerArray=this.moveTrigger.split(" "),this.stopTriggerArray=this.stopTrigger.split(" "),this.stopEvents=[this.stopTrigger,this.options.stopEvents].join(" "),this.options.constrainTo==="window"?this.$container=this.$document:this.options.constrainTo&&this.options.constrainTo!=="parent"?this.$container=e(this.options.constrainTo):this.$container=this.$el.parent(),this.isPointerEventCompatible()&&this.applyMSDefaults(),this.CSSEaseHash=this.getCSSEaseHash(),this.scale=1,this.started=!1,this.disabled=!1,this.resetVelocityQueue(),this.init()}var r="pep",i={initiate:function(){},start:function(){},drag:function(){},stop:function(){},rest:function(){},moveTo:!1,callIfNotStarted:["stop","rest"],startThreshold:[0,0],grid:[1,1],debug:!1,activeClass:"pep-active",multiplier:1,velocityMultiplier:2.5,shouldPreventDefault:!0,allowDragEventPropagation:!0,stopEvents:"",hardwareAccelerate:!0,useCSSTranslation:!0,disableSelect:!0,cssEaseString:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",cssEaseDuration:1e3,shouldEase:!0,droppable:!1,droppableActiveClass:"pep-dpa",overlapFunction:!1,constrainTo:!1,removeMargins:!0,place:!0,deferPlacement:!1,axis:null,forceNonCSS3Movement:!1,elementsWithInteraction:"input",revert:!1,revertAfter:"stop",revertIf:function(){return!0}};s.prototype.init=function(){this.options.debug&&this.buildDebugDiv(),this.options.disableSelect&&this.disableSelect(),this.options.place&&!this.options.deferPlacement&&(this.positionParent(),this.placeObject()),this.ev={},this.pos={},this.subscribe()},s.prototype.subscribe=function(){var e=this;this.$el.on(this.startTrigger,function(t){e.handleStart(t)}),this.$el.on(this.startTrigger,this.options.elementsWithInteraction,function(e){e.stopPropagation()}),this.$document.on(this.stopEvents,function(t){e.handleStop(t)}),this.$document.on(this.moveTrigger,function(t){e.moveEvent=t})},s.prototype.handleStart=function(t){var n=this;if(this.isValidMoveEvent(t)&&!this.disabled){this.isPointerEventCompatible()&&t.preventManipulation&&t.preventManipulation(),t=this.normalizeEvent(t),this.options.place&&this.options.deferPlacement&&(this.positionParent(),this.placeObject()),this.log({type:"event",event:t.type}),this.options.hardwareAccelerate&&!this.hardwareAccelerated&&(this.hardwareAccelerate(),this.hardwareAccelerated=!0);var r=this.options.initiate.call(this,t,this);if(r===!1)return;clearTimeout(this.restTimeout),this.$el.addClass(this.options.activeClass),this.removeCSSEasing(),this.startX=this.ev.x=t.pep.x,this.startY=this.ev.y=t.pep.y,this.initialPosition=this.initialPosition||this.$el.position(),this.startEvent=this.moveEvent=t,this.active=!0,this.options.shouldPreventDefault&&t.preventDefault(),this.options.allowDragEventPropagation||t.stopPropagation(),function i(){if(!n.active)return;n.handleMove(),n.requestAnimationFrame(i)}(e,n)}},s.prototype.handleMove=function(){if(typeof this.moveEvent=="undefined")return;var n=this.normalizeEvent(this.moveEvent),r=t.parseInt(n.pep.x/this.options.grid[0])*this.options.grid[0],i=t.parseInt(n.pep.y/this.options.grid[1])*this.options.grid[1];this.addToLIFO({time:n.timeStamp,x:r,y:i});var s,o;e.inArray(n.type,this.startTriggerArray)>-1?(s=0,o=0):(s=r-this.ev.x,o=i-this.ev.y),this.dx=s,this.dy=o,this.ev.x=r,this.ev.y=i;if(s===0&&o===0){this.log({type:"event",event:"** stopped **"});return}var u=Math.abs(this.startX-r),a=Math.abs(this.startY-i);!this.started&&(u>this.options.startThreshold[0]||a>this.options.startThreshold[1])&&(this.started=!0,this.$el.addClass("pep-start"),this.options.start.call(this,this.startEvent,this)),this.options.droppable&&this.calculateActiveDropRegions();var f=this.options.drag.call(this,n,this);if(f===!1){this.resetVelocityQueue();return}this.log({type:"event",event:n.type}),this.log({type:"event-coords",x:this.ev.x,y:this.ev.y}),this.log({type:"velocity"});var l=this.handleConstraint(s,o),c,h;typeof this.options.moveTo=="function"?(c=s>=0?"+="+Math.abs(s/this.scale)*this.options.multiplier:"-="+Math.abs(s/this.scale)*this.options.multiplier,h=o>=0?"+="+Math.abs(o/this.scale)*this.options.multiplier:"-="+Math.abs(o/this.scale)*this.options.multiplier,this.options.constrainTo&&(c=l.x!==!1?l.x:c,h=l.y!==!1?l.y:h),this.options.axis==="x"&&(h=l.y),this.options.axis==="y"&&(c=l.x),this.options.moveTo.call(this,c,h)):this.shouldUseCSSTranslation()?(s=s/this.scale*this.options.multiplier,o=o/this.scale*this.options.multiplier,this.options.constrainTo&&(s=l.x===!1?s:0,o=l.y===!1?o:0),this.options.axis==="x"&&(o=0),this.options.axis==="y"&&(s=0),this.moveToUsingTransforms(s,o)):(c=s>=0?"+="+Math.abs(s/this.scale)*this.options.multiplier:"-="+Math.abs(s/this.scale)*this.options.multiplier,h=o>=0?"+="+Math.abs(o/this.scale)*this.options.multiplier:"-="+Math.abs(o/this.scale)*this.options.multiplier,this.options.constrainTo&&(c=l.x!==!1?l.x:c,h=l.y!==!1?l.y:h),this.options.axis==="x"&&(h=l.y),this.options.axis==="y"&&(c=l.x),this.moveTo(c,h))},s.prototype.handleStop=function(t){if(!this.active)return;this.log({type:"event",event:t.type}),this.active=!1,this.$el.removeClass("pep-start").addClass("pep-ease"),this.options.droppable&&this.calculateActiveDropRegions(),(this.started||!this.started&&e.inArray("stop",this.options.callIfNotStarted)>-1)&&this.options.stop.call(this,t,this),this.options.shouldEase?this.ease(t,this.started):this.removeActiveClass(),this.options.revert&&(this.options.revertAfter==="stop"||!this.options.shouldEase)&&this.options.revertIf&&this.options.revertIf()&&this.revert(),this.started=!1,this.resetVelocityQueue()},s.prototype.ease=function(t,n){var r=this.$el.position(),i=this.velocity(),s=this.dt,o=i.x/this.scale*this.options.multiplier,u=i.y/this.scale*this.options.multiplier,a=this.handleConstraint(o,u,!0);this.cssAnimationsSupported()&&this.$el.css(this.getCSSEaseHash());var f=i.x>0?"+="+o:"-="+Math.abs(o),l=i.y>0?"+="+u:"-="+Math.abs(u);this.options.constrainTo&&(f=a.x!==!1?a.x:f,l=a.y!==!1?a.y:l),this.options.axis==="x"&&(l="+=0"),this.options.axis==="y"&&(f="+=0");var c=!this.cssAnimationsSupported()||this.options.forceNonCSS3Movement;typeof this.options.moveTo=="function"?this.options.moveTo.call(this,f,l):this.moveTo(f,l,c);var h=this;this.restTimeout=setTimeout(function(){h.options.droppable&&h.calculateActiveDropRegions(),(n||!n&&e.inArray("rest",h.options.callIfNotStarted)>-1)&&h.options.rest.call(h,t,h),h.options.revert&&h.options.revertAfter==="ease"&&h.options.shouldEase&&h.options.revertIf&&h.options.revertIf()&&h.revert(),h.removeActiveClass()},this.options.cssEaseDuration)},s.prototype.normalizeEvent=function(e){return e.pep={},this.isPointerEventCompatible()||!this.isTouch(e)?(e.pageX?(e.pep.x=e.pageX,e.pep.y=e.pageY):(e.pep.x=e.originalEvent.pageX,e.pep.y=e.originalEvent.pageY),e.pep.type=e.type):(e.pep.x=e.originalEvent.touches[0].pageX,e.pep.y=e.originalEvent.touches[0].pageY,e.pep.type=e.type),e},s.prototype.resetVelocityQueue=function(){this.velocityQueue=new Array(5)},s.prototype.moveTo=function(e,t,n){this.log({type:"delta",x:e,y:t}),n?this.$el.animate({top:t,left:e},this.options.cssEaseDuration/2,"easeOutQuad",{queue:!1}):this.$el.stop(!0,!1).css({top:t,left:e})},s.prototype.moveToUsingTransforms=function(e,t){var n=this.matrixToArray(this.matrixString());this.cssX||(this.cssX=this.xTranslation(n)),this.cssY||(this.cssY=this.yTranslation(n)),this.cssX=this.cssX+e,this.cssY=this.cssY+t,this.log({type:"delta",x:e,y:t}),n[4]=this.cssX,n[5]=this.cssY,this.translation=this.arrayToMatrix(n),this.transform(this.translation)},s.prototype.transform=function(e){this.$el.css({"-webkit-transform":e,"-moz-transform":e,"-ms-transform":e,"-o-transform":e,transform:e})},s.prototype.xTranslation=function(e){return e=e||this.matrixToArray(this.matrixString()),parseInt(e[4],10)},s.prototype.yTranslation=function(e){return e=e||this.matrixToArray(this.matrixString()),parseInt(e[5],10)},s.prototype.matrixString=function(){var e=function(e){return!(!e||e==="none"||e.indexOf("matrix")<0)},t="matrix(1, 0, 0, 1, 0, 0)";return e(this.$el.css("-webkit-transform"))&&(t=this.$el.css("-webkit-transform")),e(this.$el.css("-moz-transform"))&&(t=this.$el.css("-moz-transform")),e(this.$el.css("-ms-transform"))&&(t=this.$el.css("-ms-transform")),e(this.$el.css("-o-transform"))&&(t=this.$el.css("-o-transform")),e(this.$el.css("transform"))&&(t=this.$el.css("transform")),t},s.prototype.matrixToArray=function(e){return e.split("(")[1].split(")")[0].split(",")},s.prototype.arrayToMatrix=function(e){return"matrix("+e.join(",")+")"},s.prototype.addToLIFO=function(e){var t=this.velocityQueue;t=t.slice(1,t.length),t.push(e),this.velocityQueue=t},s.prototype.velocity=function(){var e=0,t=0;for(var n=0;n<this.velocityQueue.length-1;n++)this.velocityQueue[n]&&(e+=this.velocityQueue[n+1].x-this.velocityQueue[n].x,t+=this.velocityQueue[n+1].y-this.velocityQueue[n].y,this.dt=this.velocityQueue[n+1].time-this.velocityQueue[n].time);return{x:e*this.options.velocityMultiplier,y:t*this.options.velocityMultiplier}},s.prototype.revert=function(){this.shouldUseCSSTranslation()&&this.moveToUsingTransforms(-this.xTranslation(),-this.yTranslation()),this.moveTo(this.initialPosition.left,this.initialPosition.top)},s.prototype.requestAnimationFrame=function(e){return t.requestAnimationFrame&&t.requestAnimationFrame(e)||t.webkitRequestAnimationFrame&&t.webkitRequestAnimationFrame(e)||t.mozRequestAnimationFrame&&t.mozRequestAnimationFrame(e)||t.oRequestAnimationFrame&&t.mozRequestAnimationFrame(e)||t.msRequestAnimationFrame&&t.msRequestAnimationFrame(e)||t.setTimeout(e,1e3/60)},s.prototype.positionParent=function(){if(!this.options.constrainTo||this.parentPositioned)return;this.parentPositioned=!0,this.options.constrainTo==="parent"?this.$container.css({position:"relative"}):this.options.constrainTo==="window"&&this.$container.get(0).nodeName!=="#document"&&this.$container.css("position")!=="static"&&this.$container.css({position:"static"})},s.prototype.placeObject=function(){if(this.objectPlaced)return;this.objectPlaced=!0,this.offset=this.options.constrainTo==="parent"||this.hasNonBodyRelative()?this.$el.position():this.$el.offset(),parseInt(this.$el.css("left"),10)&&(this.offset.left=this.$el.css("left")),parseInt(this.$el.css("top"),10)&&(this.offset.top=this.$el.css("top")),this.options.removeMargins&&this.$el.css({margin:0}),this.$el.css({position:"absolute",top:this.offset.top,left:this.offset.left})},s.prototype.hasNonBodyRelative=function(){return this.$el.parents().filter(function(){var t=e(this);return t.is("body")||t.css("position")==="relative"}).length>1},s.prototype.setScale=function(e){this.scale=e},s.prototype.setMultiplier=function(e){this.options.multiplier=e},s.prototype.removeCSSEasing=function(){this.cssAnimationsSupported()&&this.$el.css(this.getCSSEaseHash(!0))},s.prototype.disableSelect=function(){this.$el.css({"-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"})},s.prototype.removeActiveClass=function(){this.$el.removeClass([this.options.activeClass,"pep-ease"].join(" "))},s.prototype.handleConstraint=function(t,r,i){var s=this,o=this.$el.position();this.pos.x=o.left,this.pos.y=o.top;var u={x:!1,y:!1},a,f,l,c;this.log({type:"pos-coords",x:this.pos.x,y:this.pos.y});if(e.isArray(this.options.constrainTo))this.options.constrainTo[3]!==n&&this.options.constrainTo[1]!==n&&(f=this.options.constrainTo[1]===!1?Infinity:this.options.constrainTo[1],l=this.options.constrainTo[3]===!1?-Infinity:this.options.constrainTo[3]),this.options.constrainTo[0]!==!1&&this.options.constrainTo[2]!==!1&&(a=this.options.constrainTo[2]===!1?Infinity:this.options.constrainTo[2],c=this.options.constrainTo[0]===!1?-Infinity:this.options.constrainTo[0]),this.pos.x+t<l&&(u.x=l),this.pos.y+r<c&&(u.y=c);else if(typeof this.options.constrainTo=="string"){l=0,c=0,f=this.$container.width()-this.$el.outerWidth(),a=this.$container.height()-this.$el.outerHeight(),this.$el.each(function(){e(this).position().left+t<0&&(u.x=0),e(this).position().top+r<0&&(u.y=0)});var h=this.$container[0].getBoundingClientRect(),p=this.ev.x>h.left&&this.ev.x<h.right&&this.ev.y>h.top+e(this.$el[0].ownerDocument).scrollTop()&&this.ev.y<h.bottom+e(this.$el[0].ownerDocument).scrollTop();p||(u.x=l,u.y=c)}return this.$el.each(function(){f=s.$container.width()-e(this).outerWidth(),a=s.$container.height()-e(this).outerHeight(),e(this).position().left+t>f&&(u.x=f),e(this).position().top+r>a&&(u.y=a)}),this.shouldUseCSSTranslation()&&i&&(u.x===l&&this.xTranslation()&&(u.x=l-this.xTranslation()),u.x===f&&this.xTranslation()&&(u.x=f-this.xTranslation()),u.y===c&&this.yTranslation()&&(u.y=c-this.yTranslation()),u.y===a&&this.yTranslation()&&(u.y=a-this.yTranslation())),u},s.prototype.getCSSEaseHash=function(e){typeof e=="undefined"&&(e=!1);var t;if(e)t="";else{if(this.CSSEaseHash)return this.CSSEaseHash;t=["all",this.options.cssEaseDuration+"ms",this.options.cssEaseString].join(" ")}return{"-webkit-transition":t,"-moz-transition":t,"-ms-transition":t,"-o-transition":t,transition:t}},s.prototype.calculateActiveDropRegions=function(){var t=this;this.activeDropRegions=[],e.each(e(this.options.droppable),function(n,r){var i=e(r);t.isOverlapping(i,t.$el)?(i.addClass(t.options.droppableActiveClass),t.activeDropRegions.push(i)):i.removeClass(t.options.droppableActiveClass)})},s.prototype.isOverlapping=function(e,t){if(this.options.overlapFunction)return this.options.overlapFunction(e,t);var n=e[0].getBoundingClientRect(),r=t[0].getBoundingClientRect();return!(n.right<r.left||n.left>r.right||n.bottom<r.top||n.top>r.bottom)},s.prototype.isTouch=function(e){return e.type.search("touch")>-1},s.prototype.isPointerEventCompatible=function(){return"MSPointerEvent"in t},s.prototype.applyMSDefaults=function(e){this.$el.css({"-ms-touch-action":"none","touch-action":"none","-ms-scroll-chaining":"none","-ms-scroll-limit":"0 0 0 0"})},s.prototype.isValidMoveEvent=function(e){return!this.isTouch(e)||this.isTouch(e)&&e.originalEvent.touches&&e.originalEvent.touches.length===1},s.prototype.shouldUseCSSTranslation=function(){if(typeof this.useCSSTranslation!="undefined")return this.useCSSTranslation;var e=!1;return!this.options.useCSSTranslation||typeof Modernizr!="undefined"&&!Modernizr.csstransforms?e=!1:e=!0,this.useCSSTranslation=e,e},s.prototype.cssAnimationsSupported=function(){if(typeof this.cssAnimationsSupport!="undefined")return this.cssAnimationsSupport;if(typeof Modernizr!="undefined"&&Modernizr.cssanimations)return this.cssAnimationsSupport=!0,!0;var e=!1,t=document.createElement("div"),r="animation",i="",s="Webkit Moz O ms Khtml".split(" "),o="";t.style.animationName&&(e=!0);if(e===!1)for(var u=0;u<s.length;u++)if(t.style[s[u]+"AnimationName"]!==n){o=s[u],r=o+"Animation",i="-"+o.toLowerCase()+"-",e=!0;break}return this.cssAnimationsSupport=e,e},s.prototype.hardwareAccelerate=function(){this.$el.css({"-webkit-perspective":1e3,perspective:1e3,"-webkit-backface-visibility":"hidden","backface-visibility":"hidden"})},s.prototype.getMovementValues=function(){return{ev:this.ev,pos:this.pos,velocity:this.velocity()}},s.prototype.buildDebugDiv=function(){var t;e("#pep-debug").length===0&&(t=e("<div></div>"),t.attr("id","pep-debug").append("<div style='font-weight:bold; background: red; color: white;'>DEBUG MODE</div>").append("<div id='pep-debug-event'>no event</div>").append("<div id='pep-debug-ev-coords'>event coords: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").append("<div id='pep-debug-pos-coords'>position coords: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").append("<div id='pep-debug-velocity'>velocity: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").append("<div id='pep-debug-delta'>&Delta; movement: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").css({position:"fixed",bottom:5,right:5,zIndex:99999,textAlign:"right",fontFamily:"Arial, sans",fontSize:10,border:"1px solid #DDD",padding:"3px",background:"white",color:"#333"}));var n=this;setTimeout(function(){n.debugElements={$event:e("#pep-debug-event"),$velocityX:e("#pep-debug-velocity .pep-x"),$velocityY:e("#pep-debug-velocity .pep-y"),$dX:e("#pep-debug-delta .pep-x"),$dY:e("#pep-debug-delta .pep-y"),$evCoordsX:e("#pep-debug-ev-coords .pep-x"),$evCoordsY:e("#pep-debug-ev-coords .pep-y"),$posCoordsX:e("#pep-debug-pos-coords .pep-x"),$posCoordsY:e("#pep-debug-pos-coords .pep-y")}},0),e("body").append(t)},s.prototype.log=function(e){if(!this.options.debug)return;switch(e.type){case"event":this.debugElements.$event.text(e.event);break;case"pos-coords":this.debugElements.$posCoordsX.text(e.x),this.debugElements.$posCoordsY.text(e.y);break;case"event-coords":this.debugElements.$evCoordsX.text(e.x),this.debugElements.$evCoordsY.text(e.y);break;case"delta":this.debugElements.$dX.text(e.x),this.debugElements.$dY.text(e.y);break;case"velocity":var t=this.velocity();this.debugElements.$velocityX.text(Math.round(t.x)),this.debugElements.$velocityY.text(Math.round(t.y))}},s.prototype.toggle=function(e){typeof e=="undefined"?this.disabled=!this.disabled:this.disabled=!e},e.extend(e.easing,{easeOutQuad:function(e,t,n,r,i){return-r*(t/=i)*(t-2)+n},easeOutCirc:function(e,t,n,r,i){return r*Math.sqrt(1-(t=t/i-1)*t)+n},easeOutExpo:function(e,t,n,r,i){return t===i?n+r:r*(-Math.pow(2,-10*t/i)+1)+n}}),e.fn[r]=function(t){return this.each(function(){if(!e.data(this,"plugin_"+r)){var n=new s(this,t);e.data(this,"plugin_"+r,n),e.pep.peps.push(n)}})},e.pep={},e.pep.peps=[],e.pep.toggleAll=function(t){e.each(this.peps,function(e,n){n.toggle(t)})},e.pep.unbind=function(e){var t=e.data("plugin_"+r);if(typeof t=="undefined")return;t.toggle(!1),e.removeData("plugin_"+r)}}(jQuery,window),define("deps/jquery.pep",function(){}),define("helper.boxes",["modules/iframe","deps/jquery.pep"],function(iframe){createBox=function(e){var t={},n={id:null,title:null,description:null,content:null,src:null,load:null,width:500,height:300,center:!0,closable:!0,resizable:!1,draggable:!0,deleteWhenClosed:!1,blackOverlay:!1,blackOverlayOpacity:.6,blackOverlayIframe:!1};$.extend(t,n,e);var r=$('<div class="box" id="box-'+t.id+'"><div class="box-top"></div><div class="box-content-bg"><div class="box-content"></div></div></div>');return r.attr("black_overlay",t.blackOverlay),r.attr("black_overlay_opacity",t.blackOverlayOpacity),r.attr("black_overlay_iframe",t.blackOverlayIframe),r.attr("load_with_ajax",!1),r.appendTo("div#boxes"),typeof t.src!="string"?r.find(".box-content").html(t.content):(r.find(".box-content").addClass("box-content-with-iframe"),r.find(".box-content").html('<iframe src="'+t.src+'"></iframe>'),typeof t.load=="function"&&r.find(".box-content iframe").bind("load",t.load)),r.find(".box-top").append("<strong>"+t.title+"</strong>"),typeof t.description=="string"&&r.find(".box-top").append("<span>"+t.description+"</span>"),setupBox(t.id,t),r},setupBox=function(e,t){var n={},r={width:600,height:300,center:!0,closable:!0,deleteWhenClosed:!1,draggable:!1,resizable:!1};$.extend(n,r,t);var i=$("div#box-"+e);n.draggable&&(i.draggable({handle:i.find(".box-top"),start:showIframeOverlay,stop:hideIframeOverlay,shouldEase:!1}),i.find(".box-top").css("cursor","move")),n.closable&&(i.find(".box-top").append('<span class="box-close">X</span>'),i.find(".box-close").bind("click",function(){closeBox(e,n.deleteWhenClosed)})),n.resizable&&i.resizable({start:showIframeOverlay,stop:hideIframeOverlay,handles:"n, e, s, w, ne, se, sw, nw",minWidth:n.minWidth,minHeight:n.minHeight}),i.css({width:n.width,height:n.height});if(n.center){var s=-(i.width()/2),o=-(i.height()/2);i.css({top:"50%",left:"50%",marginLeft:s,marginTop:o})}},setupStaticBoxes=function(){$("div.box").each(function(){var e=hwBoolean($(this).attr("draggable")),t=hwBoolean($(this).attr("closable")),n=hwBoolean($(this).attr("resizable")),r=hwBoolean($(this).attr("center")),i=$(this).attr("width"),s=$(this).attr("height"),o=$(this).attr("min_width"),u=$(this).attr("min_height"),a=$(this).attr("id").replace("box-","");setupBox(a,{draggable:e,closable:t,resizable:n,center:r,width:i,height:s,minWidth:o,minHeight:u}),$(this).attr("draggable",null),$(this).attr("closable",null),$(this).attr("resizable",null),$(this).attr("center",null),$(this).attr("width",null),$(this).attr("height",null),$(this).attr("min_width",null),$(this).attr("min_height",null)})},openBox=function(id){var id=id.replace("box-",""),box=$("div#box-"+id);if(box.length===0)return!1;var blackOverlay=hwBoolean(box.attr("black_overlay")),blackOverlayOpacity=box.attr("black_overlay_opacity"),blackOverlayIframe=hwBoolean(box.attr("black_overlay_iframe")),loadWithAjax=hwBoolean(box.attr("load_with_ajax"));if(blackOverlay&&!boxOpen(id)){var overlay=$('<div class="black-overlay"></div>').hide().attr("id","black-overlay-box-"+id).appendTo("#boxes");blackOverlayIframe===!0&&overlay.css("zIndex",4),isNaN(blackOverlayOpacity)||overlay.css("background","rgba(0, 0, 0, "+blackOverlayOpacity+")"),overlay.show()}return loadWithAjax&&!box.data("currently-ajax-loading")&&(box.find("*").removeData(),box.find(".box-content *").remove(),createCog(box.find(".box-content"),!0),box.data("currently-ajax-loading",!0),box.find(".box-content").load(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"load_box_ajax_content",box_id:id,layout:Headway.currentLayout},function(){var loadWithAjaxCallback=eval(box.attr("load_with_ajax_callback"));loadWithAjaxCallback.call(),box.removeData("currently-ajax-loading")})),box.show()},closeBox=function(e,t){var e=e.replace("box-",""),n=$("div#box-"+e);return n.hide(),typeof t!="undefined"&&t==1&&n.remove(),$("div#black-overlay-box-"+e).remove(),!0},boxOpen=function(e){return $("div#box-"+e).is(":visible")},boxExists=function(e){return $("div#box-"+e).length===1?!0:!1},toggleBox=function(e){boxOpen(e)?closeBox(e):openBox(e)},setupStaticBoxes(),$("#boxes").on("click","div.black-overlay",function(){var e=$(this).attr("id").replace("black-overlay-","");if($("#"+e).length===0)return;if($(".qtip-tour").is(":visible"))return;closeBox(e)})}),define("helper.history",["jquery","modules/iframe","deps/mousetrap"],function(e,t,n){var r=function(e){this.settings={limit:20,call:!0},this.set(e),this.clear()};r.prototype.set=function(e){for(var t in e)this.settings[t]=e[t];return this},r.prototype.add=function(e){return this.redos=[],!e instanceof r.Occurence&&(e=new r.Occurence(e)),this.undos.unshift(e),(e.call===!0||typeof e.call=="undefined"&&this.settings.call===!0)&&e.up(),this.settings.limit&&this.undos.splice(this.settings.limit),typeof this.settings.onAdd=="function"&&this.settings.onAdd(e),this},r.prototype.clear=function(){return this.redos=[],this.undos=[],typeof this.settings.onClear=="function"&&this.settings.onClear(),this},r.prototype.revert=function(){var e;while(e=this.undos.shift())e.down();return this.clear()},r.prototype.undo=function(){var e;if(e=this.undos.shift())this.redos.unshift(e),e.down(),typeof this.settings.onUndo=="function"&&this.settings.onUndo(e),this.undos.length==0&&typeof this.settings.onBegin=="function"&&this.settings.onBegin(e);return this},r.prototype.redo=function(){var e;if(e=this.redos.shift())this.undos.unshift(e),e.up(),typeof this.settings.onRedo=="function"&&this.settings.onRedo(e),this.redos.length==0&&typeof this.settings.onEnd=="function"&&this.settings.onEnd(e);return this},r.Occurence=function(e){e=e||{},this.up=e.up||function(){},this.down=e.down||function(){}};var i={init:function(){Headway.history=new r({limit:0}),i.bind()},bind:function(){n.bind(["ctrl+z","command+z"],function(e){return Headway.history.undo(),!1}),n.bind(["ctrl+y","command+y"],function(e){return Headway.history.redo(),!1})}};return i}),define("helper.blocks",["modules/panel.inputs","helper.history"],function(panelInputs,history){getBlockByID=function(e){var e=e.toString().replace("block-","");return $i('.block[data-id="'+e+'"]')},getBlock=function(e){return $(e).length===0?$():($(e).hasClass("block")?block=$(e):$(e).parents(".block").length===1?block=$(e).parents(".block"):block=!1,block)},getBlockID=function(e){var t=getBlock(e);return t?t.data("id"):!1},getBlockWrapper=function(e){var t=getBlock(e);return t.closest(".wrapper")},getBlockType=function(e){var t=getBlock(e);return t?t.data("type"):!1},getBlockTypeNice=function(e){return typeof e!="string"?!1:getBlockTypeObject(e).name},getBlockTypeIcon=function(e,t){return typeof t=="undefined"&&(t=!1),typeof Headway.allBlockTypes[e]!="object"?null:t===!0?Headway.blockTypeURLs[e]+"/icon-white.png":Headway.blockTypeURLs[e]+"/icon.png"},getBlockTypeObject=function(e){var t=Headway.allBlockTypes;return typeof t[e]=="undefined"?{"fixed-height":!1}:t[e]},getBlockGridWidth=function(e){var t=getBlock(e);return t?t.attr("data-width"):!1},setBlockGridWidth=function(e,t){var n=getBlock(e);if(!n)return!1;var r=n.attr("data-width");return r&&n.removeClass("grid-width-"+r),n.css("width",""),n.addClass("grid-width-"+t),n.attr("data-width",String(t).replace("grid-width-","")),n},getBlockGridLeft=function(e){var t=getBlock(e);return t?t.attr("data-grid-left"):!1},setBlockGridLeft=function(e,t){var n=getBlock(e);if(!n)return!1;var r=getBlockGridLeft(n);return r&&n.removeClass("grid-left-"+r),n.addClass("grid-left-"+t),n.attr("data-grid-left",String(t).replace("grid-left-","")),n},getBlockDimensions=function(e){var t=getBlock(e);return t?{width:getBlockGridWidth(t),height:t.attr("data-height")}:!1},getBlockDimensionsPixels=function(e){var t=getBlock(e);return t?{width:t.width(),height:t.height()}:!1},getBlockPosition=function(e){var t=getBlock(e);return t?{left:getBlockGridLeft(t),top:t.attr("data-grid-top")}:!1},getBlockPositionPixels=function(e){var t=getBlock(e);return t?{left:t.position().left,top:t.position().top}:!1},isBlockMirrored=function(e){var t=getBlock(e);return t.hasClass("block-mirrored")},getBlockMirrorOrigin=function(e){var t=getBlock(e);return isBlockMirrored(t)?t.data("block-mirror"):!1},getBlockMirrorLayoutName=function(e){var t=getBlock(e);return isBlockMirrored(t)?t.data("block-mirror-layout-name"):!1},updateBlockContentCover=function(e){if(Headway.mode!="grid")return!1;e.children(".block-content-cover").remove();var t=getBlockType(e),n=getBlockTypeNice(t),r="";return e.data("temp-id")&&(r=" <span>Unsaved</span>"),n||(n="Select Block Type"),e.data("alias")&&(n=e.data("alias")+" - "+n),e.append('                              <div class="block-content-cover">                                       <svg xmlns="http://www.w3.org/2000/svg" version="1.1">                                          <line class="x-line" x1="0" y1="0" x2="100%" y2="100%" />                                               <line class="x-line" x1="0" y1="100%" x2="100%" y2="0" />                                       </svg>                                                                          <span class="block-type-and-id">'+n+r+"</span>                          </div>                  "),e.find("div.block-content-cover")},loadBlockContent=function(e){var t={},n={blockElement:!1,blockSettings:{},blockOrigin:!1,blockDefault:!1,callback:function(e){},callbackArgs:null};$.extend(t,n,e);var r=t.blockElement.find("div.block-content"),i=getBlockType(t.blockElement);return Headway.gridSafeMode==1?r.html('<div class="alert alert-red block-safe-mode"><p>Grid Safe mode enabled.  Block content not outputted.</p></div>'):Headway.mode=="grid"&&!getBlockTypeObject(i)["show-content-in-grid"]?(typeof t.callback=="function"&&t.callback(t.callbackArgs),r.html("")):(createCog(r,!0,!0,Headway.iframe.contents(),1),$.ajax({url:Headway.ajaxURL,cache:!1,type:"POST",dataType:"text",data:{security:Headway.security,action:"headway_visual_editor",method:"load_block_content",unsaved_block_settings:t.blockSettings,block_origin:t.blockOrigin,block_default:t.blockDefault,layout:Headway.currentLayout,mode:Headway.mode}}).done(function(e){typeof t.callback=="function"&&t.callback(t.callbackArgs);if(Headway.mode=="grid"){var e=e.replace(/script/g,"SCRIPTTOCHECK"),n=$($.parseHTML(e));n.find("SCRIPTTOCHECK").remove()}else var n=$(e);return typeof window.frames["content"].jQuery!="undefined"&&window.frames.content.jQuery("#block-"+getBlockID(t.blockElement)).html(n).length?(Headway.mode=="design"&&refreshInspector(),window.frames.content.jQuery("#block-"+getBlockID(t.blockElement))):(r.html(n),Headway.mode=="design"&&refreshInspector(),r)}))},refreshBlockContent=function(e,t,n,r){if(typeof e=="undefined"||!e)return!1;if(typeof r=="undefined")var r=!0;var i=function(){var r=$i('.block[data-id="'+e+'"]'),i=GLOBALunsavedValues.blocks[e].settings,s=r.data("duplicateOf")?r.data("duplicateOf"):e;loadBlockContent({blockElement:r,blockSettings:{settings:i,dimensions:getBlockDimensions(r),position:getBlockPosition(r)},blockOrigin:s,blockDefault:{type:getBlockType(r),id:0,layout:Headway.currentLayout},callback:t,callbackArgs:n})};if(!r)return i();typeof updateBlockContentFloodTimeoutAfter!="undefined"&&clearTimeout(updateBlockContentFloodTimeoutAfter),typeof updateBlockContentFloodTimeout=="undefined"?(i.call(),updateBlockContentFloodTimeout=setTimeout(function(){delete updateBlockContentFloodTimeout},500)):updateBlockContentFloodTimeoutAfter=setTimeout(function(){i.call(),delete updateBlockContentFloodTimeoutAfter},600)},setupBlockContextMenu=function(e){if(typeof e=="undefined")var e=!0;setupContextMenu({id:"block",elements:".block:visible",title:function(e){var t=getBlock(e.currentTarget),n=getBlockID(t),r=getBlockType(t),i=r?getBlockTypeNice(r)+" ":"",s=getBlockTypeIcon(r,!0),o=s?' style="background-image:url('+s+');"':null;return'<span class="type type-'+r+'" '+o+"></span>"+i+"Block"},contentsCallback:function(e){var t=$(this),n=getBlock(e.currentTarget),r=getBlockID(n),i=getBlockType(n),s=getBlockTypeNice(i),o=Headway.touch?"tap":"click";$('<li class="context-menu-block-options"><span>Open Block Options</span></li>').appendTo(t).on(o,function(){openBlockOptions(n)}),Headway.mode=="grid"&&$('<li class="context-menu-block-switch-type"><span>Switch Block Type</span></li>').appendTo(t).on(o,function(){openBlockTypeSelector(n)}),Headway.mode=="grid"&&$('<li class="context-menu-block-duplicate"><span>Duplicate Block</span></li>').appendTo(t).on(o,function(){duplicateBlock(n)}),$('<li class="context-menu-set-alias"><span>Set Block Alias</span></li>').appendTo(t).on(o,function(){var e=prompt("Please enter the desired block alias.",n.data("alias"));if(!e)return;dataSetBlockOption(getBlockID(n),"alias",e),n.data("alias",e),updateBlockContentCover(n)}),isBlockMirrored(n)&&$('<li class="context-menu-block-unmirror"><span>Unmirror Block</span></li>').appendTo(t).on(o,function(){if(!confirm("Are you sure you want to unmirror this block?\n\nIt will no longer copy the options and styling from the block it is currently mirroring."))return;updateBlockMirrorStatus(!1,n,""),dataSetBlockOption(getBlockID(n),"mirror-block",""),reloadBlockOptions(getBlockID(n))}),Headway.mode=="grid"&&$('<li class="context-menu-block-delete"><span>Delete Block</span></li>').appendTo(t).on(o,function(e){if(!confirm("Are you sure you want to delete this block?"))return!1;deleteBlock(n)})}})},bindBlockDimensionsTooltip=function(){if(Headway.touch)return!1;$i("body").delegate(".block","mouseenter",function(e){var t=this,n=typeof $(this).data("qtip")=="undefined"?!0:!1;if(typeof Headway.disableBlockDimensions!="undefined"&&Headway.disableBlockDimensions)return!1;n&&(addBlockDimensionsTooltip($(this)),$(this).data("hoverWaitTimeout",setTimeout(function(){$(t).qtip("reposition"),$(t).qtip("show"),typeof $(t).data("qtip")!="undefined"&&$i("#qtip-"+$(t).data("qtip").id).show()},300)))}),$i("body").delegate(".block","mouseleave",function(e){clearTimeout($(this).data("hoverWaitTimeout"))})},addBlockDimensionsTooltip=function(e){return Headway.touch?!1:($(e).qtip({style:{classes:"qtip-headway qtip-block-dimensions"},position:{my:"top center",at:"bottom center",container:Headway.iframe.contents().find("body"),viewport:$("#iframe-container"),effect:!1},show:{delay:300,solo:!0,effect:!1},hide:{delay:25,effect:!1},content:{text:blockDimensionsTooltipContent}}),$(e).qtip("api"))},blockDimensionsTooltipContent=function(e){var t=getBlock(this),n=getBlockID(t),r=getBlockDimensionsPixels(t).width,i=getBlockDimensionsPixels(t).height,s=getBlockType(t);if(typeof s!="undefined")var o=getBlockTypeNice(s),u=getBlockTypeIcon(s,!0),a=u?' style="background-image:url('+u+');"':null,f=t.data("alias")?": "+t.data("alias"):"",l=getBlockMirrorLayoutName(t)?" from "+getBlockMirrorLayoutName(t):"",c=isBlockMirrored(t)?'<span class="block-info-mirroring">Mirroring'+l+"</span>":"",h=isBlockMirrored(t)?"main-block-info main-block-info-mirrored":"main-block-info",p='<div class="block-info"><span class="block-info-type" '+a+"></span>"+'<span class="'+h+'">'+o+" "+f+"</span>"+c+"</div>";else var p="";if(getBlockTypeObject(s)["fixed-height"])var i=i,d="Height";else var i=Headway.mode=="grid"?i:t.css("minHeight").replace("px",""),d="Min. Height";var v='<span class="block-height"><strong>'+d+":</strong> "+i+"<small>px</small></span>",m='<span class="block-width"><strong>Width:</strong> '+r+"<small>px</small></span>";if($("#input-enable-responsive-grid label.checkbox-checked").length==1||Headway.mode!="grid"&&Headway.responsiveGrid)var m='<span class="block-width"><strong>Max Width:</strong> <small>~</small>'+r+"<small>px</small></span>";var g=getBlockTypeObject(s)["fixed-height"]?"":'<span class="block-fluid-height-message">Height will auto-expand</span>';return p+m+' <span class="block-dimensions-separator">&#9747;</span> '+v+g+'<span class="right-click-message">Right-click to open block options</span>'},openBlockOptions=function(block,subTab){if(typeof block.target!="undefined"||!block)var block=getBlock(this);if(typeof subTab=="undefined")var subTab=null;if(!block||block.hasClass("block-type-unknown"))return!1;var blockID=getBlockID(block),blockType=getBlockType(block),blockTypeName=getBlockTypeNice(blockType),readyTabs=function(){var tab=$("div#block-"+blockID+"-tab");tab.tabs(),panelInputs.bind("div#block-"+blockID+"-tab"),setupTooltips();var callback=eval(tab.find("ul.sub-tabs").attr("data-open-js-callback"));typeof callback=="function"&&callback({block:block,blockID:blockID,blockType:blockType}),handleInputTogglesInContainer(tab.find("div.sub-tabs-content")),subTab&&selectTab(subTab,$("div#block-"+blockID+"-tab")),$("div#block-"+blockID+"-tab").find("select#input-"+blockID+"-mirror-block").val()!=""&&($("div#block-"+blockID+"-tab ul.sub-tabs li:not(#sub-tab-config)").hide(),selectTab("sub-tab-config",$("div#block-"+blockID+"-tab")))},blockTypeIconURL=getBlockTypeIcon(blockType,!0),blockTypeIconStyle=blockTypeIconURL?"background-image:url("+blockTypeIconURL+");":null,blockTabName=blockTypeName+" Block";block.data("alias")&&block.data("alias").length&&(blockTabName=block.data("alias")),addPanelTab("block-"+blockID,'<span class="block-type-icon" style="'+blockTypeIconStyle+'"></span>'+blockTabName,{url:Headway.ajaxURL,data:{security:Headway.security,action:"headway_visual_editor",method:"load_block_options",block_type:blockType,block_id:blockID,duplicate_of:block.data("duplicateOf"),unsaved_block_options:getUnsavedBlockOptionValues(blockID),layout:Headway.currentLayout},callback:readyTabs},!0,!0,"block-type-"+blockType),$("div#panel").tabs("option","active",$("#panel-top").children('li[role="tab"]').index($('[aria-controls="block-'+blockID+'-tab"]')))},reloadBlockOptions=function(e,t){if(!$("ul#panel-top").find('[aria-controls="block-'+e+'-tab"]').length)return;if(typeof e=="undefined"||!e)var e=$("ul#panel-top > li.ui-state-active").attr("aria-controls").replace("block-","").replace("-tab","");if($("ul#panel-top > li.ui-state-active").attr("aria-controls").indexOf("block-")!==0)return!1;if(typeof t=="undefined"||!t)var t=$("div#block-"+e+"-tab ul.sub-tabs .ui-state-active a").attr("href").replace("#","");return removePanelTab("block-"+e),openBlockOptions(getBlockByID(e),t)},getUnsavedBlockOptionValues=function(e){if(typeof GLOBALunsavedValues=="object"&&typeof GLOBALunsavedValues["blocks"]=="object"&&typeof GLOBALunsavedValues["blocks"][e]=="object"&&typeof GLOBALunsavedValues["blocks"][e]["settings"]=="object")var t=GLOBALunsavedValues.blocks[e].settings;return typeof t=="object"&&Object.keys(t).length>0?t:null},openBlockTypeSelector=function(e){var t=getBlockID(e);removePanelTab("block-"+t),addPanelTab("block-"+t,"Select Block Type","",!0,!0);var n=$("#block-"+t+"-tab"),r=$(".block-type-selector-original").clone().removeClass("block-type-selector-original").appendTo(n).show();r.find("div.block-type").addClass("tooltip"),setupTooltips(),r.find("div.block-type").bind("click",function(n){var r=$(this).attr("id").replace("block-type-","");if(e.hasClass("blank-block"))e.parents(".wrapper").headwayGrid("setupBlankBlock",r);else if(confirm("Are you sure you wish to switch block types?  All settings for this block will be lost.")){var i=switchBlockType(e,r);t=i}$(".qtip").qtip("hide"),removePanelTab("block-"+t),openBlockOptions(getBlockByID(t))}),e.hasClass("blank-block")&&($(".wrapper").bind("mousedown",{block:e},hideBlankBlockTypeSelector),$(document).bind("keyup.esc",{block:e},hideBlankBlockTypeSelector),$i("html").bind("keyup.esc",{block:e},hideBlankBlockTypeSelector),$('ul#panel-top li a[href="#block-'+t+'-tab"]').siblings("span.close").bind("mouseup",{block:e},hideBlankBlockTypeSelector)),$("div#panel").tabs("option","active",$("#panel-top").children('li[role="tab"]').index($('[aria-controls="block-'+t+'-tab"]')));return},hideBlankBlockTypeSelector=function(e){var t=e.data.block;return t.hasClass("blank-block")&&$(e.target).parents(".block").first().get(0)!=$(t).get(0)&&(removePanelTab("block-"+getBlockID(t)),t.remove(),$(".wrapper").unbind("mousedown",hideBlankBlockTypeSelector),$(document).unbind("keyup.esc",hideBlankBlockTypeSelector),$i("html").unbind("keyup.esc",hideBlankBlockTypeSelector)),!0},switchBlockType=function(e,t,n){var r=getBlockTypeIcon(t,!0),i=getBlockType(e),s=getBlockID(e);e.removeClass("block-type-"+i),e.addClass("block-type-"+t),e.data("type",t),(typeof n=="undefined"||n)&&loadBlockContent({blockElement:e,blockOrigin:{type:t,id:0,layout:Headway.currentLayout},blockSettings:{dimensions:getBlockDimensions(e),position:getBlockPosition(e)}}),getBlockTypeObject(t)["fixed-height"]===!0?(e.removeClass("block-fluid-height"),e.addClass("block-fixed-height"),e.css("min-height").replace("px","")!="0"&&e.css({height:e.css("min-height")})):(e.removeClass("block-fixed-height"),e.addClass("block-fluid-height"),e.css("height").replace("px","")!="auto"&&e.css({height:e.css("height")})),getBlockTypeObject(t)["show-content-in-grid"]?e.removeClass("hide-content-in-grid"):e.addClass("hide-content-in-grid"),e.removeClass("block-type-unknown"),oldBlockID=s;var o=Math.ceil(Math.random()*1e9);return e.attr("id","block-"+o).attr("data-id",o).attr("data-temp-id",o).data("id",o).data("temp-id",o),removePanelTab("block-"+oldBlockID),dataDeleteBlock(oldBlockID),dataAddBlock(e),dataSetBlockPosition(o,getBlockPosition(e)),dataSetBlockDimensions(o,getBlockDimensions(e)),dataSetBlockWrapper(o,getBlockWrapper(e).attr("id")),updateBlockContentCover(e),updateBlockMirrorStatus(!1,e,"",!1),allowSaving(),$(".qtip").qtip("hide"),o},duplicateBlock=function(e){if(!$(e).length)return!1;var t=getBlockWrapper(e),n=getBlockPosition(e),r=getBlockDimensions(e),i=e.data("alias")?e.data("alias")+" Copy":"",s=e.data("duplicateOf")?e.data("duplicateOf"):getBlockID(e),o={type:getBlockType(e),top:parseInt(n.top)+20,left:n.left,width:r.width,height:r.height,settings:{duplicateOf:s,alias:i}},u=t.data("ui-headwayGrid").addBlock(o);return t.data("ui-headwayGrid").sendBlockToTop(u),i&&(u.data("alias",i),updateBlockContentCover(u)),u},blockIntersectCheck=function(e,t){if(typeof t=="undefined"||!t)var t=block.parents(".grid-container").first();var n=blockIntersectCheckCallback(e,t.find(".block"));if(n.length>1){n.addClass("block-error");var r=!1}else{var i=0;t.find(".block-error").each(function(){var e=blockIntersectCheckCallback(this,t.find(".block"));e.length===1||!e?$(this).removeClass("block-error"):i++});var r=i===0?!0:!1}return r?(Headway.overlappingBlocks=!1,hideNotification("overlapping-blocks")):(Headway.overlappingBlocks=!0,showErrorNotification({id:"overlapping-blocks",message:"There are <strong>overlapping blocks</strong>.<br />Please separate them before saving.",closeTimer:!1})),r},blockIntersectCheckCallback=function(e,t){if(e==0||t==0||!$(e).is(":visible"))return!1;var n=[],r=5,i=$(e),s=i.offset(),o=[s.left,s.left+i.outerWidth()],u=[s.top,s.top+i.outerHeight()];return $(t).each(function(){var e=$(this);if(!e.is(":visible"))return;var t=e.offset(),i=[t.left,t.left+e.outerWidth()],s=[t.top,t.top+e.outerHeight()];o[0]+r<i[1]&&o[1]-r>i[0]&&u[0]<s[1]&&u[1]>s[0]&&n.push(this)}),$(n)},deleteBlock=function(e){if(typeof e!="object")var e=$i('.block[data-id="'+e+'"]');var t=getBlockID(e),n=getBlock(e),r=n.parents(".grid-container");Headway.history.add({description:"Deleted block",up:function(){n.hide(),removePanelTab("block-"+t),dataDeleteBlock(t),blockIntersectCheck(!1,r)},down:function(){n.show(),typeof GLOBALunsavedValues["blocks"][getBlockID(n)]["delete"]!="undefined"&&delete GLOBALunsavedValues.blocks[getBlockID(n)]["delete"],blockIntersectCheck(n,r)}}),allowSaving()},exportBlockSettingsButtonCallback=function(e){var t={security:Headway.security,action:"headway_visual_editor",method:"export_block_settings","block-id":e.blockID},n=Headway.ajaxURL+"?"+$.param(t);return window.open(n)},initiateBlockSettingsImport=function(e){var t=e.input,n=e.blockID,r=$(t).parents(".ui-tabs-panel").first().find('input[name="block-import-settings-file"]'),i=hwBoolean($(t).parents(".ui-tabs-panel").first().find('input[name="block-import-settings-include-options"]').val()),s=hwBoolean($(t).parents(".ui-tabs-panel").first().find('input[name="block-import-settings-include-design"]').val());if(!r.val())return alert("You must select a block settings export file before importing.");if(!i&&!s)return alert("You must import at least the options or design when importing block settings.");var o=r.get(0).files[0];if(o&&typeof o.name!="undefined"&&typeof o.type!="undefined"){var u=new FileReader;u.onload=function(e){var t=e.target.result,r=JSON.parse(t);if(r["data-type"]!="block-settings")return alert("Cannot load block settings.  Please insure that the block settings are a proper Headway block settings export.");if(getBlockType(getBlockByID(n))!=r["type"])return alert("Block type mismatch.  Be sure that the block settings export is the same type of block type that you're importing to.");typeof r["image-definitions"]!="undefined"&&Object.keys(r["image-definitions"]).length?(showNotification({id:"importing-images",message:"Currently importing images.",closeTimer:1e4}),$.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"import_images",importFile:r},function(e){var t=e;if(typeof t["error"]!="undefined")return alert("Error while importing images for block: "+t.error);importBlockSettingsAJAXCallback(n,t,i,s)})):importBlockSettingsAJAXCallback(n,r,i,s)},u.readAsText(o)}else alert("Cannot load block settings.  Please insure that the block settings are a proper Headway block settings export.")},importBlockSettingsAJAXCallback=function(e,t,n,r){if(n){var e=switchBlockType(getBlockByID(e),getBlockType(getBlockByID(e)));importBlockSettings(t.settings,e),removePanelTab("block-"+e),openBlockOptions(getBlockByID(e))}r&&typeof t["styling"]!="undefined"&&typeof t["id"]!="undefined"&&(dataPrepareDesignEditor(),$.each(t.styling,function(n,r){var i=t.id,s=e,n=n.replace("block-"+i,"block-"+s);$.each(r.properties,function(e,t){dataSetDesignEditorProperty({element:r.element,property:e,value:t!==null?t.toString():null,specialElementType:"instance",specialElementMeta:n})})}),showNotification({id:"block-design-imported-"+e,message:"Block design successfully imported",closeTimer:6e3,success:!0})),allowSaving()},importBlockSettings=function(e,t){dataPrepareBlock(t),GLOBALunsavedValues.blocks[t].settings=e,refreshBlockContent(t),showNotification({id:"block-settings-imported-"+t,message:"Block settings successfully imported",closeTimer:6e3,success:!0})},updateBlockMirrorStatus=function(e,t,n,r){if(typeof e=="undefined"||e==0)e=$();typeof r=="undefined"&&(r=!0);if(typeof t!="object")var t=getBlock($i('.block[data-id="'+t+'"]'));typeof n=="undefined"||n==""?(e.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").show(),t.attr("id","block-"+t.data("id")),t.data("block-mirror",!1),t.removeClass("block-mirrored")):(e.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").hide(),t.attr("id","block-"+n),t.data("block-mirror",n),t.addClass("block-mirrored"))},updateBlockCustomClasses=function(e,t,n){return Headway.mode!="design"?!1:(typeof t!="object"&&(t=getBlock($i('.block[data-id="'+t+'"]'))),t.length?(t.removeClass(t.data("custom-classes")),t.data("custom-classes",n),t.addClass(n),t):!1)}}),define("util.custommouse",["jquery","jqueryUI"],function(e){e.widget("ui.custommouse",e.ui.mouse,{options:{mouseStart:function(e){},mouseDrag:function(e){},mouseStop:function(e){},mouseCapture:function(e){return!0}},_mouseStart:function(e){return this.options.mouseStart(e)},_mouseDrag:function(e){return this.options.mouseDrag(e)},_mouseStop:function(e){return this.options.mouseStop(e)},_mouseCapture:function(e){return this.options.mouseCapture(e)},widgetEventPrefix:"custommouse",_init:function(){return this._mouseInit()},_create:function(){return this.element.addClass("ui-custommouse")},_destroy:function(){return this._mouseDestroy(),this.element.removeClass("ui-custommouse")}})}),define("helper.data",["underscore"],function(_){dataHandleInput=function(input,value,additionalCallbackArgs){var input=$(input);if(!input.length)return!1;if(typeof value=="undefined")var value=input.val();var optionID=input.attr("name").toLowerCase(),optionGroup=input.attr("data-group").toLowerCase(),callback=eval(input.attr("data-callback")),dataHandlerOverrideCallback=eval(input.attr("data-data-handler-callback"))||null,panelArgs=input.parents(".sub-tabs-content-container").first().data("panel-args")||{},callbackArgs=$.extend({},{input:input,value:value},panelArgs);typeof additionalCallbackArgs=="object"&&(callbackArgs=$.extend({},callbackArgs,additionalCallbackArgs)),allowSaving();if(!input.hasClass("repeater-group-input")&&input.parents(".repeater-group").length)return updateRepeaterValues(input.parents(".repeater")),typeof callback=="function"&&callback(callbackArgs),input.parents(".repeater-group");if(input.attr("data-no-save"))return typeof callback=="function"&&callback(callbackArgs),input;if(typeof dataHandlerOverrideCallback=="function")dataHandlerOverrideCallback(callbackArgs);else{if(typeof panelArgs.block!="undefined"&&panelArgs.block){var blockID=panelArgs.blockID;return dataSetBlockOption(blockID,optionID,value),refreshBlockContent(blockID,callback,callbackArgs),input}typeof panelArgs.wrapper!="undefined"&&panelArgs.wrapper?dataSetWrapperOption(panelArgs.wrapper.id,optionID,value):dataSetOption(optionGroup,optionID,value)}return typeof callback=="function"&&callback(callbackArgs),input},dataSetOption=function(e,t,n){return dataPrepareOptionGroup(e),GLOBALunsavedValues.options[e][t]=n,allowSaving(),GLOBALunsavedValues.options[e]},dataPrepareOptionGroup=function(e){return typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["options"]!="object"&&(GLOBALunsavedValues.options={}),typeof GLOBALunsavedValues["options"][e]!="object"&&(GLOBALunsavedValues.options[e]={}),GLOBALunsavedValues.options[e]},dataSetBlockOption=function(e,t,n){return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].settings[t]=n,allowSaving(),GLOBALunsavedValues.blocks[e]},dataSetBlockPosition=function(e,t){if(typeof e=="string"&&e.indexOf("block-")!==-1)var e=e.replace("block-","");var t=t.left+","+t.top;return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].position=t,allowSaving(),GLOBALunsavedValues.blocks[e]},dataSetBlockDimensions=function(e,t){if(typeof e=="string"&&e.indexOf("block-")!==-1)var e=e.replace("block-","");var t=t.width+","+t.height;return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].dimensions=t,allowSaving(),GLOBALunsavedValues.blocks[e]},dataSetBlockWrapper=function(e,t){return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].wrapper=t.toString().replace("wrapper-",""),allowSaving(),GLOBALunsavedValues.blocks[e]},dataDeleteBlock=function(e){if(typeof e=="string"&&e.indexOf("block-")!==-1)var e=e.replace("block-","");return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e]["delete"]=!0,allowSaving(),GLOBALunsavedValues.blocks[e]},dataAddBlock=function(e){var t,n;return typeof e=="string"&&t.indexOf("block-")!==-1?t=e.replace("block-",""):t=getBlockID(e),n=getBlockType(e),dataPrepareBlock(t),GLOBALunsavedValues.blocks[t]["new"]=n,GLOBALunsavedValues.blocks[t].insert_id=e.data("desired-id"),delete GLOBALunsavedValues.blocks[t]["delete"],allowSaving(),GLOBALunsavedValues.blocks[t]},dataPrepareBlock=function(e){return typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["blocks"]!="object"&&(GLOBALunsavedValues.blocks={}),typeof GLOBALunsavedValues["blocks"][e]!="object"&&(GLOBALunsavedValues.blocks[e]={}),typeof GLOBALunsavedValues["blocks"][e]["settings"]!="object"&&(GLOBALunsavedValues.blocks[e].settings={}),GLOBALunsavedValues.blocks[e]},dataSetWrapperOption=function(e,t,n){return e=String(e).replace("wrapper-",""),dataPrepareWrapper(e),GLOBALunsavedValues.wrappers[e].settings[t]=n,allowSaving(),GLOBALunsavedValues.wrappers[e]},dataAddWrapper=function(e,t,n){return wrapperID=String(e.attr("id")).replace("wrapper-",""),dataPrepareWrapper(wrapperID),GLOBALunsavedValues.wrappers[wrapperID]={"new":!0,insert_id:e.data("desired-id"),position:n,settings:jQuery.extend({},{columns:Headway.defaultGridColumnCount,"column-width":Headway.globalGridColumnWidth,"gutter-width":Headway.globalGridGutterWidth},t)},dataSortWrappers(),allowSaving(),GLOBALunsavedValues.wrappers[wrapperID]},dataDeleteWrapper=function(e){return e=String(e).replace("wrapper-",""),dataPrepareWrapper(e),GLOBALunsavedValues.wrappers[e]["delete"]=!0,allowSaving(),GLOBALunsavedValues.wrappers[e]},dataSetWrapperWidth=function(e,t){var n=t=="fluid";return dataSetWrapperOption(e,"fluid",n)},dataSetWrapperGridWidth=function(e,t){var n=t=="fluid";return dataSetWrapperOption(e,"fluid-grid",n)},dataSortWrappers=function(){$i(".wrapper:visible").each(function(){var e=$(this).data("id");dataPrepareWrapper(e),GLOBALunsavedValues.wrappers[e].position=$i(".wrapper").index(this)})},dataPrepareWrapper=function(e){e=String(e).replace("wrapper-",""),typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["wrappers"]=="undefined"&&(GLOBALunsavedValues.wrappers={}),typeof GLOBALunsavedValues["wrappers"][e]=="undefined"&&(GLOBALunsavedValues.wrappers[e]={}),typeof GLOBALunsavedValues["wrappers"][e]["settings"]=="undefined"&&(GLOBALunsavedValues.wrappers[e].settings={})},dataHandleDesignEditorInput=function(e){var t=$(e.hiddenInput),n=e.value;if(!t.length)return!1;if(t.parents("li.uncustomized-property").length==1)return!1;var r=t.attr("element").toLowerCase(),i=t.attr("property").toLowerCase(),s=t.attr("element_selector")||!1,o=t.attr("special_element_type").toLowerCase()||!1,u=t.attr("special_element_meta").toLowerCase()||!1;e.unit=t.siblings(".property-unit-select").find("select").val(),dataSetDesignEditorProperty({element:r,property:i,value:n,specialElementType:o,specialElementMeta:u,unit:e.unit});if(n==="null"||n=="DELETE")n=null;return t.val(n),$("#design-editor-element-selector-container").find("li#element-"+r).addClass("customized-element").attr("title","You have customized a property in this property group."),$("#design-editor-main-elements").find(".ui-state-active").length&&$("#design-editor-sub-elements").find(".ui-state-active").length&&$("#design-editor-main-elements").find(".ui-state-active").addClass("has-customized-children"),t.parents(".design-editor-box").first().addClass("design-editor-box-customized"),t.parents(".design-editor-box").first().find(".design-editor-box-title").attr("title","You have customized a property in this property group."),dataDesignEditorPropertyFeedback({element:r,property:i,value:n,specialElementType:o,specialElementMeta:u,unit:e.unit})},dataDesignEditorPropertyFeedback=function(args){var element=args.element.toLowerCase(),property=args.property.toLowerCase(),value=args.value,specialElementType=args.specialElementType||!1,specialElementMeta=args.specialElementMeta||!1;if(value==="null"||value=="DELETE")args.value=null,value=null;if(!specialElementType||specialElementType=="layout")var selector=Headway.elements[element].selector;else var selector=Headway.elements[element][specialElementType+"s"][specialElementMeta].selector;if(Headway.designEditorProperties.hasOwnProperty(property)){var callback=eval("(function(params){"+Headway.designEditorProperties[property]["js-callback"]+"})");args.selector=selector,args.element=$i(selector),typeof args["unit"]=="undefined"&&(args.unit=""),callback(args)}return value==null&&selector&&property&&stylesheet.delete_rule_property(selector,property),selector},dataSetDesignEditorProperty=function(e){var t=e.element.toLowerCase(),n=e.property.toLowerCase(),r=e.value,i=e.unit,s=e.specialElementType||!1,o=e.specialElementMeta||!1;i&&i.length&&r!="null"&&r!="DELETE"&&(r+=i),dataPrepareDesignEditor(),typeof GLOBALunsavedValues["design-editor"][t]!="object"&&(GLOBALunsavedValues["design-editor"][t]={});if(s==0||o==0)typeof GLOBALunsavedValues["design-editor"][t]["properties"]!="object"&&(GLOBALunsavedValues["design-editor"][t].properties=new Object),GLOBALunsavedValues["design-editor"][t].properties[n]=r,typeof Headway.elementData!="object"&&(Headway.elementData=new Object),typeof Headway.elementData[t]=="undefined"&&(Headway.elementData[t]={properties:{}}),typeof Headway.elementData[t]["properties"]=="undefined"&&(Headway.elementData[t].properties={}),Headway.elementData[t].properties[n]=r;else{typeof GLOBALunsavedValues["design-editor"][t]["special-element-"+s]!="object"&&(GLOBALunsavedValues["design-editor"][t]["special-element-"+s]=new Object),typeof GLOBALunsavedValues["design-editor"][t]["special-element-"+s][o]!="object"&&(GLOBALunsavedValues["design-editor"][t]["special-element-"+s][o]=new Object),GLOBALunsavedValues["design-editor"][t]["special-element-"+s][o][n]=r,typeof Headway.elementData!="object"&&(Headway.elementData=new Object),typeof Headway.elementData[t]!="object"&&(Headway.elementData[t]=new Object),typeof Headway.elementData[t]["special-element-"+s]!="object"&&(Headway.elementData[t]["special-element-"+s]=new Object);if(!_.isObject(Headway.elementData[t]["special-element-"+s][o])||_.isArray(Headway.elementData[t]["special-element-"+s][o]))Headway.elementData[t]["special-element-"+s][o]=new Object;Headway.elementData[t]["special-element-"+s][o][n]=r}if(typeof designEditor!="undefined"){var u=$('ul#design-editor-element-selector li.element[data-element-id="'+t+'"]');s=="instance"?u=u.filter('[data-instance-id="'+o+'"]'):s=="state"&&(u=u.filter('[data-state-id="'+o+'"]')),designEditor.showElementPropertiesThrottled(u)}return allowSaving(),!0},dataPrepareDesignEditor=function(){return typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["design-editor"]!="object"&&(GLOBALunsavedValues["design-editor"]={}),GLOBALunsavedValues["design-editor"]}}),wrapperOptionCallbackIndependentGrid=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;var i=r.data("ui-headwayGrid");i.options.useIndependentGrid=t,i.updateGridCSS()},wrapperOptionCallbackColumnCount=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;if(r.find(".block:visible").length)return alert("This wrapper must be empty of blocks before you can change the number of columns.\n\nEither drag the blocks to another wrapper or delete them if they are no longer needed."),!1;var i=r.data("ui-headwayGrid");i.options.columns=t,i.addColumnGuides(),i.updateGridCSS()},wrapperOptionCallbackColumnWidth=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;var i=r.data("ui-headwayGrid");i.options.columnWidth=t,i.updateGridCSS()},wrapperOptionCallbackGutterWidth=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;var i=r.data("ui-headwayGrid");i.options.gutterWidth=t,i.updateGridCSS()},wrapperOptionCallbackMarginTop=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;r.css({marginTop:t}),wrapperMarginFeedbackCreator(r,"top")},wrapperOptionCallbackMarginBottom=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;r.css({marginBottom:t}),wrapperMarginFeedbackCreator(r,"bottom")},wrapperMarginFeedbackCreator=function(e,t){e.find(".wrapper-margin-feedback").length&&(clearTimeout(e.find(".wrapper-margin-feedback").data("fadeout-timeout")),e.find(".wrapper-margin-feedback").remove());var n=$('<div class="wrapper-margin-feedback"></div>').prependTo(e),r=parseInt(e.css("margin"+t.capitalize()).replace("px","")),i={position:"absolute",width:e.outerWidth(),left:0,height:r,backgroundColor:"rgba(255, 127, 0, .35)"};return i[t]="-"+r+"px",n.css(i),n.data("fadeout-timeout",setTimeout(function(){n.fadeOut(200)},400)),n},updateGridWidthInput=function(e){var t=$(e).find('input[name="columns"]').val(),n=$(e).find('input[name="column-width"]').val(),r=$(e).find('input[name="gutter-width"]').val(),i=n*t+(t-1)*r;return $(e).find('input[name="grid-width"]').val(i)},define("modules/grid/wrapper-inputs",function(){}),define("modules/grid/wrappers",["util.custommouse","qtip","helper.data","modules/grid/wrapper-inputs"],function(){setupWrapperSortables=function(){return $i("#whitewrap").sortable({items:"div.wrapper",handle:"div.wrapper-drag-handle",axis:"y",tolerance:"pointer",placeholder:"wrapper-sortable-placeholder",start:function(e,t){$i(".wrapper").each(function(){$(this).data("current-height",$(this).height())}),$i(".wrapper-fixed").css({height:"100px"}),$i(".wrapper-fluid").css({height:"130px"}),$i(".wrapper .grid-container").css({height:"100%",overflow:"hidden"}),$(t.item).hasClass("wrapper-fixed-grid")&&$(t.item).css({left:"50%",marginLeft:"-"+$(t.item).outerWidth()/2+"px"}),t.placeholder.css({width:t.item.outerWidth(),height:t.item.outerHeight(),marginTop:t.item.css("marginTop"),marginBottom:t.item.css("marginBottom")}),$("#iframe-container").scrollTop(t.placeholder.offset().top-300),$(this).sortable("refreshPositions")},stop:function(e,t){$i(".wrapper").css({marginLeft:"",left:""}),$i(".wrapper").each(function(){$(this).height($(this).data("current-height")),$(this).removeData("current-height")}),$i(".wrapper, .wrapper .grid-container").css({overflow:""}),$i(".wrapper").each(function(){$(this).headwayGrid("updateGridContainerHeight")}),dataSortWrappers()}})},setupWrapperResizable=function(e){if(typeof e=="undefined")var e=$i(".wrapper");e.each(function(){var e=parseInt($(this).css("minHeight").replace("px",""));$(this).resizable({handles:"n, s",grid:5,minHeight:e,start:function(t,n){$(t.toElement).hasClass("ui-resizable-n")?$(this).data("resizing-position","n"):$(this).data("resizing-position","s");if($(this).find(".block").length){var r=0,i=null;$(this).find(".block:visible").each(function(){var e=$(this).position().top,t=$(this).outerHeight()+e;t>r&&(r=t);if(e<i||i===null)i=e;$(this).data("resize-original-block-top",$(this).position().top)});if($(this).data("resizing-position")=="n")var s=r-i;else var s=r}else var s=e;$(this).resizable("option","minHeight",s)},resize:function(e,t){var n=t.originalSize.height-t.size.height,r=t.size.height;$(this).find(".grid-container").height(r),$(this).css({top:"",height:""});if($(this).data("resizing-position")=="n"){var i=!1;$(this).find(".block").each(function(){if($(this).data("resize-original-block-top")-n<0)return i=!0,!1}),i||$(this).find(".block").each(function(){$(this).css({top:$(this).data("resize-original-block-top")-n})})}},stop:function(){$(this).find(".block").each(function(){var e=$(this),t=getBlockID(e);e.attr("data-grid-top",e.position().top),dataSetBlockPosition(t,getBlockPosition(e))}),$(this).data("resizing-position",null)}})})},stopWrapperResizable=function(e){if(!e.length||!e.resizable)return!1;e.resizable("destroy"),setupWrapperResizable(e)},addEdgeInsertWrapperButtons=function(){var e='<div class="add-wrapper-button-fixed tooltip" title="Add Wrapper">+</div>';$('<div class="add-wrapper-buttons add-wrapper-buttons-top">'+e+"</div>").data("position","top").prependTo($i("body")),$('<div class="add-wrapper-buttons add-wrapper-buttons-bottom">'+e+"</div>").data("position","bottom").appendTo($i("body"))},setupWrapperContextMenu=function(){setupContextMenu({id:"wrapper",elements:".wrapper",title:function(e){var t=$(e.currentTarget),n=getWrapperID(t);return"Wrapper"},contentsCallback:function(e){var t=$(this),n=$(e.currentTarget),r=getWrapperID(n);$('<li class="context-menu-wrapper-options"><span>Open Wrapper Options</span></li>').appendTo(t).on("click",function(){openWrapperOptions(r)}),n.hasClass("wrapper-fluid")&&Headway.mode=="grid"?($('<li class="context-menu-wrapper-to-fixed"><span>Change Wrapper to Fixed</span></li>').appendTo(t).find("span").on("click",function(){n.removeClass("wrapper-fluid"),n.removeClass("wrapper-fluid-grid"),n.addClass("wrapper-fixed"),n.addClass("wrapper-fixed-grid"),dataSetWrapperWidth(getWrapperID(n),"fixed"),dataSetWrapperGridWidth(getWrapperID(n),"fixed"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()}),n.hasClass("wrapper-fixed-grid")?$('<li class="context-menu-wrapper-grid-to-fluid"><span>Change Grid to Fluid</span></li>').appendTo(t).find("span").on("click",function(){n.removeClass("wrapper-fixed-grid"),n.addClass("wrapper-fluid-grid"),dataSetWrapperWidth(getWrapperID(n),"fluid"),dataSetWrapperGridWidth(getWrapperID(n),"fluid"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()}):n.hasClass("wrapper-fluid-grid")&&$('<li class="context-menu-wrapper-grid-to-fixed"><span>Change Grid to Fixed</span></li>').appendTo(t).find("span").on("click",function(){n.removeClass("wrapper-fluid-grid"),n.addClass("wrapper-fixed-grid"),dataSetWrapperWidth(getWrapperID(n),"fluid"),dataSetWrapperGridWidth(getWrapperID(n),"fixed"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()})):n.hasClass("wrapper-fixed")&&Headway.mode=="grid"&&$('<li class="context-menu-wrapper-to-fluid"><span>Change Wrapper to Fluid</span></li>').appendTo(t).on("click",function(){n.removeClass("wrapper-fixed"),n.addClass("wrapper-fluid"),n.addClass("wrapper-fixed-grid"),dataSetWrapperWidth(getWrapperID(n),"fluid"),dataSetWrapperGridWidth(getWrapperID(n),"fixed"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()}),$('<li class="context-menu-set-alias"><span>Set Wrapper Alias</span></li>').appendTo(t).on("click",function(){var e=prompt("Please enter the desired wrapper alias.",n.data("alias"));if(!e)return;dataSetWrapperOption(getWrapperID(n),"alias",e),n.data("alias",e)}),$i(".wrapper:visible").length>=2&&Headway.mode=="grid"&&$('<li class="context-menu-wrapper-delete"><span>Delete Wrapper</span></li>').appendTo(t).on("click",function(){deleteWrapper(r)})}})},bindWrapperButtons=function(){$i("body").delegate(".add-wrapper-button-fixed","click",function(){return addWrapper($(this).parents(".add-wrapper-buttons").data("position"),{fluid:!1})}),$i("body").delegate(".add-wrapper-fluid-fixed-grid","click",function(){return addWrapper($(this).parents(".add-wrapper-buttons").data("position"),{fluid:!0})}),$i("body").delegate(".add-wrapper-fluid-fluid-grid","click",function(){return addWrapper($(this).parents(".add-wrapper-buttons").data("position"),{fluid:!0,"fluid-grid":!0})}),$i("body").delegate(".wrapper-buttons .wrapper-options","click",function(){return openWrapperOptions(getWrapperID($(this).closest(".wrapper")))}),bindWrapperMarginButtons($i(".wrapper-buttons .wrapper-margin-handle"))},addWrapper=function(e,t,n){typeof t.id!="undefined"&&delete t.id;var t=$.extend({},{fluid:!1,"fluid-grid":!1,"use-independent-grid":!1},t);typeof t["fluid"]!="boolean"&&(t.fluid=hwBoolean(t.fluid)),typeof t["fluid-grid"]!="boolean"&&(t["fluid-grid"]=hwBoolean(t["fluid-grid"]));var r=Math.ceil(Math.random()*1e9),i=$('<div class="wrapper"><div class="grid-container"></div></div>');i.attr("id","wrapper-"+r).attr("data-id",r).attr("data-temp-id",r).attr("data-desired-id",t.id?t.id:null).data("id",r).data("temp-id",r).data("desired-id",t.id?t.id:null),i.prepend('<div class="wrapper-mirror-overlay"></div>'),i.find(".grid-container").append('                                            <div class="wrapper-mirror-notice">                                                     <div>                                                   <h2>Wrapper Mirrored</h2>                                                       <p>This wrapper is mirroring blocks from another wrapper.</p>                                                   <small>Mirroring can be disabled via Wrapper Options in the right-click menu</small>                                                    </div>                                          </div><!-- .wrapper-mirror-notice -->                                   '),addWrapperButtons(i),t.fluid?i.addClass("wrapper-fluid"):i.addClass("wrapper-fixed"),t["fluid-grid"]?i.addClass("wrapper-fluid-grid"):i.addClass("wrapper-fixed-grid");switch(e){case"top":i.prependTo($i("#whitewrap"));break;case"bottom":i.insertBefore($i("#wrapper-buttons-template"))}t.fluid&&(i.css("margin"+e.capitalize(),0),dataSetDesignEditorProperty({element:"wrapper",property:"margin-"+e,value:0,specialElementType:"instance",specialElementMeta:"wrapper-"+r})),dataAddWrapper(i,t,$i(".wrapper").index(i)),allowSaving(),i.find(".grid-container").height(100),i.data("wrapper-settings",t),i.headwayGrid(),setupWrapperResizable(i),bindWrapperMarginButtons(i.find(".wrapper-margin-handle"));var s=t.fluid?"Fluid":"Fixed";return(typeof n=="undefined"||!n)&&showNotification({id:"wrapper-created-"+r,message:s+" wrapper created.",closable:!0,closeTimer:5e3}),setupTooltips("iframe"),i},deleteWrapper=function(e,t){var n=$i('.wrapper[data-id="'+e+'"]');return n.length&&(t||confirm("Are you sure you want to remove this wrapper?  All blocks inside the wrapper will be deleted as well."))?(dataDeleteWrapper(e),n.find(".block").each(function(){deleteBlock($(this))}),n.remove()):!1},addWrapperButtons=function(e){e.each(function(){if($(this).find(".wrapper-buttons").length)return;var e=$i("#wrapper-buttons-template").first().clone().attr("id","").addClass("wrapper-buttons");return e.prependTo($(this))})},bindWrapperMarginButtons=function(e){var t=function(e){var t=$(e.target);t.length||(t=$i(".wrapper-handle[data-dragging]").first());var n=t.closest(".wrapper"),r=t.hasClass("wrapper-top-margin-handle")?"Top":"Bottom",i='<span style="opacity: .8;">'+r+" Margin:</span> "+n.css("margin"+r),s=t.data("dragging")?"":"Drag to change wrapper's <strong>"+r.toLowerCase()+" margin</strong><br />";return s+i};e.qtip({content:{text:t},style:{classes:"qtip-headway"},show:{delay:10,event:"mouseenter"},position:{my:"right center",at:"left center",container:Headway.iframe.contents().find("body"),viewport:$("#iframe-container"),effect:!1}}),e.custommouse({mouseStart:function(e){this.handle=$(e.currentTarget).hasClass("wrapper-margin-handle")?$(e.currentTarget):$(e.currentTarget).parents(".wrapper-margin-handle").first(),this.dragStart={left:e.pageX,top:e.pageY},this.marginToChange=this.handle.hasClass("wrapper-top-margin-handle")?"marginTop":"marginBottom",this.wrapper=$(e.currentTarget).closest(".wrapper"),this.originalWrapperMargin=parseInt(this.wrapper.css(this.marginToChange).replace("px","")),this.handle.siblings(".wrapper-handle[data-hasqtip], .wrapper-options[data-hasqtip]").each(function(){var e=$(this).qtip("api");typeof e!="undefined"&&e.rendered&&(e.disable(),e.hide())}),this.wrapper.addClass("wrapper-handle-in-use")},mouseDrag:function(e){var n=e.pageY-this.dragStart.top,r=2,i=Math.round(n/r),s=this.originalWrapperMargin+i;s<0&&(s=0),this.handle.attr("data-dragging",!0),this.handle.qtip("show"),this.handle.qtip("reposition"),this.handle.qtip("option","content.text",t),this.wrapper.css(this.marginToChange,s),dataSetDesignEditorProperty({element:"wrapper",property:"margin-"+this.marginToChange.replace("margin","").toLowerCase(),value:s.toString(),specialElementType:"instance",specialElementMeta:"wrapper-"+getWrapperID(this.wrapper)})},mouseStop:function(e){this.handle.removeAttr("data-dragging"),this.handle.data("dragging",!1);var t=this.handle.qtip("api");t.hide(),$i("#qtip-"+t.id).hide(),this.handle.siblings(".wrapper-handle, .wrapper-options").qtip("enable"),this.wrapper.removeClass("wrapper-handle-in-use")}})},populateWrapperMirrorNotice=function(e){var t=getWrapperMirror(getWrapperID(e));if(!t)return;e.find(".wrapper-mirror-notice-id").text(t.replace("wrapper-","")),e.find(".wrapper-mirror-notice-layout").hide()},assignDefaultWrapperID=function(){if($i("#wrapper-default").length){var e=Math.ceil(Math.random()*1e9),t=$i("#wrapper-default");t.attr("id","wrapper-"+e).attr("data-id",e).attr("data-temp-id",e).attr("data-desired-id",null).data("id",e).data("temp-id",e).data("desired-id",null),dataAddWrapper(t,{fluid:!1,"fluid-grid":!1},$i(".wrapper").index(t)),t.find(".block").each(function(){dataSetBlockWrapper(getBlockID($(this)),e)})}}}),define("modules/design/mode-design",["jquery","underscore","deps/colorpicker","helper.blocks","modules/grid/wrappers"],function(e,t){designEditorRequestElements=function(t){return Headway.elementsRequest&&(!t||typeof t=="undefined")?Headway.elementsRequest:(Headway.elementsRequest=e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"get_design_editor_elements",layout:Headway.currentLayout},function(t){Headway.elementGroups=e.extend({},t.groups),delete t.groups,Headway.elements=t},"json"),Headway.elementsRequest)},designEditorRequestElementData=function(t){return Headway.elementDataRequest&&(!t||typeof t=="undefined")?Headway.elementDataRequest:(Headway.elementDataRequest=e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"get_design_editor_element_data",layout:Headway.currentLayout},function(e){Headway.elementData=e},"json"),Headway.elementDataRequest)},designEditorTabEditor=function(){var n=this;this._init=function(){createCog(e("#design-editor-element-selector")),e.when(designEditorRequestElements(),designEditorRequestElementData()).then(this.setupElementSelector),this.bindElementSelector(),this.setupTabs(),this.setupBoxes(),this.bindDesignEditorInfo()},this.setupTabs=function(){e("#side-panel-top").tabs()},this.setupBoxes=function(){designEditorBindPropertyBoxToggle()},this.setupElementSelector=function(){e("#design-editor-element-selector").empty(),e.each(Headway.elementGroups,function(t,n){var r=e('<li id="element-group-'+t+'" class="element-group has-children">                                                                                     <span class="element-group-name">'+n.name+'</span>                                                                                      <span class="element-expander"></span>                                                                                  <ul class="group-elements"></ul>                                                                                </li>');typeof n.description!="undefined"&&n.description&&r.find(".element-group-name").after('<small class="description">'+n.description+"</small>"),r.appendTo("#design-editor-element-selector")}),e.each(Headway.elements,designEditor.addElementToSelector),e("#design-editor-element-selector li.element").each(function(){var t=e(this).data("parent");if(!t)return;var n=e("#design-editor-element-selector li#element-"+t);n.hasClass("has-children")||(n.addClass("has-children"),n.prepend('<span class="element-expander"></span>'),n.append('<ul class="children-elements"></ul>')),e(this).appendTo(n.find("> ul.children-elements")),e(this).hasClass("customized-element")&&n.addClass("had-customized-children")}),e("#design-editor-element-selector li.element").each(function(){designEditor.addElementStates(e(this)),designEditor.addElementInstances(e(this))}),e("body").bind("headwayIframeLoad",function(){designEditor.showOnlyLayoutElements()})},this.showAllElements=function(t){e("#design-editor-element-selector-container").removeClass("show-only-layout-elements"),e("#design-editor-element-selector li.not-on-layout").each(function(){e(this).show().removeClass("not-on-layout")})},this.showOnlyLayoutElements=function(){e("#design-editor-element-selector-container").addClass("show-only-layout-elements"),e("#design-editor-element-selector li.element").each(function(){if(!e(this).data("selector"))return;!$i(e(this).data("selector")).length&&!e(this).data("state-id")?e(this).hide().addClass("not-on-layout"):e(this).show().removeClass("not-on-layout")})},this.bindElementSelector=function(){var t=e("ul#design-editor-element-selector"),n=e("ul#design-editor-styles");t.on("click",designEditor.processNoElementClick),t.on("mouseenter","li span.element-name",designEditor.processElementMouseEnter),t.on("mouseleave","li span.element-name",designEditor.processElementMouseLeave),t.on("click","li span.element-name",designEditor.processElementClick),t.on("click","li span.element-expander",designEditor.processElementExpanderClick),t.on("click","li span.element-name span.element-name-button-layout-specific",designEditor.processElementNameLayoutSpecific),t.on("click","li span.element-name span.element-name-button-live-css",designEditor.processElementNameLiveCSS),n.on("click","li.property .property-value",designEditor.processPropertyValueClick),n.on("click","li.property .property-delete",designEditor.processPropertyDeleteClick),e("#side-panel-collapse-arrow").on("click",toggleDesignEditor),e("#element-selector-show-current-layout-elements").on("click",designEditor.showOnlyLayoutElements),e("#element-selector-show-all-elements").on("click",designEditor.showAllElements)},this.addElementToSelector=function(t,n){var r=n.description?'<small class="description">'+n.description+"</small>":"",i=e('<li id="element-'+t+'" data-element-id="'+t+'" class="element" data-selector="'+n.selector+'">                                                                                          <span class="element-name">'+n.name+"</span>                                                                                            "+r+"                                                                                   </li>");i.data({group:n.group,parent:n.parent,selector:n.selector,id:t}),n.customized&&i.addClass("customized-element"),i.appendTo(e("li#element-group-"+n.group+" ul.group-elements"))},this.addElementInstances=function(n){var r=n.data("element-id"),i=designEditorGetElementObject(r,!1).instances;if(t.isEmpty(i))return!1;var s=e.map(i,function(e,t){return[e]});s.sort(function(e,t){return e.name<t.name?-1:e.name>t.name?1:0}),n.hasClass("has-children")||(n.addClass("has-children"),n.prepend('<span class="element-expander"></span>'),n.append('<ul class="children-elements"></ul>')),n.children(".children-elements").prepend('                                                       <li id="element-'+r+'-instances" class="element element-instances-container has-children">                                                              <span class="element-expander"></span>                                                          <span class="element-name">Instances</span>                                                             <ul class="children-elements"></ul>                                                     </li>                                           '),n.addClass("instances-visible"),e.each(s,function(t,i){var s=i.id,o=i.name;typeof i["state-of"]!="undefined"&&i["state-of"]&&(o="  -- "+i["state-name"]);var u=e('<li id="element-instance-'+s+'" data-element-id="'+r+'" data-instance-id="'+s+'" data-selector="'+i.selector+'" class="element element-instance">                                                                          <span class="element-name">'+o+'</span>                                                                         <small class="description">'+i["layout-name"]+"</small>                                                                 </li>").appendTo(n.find("> ul.children-elements > li.element-instances-container > ul.children-elements"));u.data({selector:i.selector}),typeof i["customized"]!="undefined"&&i.customized&&u.addClass("customized-element")})},this.addElementStates=function(n){var r=n.data("element-id"),i=designEditorGetElementObject(r).states;if(t.isEmpty(i))return!1;n.hasClass("has-children")||(n.addClass("has-children"),n.prepend('<span class="element-expander"></span>'),n.append('<ul class="children-elements"></ul>')),n.children(".children-elements").prepend('                                                  <li id="element-'+r+'-states" class="element element-states-container has-children">                                                            <span class="element-expander"></span>                                                          <span class="element-name">States</span>                                                                <ul class="children-elements"></ul>                                                     </li>                                           '),n.addClass("states-visible"),e.each(i,function(t,i){var s=e('<li id="element-state-'+t+"-for-"+r+'" data-element-id="'+r+'" data-state-id="'+t+'" data-selector="'+i.selector+'" class="element element-state">                                                                              <span class="element-name">'+i.name+"</span>                                                                    </li>").appendTo(n.find("> ul.children-elements > li.element-states-container > ul.children-elements"));s.data({selector:i.selector})})},this.showElementProperties=function(r){if(typeof r!="object")var r=e(this);var i=r.data("element-id");e("ul#design-editor-styles").empty().show(),e(".design-editor-styles-message").hide();if(t.isEmpty(Headway.elementData[i])){e("ul#design-editor-styles").empty(),e("#design-editor-styles-no-styles").show(),e("#design-editor-styles-nothing-selected").hide();return}e("ul#design-editor-styles").prepend("<h2>"+r.children(".element-name").first().text()+"</h2>");var s=Headway.elementData[i],o=e('<li class="properties"><ul></ul></li>'),u=e("ul#design-editor-styles");t.isEmpty(Headway.elementData[i].properties)||e.each(Headway.elementData[i].properties,function(e,t){n.addElementProperty(u,e,t)});var a=["instance","state","layout"];return e.each(a,function(r,s){t.isEmpty(Headway.elementData[i]["special-element-"+s])||e.each(Headway.elementData[i]["special-element-"+s],function(r,o){if(s=="layout")var a=e('#layout-selector span[data-layout-id="'+r+'"] strong').text(),f="";else{if(!!t.isUndefined(designEditorGetElementObject(i,!1)[s+"s"][r]))return;var a=designEditorGetElementObject(i,!1)[s+"s"][r].name;if(typeof designEditorGetElementObject(i,false)[s+"s"][r]["layout-name"]!="undefined")var f=" &ndash; Layout: "+designEditorGetElementObject(i,!1)[s+"s"][r]["layout-name"];else var f=""}e.each(o,function(e,t){n.addElementProperty(u,e,t,{type:s,id:r,name:a,layoutName:f})})})}),setupTooltips(),o},this.showElementPropertiesThrottled=t.throttle(this.showElementProperties,300),this.addElementProperty=function(n,r,i,s){if(i=="DELETE")return!1;if(typeof Headway.designEditorProperties[r]=="undefined")return!1;var o,u=Headway.designEditorProperties[r],a=u.group.toLowerCase().replace(" ","-");n.find('.property-value-group-name[data-property-group-id="'+a+'"]').length||(n.append('<li class="property-value-group-name" data-property-group-id="'+a+'">'+u.group+"</strong></li>"),n.append('<ul data-property-group-id="'+a+'"></ul>'));if(t.isEmpty(i))o="Inheriting";else if(u["type"]=="color"){var f=i.replace("#","");f.length==6&&(f="#"+f),o='                                                                       <div class="colorpicker-box-container">                                                                         <div style="background-color: '+f+'" class="colorpicker-box"></div>                                                                     </div>',i.replace("#","").toUpperCase().length==6&&(o+='<span style="font-family:monospace;">#'+i.replace("#","").toUpperCase()+"</span>")}else if(u["type"]=="image")o='                                                                       <span class="tooltip tooltip-left" title="&lt;img src=\''+i+"' style='max-width:300px;height:auto;' /&gt;\" >Preview</span>                                                             ";else if(u.unit&&i){if(typeof u["unit"]!="object")var l=u.unit;else{var l=i.replace(/^[+-]?\d+(\.\d+)?/g,"");l||(u.unit["default"]||(u.unit["default"]="px"),l=u.unit["default"]),i=i.replace(l,"")}o=i+'<span class="unit">'+l+"</span>"}else if(u["type"]=="font-family-select"){var c=i.split("|"),h=t.first(c)=="google"?!0:!1;if(h){var p=c[1];webFontQuickLoad(i)}else var p=i;o='<span style="font-family:'+p+';">'+p.capitalize()+"</span>"}else t.isString(i)&&(o=i.capitalize());if(typeof s=="undefined"){var d=e('                                                                         <li class="property" data-property-id="'+r+'" data-property-group-id="'+a+'">                                                                                   <strong title="'+u.name+'">'+u.name+'</strong>                                                                                  <span class="property-delete"></span>                                                                                   <span class="property-value" title="Click to Edit">'+o+"</span>                                                                         </li>                                                                   ");d.appendTo(n.find('ul[data-property-group-id="'+a+'"]'))}else{n.find('[data-property-id="'+r+'"]:not([data-special-element-type])').length||n.find('ul[data-property-group-id="'+a+'"]').append('                                                                                            <li class="property" data-property-id="'+r+'" data-property-group-id="'+a+'">                                                                                                   <strong>'+u.name+"</strong>                                                                                             </li>                                                                                   ");var d=e('                                                                            <li class="property" data-property-id="'+r+'" data-property-group-id="'+a+'" data-special-element-type="'+s.type+'" data-special-element-id="'+s.id+'">                                                                                 <strong title="'+s.name.split(" &ndash; ")[0]+s.layoutName+'">'+s.name.split(" &ndash; ")[0]+'</strong>                                                                                         <span class="property-delete"></span>                                                                                   <span class="property-value" title="Click to Edit">'+o+"</span>                                                                         </li>                                                                   ");n.find('[data-property-id="'+r+'"]').not("[data-special-element-type]").last().addClass("has-special-element-properties"),d.insertAfter(n.find('[data-property-id="'+r+'"]').last())}},this.processPropertyValueClick=function(){var n=e("ul#design-editor-element-selector li.ui-state-active").first(),r=n.data("element-id"),i=e(this).parents("li.property").first(),s=i.data("special-element-type"),o=i.data("special-element-id");return t.isEmpty(s)?n.children("span.element-name").trigger("click",[i.data("property-group-id")]):designEditor.selectSpecialElement(r,s,o,i.data("property-group-id"))},this.processPropertyDeleteClick=function(){var n=e("ul#design-editor-element-selector li.ui-state-active").first(),r=designEditorGetElementObject(n.data("element-id"),!1),i=e(this).parents("li.property").first(),s=i.data("property-id"),o=i.data("special-element-type"),u=i.data("special-element-id");if(t.isEmpty(o))var a=r.selector;else if(o=="layout")var a=("body.layout-using-"+u+" "+r.selector).replace(" body","");else var a=r[o+"s"][u].selector;stylesheet.delete_rule_property(a,s),i.remove(),n.find("> .children-elements > .properties ul li").length||(n.find("> .children-elements > .properties").remove(),n.removeClass("properties-visible"),n.find("> .children-elements li").length||(n.find("> .children-elements, > .element-expander").remove(),n.removeClass("has-children").removeClass("children-visible"))),dataSetDesignEditorProperty({element:r.id,property:s,value:"DELETE",specialElementType:o,specialElementMeta:u})},this.processNoElementClick=function(t){if(e(t.target).is("span"))return;e("body").removeClass("design-editor-element-selected"),e("ul#design-editor-element-selector").find(".ui-state-active").addClass("element-just-selected").removeClass("ui-state-active"),removeInspectorVisibleBoxModal(),setSelectedElement({}),$i(".inspector-element-selected").removeClass("inspector-element-selected"),e("#design-editor-styles-no-styles").hide(),e("#design-editor-styles-nothing-selected").show(),e("ul#design-editor-styles").empty().hide()},this.processElementExpanderClick=function(t){e(this).parent().toggleClass("children-visible")},this.processElementMouseEnter=function(t){var n=e(this).parent();if(n.hasClass("element-group")||n.hasClass("element-instances-container")||n.hasClass("element-states-container"))return;var r=n.data("element-id"),i=designEditorGetElementObject(r,!1);e(".element-just-selected").removeClass("element-just-selected"),$i(".inspector-element-hover").removeClass("inspector-element-hover"),$i(n.data("selector")).addClass("inspector-element-hover");if(!n.hasClass("element-name-has-buttons")){var s=n.children(".element-name");!n.hasClass("element-instance")&&!n.hasClass("element-state")&&s.append('<span class="element-name-button element-name-button-layout-specific tooltip" title="Edit Element Only On This Layout"></span>'),s.append('<span class="element-name-button element-name-button-live-css tooltip" title="Edit in Live CSS"></span>'),s.find(".tooltip").qtip({style:{classes:"qtip-headway qtip-headway-element-selector",tip:!1},position:{my:"bottom left",at:"top center",viewport:e(window),adjust:{y:-5,method:"flipinvert"}}}),n.addClass("element-name-has-buttons")}},this.processElementMouseLeave=function(t){var n=e(this).parent();if(n.hasClass("element-group")||n.hasClass("ui-state-active")||n.hasClass("element-instances-container"))return;var r=n.data("element-id"),i=designEditorGetElementObject(r);$i(n.data("selector")).removeClass("inspector-element-hover"),n.children(".element-name").find(".element-name-button").each(function(){e(this).qtip("api").destroy(!0),e(this).remove()}),n.removeClass("element-name-has-buttons")},this.processElementClick=function(t,n){var r=e(this).parent();if(e(t.target).hasClass("element-name-button")||r.hasClass("element-instances-container"))return;if(r.hasClass("element-group"))return;if(r.hasClass("element-instance"))return designEditor.selectSpecialElement(r.data("element-id"),"instance",r.data("instance-id"),n);if(r.hasClass("element-state"))return designEditor.selectSpecialElement(r.data("element-id"),"state",r.data("state-id"),n);var i=getElementNodeName(r),s=r.data("element-id"),o=designEditorGetElementObject(s,!1);e("body").addClass("design-editor-element-selected"),r.hasClass("has-children")&&r.addClass("children-visible"),e(this).parents("li.has-children").addClass("children-visible"),e("div#design-editor-element-selector-container").animate({scrollTop:r.offset().top-(150-e("div#design-editor-element-selector-container").scrollTop())},300),e("div.design-editor-info span.customize-for-regular-element").hide(),e("div.design-editor-info span.customize-element-for-layout").show(),inspectorSelectElement(o.selector),setSelectedElement({id:s,name:i,object:o}),designEditorShowCog(),e.when(designEditor.loadElementInputs(s)).then(function(){designEditorShowContent(n)}),e("ul#design-editor-element-selector").find(".ui-state-active").removeClass("ui-state-active"),r.addClass("ui-state-active"),designEditor.showElementProperties(r)},this.processElementNameLayoutSpecific=function(){var t=e(this).parents("li.element").first(),n=t.data("element-id");designEditor.selectSpecialElement(n,"layout",Headway.currentLayout)},this.processElementNameLiveCSS=function(){var t=e(this).parents("li.element").first(),n=t.data("selector"),r=typeof liveCSSEditor=="undefined"||!liveCSSEditor?e("textarea#live-css").val():liveCSSEditor.getValue(),i=r?"\n\n":"";e("textarea#live-css").val(r+i+n+" {\n\n}"),e("#open-live-css").trigger("click");if(typeof liveCSSEditor!="undefined"){liveCSSEditor.setValue(e("textarea#live-css").val());var s=liveCSSEditor.session.getLength();liveCSSEditor.gotoLine(s-1),liveCSSEditor.focus()}},this.processElementCopy=function(n){var r=getSelectedElement();if(!r)return;var i=typeof r.specialElementName!="undefined"?r.specialElementName:r.name;if(!t.isEmpty(Headway.elementData[r.id]))if(r.specialElementType&&!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType])){if(!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]))var s=Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]}else if(!t.isEmpty(Headway.elementData[r.id].properties))var s=Headway.elementData[r.id].properties;if(typeof s=="undefined"||t.isEmpty(s))return!1;showNotification({id:"copied-design-properties",message:"Copied properties from <strong>"+i+"</strong>",closeTimer:2e3,overwriteExisting:!0}),Headway.designEditorClipboard=e.extend({},s)},this.processElementPaste=function(n){var r=getSelectedElement();if(!r||typeof Headway.designEditorClipboard=="undefined")return;var i=typeof r.specialElementName!="undefined"?r.specialElementName:r.name;if(!t.isEmpty(Headway.elementData[r.id]))if(r.specialElementType&&!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType])){if(!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]))var s=Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]}else if(!t.isEmpty(Headway.elementData[r.id].properties))var s=Headway.elementData[r.id].properties;if(typeof s=="undefined")var s={};e.each(s,function(e,t){dataSetDesignEditorProperty({element:r.id,property:e,value:"DELETE",specialElementType:r.specialElementType,specialElementMeta:r.specialElementID})}),e.each(Headway.designEditorClipboard,function(e,t){typeof Headway.designEditorProperties[e]["unit"]!="undefined"&&!isNaN(t)&&(typeof Headway.designEditorProperties[e]["unit"]=="string"?t+=Headway.designEditorProperties[e].unit:typeof Headway.designEditorProperties[e]["unit"]["default"]!="undefined"&&(t+=Headway.designEditorProperties[e].unit["default"])),dataSetDesignEditorProperty({element:r.id,property:e,value:t,specialElementType:r.specialElementType,specialElementMeta:r.specialElementID})});if(r.specialElementType)var s=Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID];else var s=Headway.elementData[r.id].properties;e.each(s,function(e,t){dataDesignEditorPropertyFeedback({element:r.id,property:e,value:t,specialElementType:r.specialElementType,specialElementMeta:r.specialElementID})}),showNotification({id:"copied-design-properties",message:"Pasted properties onto <strong>"+i+"</strong>",closeTimer:2e3,overwriteExisting:!0,success:!0})},this.loadElementInputs=function(t,n){var r={security:Headway.security,action:"headway_visual_editor",method:"get_element_inputs",unsavedValues:designEditorGetUnsavedValues(t),element:designEditorGetElementObject(t)};if(typeof n=="object"){var i=Object.keys(n)[0],s=n[i];r.specialElementType=i,r.specialElementMeta=s,r.unsavedValues=designEditorGetUnsavedValues(t,i,s),i=="instance"&&(r.element=designEditorGetElementObject(t,!0,s))}return e.post(Headway.ajaxURL,r).success(function(n){var r=e("div.design-editor-options");r.html(n),e("div.design-editor-options").data({element:t,specialElementType:!1,specialElementMeta:!1}),e("div.design-editor-options").find(".property-font-family-select").each(function(){webFontQuickLoad(e(this).find("span.font-name").data("webfont-value"))}),Headway.iframe.focus()})},this.bindDesignEditorInfo=function(){e("span.customize-element-for-layout").bind("click",function(){var e=designEditor.getCurrentElement(),t=e.data("element-id");designEditor.selectSpecialElement(t,"layout",Headway.currentLayout)}),e("span.customize-for-regular-element").bind("click",function(){designEditor.getCurrentElement().find("> span.element-name").trigger("click")})},this.selectSpecialElement=function(t,n,r,i){var s=e("ul#design-editor-element-selector li.element-"+n).filter("[data-"+n+'-id="'+r+'"]').filter('[data-element-id="'+t+'"]');s.length||(s=e('ul#design-editor-element-selector li.element[data-element-id="'+t+'"]').first());var o=designEditorGetElementObject(t,!1),u=n!="layout"?o[n+"s"][r].name:Headway.currentLayoutName,a=n!="layout"?o[n+"s"][r].selector:o.selector;e("body").addClass("design-editor-element-selected"),s.parents("li").addClass("children-visible"),e("div#design-editor-element-selector-container").animate({scrollTop:s.offset().top-(e("div#design-editor-element-selector-container").height()/1.5-e("div#design-editor-element-selector-container").scrollTop())},300),designEditor.showElementProperties(s),n=="layout"?(e("div.design-editor-info span.customize-for-regular-element").show(),e("div.design-editor-info span.customize-element-for-layout").hide()):(e("div.design-editor-info span.customize-for-regular-element").hide(),e("div.design-editor-info span.customize-element-for-layout").hide()),inspectorSelectElement(a);var f={},l={};f[n]=u,l[n]=r,setSelectedElement({id:t,selector:a,name:o.name,specialElementType:n,specialElementID:r,specialElementName:u,object:o});if(typeof loadInputs=="undefined"||loadInputs)designEditorShowCog(),e.when(designEditor.loadElementInputs(t,l)).then(function(){designEditorShowContent(i)});e("ul#design-editor-element-selector").find(".ui-state-active").removeClass("ui-state-active"),s.addClass("ui-state-active")},this.getCurrentElement=function(){return e("ul#design-editor-element-selector li.ui-state-active")},this.switchLayout=function(){if(typeof Headway.switchedToLayout=="undefined"||!Headway.switchedToLayout)return;e.when(designEditorRequestElements(!0)).then(function(){designEditor.setupElementSelector.apply(designEditor),e("div.design-editor-options").hide()})}},toggleDesignEditor=function(){return e("body").hasClass("side-panel-hidden")?showDesignEditor():hideDesignEditor()},hideDesignEditor=function(){return e("body").hasClass("side-panel-hidden")?!1:(e("body").addClass("side-panel-hidden"),setTimeout(repositionTooltips,400),e("#design-editor-toggle span").text("eee"),e.cookie("hide-design-editor",!0),!0)},showDesignEditor=function(){return e("body").hasClass("side-panel-hidden")?(e("body").removeClass("side-panel-hidden"),setTimeout(repositionTooltips,400),e("#design-editor-toggle span").text("iii"),e.cookie("hide-design-editor",!1),!0):!1},designEditorShowCog=function(){e("div#side-panel").addClass("properties-loading"),e("div.design-editor-info").hide(),e("div.design-editor-options").hide(),createCog(e("div#side-panel-bottom"),!0,!0)},designEditorShowContent=function(n){e("div#side-panel-bottom").find(".cog-container").remove(),e("div.design-editor-info").show(),e("div.design-editor-options").show(),e("div#side-panel").removeClass("properties-loading"),t.isEmpty(n)||e(".design-editor-box-"+n).find(".design-editor-box-title").trigger("click"),setupTooltips()},designEditorGetElementObject=function(t,n,r){var i=e("ul#design-editor-element-selector").find("#element-"+t),s=i.data("group"),o=i.data("parent");if(typeof n=="undefined")var n=!0;var t=jQuery.extend(!0,{},Headway.elements[t]);return n&&(typeof r!="undefined"&&r?e.each(t.instances,function(e,n){e!=r&&delete t.instances[e]}):delete t.instances),t},designEditorGetUnsavedValues=function(e,n,r){if(typeof n=="undefined")var n=!1;if(typeof r=="undefined")var r=!1;if(typeof GLOBALunsavedValues=="undefined"||typeof GLOBALunsavedValues["design-editor"]=="undefined"||typeof GLOBALunsavedValues["design-editor"][e]=="undefined")return null;if(!n||!r){if(typeof GLOBALunsavedValues["design-editor"][e]["properties"]=="undefined")return null;var i=GLOBALunsavedValues["design-editor"][e].properties}else{if(typeof GLOBALunsavedValues["design-editor"][e]["special-element-"+n]=="undefined")return null;if(typeof GLOBALunsavedValues["design-editor"][e]["special-element-"+n][r]=="undefined")return null;var i=GLOBALunsavedValues["design-editor"][e]["special-element-"+n][r]}return t.isEmpty(i)?null:i},designEditorBindPropertyBoxToggle=function(){e("div.design-editor-options").delegate("span.design-editor-box-title","click",function(){var t=e(this).parents("div.design-editor-box"),n=t.hasClass("design-editor-box-open");e("div.design-editor-options div.design-editor-box-open").removeClass("design-editor-box-open"),!t.hasClass("design-editor-box-open")&&!n&&t.addClass("design-editor-box-open")})},designEditorBindPropertyInputs=function(){e(".design-editor-options-container").delegate("div.customize-property","click",function(){var t=e(this).parents("li").first();if(t.hasClass("lockable-property")&&t.parents(".box-model-inputs").hasClass("box-model-inputs-locked"))var t=e(this).parents(".box-model-inputs").find("> li.lockable-property");t.each(function(){e(this).find(".customize-property").fadeOut(150),e(this).removeClass("uncustomized-property"),e(this).addClass("customized-property-by-user"),e(this).attr("title","You have customized this property.");var t=e(this).find("input.property-hidden-input"),n=t.parent().find("select, input:not(.property-hidden-input)").first();!t.val()&&n.length&&t.val(n.val()),dataHandleDesignEditorInput({hiddenInput:t,value:t.val()})})}),e(".design-editor-options-container").delegate("span.uncustomize-property","click",function(){if(!confirm("Are you sure you wish to delete this customization?"))return!1;var t=e(this).parents("li").first();if(t.hasClass("lockable-property")&&t.parents(".box-model-inputs").hasClass("box-model-inputs-locked"))var t=e(this).parents(".box-model-inputs").find("> li.lockable-property");t.each(function(){var t=e(this).find("input.property-hidden-input");e(this).find("div.customize-property").fadeIn(150),dataHandleDesignEditorInput({hiddenInput:t,value:"DELETE",unit:""}),e(this).addClass("uncustomized-property",150),e(this).removeClass("customized-property-by-user"),e(this).attr("title","You have set this property to inherit.")})}),e(".design-editor-options-container").delegate(".design-editor-property-font-family span.open-font-browser","click",function(){typeof fontBrowserOpen=="function"&&fontBrowserOpen.apply(this)}),e(".design-editor-options-container").delegate("span.design-editor-lock-sides","click",function(){e(this).parent().hasClass("box-model-inputs-locked")?e(this).attr("data-locked",!1).attr("title","Unlock sides").parent().removeClass("box-model-inputs-locked"):e(this).attr("data-locked",!0).attr("title","Lock sides").parent().addClass("box-model-inputs-locked")}),e(".design-editor-options-container").delegate('.box-model-inputs-locked li.lockable-property input[type="number"]',"keyup blur change",function(t,n){if(typeof n!="undefined"&&n)return;e(this).parents(".box-model-inputs-locked").find(".lockable-property").removeClass("uncustomized-property"),e(this).parents(".box-model-inputs-locked").find('li.lockable-property input[type="number"]').not(e(this)).val(e(this).val()).trigger("change",[!0])}),e(".design-editor-options-container").delegate(".box-model-inputs-locked li.lockable-property select","change",function(t,n){if(typeof n!="undefined"&&n)return;e(this).parents(".box-model-inputs-locked").find(".lockable-property").removeClass("uncustomized-property"),e(this).parents(".box-model-inputs-locked").find("li.lockable-property select").not(e(this)).val(e(this).val()).trigger("change",[!0])}),e(".design-editor-options-container").delegate("div.property-select select","change",designEditorInputSelect),e(".design-editor-options-container").delegate("div.property-integer input","focus",designEditorInputIntegerFocus),e(".design-editor-options-container").delegate("div.property-integer input","keyup blur change",designEditorInputIntegerChange),e(".design-editor-options-container").delegate("div.property-integer .property-unit-select select","change",designEditorInputIntegerUnitChange),e(".design-editor-options-container").delegate("div.property-image span.button","click",designEditorInputImageUpload),e(".design-editor-options-container").delegate("div.property-image span.delete-image","click",designEditorInputImageUploadDelete),e(".design-editor-options-container").delegate("div.property-color div.colorpicker-box","click",designEditorInputColor)},designEditorInputSelect=function(t){var n=e(this).parent().siblings("input.property-hidden-input");dataHandleDesignEditorInput({hiddenInput:n,value:e(this).val()})},designEditorInputIntegerFocus=function(t){typeof originalValues!="undefined"&&delete originalValues,originalValues=new Object;var n=e(this).siblings("input.property-hidden-input"),r=n.attr("selector")+"-"+n.attr("property");originalValues[r]=e(this).val()},designEditorInputIntegerUnitChange=function(t){e(this).parents(".property-integer").find('input[type="number"]').trigger("change")},designEditorInputIntegerChange=function(t){var n=e(this).siblings("input.property-hidden-input"),r=e(this).val();if(t.type=="keyup"&&r=="-")return;if(isNaN(r)){r=r.replace(/[^0-9]*/ig,"");if(r==="")var i=n.attr("selector")+"-"+n.attr("property"),r=originalValues[i];e(this).val(r)}r.length>1&&r[0]==0&&(r=r.replace(/^[0]+/g,""),e(this).val(r)),dataHandleDesignEditorInput({hiddenInput:n,value:e(this).val()})},designEditorInputImageUpload=function(t){var n=this;openImageUploader(function(t,r){var i=e(n).siblings("input");e(n).siblings(".image-input-controls-container").find("span.src").text(r),e(n).siblings(".image-input-controls-container").show(),dataHandleDesignEditorInput({hiddenInput:i,value:t})})},designEditorInputImageUploadDelete=function(t){if(!confirm("Are you sure you wish to remove this image?"))return!1;e(this).parent(".image-input-controls-container").hide(),e(this).hide();var n=e(this).parent().siblings("input");dataHandleDesignEditorInput({hiddenInput:n,value:"none"})},designEditorInputColor=function(t){e("div.design-editor-options-container").css("overflow-y","hidden");var n=e(this).parent().siblings("input"),r=n.val();r=="transparent"&&(r="00FFFFFF");var i=function(e,t){var r="#"+e.hex;if(e.a!=100)var r=e.rgba;dataHandleDesignEditorInput({hiddenInput:n,value:r})};e(this).colorpicker({realtime:!0,alpha:!0,alphaHex:!0,allowNull:!1,showAnim:!1,swatches:typeof Headway.colorpickerSwatches=="object"&&Headway.colorpickerSwatches.length?Headway.colorpickerSwatches:!0,color:r,beforeShow:function(e,t){showIframeOverlay()},onClose:function(t,n){i(t,n),hideIframeOverlay(),e("div.design-editor-options-container").css("overflow-y","auto")},onSelect:function(e,t){i(e,t)},onAddSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)},onDeleteSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)}}),e.colorpicker._showColorpicker(e(this)),setupTooltips()},propertyInputCallbackFontFamily=function(t){var n=t.selector,r=t.value,i=t.element,s=t.stack?t.stack:t.value;if(!r){stylesheet.delete_rule_property(n,"font-family");return}if(!r.match(/\|/g)){stylesheet.update_rule(n,{"font-family":s});return}var o=r.split("|"),u={},a="";typeof o[2]!="undefined"&&o[2]&&(a=":"+o[2]),u[o[0]]={families:[o[1]+a]};var s=o[1];stylesheet.update_rule(n,{"font-family":s}),typeof e("iframe#content").get(0).contentWindow.WebFont=="object"&&e("iframe#content").get(0).contentWindow.WebFont.load(u)},propertyInputCallbackBackgroundImage=function(e){var t=e.selector,n=e.value,r=e.element;n!="none"?stylesheet.update_rule(t,{"background-image":"url("+n+")"}):n=="none"&&stylesheet.update_rule(t,{"background-image":"none"})},propertyInputCallbackFontStyling=function(e){var t=e.selector,n=e.value,r=e.element;n==="normal"?stylesheet.update_rule(t,{"font-style":"normal","font-weight":"normal"}):n==="bold"?stylesheet.update_rule(t,{"font-style":"normal","font-weight":"bold"}):n==="light"?stylesheet.update_rule(t,{"font-style":"normal","font-weight":"lighter"}):n==="italic"?stylesheet.update_rule(t,{"font-style":"italic","font-weight":"normal"}):n==="bold-italic"?stylesheet.update_rule(t,{"font-style":"italic","font-weight":"bold"}):n===null&&(stylesheet.delete_rule_property(t,"font-style"),stylesheet.delete_rule_property(t,"font-weight"))},propertyInputCallbackCapitalization=function(e){var t=e.selector,n=e.value,r=e.element;n==="none"||n==null?stylesheet.update_rule(t,{"text-transform":"none","font-variant":"normal"}):n==="small-caps"?stylesheet.update_rule(t,{"text-transform":"none","font-variant":"small-caps"}):stylesheet.update_rule(t,{"text-transform":n,"font-variant":"normal"})},propertyInputCallbackShadow=function(t){var n=t.selector,r=t.value,i=t.element,s=t.property,o=s.indexOf("box-shadow")===0?"box-shadow":"text-shadow",u=$i(n).css(o)||!1;if(u==0||u=="none")u="rgba(0, 0, 0, 0) 0 0 0";var a=u.replace(/, /g,",").replace(/px/g,"").split(" "),f=e('li[data-property-id="'+o+"-color"+'"] input').val()||a[0],l=e('li[data-property-id="'+o+"-horizontal-offset"+'"] input').val()||a[1],c=e('li[data-property-id="'+o+"-vertical-offset"+'"] input').val()||a[2],h=e('li[data-property-id="'+o+"-blur"+'"] input').val()||a[3],p=e('li[data-property-id="'+o+"-position"+'"] input').val()||a[4];switch(s){case o+"-horizontal-offset":l=r||0;break;case o+"-vertical-offset":c=r||0;break;case o+"-blur":h=r||0;break;case o+"-inset":p=r;break;case o+"-color":f=r}if(!f)return stylesheet.delete_rule_property(n,o);p=="inset"?p=" inset":p="";var d=f+" "+l+"px "+c+"px "+h+"px"+p,v={};v[o]=d,stylesheet.update_rule(n,v),updateInspectorVisibleBoxModal()},addInspector=function(t){if(typeof Headway.elements=="undefined")return e.when(designEditorRequestElements()).then(addInspector);e.each(Headway.elements,function(e,t){if(!t.inspectable)return;addInspectorProcessElement(t)}),(typeof t=="undefined"||t!==!0)&&$i("body").qtip({id:"",style:{classes:"qtip-headway qtip-inspector-tooltip"},position:{target:[-9999,-9999],my:"center",at:"center",container:$i("body"),viewport:$iDocument(),effect:!1,adjust:{x:35,y:35,method:"flipinvert"}},content:{text:"Hover over an element."},show:{event:!1,ready:!0},hide:!1,events:{render:function(t,n){delete inspectorElement,delete inspectorTooltip,delete inspectorElementOptions,inspectorTooltip=n,e("#toggle-inspector").hasClass("inspector-disabled")?disableInspector():enableInspector()}}})},refreshInspector=function(){return addInspector(!0)},addInspectorProcessElement=function(t){if(t["group"]=="default-elements")return;if(!$i(t.selector).length)return;t["selector"].indexOf(":")==-1&&($i(t.selector).data({inspectorElementOptions:t}),$i(t.selector).addClass("inspector-element")),e.each(t.instances,function(n,r){if(r["selector"].indexOf(":")!=-1)return;if(!$i(r.selector).length)return;var i=jQuery.extend(!0,{},t);i.parentName=t.name,i.instance=r.id,i.name=r.name,i.selector=r.selector,i.instances={},e.each(t.instances,function(e,t){t["state-of"]==n&&(i.instances[e]=t)}),e.each(i.selector.split(","),function(e,t){if(t.indexOf(":")!=-1)return;$i(t).data({inspectorElementOptions:i}),$i(t).addClass("inspector-element")})})},enableInspector=function(){if(Headway.mode!="design"||!Headway.designEditorSupport)return!1;Headway.inspectorDisabled=!1,Headway.disableBlockDimensions=!0,$i("body").addClass("disable-block-hover").removeClass("inspector-disabled"),$i(".block[data-hasqtip]").each(function(){var t=e(this).qtip("api");t.destroy()}),inspectorTooltip.show();var t=Headway.touch?"tap":"mousemove";$i("html").bind(t,inspectorMouseMove),setupInspectorContextMenu(),deactivateContextMenu("block"),deactivateContextMenu("wrapper"),Headway.iframe.contents().bind("keydown",inspectorNudging),Headway.iframe.bind("keydown",inspectorNudging),Headway.iframe.bind("mouseover",function(){Headway.iframe.focus()}),showNotification({id:"inspector",message:"<strong>Right-click</strong> highlighted elements to style them.<br /><br />Once an element is selected, you may nudge it using your arrow keys.<br /><br />The faded orange and purple are the margins and padding.  These colors are only visible when the inspector is active.",closeConfirmMessage:"Please be sure you understand how the Design Editor inspector works before hiding this message.",closeTimer:!1,closable:!0,doNotShowAgain:!0}),updateInspectorVisibleBoxModal(),e("#toggle-inspector").removeClass("inspector-disabled")},disableInspector=function(){if(Headway.mode!="design"||!Headway.designEditorSupport)return!1;Headway.inspectorDisabled=!0,delete Headway.disableBlockDimensions,delete inspectorElement,$i(".inspector-element-hover").removeClass("inspector-element-hover"),$i("body").removeClass("disable-block-hover").addClass("inspector-disabled"),$i(".block").qtip("enable"),e(inspectorTooltip.elements.tooltip).hide(),hideNotification("inspector"),$i("html").unbind("mousemove",inspectorMouseMove),deactivateContextMenu("inspector"),setupBlockContextMenu(),setupWrapperContextMenu(),Headway.iframe.contents().unbind("keydown",inspectorNudging),Headway.iframe.unbind("keydown",inspectorNudging),removeInspectorVisibleBoxModal(),e("#toggle-inspector").addClass("inspector-disabled")},toggleInspector=function(){if(Headway.mode!="design"||!Headway.designEditorSupport)return!1;if(e("#toggle-inspector").hasClass("inspector-disabled"))return enableInspector();disableInspector()},inspectorSelectElement=function(t){$i(".inspector-element-selected").each(function(){e(this).removeClass("inspector-element-selected"),removeInspectorVisibleBoxModal(e(this))}),$i(t).addClass("inspector-element-selected"),updateInspectorVisibleBoxModal()},removeInspectorVisibleBoxModal=function(t){if(typeof t=="undefined")var t=$i(".inspector-element-selected");return e(t).data("previousBoxShadow")?(e(t).data("previousBoxShadow",null),e(t).css("boxShadow","")):!1},updateInspectorVisibleBoxModal=function(){if(typeof Headway.inspectorDisabled!="undefined"&&Headway.inspectorDisabled)return;$i(".inspector-element-selected").each(function(){removeInspectorVisibleBoxModal(e(this));var t=this,n=e(this).css("box-shadow"),r=n!="none"?n.split(","):[];e(this).data("previousBoxShadow",n),e.each(["paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft"],function(n,i){var s=e(t).css(i).replace(/^[+-]?\d+(\.\d+)?/g,""),o=e(t).css(i).replace(s,"");if(o=="auto")return;var u=i.indexOf("padding")!==-1?"rgba(0, 0, 255, .15)":"rgba(255, 127, 0, .15)",a="",f="";if(i=="paddingRight"||i=="paddingBottom"||i=="marginLeft"||i=="marginTop")a="-";var l=a+o+s;if(i.toLowerCase().indexOf("left")!==-1||i.toLowerCase().indexOf("right")!==-1)var c=l+" 0";else var c="0 "+l;i.indexOf("padding")!==-1&&(f="inset "),r.push(f+c+" 0 0 "+u)}),e(this).css({boxShadow:r.join(",")})})},inspectorMouseMove=function(t){if(Headway.inspectorDisabled)return;var n=e(t.target);n.hasClass("inspector-element")||(n=n.parents(".inspector-element").first());if(typeof inspectorElement=="undefined"||!n.is(inspectorElement)){inspectorElement=e(t.target),inspectorElement.hasClass("inspector-element")||(inspectorElement=inspectorElement.parents(".inspector-element").first());var r=inspectorElement.data("inspectorElementOptions");if(typeof r=="object"){$i(".inspector-element-hover").removeClass("inspector-element-hover"),$i(r.selector).addClass("inspector-element-hover");var i=e("#design-editor-element-selector").find("li#element-"+r.id),s=i.children(".element-name").text(),o='<span class="inspector-tooltip-element-path">',u=[];i.parents("li").reverse().each(function(){u.push(e(this).children(".element-group-name, .element-name").first().text())});var a="";typeof r.instance!="undefined"&&(r.name.indexOf(" &ndash; ")!==-1?a='<span class="inspector-tooltip-instance">Inside <strong>'+r.name.split(" &ndash; ")[0]+"</strong></span>":s=r.name);if(u.join(" > ").length+s.length>40)while(u.join(" > ").length+s.length>40&&s.length<40)u.shift(),tooltipElementPathStr='<span class="ellipsis">...</span> '+u.join(" &rsaquo; ");else tooltipElementPathStr=u.join(" &rsaquo; ");o+=tooltipElementPathStr,o+=" &rsaquo; <strong>"+s+"</strong></span>",o+=a,o+='<small class="right-click-message">Right-click to style</small>',inspectorTooltip.set("content.text",o)}}inspectorTooltip.show();var f=$i("#ui-tooltip-inspector-tooltip").width(),l=$i("body").width()-t.pageX-f+15,c=l>0?t.pageX:t.pageX+l;inspectorTooltip.set("position.target",[c,t.pageY])},setupInspectorContextMenu=function(){return setupContextMenu({id:"inspector",elements:"body",title:function(e){return inspectorElement.data("inspectorElementOptions").name},onShow:inspectorContextMenuOnShow,onHide:function(){inspectorTooltip.show(),Headway.inspectorDisabled=!1},onItemClick:inspectorContextMenuItemClick,contentsCallback:inspectorContextMenuContents})},inspectorContextMenuOnShow=function(t){e(this).data("element-options",inspectorElement.data("inspectorElementOptions")),e(inspectorTooltip.elements.tooltip).hide(),Headway.inspectorDisabled=!0},inspectorContextMenuItemClick=function(t,n){if(e(this).hasClass("group-title")&&!e(this).hasClass("group-title-clickable"))return;if(e(this).parents("li").first().hasClass("inspector-context-menu-block-options"))openBlockOptions(getBlock(e(inspectorElement)));else{var r=t.data("element-options"),i=e(this).parents("li").first().data("instance-id"),s=e(this).parents("li").first().data("state-id");inspectorTooltip.show(),Headway.inspectorDisabled=!1,e("#design-editor-element-selector-container .ui-state-active").removeClass("ui-state-active"),typeof i!="undefined"?designEditor.selectSpecialElement(r.id,"instance",i):typeof s!="undefined"?designEditor.selectSpecialElement(r.id,"state",s):e(this).parents("li").first().hasClass("inspector-context-menu-parent")||e("ul#design-editor-element-selector li#element-"+r.id).find("> span").trigger("click"),e(this).parents("li").first().hasClass("inspector-context-menu-edit-for-layout")&&designEditor.selectSpecialElement(r.id,"layout",Headway.currentLayout)}},inspectorContextMenuContents=function(n){var r=e(this),i=r.data("element-options"),s=typeof i.instance!="undefined"&&i.instance,o=r;if(s){r.append('<li class="inspector-context-menu-edit-instance" data-instance-id="'+i.instance+'"><span>Edit This Instance</span></li>');var o=e('<li class="inspector-context-menu-edit-normal"><span class="group-title group-title-clickable">Edit Regular Element<small>'+i.parentName+"</small></span><ul></ul></li>").appendTo(r);o=o.find("ul").first()}else o.append('<li class="inspector-context-menu-edit-normal"><span>Edit</span></li>');o.append('<li class="inspector-context-menu-edit-for-layout"><span>Edit For This Layout</span></li>');if(!t.isEmpty(i.states)){var u=e('<li class="inspector-context-menu-states"><span class="group-title">States</span><ul></ul></li>').appendTo(o);e.each(i.states,function(e,t){u.find("ul").append('<li data-state-id="'+e+'"><span>Edit '+t.name+"</span></li>")})}if(!t.isEmpty(i.instances)){if(typeof i.instance=="undefined"||!i.instance)var a=e('<li class="inspector-context-menu-instances"><span class="group-title">Instances</span><ul></ul></li>').appendTo(r);else var a=!1;e.each(i.instances,function(t,n){n["state-of"]==i.instance&&(r.find("> li.inspector-context-menu-instance-states").length||e('<li class="inspector-context-menu-instance-states"><span class="group-title">Instance States</span><ul></ul></li>').insertAfter(r.find("li.inspector-context-menu-edit-instance")),r.find("> li.inspector-context-menu-instance-states ul").append('<li data-instance-id="'+t+'"><span>Edit '+n["state-name"]+"</span></li>"))}),a&&!a.find("ul li").length&&a.remove()}if(inspectorElement.parents(".inspector-element").length){var f=e('<li class="inspector-context-menu-parents"><span class="group-title">Parents</span><ul></ul></li>').appendTo(r);inspectorElement.parents(".inspector-element").each(function(){var t=e(this);e('<li class="inspector-context-menu-parent" data-parent-id="'+e(this).data("inspectorElementOptions").id+'"><span>'+e(this).data("inspectorElementOptions").name+"</span></li>").appendTo(f.find("ul")).bind("click",function(){inspectorElement=t;var e=typeof n.data!="undefined"?n.data.x:n.originalEvent.clientX,r=typeof n.data!="undefined"?n.data.y:n.originalEvent.clientY;t.trigger("contextmenu",{x:e,y:r})})})}if(getBlock(inspectorElement))var l=getBlock(inspectorElement),c=getBlockID(l),h=getBlockTypeNice(getBlockType(l)),p=e('<li class="inspector-context-menu-block-options"><span>Open Block Options</span></li>').appendTo(r)},inspectorNudging=function(t){var n=t.keyCode;if(n<37||n>40||!$i(".inspector-element-selected").length||$i(".inspector-element-selected").is("body"))return;var r=t.shiftKey?5:1,i=e(".design-editor-box-nudging .design-editor-property-position select",".design-editor-options-container"),s=i.parents(".design-editor-property-position").find('input[type="hidden"]'),o=s.attr("element_selector");e(".design-editor-box-nudging .uncustomized-property .customize-property span",".design-editor-options-container").trigger("click");if($i(".inspector-element-selected").css("position")!="static"){var u=$i(".inspector-element-selected").css("position");$i(".inspector-element-selected").css({position:u}),i.val(u).trigger("change")}else{var u="relative";$i(".inspector-element-selected").css({position:u}),i.val(u).trigger("change")}switch(n){case 37:var a=parseInt($i(".inspector-element-selected").css("left"));if(isNaN(a))var a=0;stylesheet.update_rule(o,{left:a-r+"px"});var f=$i(".inspector-element-selected").css("left").replace("px","");e('.design-editor-box-nudging .design-editor-property-left input[type="text"]',".design-editor-options-container").val(f).trigger("change");break;case 38:var l=parseInt($i(".inspector-element-selected").css("top"));isNaN(l)&&(l=0),stylesheet.update_rule(o,{top:l-r+"px"});var c=$i(".inspector-element-selected").css("top").replace("px","");e('.design-editor-box-nudging .design-editor-property-top input[type="text"]',".design-editor-options-container").val(c).trigger("change");break;case 39:var a=parseInt($i(".inspector-element-selected").css("left"));if(isNaN(a))var a=0;stylesheet.update_rule(o,{left:a+r+"px"});var f=$i(".inspector-element-selected").css("left").replace("px","");e('.design-editor-box-nudging .design-editor-property-left input[type="text"]',".design-editor-options-container").val(f).trigger("change");break;case 40:var l=parseInt($i(".inspector-element-selected").css("top"));isNaN(l)&&(l=0),stylesheet.update_rule(o,{top:l+r+"px"});var c=$i(".inspector-element-selected").css("top").replace("px","");e('.design-editor-box-nudging .design-editor-property-top input[type="text"]',".design-editor-options-container").val(c).trigger("change")}return t.preventDefault(),!1},getElementNodeName=function(e){var t=e.clone();return t.find("> span").children().remove().end().text()},getSelectedElement=function(){return typeof Headway.designEditorCurrentElement!="undefined"?Headway.designEditorCurrentElement:null},setSelectedElement=function(e){Headway.designEditorCurrentElement=e;if(t.isEmpty(e))return;var n={};typeof e.specialElementType!="undefined"&&(n[e.specialElementType]=e.specialElementName),setSelectedElementDetails(n,e.object)},setSelectedElementDetails=function(n,r){var n=e.extend({},{instance:r.name,layout:"all layouts",state:"all states"},n),i=e("span.design-editor-selection-details");i.find(".design-editor-selected-element").html(n.instance),i.find("strong.design-editor-selection-details-layout").html(n.layout),typeof r.states=="undefined"||t.isEmpty(r.states)?i.find("span.design-editor-selection-details-state-container").hide():(i.find("span.design-editor-selection-details-state-container").show(),n.state=="all states"?i.find(".design-editor-selection-details-state-before").text("and"):i.find(".design-editor-selection-details-state-before").text("when"),n.state=="Hover"&&(n.state="hovered"),i.find("strong.design-editor-selection-details-state").html(n.state.toLowerCase()));var s=e(".design-editor-info").outerHeight();return e(".design-editor-info").css("marginTop","-"+s+"px"),e("#side-panel-bottom").css("paddingTop",s+"px"),e("span.design-editor-selection-details")},sanitizeElementName=function(t){return e.trim(t.escapeHTML())};var n={init:function(){designEditor=new designEditorTabEditor,designEditor._init(),n.bind(),designEditorBindPropertyInputs();try{e.getScript(Headway.headwayURL+"/library/visual-editor/"+Headway.scriptFolder+"/util.fonts-browser.js"),e.getScript("//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js")}catch(t){}e.cookie("hide-design-editor")==="true"&&hideDesignEditor()},bind:function(){e("#toggle-inspector").bind("click",toggleInspector)},iframeCallback:function(){bindBlockDimensionsTooltip(),addInspector(),designEditor.switchLayout()}};return n}),define("util.tour",["jquery","util.tooltips","helper.boxes","modules/panel"],function(e,t,n){return tourStepsGrid=[{beginning:!0,title:"Welcome to the Headway Visual Editor!",content:"<p>If this is your first time in the Headway Visual Editor, <strong>we recommend following this tour so you can get the most out of Headway</strong>.</p><p>Or, if you're experienced or want to dive in right away, just click the close button in the top right at any time.</p>"},{target:e("li#mode-grid"),title:"Mode Selector",content:"<p>The Headway Visual Editor is split up into 2 modes.</p><p><ul><li><strong>Grid</strong> &ndash; Build your layouts</li><li><strong>Design</strong> &ndash; Add colors, customize fonts, and more!</li></ul></p>",position:{my:"top left",at:"bottom center"}},{target:e("#layout-selector-select-content"),title:"Layout Selector",content:'<p style="font-size:12px;">Since you may not want every page to be the same, you may use the Layout Selector to select which page, post, or archive to edit.</p><p style="font-size:12px;">The Layout Selector is based off of inheritance.  For example, you can customize the "Page" layout and all pages will follow that layout.  Plus, you can customize a specific page and it\'ll be different than all other pages.</p><p style="font-size:12px;">The layout selector will allow you to be as precise or broad as you wish.  It\'s completely up to you!</p>',position:{my:"top center",at:"bottom center"}},{target:e("div#box-grid-wizard"),title:"The Headway Grid",content:'<p>Now we\'re ready to get started with the Headway Grid.  In other words, the good stuff.</p><p>To build your first layout, please select a preset to the right to pre-populate the grid.  Or, you may select "Use Empty Grid" to start with a completely blank grid.</p><p>Once you have a preset selected, click "Finish".</p>',position:{my:"right top",at:"left center"},nextHandler:{showButton:!1,clickElement:"#grid-wizard-button-preset-use-preset, span.grid-wizard-use-empty-grid",message:'Please click <strong>"Finish"</strong> or <strong>"Use Empty Grid"</strong> to continue.'}},{iframeTarget:"div.grid-container",title:"Adding Blocks",content:"<p>To add a block, simply place your mouse into the grid then click at where you'd like the top-left point of the block to be.</p><p>Drag your mouse and the block will appear!  Once the block appears, you may choose the block type.</p><p>Hint: Don't worry about being precise, you may always move or resize the block.</p>",position:{my:"right top",at:"left top",adjustY:100},maxWidth:280},{iframeTarget:"div.grid-container",title:"Modifying Blocks",content:'                                    <p style="font-size:12px;">After you\'ve added the desired blocks to your layout, you may move, resize, delete, or change the options of the block at any time.</p>                                     <ul style="font-size:12px;">                                            <li><strong>Moving Blocks</strong> &ndash; Click and drag the block.  If you wish to move multiple blocks simultaneously, double-click on a block to enter <em>Mass Block Selection Mode</em>.</li>                                             <li><strong>Resizing Blocks</strong> &ndash; Grab the border or corner of the block and drag your mouse.</li>                                           <li><strong>Block Options (e.g. header image)</strong> &ndash; Hover over the block then click the block options icon in the top-right.</li>                                            <li><strong>Deleting Blocks</strong> &ndash; Move your mouse over the desired block, then click the <em>X</em> icon in the top-right.</li>                                      </ul>',position:{my:"right top",at:"left top",adjustY:100},maxWidth:280},{target:e("#save-button-container"),title:"Saving",content:"<p>Now that you hopefully have a few changes to be saved, you can save using this spiffy Save button.</p><p>For those of you who like hotkeys, use <strong>Ctrl + S</strong> to save.</p>",position:{my:"top right",at:"bottom center"},tip:"top right"},{target:e("li#mode-design a"),title:"Design Mode",content:"<p>Thanks for sticking with us!</p><p>Now that you have an understanding of the Grid Mode, we hope you stick with us and head on over to the Design Mode.</p>",position:{my:"top left",at:"bottom center",adjustY:5},tip:"top left",buttonText:"Continue to Design Mode",buttonCallback:function(){e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"ran_tour",mode:"grid",complete:function(){Headway.ranTour.grid=!0,e("li#mode-design a").trigger("click"),window.location=e("li#mode-design a").attr("href")}})}}],tourStepsDesign=[{beginning:!0,title:"Welcome to the Headway Design Editor!",content:"<p>In the <strong>Design Editor</strong>, you can style your elements however you'd like.</p><p>Whether it's fonts, colors, padding, borders, shadows, or rounded corners, you can use the design editor.</p><p>Stick around to learn more!</p>"},{target:"#side-panel-top",title:"Element Selector",content:"<p>The element selector allows you choose which element to edit.</p>",position:{my:"right top",at:"left center"},callback:function(){e("li#element-block-header > span.element-name").trigger("click")}},{target:"#toggle-inspector",title:"Inspector",content:"                                     <p>Instead of using the <em>Element Selector</em>, let the Inspector do the work for you.</p>                                   <p><strong>Try it out!</strong> Point and right-click on the element you wish to edit and it will become selected!</p>                          ",position:{my:"top right",at:"bottom center",adjustX:10,adjustY:5}},{target:"window",title:"Have fun building with Headway!",content:'<p>We hope you find Headway to the most powerful and easy-to-use WordPress framework around.</p><p>If you have any questions, please don\'t hesitate to visit the <a href="http://support.headwaythemes.com/?utm_source=visualeditor&utm_medium=headway&utm_campaign=tour" target="_blank">support forums</a>.</p>',end:!0}],{start:function(){if(Headway.mode=="grid"){var t=tourStepsGrid;hidePanel(),openBox("grid-wizard")}else{if(Headway.mode!="design")return;var t=tourStepsDesign;showPanel(),require(["modules/design/mode-design"],function(){showDesignEditor()}),typeof e("div#panel").data("ui-tabs")!="undefined"&&selectTab("editor-tab",e("div#panel"))}e('<div class="black-overlay"></div>').hide().attr("id","black-overlay-tour").css("zIndex",15).appendTo("body").fadeIn(500),e(document.body).qtip({id:"tour",content:{text:t[0].content+'<div id="tour-next-container"><span id="tour-next" class="tour-button button button-blue">Continue Tour <span class="arrow">&rsaquo;</span></span></div>',title:{text:t[0].title,button:"Skip Tour"}},style:{classes:"qtip-tour",tip:{width:18,height:10,mimic:"center",offset:10}},position:{my:"center",at:"center",target:e(window),viewport:e(window),adjust:{y:5,method:"shift shift"}},show:{event:!1,ready:!0,effect:function(){e(this).fadeIn(500)}},hide:!1,events:{render:function(n,r){var i=r.elements.tooltip;r.step=0,i.bind("next",function(n){e(window).trigger("resize"),r.step+=1,r.step=Math.min(t.length-1,Math.max(0,r.step)),currentTourStep=t[r.step],e("div#black-overlay-tour").fadeOut(100,function(){e(this).remove()}),typeof currentTourStep.callback=="function"&&currentTourStep.callback.apply(r),currentTourStep.target=="window"?currentTourStep.target=e(window):typeof currentTourStep.target=="string"?currentTourStep.target=e(currentTourStep.target):typeof currentTourStep.iframeTarget=="string"&&(currentTourStep.target=$i(currentTourStep.iframeTarget).first()),r.set("position.target",currentTourStep.target),typeof currentTourStep.maxWidth!="undefined"&&window.innerWidth<1440?e(".qtip-tour").css("maxWidth",currentTourStep.maxWidth):e(".qtip-tour").css("maxWidth",350);var i="Next";if(typeof currentTourStep.buttonText=="string")var i=currentTourStep.buttonText;if(typeof currentTourStep.end!="undefined"&&currentTourStep.end===!0)var s='<div id="tour-next-container"><span id="tour-finish" class="tour-button button button-blue">Close Tour <span class="arrow">&rsaquo;</span></div>';else if(typeof currentTourStep.nextHandler=="undefined"||currentTourStep.nextHandler.showButton)var s='<div id="tour-next-container"><span id="tour-next" class="tour-button button button-blue">'+i+' <span class="arrow">&rsaquo;</span></div>';else var s='<div id="tour-next-container"><p>'+currentTourStep.nextHandler.message+"</p></div>";if(typeof currentTourStep.nextHandler!="undefined"&&e(currentTourStep.nextHandler.clickElement)){var o=function(t){e(".qtip-tour").triggerHandler("next"),t.preventDefault(),e(this).unbind("click",o)};e(currentTourStep.nextHandler.clickElement).bind("click",o)}r.set("content.text",currentTourStep.content+s),r.set("content.title",currentTourStep.title),typeof currentTourStep.end=="undefined"?(typeof currentTourStep.position!="undefined"?(r.set("position.my",currentTourStep.position.my),r.set("position.at",currentTourStep.position.at),typeof currentTourStep.position.adjustX!="undefined"?r.set("position.adjust.x",currentTourStep.position.adjustX):r.set("position.adjust.x",0),typeof currentTourStep.position.adjustY!="undefined"?r.set("position.adjust.y",currentTourStep.position.adjustY):r.set("position.adjust.y",0)):(r.set("position.my","top center"),r.set("position.at","bottom center")),typeof currentTourStep.tip!="undefined"&&r.set("style.tip.corner",currentTourStep.tip)):(r.set("position.my","center"),r.set("position.at","center"))}),e("div.qtip-tour").on("click","span#tour-next",function(t){typeof currentTourStep=="object"&&typeof currentTourStep.buttonCallback=="function"&&currentTourStep.buttonCallback.call(),e(".qtip-tour").triggerHandler("next"),t.preventDefault()}),e("div.qtip-tour").on("click","span#tour-finish",function(t){e(".qtip-tour").qtip("hide")})},hide:function(t,n){e("div#tour-overlay").remove(),e("div#black-overlay-tour").fadeOut(100,function(){e(this).remove()}),e(".qtip-tour").fadeOut(100,function(){e(this).qtip("destroy")}),Headway.ranTour[Headway.mode]==0&&Headway.ranTour.legacy!=1&&(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"ran_tour",mode:Headway.mode}),Headway.ranTour[Headway.mode]=!0)}}})}}}),define("modules/menu",["jquery","util.tour","helper.ace"],function(e,t,n){var r={init:function(){r.bind()},bind:function(){e("ul#modes li").on("click",function(){e(this).siblings("li").removeClass("active"),e(this).addClass("active")}),e("ul#modes li a").bind("click",function(){e(this).attr("href",e(this).attr("href")+"&ve-layout="+Headway.currentLayout)}),e("#menu-link-view-site a").bind("click",function(){e(this).attr("href",Headway.homeURL+"/?headway-trigger=layout-redirect&layout="+Headway.currentLayout)}),e("span#save-button").click(function(){return save(),!1}),e("#snapshots-button").bind("click",function(){openBox("snapshots")}),e("#tools-tour").bind("click",t.start),e("#tools-grid-wizard").bind("click",function(){hidePanel(),openBox("grid-wizard")}),e("#open-live-css").bind("click",function(){n.showEditor("live-css","css",e("textarea#live-css").val(),function(t){var n=t.getValue(),r=e("textarea#live-css");r.val(n),dataHandleInput(r),$i("style#live-css-holder").html(n),allowSaving()})}),e("#tools-clear-cache").bind("click",function(){var t={security:Headway.security,action:"headway_visual_editor",method:"clear_cache"};e.post(Headway.ajaxURL,t,function(e){e==="success"?showNotification({id:"cache-cleared",message:"The cache was successfully cleared!",success:!0}):showErrorNotification({id:"error-could-not-clear-cache",message:"Error: Could not clear cache."})})})}};return r}),define("modules/snapshots",["jquery","ko"],function(e,t){var n={init:function(){n.bind(),n.setupViewModel()},setupViewModel:function(){Headway.viewModels.snapshots={snapshots:t.observableArray(Headway.snapshots),formatSnapshotDatetime:function(e){var t=e.split(/[- :]/);return(new Date(Date.UTC(t[0],t[1]-1,t[2],t[3],t[4],t[5]))).toLocaleString()},rollbackToSnapshot:function(t,n){if(!confirm("Are you sure you wish to rollback?\n\nYou will lose all between this snapshot and now unless you save another snapshot."))return!1;var r=e(n.target);if(r.attr("disabled"))return!1;r.attr("disabled",!0),r.addClass("button-depressed"),r.text("Rolling Back.."),e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"rollback_to_snapshot",layout:Headway.currentLayout,snapshot_id:t.id,mode:Headway.mode},function(e){if(typeof e.error!="undefined")return;showNotification({id:"rolled-back-successfully",message:"Successfully rolled back to snapshot.<br /><br /><strong>Refreshing Visual Editor in 3 seconds</strong>.",success:!0}),r.text("Rolled Back!"),setTimeout(function(){allowVEClose(),document.location.reload(!0)},1e3)})},deleteSnapshot:function(t,n){if(!confirm("Are you sure you wish to delete this snapshot?\n\nYou cannot undo this or restore another snapshot to bring this snapshot back."))return!1;var r=e(n.target);if(r.hasClass("deletion-in-progress"))return!1;r.addClass("deletion-in-progress"),e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"delete_snapshot",layout:Headway.currentLayout,snapshot_id:t.id,mode:Headway.mode},function(e){if(typeof e.error!="undefined")return;showNotification({id:"deleted-snapshot-successfully",message:"Successfully deleted snapshot.",success:!0}),Headway.viewModels.snapshots.snapshots.remove(t)})},saveSnapshot:function(t,n){var r=e(n.target);if(r.attr("disabled"))return!1;r.attr("disabled",!0),r.text("Saving Snapshot..."),r.siblings(".spinner").show();var i=prompt("(Optional)\n\nEnter name or description of the changes in this snapshot.");e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"save_snapshot",layout:Headway.currentLayout,mode:Headway.mode,snapshot_comments:i},function(e){if(typeof e.timestamp=="undefined")return;showNotification({id:"snapshot-saved",message:"Snapshot saved.",success:!0}),Headway.viewModels.snapshots.snapshots.unshift({id:e.id,timestamp:e.timestamp,comments:e.comments}),r.text("Save Snapshot"),r.removeAttr("disabled"),r.siblings(".spinner").hide()})}},e(document).ready(function(){t.applyBindings(Headway.viewModels.snapshots,e("#box-snapshots").get(0))})},bind:function(){}};return n}),define("helper.wrappers",["modules/panel.inputs"],function(e){getWrapperID=function(e){return!$(e).length||!$(e).data("id")?null:$(e).data("id").toString().replace("wrapper-","")},openWrapperOptions=function(t){var t="wrapper-"+t,n=function(){var n=$("div#"+t+"-tab");n.tabs(),e.bind("div#"+t+"-tab"),handleInputTogglesInContainer(n.find("div.sub-tabs-content")),setupTooltips(),updateGridWidthInput($("div#"+t+"-tab")),$("div#"+t+"-tab").find('select[name="mirror-wrapper"]').val()&&($("div#"+t+"-tab ul.sub-tabs li:not(#sub-tab-config)").hide(),selectTab("sub-tab-config",$("div#"+t+"-tab")))},r=t.replace("wrapper-",""),i="Wrapper";typeof $i("#"+t).data("alias")!="undefined"&&$i("#"+t).data("alias")&&(i+=" ("+$i("#"+t).data("alias")+")"),addPanelTab(t,i,{url:Headway.ajaxURL,data:{security:Headway.security,action:"headway_visual_editor",method:"load_wrapper_options",wrapper_id:t.replace("wrapper-",""),unsaved_wrapper_options:getUnsavedWrapperOptionValues(t),layout:Headway.currentLayout},callback:n},!0,!0,"wrapper-options"),$("div#panel").tabs("option","active",$("#panel-top").children('li[role="tab"]').index($('[aria-controls="'+t+'-tab"]')))},getUnsavedWrapperOptionValues=function(e){if(typeof GLOBALunsavedValues=="object"&&typeof GLOBALunsavedValues["wrappers"]=="object"&&typeof GLOBALunsavedValues["wrappers"][e]=="object")var t=GLOBALunsavedValues.wrappers[e];return typeof t=="object"&&Object.keys(t).length>0?t:null},getWrapperMirror=function(e){return $i('.wrapper[data-id="'+e.replace("wrapper-","")+'"]').data("mirror-wrapper")},updateWrapperMirrorStatus=function(e,t,n){var e=e.replace("wrapper-",""),r=$i('.wrapper[data-id="'+e+'"]');populateWrapperMirrorNotice($i('.wrapper[data-id="'+e+'"]'));if(t){var t=t.replace("wrapper-","");r.addClass("wrapper-mirrored"),r.headwayGrid("disable"),typeof n!="undefined"&&n.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").hide()}else r.removeClass("wrapper-mirrored"),r.headwayGrid("enable"),typeof n!="undefined"&&n.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").show();r.data("ui-headwayGrid").updateGridContainerHeight(),r.data("ui-headwayGrid").resetGridCalculations(),r.data("ui-headwayGrid").alignAllBlocksWithGuides()},updateWrapperCustomClasses=function(e,t){if(Headway.mode!="design")return!1;var n=$i('.wrapper[data-id="'+e+'"]');return n.length?(n.removeClass(n.data("custom-classes")),n.data("custom-classes",t),n.addClass(t),n):!1}}),setupContextMenu=function(e){if(typeof e!="object")return!1;var e=$.extend(!0,{},{isIframeElement:!0},e);deactivateContextMenu(e.id);var t=Headway.touch?"taphold.contextMenu"+e.id:"contextmenu.contextMenu"+e.id;e.isIframeElement?$iDocument().on(t,e.elements,function(t,n){t.data=n,contextMenuCreator(e,t,!0)}):$(document).on(t,e.elements,function(t,n){t.data=n,contextMenuCreator(e,t,!1)});var n=function(t){if(t.which!==0&&t.which!==1||$(t.originalEvent.target).parents("#context-menu-"+e.id).length)return;var n=$("#context-menu-"+e.id);typeof e.onHide=="function"&&e.onHide.apply(n),n.remove()},r=Headway.touch?"touchstart":"click";$("body").on(r+".contextMenu"+e.id,n),$i("body").on(r+".contextMenu"+e.id,n)},deactivateContextMenu=function(e){return $(document).off(".contextMenu"+e),$iDocument().off(".contextMenu"+e),$("body").off(".contextMenu"+e),$i("body").off(".contextMenu"+e),!0},contextMenuCreator=function(e,t,n){t.stopPropagation();if(typeof e!="object")return!1;$(".context-menu").remove();var r=typeof e.title=="function"?e.title.apply(undefined,[t]):e.title,i=$('<ul id="context-menu-'+e.id+'" class="context-menu"><h3>'+r+"</h3></ul>");typeof e.onShow=="function"&&e.onShow.apply(i,[t]),e.contentsCallback.apply(i,[t]);var s=t,o=function(t){typeof e.onItemClick=="function"&&e.onItemClick.apply(this,[i,s]),typeof e.onHide=="function"&&e.onHide.apply(i),i.remove()},u=Headway.touch?"tap":"click";i.delegate("span",u,o);if(typeof t.originalEvent!="undefined"&&typeof t.originalEvent.clientX!="undefined")var a=t.originalEvent.clientX,f=t.originalEvent.clientY+40;else var a=t.data.x,f=t.data.y+40;i.css({left:a,top:f}),i.delegate("li:has(ul) span","hover",function(){var e=$(this).siblings("ul"),t=e.offset();if(!t||e.offset().left+e.outerWidth()<$("iframe.content").width())return;e.css("right",e.css("left")),e.css("left","auto"),e.css("width","190px"),e.css("zIndex","999999")}),i.appendTo($("body"));if(a+i.outerWidth()>$(window).width()){var l=$(window).width()-(a+i.outerWidth());i.css("left",a+l-20)}if(f+i.outerHeight()>$(window).height()){var l=$(window).height()-(f+i.outerHeight());i.css("top",f+l-20)}return t.preventDefault(),!1},define("helper.context-menus",function(){}),showNotification=function(e){var e=$.extend({},{id:null,message:null,error:!1,success:!1,closeTimer:3e3,closable:!1,closeOnEscKey:!1,closeCallback:function(){},closeConfirmMessage:null,fadeInDuration:350,timerFadeOutDuration:1500,closeFadeOutDuration:350,doNotShowAgain:!1,overwriteExisting:!1,opacity:1},e);if(e.doNotShowAgain&&$.cookie("headway-hide-notification-"+e.id))return;if($("#notification-"+e.id).length){if(!e.overwriteExisting)return $("#notification-"+e.id).fadeIn(e.fadeInDuration);hideNotification(e.id)}var t=$('<div class="notification"><p>'+e.message+"</p></div>");t.attr("id","notification-"+e.id),e.error&&t.addClass("notification-error"),e.success&&t.addClass("notification-success"),e.closable&&t.addClass("notification-closable"),t.css("opacity",e.notification).hide(),t.data("notification-args",e);if(e.closable){var n=$('<span class="close">Close</span>'),r=function(){if(e.closeConfirmMessage&&!confirm(e.closeConfirmMessage))return!1;hideNotification(e.id),$(document).unbind(".notification_"+e.id),$i("html").unbind(".notification_"+e.id)};n.appendTo(t),n.on("click",r),e.closeOnEscKey&&($(document).bind("keyup.notification_"+e.id,r),$i("html").bind("keyup.notification_"+e.id,r))}return e.closeTimer&&setTimeout(function(){t.fadeOut(e.timerFadeOutDuration,function(){$(this).remove()})},e.closeTimer),t.appendTo("#notification-center").fadeIn(350),t},showErrorNotification=function(e){var e=$.extend({},{error:!0,closeTimer:6e3},e);return showNotification(e)},hideNotification=function(e,t){var n=$("#notification-"+e);if(!n||!n.length)return!1;var r=n.data("notification-args");return typeof r.closeCallback=="function"&&r.closeCallback.apply(n),typeof t=="undefined"||t?n.fadeOut(r.closeFadeOutDuration,function(){$(this).remove(),r.doNotShowAgain&&$.cookie("headway-hide-notification-"+r.id,!0)}):(n.remove(),r.doNotShowAgain&&$.cookie("headway-hide-notification-"+r.id,!0)),n},updateNotification=function(e,t){var n=$("#notification-"+e);return n.find("p").html(t)},define("helper.notifications",function(){}),define("modules/grid/grid",["jquery","helper.history","helper.data"],function(e,t){e.widget("ui.headwayGrid",e.ui.mouse,{options:{useIndependentGrid:!1,columns:Headway.defaultGridColumnCount,columnWidth:Headway.defaultGridColumnWidth,gutterWidth:Headway.defaultGridGutterWidth,yGridInterval:5,minBlockHeight:10,selectedBlocksContainerClass:"selected-blocks-container",defaultBlockClass:"block",defaultBlockContentClass:"block-content"},_create:function(){this.wrapper=this.element,this.container=this.wrapper.find(".grid-container"),this.iframe=e(Headway.iframe),this.contents=e(this.iframe).contents(),this.document=e(this.iframe).contents(),this.options.useIndependentGrid=this.wrapper.data("wrapper-settings")["use-independent-grid"],this.wrapper.data("wrapper-settings").columns&&(this.options.columns=this.wrapper.data("wrapper-settings").columns),this.wrapper.data("wrapper-settings")["column-width"]&&(this.options.columnWidth=this.wrapper.data("wrapper-settings")["column-width"]),this.wrapper.data("wrapper-settings")["gutter-width"]&&(this.options.gutterWidth=this.wrapper.data("wrapper-settings")["gutter-width"]),this.addColumnGuides(),this.updateGridCSS(),this.helperTemplate=e('<div class="ui-grid-helper block"></div>'),this.offset=this.container.offset(),this.wrapper.addClass("ui-headway-grid"),this.wrapper.disableSelection(),this._mouseInit(),this._on(this.wrapper,{mousedown:"wrapperMouseDown"}),this._on(this.contents,{mousedown:"iframeMouseDown",mouseup:"iframeMouseUp"}),this._on(this.iframe,{mouseleave:"iframeMouseLeave"}),this._on(this.contents,{mousemove:"iframeMouseMove"}),this._on(e(window),{resize:"resetGridCalculations"}),this._on(e(window),{resize:"alignAllBlocksWithGuides"}),this.initResizable(this.container.children("."+this.options.defaultBlockClass.replace(".",""))),this.initDraggable(this.container.children("."+this.options.defaultBlockClass.replace(".",""))),this.updateGridContainerHeight(),this.container.delegate("."+this.options.defaultBlockClass.replace(".",""),"dblclick",function(t){var n=e(this).parents(".ui-headway-grid").data("ui-headwayGrid");e(this).hasClass("grouped-block")&&n.container.find(".grouped-block").length===1?(e(this).removeClass("grouped-block"),n.container.removeClass("grouping-active"),hideNotification("mass-block-selection")):e(this).hasClass("grouped-block")?e(this).removeClass("grouped-block"):(e(this).addClass("grouped-block"),n.container.addClass("grouping-active"),showNotification({id:"mass-block-selection",message:"Mass Block Selection Mode",closable:!0,closeOnEscKey:!0,closeTimer:!1,opacity:.8,closeCallback:function(){$i(".grouped-block").removeClass("grouped-block"),n.container.removeClass("grouping-active")}}))}),this.alignAllBlocksWithGuides()},resetGridCalculations:function(){this.grid={columns:this.container.find(".grid-guide").length,columnWidth:parseInt(this.container.find(".grid-guide:eq(1)").outerWidth()),gutterWidth:parseInt(this.container.find(".grid-guide:eq(1)").css("marginLeft").replace("px",""))};var t=this;this.wrapper.find(".block:visible").each(function(){e(this).data("plugin_pep")&&(e(this).data("plugin_pep").options.grid=[t.grid.columnWidth+t.grid.gutterWidth,t.options.yGridInterval]),e(this).data("ui-resizable")&&(e(this).resizable("option","grid",[t.grid.columnWidth+t.grid.gutterWidth,t.options.yGridInterval]),e(this).resizable("option","maxWidth",t.grid.columns*(t.grid.columnWidth+t.grid.gutterWidth)))})},_destroy:function(){return this.element.resizable("destroy"),this.element.removeClass("ui-grid ui-grid-disabled").removeData("grid").unbind(".grid"),this._mouseDestroy(),this.element.find(".ui-resizable").resizable("destroy"),this},disable:function(){this.element.resizable("disable"),this.element.find(".ui-resizable").resizable("disable")},enable:function(){this.element.resizable("enable"),this.element.find(".ui-resizable").resizable("enable")},iframeMouseDown:function(t){this._iframeMouseDownEvent=t,this._iframeMouseDownEventElement=e(t.originalEvent.target)},iframeMouseUp:function(e){delete this._iframeMouseDownEvent,delete this._iframeMouseDownEventElement},iframeMouseLeave:function(e){$iDocument().trigger("mouseup")},iframeMouseMove:function(t){if(typeof this._iframeMouseDownEvent!="undefined"||typeof this._doingHoverBlockToTop!="undefined"||!Headway.touch)return;this._doingHoverBlockToTop=!0,setTimeout(e.proxy(function(){var n=[],r=t.pageX,i=t.pageY;e(this.container).find(".block").each(function(){var t=e(this),s=t.offset(),o=s.left,u=s.top,a=o+t.width(),f=u+t.height();if(r<o||r>a)return;if(i<u||i>f)return;n.push(t)}),n.sort(function(e,t){return t.width()*t.height()>e.width()*e.height()?1:0}),this.sendBlockToTop(e(n.pop())),delete this._doingHoverBlockToTop},this),50)},wrapperMouseDown:function(t){if(!t||this.container.hasClass("grouping-active")||getBlock(t.target))return;$i(".blank-block").each(function(){removePanelTab("block-"+getBlockID(e(this))),e(this).remove()})},_mouseStart:function(t){this.mouseStartPosition=[t.pageX-this.container.offset().left,t.pageY-this.container.offset().top];var n=e(t.target);return!t||t.ctrlKey||this.container.hasClass("grouping-active")||getBlock(t.target)||n.hasClass("wrapper-handle")||n.parents(".wrapper-handle").length||n.hasClass("ui-resizable-handle")&&n.parent().hasClass("wrapper")||this.wrapper.hasClass("wrapper-mirrored")?!0:(this._trigger("start",t),this.helper=e(this.helperTemplate).clone().appendTo(this.container),this.helper.css({width:this.grid.columnWidth,height:0,top:0,left:0,display:"none"}),this.wrapper.hasClass("wrapper-fluid")&&this.wrapper.find(".wrapper-buttons").hide(),this.draggingOnWrapper=!0,addBlockDimensionsTooltip(this.helper),!0)},_mouseDrag:function(t){var n=e(t.target);if(!t||!this.helper||t.ctrlKey||this.container.hasClass("grouping-active")||!this.helper&&getBlock(t.target)||n.hasClass("wrapper-handle")||n.parents(".wrapper-handle").length||n.hasClass("ui-resizable-handle")&&n.parent().hasClass("wrapper")||!this.draggingOnWrapper||typeof this.draggingOnWrapper=="undefined"||this.wrapper.hasClass("wrapper-mirrored"))return;var r=e(this.container),i=r.offset(),s=this.mouseStartPosition[0],o=this.mouseStartPosition[1],u=t.pageX-i.left,a=t.pageY-i.top;if(s>u){var f=u;u=s,s=f}if(o>a){var f=a;a=o,o=f}var l=i.left,c=i.top,h=r.height(),p=r.width();if(u>=p&&s>=p)return;if(a>=h&&o>=h)return;s<0&&(s=0),o<0&&(o=0),a>h&&(a=h);var d=s.toNearest(this.grid.columnWidth+this.grid.gutterWidth),v=o.toNearest(this.options.yGridInterval),m=u.toNearest(this.grid.columnWidth+this.grid.gutterWidth)-d-this.grid.gutterWidth,g=a.toNearest(this.options.yGridInterval)-o.toNearest(this.options.yGridInterval);Headway.blankBlockOptions={display:"block",left:d,top:v,width:m,height:g},d+m>this.grid.columns*(this.grid.columnWidth+this.grid.gutterWidth)&&(Headway.blankBlockOptions.width=p-Headway.blankBlockOptions.left),t.pageY>c+h&&(Headway.blankBlockOptions.height=h-v),this.helper.css(Headway.blankBlockOptions);var y=Math.round((Headway.blankBlockOptions.width+this.grid.gutterWidth)/(this.grid.columnWidth+this.grid.gutterWidth)),b=Math.round(Headway.blankBlockOptions.left/(this.grid.columnWidth+this.grid.gutterWidth));return y==0&&(y=1),y&&setBlockGridWidth(this.helper,y),b&&setBlockGridLeft(this.helper,b),this.alignBlockWithGuides(this.helper),Headway.blankBlockOptions.height<this.options.minBlockHeight?this.helper.addClass("block-error"):this.helper.hasClass("block-error")&&this.helper.removeClass("block-error"),e.support.touch||(this.helper.qtip("option","hide.delay",1e4),this.helper.qtip("option","show.delay",10),this.helper.qtip("show"),this.helper.qtip("option","content.text",blockDimensionsTooltipContent),this.helper.qtip("reposition")),this._trigger("drag",t),this.draggingOnWrapper=!0,!1},_mouseStop:function(e){if(!e||e.ctrlKey||this.container.hasClass("grouping-active")||!this.helper||this.wrapper.hasClass("wrapper-mirrored"))return;return this._trigger("stop",e),Headway.blankBlockOptions={width:getBlockGridWidth(this.helper),left:getBlockGridLeft(this.helper),pixelWidth:this.helper.width(),pixelLeft:this.helper.position().left,height:this.helper.height(),top:this.helper.position().top},this.helper.qtip("api")&&this.helper.qtip("api").destroy(!0),this.wrapper.find(".wrapper-buttons").show(),this.helper.remove(),delete this.helper,Headway.blankBlockOptions.pixelWidth<this.grid.columnWidth||Headway.blankBlockOptions.height<this.options.minBlockHeight?!1:(this.addBlankBlock(Headway.blankBlockOptions),this.mouseStartPosition=!1,delete this.draggingOnWrapper,!1)},initResizable:function(t){if(typeof t=="string")var t=e(t);t.resizable({handles:"n, e, s, w, ne, se, sw, nw",grid:[this.grid.columnWidth+this.grid.gutterWidth,this.options.yGridInterval],containment:this.container,minHeight:this.options.minBlockHeight,maxWidth:this.grid.columns*(this.grid.columnWidth+this.grid.gutterWidth),start:this.resizableStart,resize:this.resizableResize,stop:this.resizableStop})},resizableStart:function(t,n){var r=getBlock(n.element),i=r.parents(".ui-headway-grid").data("ui-headwayGrid"),s=parseInt(r.css("minHeight").replace("px","")),o=r.height();s<=o&&r.css("minHeight",0),r.addClass("block-hover"),r.qtip("option","hide.delay",1e4),r.qtip("show"),r.qtip("reposition"),e(r).data("old-position",getBlockPosition(r)),e(r).data("old-position-pixels",getBlockPositionPixels(r)),e(r).data("old-dimensions",getBlockDimensions(r)),e(r).data("old-dimensions-pixels",getBlockDimensionsPixels(r)),i.wrapper.hasClass("wrapper-fluid")&&i.wrapper.find(".wrapper-buttons").hide()},resizableResize:function(e,t){var n=getBlock(t.element),r=n.parents(".ui-headway-grid").data("ui-headwayGrid"),i=Math.round((n.width()+r.grid.gutterWidth)/(r.grid.columnWidth+r.grid.gutterWidth)),s=Math.round(n.position().left/(r.grid.columnWidth+r.grid.gutterWidth));setBlockGridWidth(n,i),setBlockGridLeft(n,s),r.alignBlockWithGuides(n);var o=n.data("qtip");$i("#qtip-"+o.id).remove(),o.rendered=!1,o.render(),o.show()},resizableStop:function(e,t){var n=getBlock(t.element),r=n.parents(".ui-headway-grid").data("ui-headwayGrid"),i=n.data("old-position"),s=n.data("old-dimensions"),o={left:Math.round(n.position().left/(r.grid.columnWidth+r.grid.gutterWidth)),top:getBlockPositionPixels(n).top},u={width:Math.ceil(n.width()/(r.grid.columnWidth+r.grid.gutterWidth)),height:getBlockDimensionsPixels(n).height};r.wrapper.find(".wrapper-buttons").show();var a=function(e,t){setBlockGridWidth(n,e.width),setBlockGridLeft(n,t.left),n.height(e.height),n.css("top",t.top+"px"),n.attr({"data-grid-top":t.top,"data-height":e.height}),f()},f=function(){n.css("width",""),n.css("left",""),r.alignBlockWithGuides(n),dataSetBlockDimensions(getBlockID(n),getBlockDimensions(n)),dataSetBlockPosition(getBlockID(n),getBlockPosition(n)),blockIntersectCheck(n)?allowSaving():disallowSaving(),n.qtip("option","show.delay",300),n.qtip("option","hide.delay",25),n.qtip("show"),n.qtip("reposition"),n.removeClass("block-hover")};Headway.history.add({description:"Resized block",up:function(){a(u,o)},down:function(){a(s,i)}})},initDraggable:function(t){typeof t=="string"&&(t=e(t)),t.css("cursor","move").pep({grid:[this.grid.columnWidth+this.grid.gutterWidth,this.options.yGridInterval],constrainTo:"parent",shouldEase:!1,start:this.draggableStart,stop:this.draggableStop,drag:this.draggableDrag})},draggableStart:function(t,n){if(t.ctrlKey)return!1;if(e(t.target).hasClass("ui-resizable-handle"))return e(n.el).trigger("stop"),!1;var r=n.el,i=getBlock(r).parents(".ui-headway-grid").data("ui-headwayGrid");blockGroupingOriginals={},blockGroupingOriginals[getBlockID(r)]={top:getBlockPositionPixels(r).top,left:getBlockPositionPixels(r).left},e(r).hasClass("grouped-block")?(e(r).data("plugin_pep").$el=i.container.find(".grouped-block"),i.container.find(".grouped-block").each(function(t){e(this).data("old-position",getBlockPosition(e(this))),e(this).data("old-position-pixels",getBlockPositionPixels(e(this)))}),i.sendBlockToTop(i.container.find(".grouped-block"))):(i.container.removeClass("grouping-active"),i.container.find(".grouped-block").removeClass("grouped-block"),hideNotification("mass-block-selection"),i.sendBlockToTop(e(r)),e(r).data("plugin_pep").$el=e(r),e(r).data("old-position",getBlockPosition(r)),e(r).data("old-position-pixels",getBlockPositionPixels(r))),i.wrapper.hasClass("wrapper-fluid")&&i.wrapper.find(".wrapper-buttons").hide(),e(getBlock(n.el)).qtip("hide"),e(getBlock(n.el)).qtip("disable")},draggableDrag:function(t,n){if(e(n.startEvent.target).hasClass("ui-resizable-handle"))return!1;var r=n.el,i=e(r),s,o=getBlock(e(r)).parents(".grid-container"),u=getBlock(e(r)).parents(".ui-headway-grid").data("ui-headwayGrid"),a=getBlock(e(r)).parents(".wrapper");$i(".grid-container").length>1&&!u.container.find(".grouped-block").length&&($i(".grid-container").not(o).each(function(){var n=e(this).closest(".wrapper")[0].getBoundingClientRect(),i=e(this)[0].getBoundingClientRect();s=t.pageX>n.left&&t.pageX<n.right&&t.pageY>n.top+$iDocument().scrollTop()&&t.pageY<n.bottom+$iDocument().scrollTop(),s?e(this).addClass("ui-state-hover"):e(this).removeClass("ui-state-hover");if(s){var o=e(r).data("wrapper-droppable-clone"),a={top:t.pageY-i.top-$iDocument().scrollTop(),left:t.pageX-i.left};if(!o){var o=e(r).clone().css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"",left:e(r).position().left.toNearest(u.grid.columnWidth+u.grid.gutterWidth)}).appendTo(e(this));o.data("left-difference",a.left-e(r).position().left.toNearest(u.grid.columnWidth+u.grid.gutterWidth)),e(r).data("ghost-position",e(r).position()).css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""}).addClass("block-ghost"),e(r).data("wrapper-droppable-clone",o),delete e(r).data("plugin_pep").translation,delete e(r).data("plugin_pep").cssX,delete e(r).data("plugin_pep").cssY}else e(o).closest(e(this)).length||e(o).appendTo(e(this));var f=parseInt(a.top).toNearest(u.options.yGridInterval),l=parseInt(a.left-o.data("left-difference")).toNearest(u.grid.columnWidth+u.grid.gutterWidth);return parseInt(l)+parseInt(e(r).width())>e(this).width()&&(l=e(this).width()-e(r).width()),e(r).height()+f>e(this).height()&&(f=e(this).height()-e(r).height()),f<0&&(f=0),l<0&&(l=0),e(r).height()>e(this).height()&&(e(this).attr("data-original-height")||e(this).attr("data-original-height",e(this).height()),e(this).height(e(r).height())),e(o).css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"",top:parseInt(f).toNearest(u.options.yGridInterval),left:parseInt(l).toNearest(u.grid.columnWidth+u.grid.gutterWidth)}),!1}}),s||($i(".block-ghost").each(function(){e(this).data("wrapper-droppable-clone").remove(),e(this).removeData("wrapper-droppable-clone"),e(this).removeClass("block-ghost"),e(this).css({left:e(this).data("ghost-position").left,top:e(this).data("ghost-position").top,transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""})}),$i("[data-original-height]").each(function(){e(this).height(e(this).data("original-height")),e(this).removeAttr("data-original-height")})));if(s)return!1;e(getBlock(n.helper)).qtip("hide")},draggableStop:function(t,n){if(e(n.startEvent.target).hasClass("ui-resizable-handle"))return!1;var r=e(n.el),i=getBlock(e(r)).parents(".grid-container"),s=getBlock(e(r)).parents(".ui-headway-grid").data("ui-headwayGrid"),o,u;$i(".grid-container").length>1&&!s.container.find(".grouped-block").length&&$i(".grid-container").not(i).each(function(){var n=e(this).closest(".wrapper")[0].getBoundingClientRect();o=t.pageX>n.left&&t.pageX<n.right&&t.pageY>n.top+$iDocument().scrollTop()&&t.pageY<n.bottom+$iDocument().scrollTop();if(o||!t.originalEvent&&e(this).find(e(r).data("wrapper-droppable-clone")).length)return o=!0,u=e(this),!1;u=!1}),$i(".grid-container.ui-state-hover").removeClass("ui-state-hover");if(o&&$i(".grid-container").length>1){var a=u.parents(".wrapper").data("ui-headwayGrid"),f=r.parents(".grid-container");u.append(r),e(r).css(e(r).data("wrapper-droppable-clone").position()),e(r).css("transform",""),e(r).data("wrapper-droppable-clone").remove(),e(r).removeClass("block-ghost").removeData("wrapper-droppable-clone"),setBlockGridLeft(r,Math.round(e(r).position().left/(s.grid.columnWidth+s.grid.gutterWidth))),$i("[data-original-height]").removeAttr("data-original-height"),r.resizable("destroy"),u.parents(".wrapper").headwayGrid("initResizable",r),e.pep.unbind(r),u.parents(".wrapper").headwayGrid("initDraggable",r),blockIntersectCheck(!1,f),blockIntersectCheck(!1,u),dataSetBlockPosition(getBlockID(r),getBlockPosition(r)),dataSetBlockWrapper(getBlockID(r),getBlockWrapper(r).attr("id")),r.parents(".ui-headway-grid").first().data("ui-headwayGrid").alignBlockWithGuides(r)}if(s.container.find(".grouped-block").length)var l=s.container.find(".grouped-block");else var l=getBlock(n.el);s.wrapper.find(".wrapper-buttons").show();var c=[];if(l.length===1)var h="Moved block";else var h="Mass Moved Blocks: ";l.each(function(){c.push({block:e(this),newPosition:{left:Math.round(e(this).position().left/(s.grid.columnWidth+s.grid.gutterWidth)),top:getBlockPositionPixels(e(this)).top},newPositionPixels:getBlockPositionPixels(e(this)),oldPosition:e(this).data("old-position"),oldPositionPixels:e(this).data("old-position-pixels")}),l.length>1&&(h+=", ")}),l.length>1&&(h=h.substring(0,h.length-2));var p=function(e,t){var n=e.block,r=e.newPosition.left,i=e.newPosition.top,s=e.newPositionPixels.left;t&&(r=e.oldPosition.left,i=e.oldPosition.top,s=e.oldPositionPixels.left),setBlockGridLeft(n,r),n.attr({"data-grid-top":i}),n.css("top",i+"px"),n.css("left",s+"px"),n.css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""}),delete n.data("plugin_pep").translation,delete n.data("plugin_pep").cssX,delete n.data("plugin_pep").cssY,dataSetBlockPosition(getBlockID(n),getBlockPosition(n)),dataSetBlockWrapper(getBlockID(n),getBlockWrapper(n).attr("id")),blockIntersectCheck(n)?allowSaving():disallowSaving()};Headway.history.add({description:h,up:function(){jQuery.each(c,function(e,t){p(t,!1)})},down:function(){jQuery.each(c,function(e,t){p(t,!0)})}}),e(document).focus(),e(getBlock(n.el)).qtip("enable"),e(getBlock(n.el)).qtip("show"),e(r).data("hoverWaitTimeout",setTimeout(function(){e(getBlock(n.el)).qtip("reposition"),e(getBlock(n.el)).qtip("show")},300))},addBlankBlock:function(t,n){var r={top:0,left:0,width:140,height:this.options.minBlockHeight,id:null};t=e.extend({},r,t);if(typeof i=="undefined")var i=!0;typeof n=="undefined"&&(n=!1);var s=Math.ceil(Math.random()*1e9);Headway.blankBlock=e('<div><div class="block-content-fade block-content"></div></div>').attr("id","block-"+s).attr("data-id",s).attr("data-temp-id",s).attr("data-desired-id",t.id?t.id:null).data("id",s).data("temp-id",s).data("desired-id",t.id?t.id:null).addClass(this.options.defaultBlockClass.replace(".","")).addClass("blank-block").addClass("hide-content-in-grid"),updateBlockContentCover(Headway.blankBlock);var o=Headway.blankBlock;return o.css({height:parseInt(t.height),top:parseInt(t.top),position:"absolute",visibility:"hidden",left:"",width:""}),setBlockGridLeft(o,t.left),setBlockGridWidth(o,t.width),o.attr({"data-height":parseInt(t.height),"data-grid-top":parseInt(t.top)}),o.appendTo(this.container),this.alignBlockWithGuides(o),o.css("visibility","visible"),n==0&&openBlockTypeSelector(e(Headway.blankBlock)),this.initResizable(o),this.initDraggable(o),blockIntersectCheck(o),o},setupBlankBlock:function(e,t,n){if(typeof n=="undefined")var n=!0;if(typeof t=="undefined")var t=!1;Headway.blankBlock.removeClass("blank-block"),Headway.blankBlock.addClass("block-type-"+e),Headway.blankBlock.data("type",e),n&&loadBlockContent({blockElement:Headway.blankBlock,blockOrigin:{type:e,id:0,layout:Headway.currentLayout},blockSettings:{dimensions:getBlockDimensions(Headway.blankBlock),position:getBlockPosition(Headway.blankBlock)}}),getBlockTypeObject(e)["fixed-height"]===!0?Headway.blankBlock.addClass("block-fixed-height"):Headway.blankBlock.addClass("block-fluid-height"),getBlockTypeObject(e)["show-content-in-grid"]&&Headway.blankBlock.removeClass("hide-content-in-grid"),dataAddBlock(Headway.blankBlock),dataSetBlockPosition(getBlockID(Headway.blankBlock),getBlockPosition(Headway.blankBlock)),dataSetBlockDimensions(getBlockID(Headway.blankBlock),getBlockDimensions(Headway.blankBlock)),dataSetBlockWrapper(getBlockID(Headway.blankBlock),Headway.blankBlock.closest(".wrapper").attr("id")),blockIntersectCheck(Headway.blankBlock)?allowSaving():disallowSaving(),updateBlockContentCover(Headway.blankBlock);var r=Headway.blankBlock;return Headway.history.add({description:"Added "+getBlockTypeNice(e)+" block",up:function(){r.show(),typeof GLOBALunsavedValues["blocks"][getBlockID(r)]["delete"]!="undefined"&&delete GLOBALunsavedValues.blocks[getBlockID(r)]["delete"],blockIntersectCheck(r,r.parents(".grid-container"))},down:function(){r.hide(),removePanelTab("block-"+getBlockID(r)),dataDeleteBlock(getBlockID(r)),blockIntersectCheck(!1,r.parents(".grid-container"))}}),delete Headway.blankBlock,delete Headway.blankBlockOptions,r},addBlock:function(t){var n={top:0,left:0,width:1,height:this.options.minBlockHeight,type:null,id:null,settings:[]},t=e.extend({},n,t);if(this.addBlankBlock(t,!0)){var r=this.setupBlankBlock(t.type,!0,!1),i=getBlockID(r);return e.each(t.settings,function(e,t){dataSetBlockOption(i,e,t),e=="mirror-block"&&updateBlockMirrorStatus(!1,r,t,!1)}),typeof t.settings.duplicateOf!="undefined"&&r.data("duplicateOf",t.settings.duplicateOf),refreshBlockContent(i,!1,!1,!1),this.updateGridContainerHeight(),r}return!1},sendBlockToTop:function(e){if(typeof e=="string")var e=getBlock(e);if(!e||!e.length)return;$i(".block").css("zIndex",1),e.css("zIndex",2)},updateGridContainerHeight:function(){var t=this.container,n=this.wrapper;t.css("height",this.wrapper.height());if(t.find(".block:visible").length){var r=0;t.find(".block:visible").each(function(){var t=e(this).outerHeight()+e(this).position().top;t>r&&(r=t)}),t.height(r)}},addColumnGuides:function(){var t=this.container;t.find(".grid-guides").remove();var n=e('<div class="grid-guides grid-guides-grey"></div><!-- #grid -->');for(i=1;i<=this.options.columns;i++)n.append('<div class="grid-guide grid-width-1 grid-guide-'+i+'"></div>');n.prependTo(t)},alignBlockWithGuides:function(t){var n=this.container.children(".grid-guides:visible");if(!n.length)return;var r=parseInt(getBlockGridLeft(t)),i=parseInt(getBlockGridWidth(t));if(typeof r=="undefined"||isNaN(r)||r<0)r=0;if(typeof i=="undefined"||isNaN(i)||i==0)i=1;var s=r+1<this.grid.columns?r+1:this.grid.columns,o=n.find(".grid-guide-"+s),u=r+i<this.grid.columns?r+i:this.grid.columns,a=n.find(".grid-guide-"+u);a.length||(a=o);if(r+1<=r+i){var f=parseInt(o.css("marginLeft").replace("px","")),l=parseInt(a.css("marginLeft").replace("px","")),c=o.position().left+f,h=a.position().left+a.outerWidth()-o.position().left-1;r==0&&(h+=l),t.css({top:e(t).position().top,transform:"",left:Math.ceil(c)+"px",width:Math.ceil(h)+"px"})}},alignAllBlocksWithGuides:function(){var t=this;this.container.find(".block:visible").each(function(){t.alignBlockWithGuides(e(this))})},updateGridCSS:function(){var t=this,n=this.wrapper,r=e("div#wrapper-"+getWrapperID(n)+"-tab"),i="div#"+n.attr("id");return n.attr("data-temp-id")&&(i='div.wrapper[data-temp-id="'+n.attr("data-temp-id")+'"]'),typeof this.options.useIndependentGrid!="undefined"&&this.options.useIndependentGrid===!0||typeof this.options.useIndependentGrid=="string"&&hwBoolean(this.options.useIndependentGrid)?updateGridCSS(i,this.options.columns,this.options.columnWidth,this.options.gutterWidth,r):updateGridCSS(i,this.options.columns,Headway.globalGridColumnWidth,Headway.globalGridGutterWidth,r),this.resetGridCalculations(),e($iDocument()).ready(function(){t.alignAllBlocksWithGuides()}),n}}),e.extend(e.ui.headwayGrid,{version:"2.1"})}),bindGridWizard=function(){var e={"right-sidebar":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:18,height:320,type:"content"},{top:190,left:18,width:6,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:520,left:0,width:24,height:70,type:"footer"}],"left-sidebar":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:6,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:190,left:6,width:18,height:320,type:"content"},{top:520,left:0,width:24,height:70,type:"footer"}],"two-right":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:16,height:320,type:"content"},{top:190,left:16,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:190,left:20,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-2"},{top:520,left:0,width:24,height:70,type:"footer"}],"two-both":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:190,left:4,width:16,height:320,type:"content"},{top:190,left:20,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-2"},{top:520,left:0,width:24,height:70,type:"footer"}],"all-content":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:24,height:320,type:"content"},{top:520,left:0,width:24,height:70,type:"footer"}]};$("div#boxes").delegate("div#box-grid-wizard span.layout-preset","mousedown",function(){$("div#box-grid-wizard span.layout-preset-selected").removeClass("layout-preset-selected"),$(this).addClass("layout-preset-selected")}),$("div#boxes").delegate("span#grid-wizard-button-preset-next","click",function(){var e=$("div#box-grid-wizard span.layout-preset-selected").attr("id").replace("layout-","");switch(e){case"right-sidebar":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").hide(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Right Sidebar");break;case"left-sidebar":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").hide(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Left Sidebar");break;case"two-right":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Left Sidebar"),$("div#grid-wizard-presets-mirroring-select-sidebar-2 h5").text("Right Sidebar");break;case"two-both":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Left Sidebar"),$("div#grid-wizard-presets-mirroring-select-sidebar-2 h5").text("Right Sidebar");break;case"all-content":$("div#grid-wizard-presets-mirroring-select-sidebar-1").hide(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").hide()}$(this).hide(),$("span#grid-wizard-button-preset-previous").show(),$("span#grid-wizard-button-preset-use-preset").show(),$("div#grid-wizard-presets-step-1").hide(),$("div#grid-wizard-presets-step-2").show()}),$("div#boxes").delegate("span#grid-wizard-button-preset-previous","click",function(){$(this).hide(),$("span#grid-wizard-button-preset-use-preset").hide(),$("span#grid-wizard-button-preset-next").show(),$("div#grid-wizard-presets-step-2").hide(),$("div#grid-wizard-presets-step-1").show()}),$("div#boxes").delegate("span#grid-wizard-button-preset-use-preset","click",function(){var t=$("div#box-grid-wizard span.layout-preset-selected").attr("id").replace("layout-","");return $i(".block").each(function(){deleteBlock(this)}),$.each(e[t],function(){var e=this;delete e.mirroringOrigin;var t=typeof this.mirroringOrigin!="undefined"?this.mirroringOrigin:this.type,n=$("div#grid-wizard-presets-mirroring-select-"+t+" select").val();n!==""&&(e.settings={},e.settings["mirror-block"]=n),$i(".ui-headway-grid").first().data("ui-headwayGrid").addBlock(e)}),closeBox("grid-wizard")}),$("div#boxes").delegate("span#grid-wizard-button-clone-page","click",function(){var e=$("select#grid-wizard-pages-to-clone").val();if(e===""||!e)return alert("Please select a page to clone.");if($(this).hasClass("button-depressed"))return;$(this).text("Cloning...").addClass("button-depressed").css("cursor","default");var t=$.ajax(Headway.ajaxURL,{type:"POST",async:!0,data:{action:"headway_visual_editor",method:"get_layout_blocks_in_json",security:Headway.security,layout:e},success:function(e,t){if(t==0)return!1;$i(".wrapper").each(function(){deleteWrapper(getWrapperID($(this)),!0)});var n=e.wrappers,r=e.blocks,i=Object.keys(r).length,s={};return $.each(n,function(e,t){var n=t.styling;delete t.styling;var r=addWrapper("bottom",t.settings,!0),i=getWrapperID(r);s[e.replace("wrapper-","")]=i,typeof t["mirror_id"]!="undefined"&&(updateWrapperMirrorStatus(i,t.mirror_id),dataSetWrapperOption(i,"mirror-wrapper",t.mirror_id)),$.each(n,function(e,t){dataSetDesignEditorProperty({element:"wrapper",property:e,value:t!==null?t.toString():null,specialElementType:"instance",specialElementMeta:"wrapper-"+i});if(e.indexOf("margin")===0){var n=e.replace("margin-","").capitalize();r.css("margin"+n,t+"px")}else if(e.indexOf("padding")===0){var s=e.replace("padding-","").capitalize();r.css("padding"+s,t+"px")}})}),$.each(r,function(){var e=this.mirror_id?this.mirror_id:this.id,t={type:this.type,top:this.position.top,left:this.position.left,width:this.dimensions.width,height:this.dimensions.height,settings:$.extend({},this.settings,{"mirror-block":e})},n=typeof this.wrapper_id!="undefined"&&this.wrapper_id?this.wrapper_id:"default";if(typeof s[n.replace("wrapper-","")]!="undefined")var r="#wrapper-"+s[n.replace("wrapper-","")],i=$i(".ui-headway-grid").filter(r).first();else var i=$i(".ui-headway-grid").last();var o=i.data("ui-headwayGrid").addBlock(t),u=getBlockID(o),a=this.id;typeof this.styling!="undefined"&&this.styling&&$.each(this.styling,function(e,t){var e=e.replace("block-"+a,"block-"+u);$.each(t.properties,function(n,r){dataSetDesignEditorProperty({group:"blocks",element:t.element,property:n,value:r!==null?r.toString():null,specialElementType:"instance",specialElementMeta:e})})})}),closeBox("grid-wizard")}})}),$("div#boxes").delegate("span#grid-wizard-button-assign-template","click",function(){var e=$("select#grid-wizard-assign-template").val().replace("template-","");return e===""?alert("Please select a shared layout to assign."):($.post(Headway.ajaxURL,{action:"headway_visual_editor",method:"assign_template",security:Headway.security,template:e,layout:Headway.currentLayout},function(t){if(typeof t=="undefined"||t=="failure")return showErrorNotification({id:"error-could-not-assign-template",message:"Error: Could not assign shared layout."}),!1;$("div#layout-selector li.layout-selected").removeClass("layout-item-customized"),$("div#layout-selector li.layout-selected").addClass("layout-item-template-used"),$("div#layout-selector li.layout-selected span.status-template").text(t),showIframeLoadingOverlay(),changeTitle("Visual Editor: Assigning Template"),startTitleActivityIndicator(),Headway.currentLayoutTemplate="template-"+e,Headway.currentLayoutTemplateName=$('span.layout[data-layout-id="template-'+e+'"]').find(".template-name").text(),headwayIframeLoadNotification="Template assigned successfully!",loadIframe(Headway.instance.iframeCallback)}),closeBox("grid-wizard"))}),$("div#boxes").delegate("span.grid-wizard-use-empty-grid","click",function(){$i(".block").each(function(){deleteBlock(this)}),closeBox("grid-wizard")}),initiateLayoutImport=function(e){var t=e;if(!t.val())return alert("You must select a Headway layout file before importing.");var n=t.get(0).files[0];if(n&&typeof n.name!="undefined"&&typeof n.type!="undefined"){var r=new FileReader;r.onload=function(e){var t=e.target.result,n=JSON.parse(t);if(n["data-type"]!="layout")return alert("Cannot load layout file.  Please insure that the selected file is a valid Headway layout export.");typeof n["image-definitions"]!="undefined"&&Object.keys(n["image-definitions"]).length?(showNotification({id:"importing-images",message:"Currently importing images.",closeTimer:1e4}),$.post(Headway.ajaxURL,{action:"headway_visual_editor",method:"import_images",security:Headway.security,importFile:n},function(e){var t=e;if(typeof t["error"]!="undefined")return alert("Error while importing images for layout: "+t.error);importLayout(t)})):importLayout(n)},r.readAsText(n)}else alert("Cannot load layout file.  Please insure that the selected file is a valid Headway layout export.")},importLayout=function(e){$i(".block").each(function(){deleteBlock(this)});var t=e.blocks,n=Object.keys(t).length;return $.each(t,function(){var e={type:this.type,top:this.position.top,left:this.position.left,width:this.dimensions.width,height:this.dimensions.height,settings:this.settings};$i(".ui-headway-grid").first().data("ui-headwayGrid").addBlock(e)}),showNotification({id:"layout-successfully-imported",message:"Layout successfully imported.<br /><br />Remember to save if you wish to keep the layout.",closeTimer:!1,closable:!0,success:!0}),closeBox("grid-wizard"),allowSaving(),!0},$("div#boxes").delegate("#grid-wizard-import-select-file","click",function(){$(this).siblings('input[type="file"]').trigger("click")}),$("div#boxes").delegate('#grid-wizard-import input[type="file"]',"change",function(e){if(e.target.files[0].name.split(".").slice(-1)[0]!="json")return $(this).val(null),alert("Invalid layout file.  Please be sure that the layout is a valid JSON formatted file.");initiateLayoutImport($(this))}),$("div#boxes").delegate("#grid-wizard-export-download-file","click",function(){var e={action:"headway_visual_editor",security:Headway.security,method:"export_layout",layout:Headway.currentLayout},t=Headway.ajaxURL+"?"+$.param(e);return window.open(t)})},define("modules/grid/grid-wizard",function(){}),define("modules/grid/mode-grid",["jquery","modules/grid/grid","deps/itstylesheet","modules/grid/wrappers","modules/grid/grid-wizard","deps/jquery.pep","helper.blocks","helper.wrappers"],function(e,t,n){var r={init:function(){bindGridWizard()},iframeCallback:function(){$i(".block").each(function(){updateBlockContentCover(e(this)),loadBlockContent({blockElement:e(this),blockOrigin:getBlockID(e(this))})}),gridStylesheet=new ITStylesheet({document:Headway.iframe.contents()[0],href:"/?headway-trigger=compiler&file=ve-iframe-grid-dynamic"},"find"),addEdgeInsertWrapperButtons(),addWrapperButtons($i("div.wrapper")),bindWrapperButtons(),setupWrapperSortables(),setupWrapperResizable(),setupWrapperContextMenu(),assignDefaultWrapperID(),$i(".grid-container").length===1&&!$i(".block").length&&$i(".grid-container").height(500),$i("div.wrapper").headwayGrid(),$i("div.wrapper-mirrored").headwayGrid("disable"),updateGridWidthInput("#sub-tab-grid-content"),setupBlockContextMenu(),bindBlockDimensionsTooltip()}};return updateGridCSS=function(e,t,n,r,s){var o=n*t+(t-1)*r,u=n*t/o,a=r*t/o,f=100/t*u,l=100/t*a,c=9,h=e+" ";gridStylesheet.update_rule(h+".grid-guides .grid-guide",{margin:"0 0 0 "+Math.round(l,c)+"%"});for(i=1;i<=t;i++)gridStylesheet.update_rule(h+".grid-width-"+i,{width:Math.round(f*i+(i-1)*l,c)+"%"}),gridStylesheet.update_rule(h+".grid-left-"+i,{left:"0 0 0 "+Math.round((f+l)*i,c)+"%"});gridStylesheet.update_rule(h+"div.grid-container",{width:o+1+"px"}),gridStylesheet.update_rule(e+".wrapper-fixed",{width:o+"px"}),typeof s!="undefined"&&s.length&&updateGridWidthInput(s)},r}),require.config({paths:{ko:"deps/knockout",underscore:"deps/underscore",jqueryUI:"deps/jquery.ui",qtip:"deps/jquery.qtip"},shim:{underscore:{exports:"_"}}}),require(["jquery","util.loader"],function(e){startTitleActivityIndicator(),Headway.blockTypeURLs=e.parseJSON(Headway.blockTypeURLs.replace(/&quot;/g,'"')),Headway.allBlockTypes=e.parseJSON(Headway.allBlockTypes.replace(/&quot;/g,'"')),Headway.ranTour=e.parseJSON(Headway.ranTour.replace(/&quot;/g,'"')),Headway.designEditorProperties=e.parseJSON(Headway.designEditorProperties.replace(/&quot;/g,'"')),require(["modules/layout-selector"],function(e){e.init()}),require(["modules/panel","modules/iframe"],function(e,t){e.init(),t.init()}),require(["modules/menu"],function(e){e.init()}),require(["modules/snapshots"],function(e){e.init()}),require(["util.tour"],function(e){Headway.ranTour[Headway.mode]==0&&Headway.ranTour.legacy==0&&e.start()}),require(["helper.data","helper.blocks","helper.wrappers","helper.context-menus","helper.notifications","helper.boxes","helper.history"],function(e,t,n,r,i,s,o){o.init()});switch(Headway.mode){case"grid":require(["modules/grid/mode-grid","modules/iframe"],function(e){Headway.instance=e,e.init(),waitForIframeLoad(e.iframeCallback)});break;case"design":require(["modules/design/mode-design","modules/iframe"],function(e){Headway.instance=e,e.init(),waitForIframeLoad(e.iframeCallback)})}e(document).ready(function(){e("body").addClass("show-ve")}),e(window).bind("load",function(){setTimeout(function(){e("div#ve-loading-overlay").remove()},1e3)})}),define("app",function(){});
\ No newline at end of file
+function ITStylesheet(e,t){return"undefined"!=typeof e.document&&(this.document=e.document,delete e.document),this.property_dom_names={},this.property_standard_names={},this.converted_rgb_values={},this.args="undefined"!=typeof e?e:{},this.action="undefined"!=typeof t?t:"load",this.init=function(){"find"===this.action?this._find_stylesheet():this._load_stylesheet()},this._load_stylesheet=function(){e=this.args;var t;"undefined"!=typeof e.href?(t=this.document.createElement("link"),t.href=e.href,this.type="link"):(t=this.document.createElement("style"),this.type="style"),t.type="text/css","undefined"!=typeof e.title&&(t.title=e.title),"undefined"!=typeof e.rel&&(t.rel=e.rel),"undefined"!=typeof e.media&&(t.media=e.media),"undefined"!=typeof e.href&&"undefined"==typeof e.rel&&(t.rel="stylesheet");var n="";"undefined"!=typeof e.content&&(n=e.content,delete e.content);var r=Math.floor(Math.random()*1e3)+1;this.$stylesheet_node=jQuery(t).insertBefore($i("style#live-css-holder")).addClass("ITStylesheet").attr("id","itstylesheet-"+r),this.stylesheet_node=this.$stylesheet_node[0];var i=this;jQuery.each(this.document.styleSheets,function(e,t){if(typeof t.ownerNode.id=="undefined"||!t.ownerNode.id||t.ownerNode.id!="itstylesheet-"+r)return;return i.stylesheet=t,!1}),this._find_rules(),""!==n&&this.set_rules(n)},this._find_stylesheet=function(){e=this.args;for(var t=0;t<this.document.styleSheets.length;t++){if("undefined"!=typeof e.href&&typeof this.document.styleSheets[t].href=="string"&&this.document.styleSheets[t].href.indexOf(e.href)===-1)continue;if("undefined"!=typeof e.title&&e.title!==this.document.styleSheets[t].title)continue;if("undefined"!=typeof e.rel&&e.rel!==this.document.styleSheets[t].rel)continue;if("undefined"!=typeof e.media&&e.media!==this.document.styleSheets[t].media)continue;if("undefined"!=typeof e.type&&e.type!==this.document.styleSheets[t].type)continue;if("undefined"!=typeof e.disabled&&e.disabled!==this.document.styleSheets[t].disabled)continue;this.type="link",this.stylesheet=this.document.styleSheets[t],this._find_rules();break}},this._find_rules=function(){if("undefined"==typeof this.stylesheet)return;this.stylesheet.cssRules?this.rules=this.stylesheet.cssRules:this.rules=this.stylesheet.rules},this._get_style_from_declarations=function(e){var t="";for(property in e)t+=property+":"+e[property]+"; ";return t},this._get_rules_obj_from_string=function(e){var t={},n=e.match(/\s*[^{;]+\s*{\s*[^{}]+\s*}/g);if(-1===n)return t;for(var r=0;r<n.length;r++){var i=n[r].match(/\s*([^{;]+)\s*{\s*([^{}]+)\s*}/);t[i[1]]=i[2]}return t},this._get_property_dom_name=function(e){if("undefined"!=typeof this.property_dom_names[e])return this.property_dom_names[e];var t=e.split("-"),n=t.shift();while(t.length>0){var r=t.shift();r=r.charAt(0).toUpperCase()+r.substr(1),n+=r}return this.property_dom_names[e]=n,n},this._get_property_standard_name=function(e){if("undefined"!=typeof this.property_standard_names[e])return this.property_standard_names[e];var t=e;return"padding-right-value"===e?t="padding-right":"padding-left-value"===e?t="padding-left":"margin-right-value"===e?t="margin-right":"margin-left-value"===e&&(t="margin-left"),this.property_standard_names[e]=t,t},this._delete_rule_at_index=function(e){this.stylesheet.deleteRule?this.stylesheet.deleteRule(e):this.stylesheet.removeRule(e)},this._get_stylesheet_rules=function(e){return e.cssRules?e.cssRules:e.rules},this._get_stylesheet_rules_object=function(e){var t=this._get_stylesheet_rules(e),n={},r=[];for(var i=0;i<t.length;i++)n[t[i].selectorText]=this._get_rule_declarations_object(t[i]),r.push(t[i].selectorText);r.sort();var s={};for(var i=0;i<r.length;i++)s[r[i]]=n[r[i]];return s},this._get_rule_declarations_object=function(e){var t={},n;e.style?n=e.style:n=e;var r=[];for(var i=0;i<n.length;i++)r.push(n[i]);r.sort();for(var i=0;i<r.length;i++){var s=this._get_property_standard_name(r[i]);"undefined"!=typeof n[s]?t[s]=n[s]:t[s]=n[this._get_property_dom_name(s)]}return t},this.get_rule_index=function(e){if("undefined"==typeof e)return!1;indexes=new Array,this.rules||this._find_rules();if(!this.rules)return!1;if("undefined"!=typeof this.rules[e])return e;for(var t=0;t<this.rules.length;t++)typeof this.rules[t].selectorText=="string"&&this.rules[t].selectorText.toLowerCase()==e.toLowerCase()&&indexes.push(t);return indexes.length!==0?indexes[indexes.length-1]:!1},this.get_rule=function(e){if("undefined"==typeof e)return!1;var t=this.get_rule_index(e);return!1===t||"undefined"==typeof this.rules[t]?!1:this.rules[t]},this.add_rule=function(e,t){return this.update_rule(e,t)},this.update_rule=function(e,t,n){if("undefined"==typeof this.rules||"undefined"==typeof e)return!1;"undefined"==typeof t&&(t={}),"undefined"==typeof n&&(n=!1);if(n)var r=e.split(",");else var r=new Array(e);var i=[];for(var s=0;s<r.length;s++){var o=r[s];if("undefined"==typeof o)continue;var u=this.get_rule(o);try{if(!1===u){var a=this.rules.length;string_declarations="string"==typeof t?t:this._get_style_from_declarations(t),this.stylesheet.addRule?this.stylesheet.addRule(o,string_declarations,a):this.stylesheet.insertRule(o+" {"+string_declarations+"}",a),u=this.rules[a]}else for(property in t)u.style.setAttribute?u.style.setAttribute(property,t[property]):u.style.setProperty(property,t[property],null);i.push(u)}catch(f){}}return i},this.delete_all_rules=function(){while(this.rules.length>0)this._delete_rule_at_index(0)},this.delete_rule=function(e){var t=this.get_rule_index(e);return!1===t?!1:(this._delete_rule_at_index(t),!0)},this.delete_rule_property=function(e,t){var n={};n[t]=null,this.update_rule(e,n)},this._convert_rgb_to_hex=function(e){if("undefined"!=typeof this.converted_rgb_values[e])return this.converted_rgb_values[e];var t=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(e),n=parseInt(t[1]),r=parseInt(t[2]),i=parseInt(t[3]),s=i|r<<8|n<<16;hex=s.toString(16).toUpperCase();while(hex.length<6)hex="0"+hex;return this.converted_rgb_values[e]="#"+hex,"#"+hex},this.get_stylesheet_text=function(){var e=this._get_stylesheet_rules_object(this.stylesheet),t="",n=/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)/;for(selector in e){var r="";for(property in e[selector]){var i=e[selector][property];if("undefined"==typeof i)continue;n.test(i)&&(i=this._convert_rgb_to_hex(i)),r+="      "+property+": "+i+";\n"}if(""===r)continue;""!==t&&(t+="\n"),t+=selector+" {\n"+r+"}"}return t},this.get_computed_style=function(e){return window.getComputedStyle?window.getComputedStyle(e,""):e.currentStyle},this.set_rules=function(e){this.delete_all_rules(),"string"==typeof e&&(e=this._get_rules_obj_from_string(e));for(selector in e)this.update_rule(selector,e[selector])},this.init(),!0}define("util.misc",["jquery"],function(e){updateQueryStringParameter=function(e,t,n){var r=new RegExp("([?|&])"+t+"=.*?(&|$)","i"),i=e.indexOf("?")!==-1?"&":"?";return e.match(r)?e.replace(r,"$1"+t+"="+n+"$2"):e+i+t+"="+n},jQuery.fn.reverse=[].reverse,Number.prototype.toNearest=function(e){return Math.round(this/e)*e},Math._round=Math.round,Math.round=function(e,t){t=Math.abs(parseInt(t))||0;var n=Math.pow(10,t);return Math._round(e*n)/n},String.prototype.repeatStr=function(e){return e<=0?"":Array.prototype.join.call({length:e+1},this)},String.prototype.capitalize=function(){return this.replace(/(^|\s)([a-z])/g,function(e,t,n){return t+n.toUpperCase()})},hwBoolean=function(e){if(typeof e=="boolean")return e;if(typeof e=="undefined")return!1;if(typeof e=="number")return e===1?!0:e===0?!1:null;if(e===null)return!1;if(typeof e=="string"){var t=e.split(/\b/g);return t[0]==="1"||t[0]==="true"?!0:t[0]==="0"||t[0]==="false"?!1:null}return null},Number.prototype.toBool=function(){return this===1?!0:this===0?!1:null},String.prototype.toBool=function(){var e=this.split(/\b/g);return e[0]==="1"||e[0]==="true"?!0:e[0]==="0"||e[0]==="false"?!1:null},String.prototype.escapeHTML=function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}}),define("util.loader",["jquery","util.misc"],function(e){createCog=function(t,n,r,i,s){if(e(t).length===0||e(t).find(".cog-container:visible").length)return!1;var r=typeof r=="undefined"?!1:r,o='<div class="cog-container"><div class="cog-bottom-left"></div><div class="cog-top-right"></div></div>';return r?t.append(o):t.html(o),typeof s!="undefined"&&t.find(".cog-container").css({opacity:s}),!0},changeTitle=function(t){return e("title").text(t)},startTitleActivityIndicator=function(){return typeof titleActivityIndicatorInstance=="number"?!1:(titleActivityIndicatorInstance=window.setInterval(titleActivityIndicator,500),titleActivityIndicatorSavedTitle=e("title").text(),!0)},stopTitleActivityIndicator=function(){return typeof titleActivityIndicatorInstance!="number"?!1:(window.clearInterval(titleActivityIndicatorInstance),changeTitle(titleActivityIndicatorSavedTitle),delete titleActivityIndicatorCounter,delete titleActivityIndicatorSavedTitle,delete titleActivityIndicatorInstance,!0)},titleActivityIndicator=function(){typeof titleActivityIndicatorCounter=="undefined"&&(titleActivityIndicatorCounter=0,titleActivityIndicatorCounterPos=!0),titleActivityIndicatorCounterPos===!0?++titleActivityIndicatorCounter:--titleActivityIndicatorCounter,titleActivityIndicatorCounter===3?titleActivityIndicatorCounterPos=!1:titleActivityIndicatorCounter===0&&(titleActivityIndicatorCounterPos=!0);var e=titleActivityIndicatorSavedTitle+".".repeatStr(titleActivityIndicatorCounter);changeTitle(e)}}),function(){var DEBUG=!0;(function(undefined){var window=this||(0,eval)("this"),document=window.document,navigator=window.navigator,jQuery=window.jQuery,JSON=window.JSON;(function(e){if(typeof require=="function"&&typeof exports=="object"&&typeof module=="object"){var t=module.exports||exports;e(t)}else typeof define=="function"&&define.amd?define("ko",["exports"],e):e(window.ko={})})(function(e){function r(e,t){var r=e===null||typeof e in n;return r?e===t:!1}function i(e,t){var n;return function(){n||(n=setTimeout(function(){n=undefined,e()},t))}}function s(e,t){var n;return function(){clearTimeout(n),n=setTimeout(e,t)}}function o(e){var n=this;return e&&t.utils.objectForEach(e,function(e,r){var i=t.extenders[e];typeof i=="function"&&(n=i(n,r)||n)}),n}function d(e){t.bindingHandlers[e]={init:function(n,r,i,s,o){var u=function(){var t={};return t[e]=r(),t};return t.bindingHandlers.event.init.call(this,n,u,i,s,o)}}}function g(e,n,r,i){t.bindingHandlers[e]={init:function(e,s,o,u,a){var f,l;return t.computed(function(){var o=t.utils.unwrapObservable(s()),u=!r!=!o,c=!l,h=c||n||u!==f;h&&(c&&t.computedContext.getDependenciesCount()&&(l=t.utils.cloneNodes(t.virtualElements.childNodes(e),!0)),u?(c||t.virtualElements.setDomNodeChildren(e,t.utils.cloneNodes(l)),t.applyBindingsToDescendants(i?i(a,o):a,e)):t.virtualElements.emptyNode(e),f=u)},null,{disposeWhenNodeIsRemoved:e}),{controlsDescendantBindings:!0}}},t.expressionRewriting.bindingRewriteValidators[e]=!1,t.virtualElements.allowedBindings[e]=!0}var t=typeof e!="undefined"?e:{};t.exportSymbol=function(e,n){var r=e.split("."),i=t;for(var s=0;s<r.length-1;s++)i=i[r[s]];i[r[r.length-1]]=n},t.exportProperty=function(e,t,n){e[t]=n},t.version="3.1.0",t.exportSymbol("version",t.version),t.utils=function(){function e(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])}function n(e,t){if(t)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function r(e,t){return e.__proto__=t,e}function h(e,n){if(t.utils.tagNameLower(e)!=="input"||!e.type)return!1;if(n.toLowerCase()!="click")return!1;var r=e.type;return r=="checkbox"||r=="radio"}var i={__proto__:[]}instanceof Array,s={},o={},u=navigator&&/Firefox\/2/i.test(navigator.userAgent)?"KeyboardEvent":"UIEvents";s[u]=["keyup","keydown","keypress"],s.MouseEvents=["click","dblclick","mousedown","mouseup","mousemove","mouseover","mouseout","mouseenter","mouseleave"],e(s,function(e,t){if(t.length)for(var n=0,r=t.length;n<r;n++)o[t[n]]=e});var a={propertychange:!0},f=document&&function(){var e=3,t=document.createElement("div"),n=t.getElementsByTagName("i");while(t.innerHTML="<!--[if gt IE "+ ++e+"]><i></i><![endif]-->",n[0]);return e>4?e:undefined}(),l=f===6,c=f===7;return{fieldsIncludedWithJsonPost:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],arrayForEach:function(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)},arrayIndexOf:function(e,t){if(typeof Array.prototype.indexOf=="function")return Array.prototype.indexOf.call(e,t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},arrayFirst:function(e,t,n){for(var r=0,i=e.length;r<i;r++)if(t.call(n,e[r],r))return e[r];return null},arrayRemoveItem:function(e,n){var r=t.utils.arrayIndexOf(e,n);r>0?e.splice(r,1):r===0&&e.shift()},arrayGetDistinctValues:function(e){e=e||[];var n=[];for(var r=0,i=e.length;r<i;r++)t.utils.arrayIndexOf(n,e[r])<0&&n.push(e[r]);return n},arrayMap:function(e,t){e=e||[];var n=[];for(var r=0,i=e.length;r<i;r++)n.push(t(e[r],r));return n},arrayFilter:function(e,t){e=e||[];var n=[];for(var r=0,i=e.length;r<i;r++)t(e[r],r)&&n.push(e[r]);return n},arrayPushAll:function(e,t){if(t instanceof Array)e.push.apply(e,t);else for(var n=0,r=t.length;n<r;n++)e.push(t[n]);return e},addOrRemoveItem:function(e,n,r){var i=t.utils.arrayIndexOf(t.utils.peekObservable(e),n);i<0?r&&e.push(n):r||e.splice(i,1)},canSetPrototype:i,extend:n,setPrototypeOf:r,setPrototypeOfOrExtend:i?r:n,objectForEach:e,objectMap:function(e,t){if(!e)return e;var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r],r,e));return n},emptyDomNode:function(e){while(e.firstChild)t.removeNode(e.firstChild)},moveCleanedNodesToContainerElement:function(e){var n=t.utils.makeArray(e),r=document.createElement("div");for(var i=0,s=n.length;i<s;i++)r.appendChild(t.cleanNode(n[i]));return r},cloneNodes:function(e,n){for(var r=0,i=e.length,s=[];r<i;r++){var o=e[r].cloneNode(!0);s.push(n?t.cleanNode(o):o)}return s},setDomNodeChildren:function(e,n){t.utils.emptyDomNode(e);if(n)for(var r=0,i=n.length;r<i;r++)e.appendChild(n[r])},replaceDomNodes:function(e,n){var r=e.nodeType?[e]:e;if(r.length>0){var i=r[0],s=i.parentNode;for(var o=0,u=n.length;o<u;o++)s.insertBefore(n[o],i);for(var o=0,u=r.length;o<u;o++)t.removeNode(r[o])}},fixUpContinuousNodeArray:function(e,t){if(e.length){t=t.nodeType===8&&t.parentNode||t;while(e.length&&e[0].parentNode!==t)e.shift();if(e.length>1){var n=e[0],r=e[e.length-1];e.length=0;while(n!==r){e.push(n),n=n.nextSibling;if(!n)return}e.push(r)}}return e},setOptionNodeSelectionState:function(e,t){f<7?e.setAttribute("selected",t):e.selected=t},stringTrim:function(e){return e===null||e===undefined?"":e.trim?e.trim():e.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},stringTokenize:function(e,n){var r=[],i=(e||"").split(n);for(var s=0,o=i.length;s<o;s++){var u=t.utils.stringTrim(i[s]);u!==""&&r.push(u)}return r},stringStartsWith:function(e,t){return e=e||"",t.length>e.length?!1:e.substring(0,t.length)===t},domNodeIsContainedBy:function(e,t){if(e===t)return!0;if(e.nodeType===11)return!1;if(t.contains)return t.contains(e.nodeType===3?e.parentNode:e);if(t.compareDocumentPosition)return(t.compareDocumentPosition(e)&16)==16;while(e&&e!=t)e=e.parentNode;return!!e},domNodeIsAttachedToDocument:function(e){return t.utils.domNodeIsContainedBy(e,e.ownerDocument.documentElement)},anyDomNodeIsAttachedToDocument:function(e){return!!t.utils.arrayFirst(e,t.utils.domNodeIsAttachedToDocument)},tagNameLower:function(e){return e&&e.tagName&&e.tagName.toLowerCase()},registerEventHandler:function(e,n,r){var i=f&&a[n];if(!i&&jQuery)jQuery(e).bind(n,r);else if(!i&&typeof e.addEventListener=="function")e.addEventListener(n,r,!1);else{if(typeof e.attachEvent=="undefined")throw new Error("Browser doesn't support addEventListener or attachEvent");var s=function(t){r.call(e,t)},o="on"+n;e.attachEvent(o,s),t.utils.domNodeDisposal.addDisposeCallback(e,function(){e.detachEvent(o,s)})}},triggerEvent:function(e,t){if(!e||!e.nodeType)throw new Error("element must be a DOM node when calling triggerEvent");var n=h(e,t);if(jQuery&&!n)jQuery(e).trigger(t);else if(typeof document.createEvent=="function"){if(typeof e.dispatchEvent!="function")throw new Error("The supplied element doesn't support dispatchEvent");var r=o[t]||"HTMLEvents",i=document.createEvent(r);i.initEvent(t,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,e),e.dispatchEvent(i)}else if(n&&e.click)e.click();else{if(typeof e.fireEvent=="undefined")throw new Error("Browser doesn't support triggering events");e.fireEvent("on"+t)}},unwrapObservable:function(e){return t.isObservable(e)?e():e},peekObservable:function(e){return t.isObservable(e)?e.peek():e},toggleDomNodeCssClass:function(e,n,r){if(n){var i=/\S+/g,s=e.className.match(i)||[];t.utils.arrayForEach(n.match(i),function(e){t.utils.addOrRemoveItem(s,e,r)}),e.className=s.join(" ")}},setTextContent:function(e,n){var r=t.utils.unwrapObservable(n);if(r===null||r===undefined)r="";var i=t.virtualElements.firstChild(e);!i||i.nodeType!=3||t.virtualElements.nextSibling(i)?t.virtualElements.setDomNodeChildren(e,[e.ownerDocument.createTextNode(r)]):i.data=r,t.utils.forceRefresh(e)},setElementName:function(e,t){e.name=t;if(f<=7)try{e.mergeAttributes(document.createElement("<input name='"+e.name+"'/>"),!1)}catch(n){}},forceRefresh:function(e){if(f>=9){var t=e.nodeType==1?e:e.parentNode;t.style&&(t.style.zoom=t.style.zoom)}},ensureSelectElementIsRenderedCorrectly:function(e){if(f){var t=e.style.width;e.style.width=0,e.style.width=t}},range:function(e,n){e=t.utils.unwrapObservable(e),n=t.utils.unwrapObservable(n);var r=[];for(var i=e;i<=n;i++)r.push(i);return r},makeArray:function(e){var t=[];for(var n=0,r=e.length;n<r;n++)t.push(e[n]);return t},isIe6:l,isIe7:c,ieVersion:f,getFormFields:function(e,n){var r=t.utils.makeArray(e.getElementsByTagName("input")).concat(t.utils.makeArray(e.getElementsByTagName("textarea"))),i=typeof n=="string"?function(e){return e.name===n}:function(e){return n.test(e.name)},s=[];for(var o=r.length-1;o>=0;o--)i(r[o])&&s.push(r[o]);return s},parseJson:function(e){if(typeof e=="string"){e=t.utils.stringTrim(e);if(e)return JSON&&JSON.parse?JSON.parse(e):(new Function("return "+e))()}return null},stringifyJson:function(e,n,r){if(!JSON||!JSON.stringify)throw new Error("Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js");return JSON.stringify(t.utils.unwrapObservable(e),n,r)},postJson:function(n,r,i){i=i||{};var s=i.params||{},o=i.includeFields||this.fieldsIncludedWithJsonPost,u=n;if(typeof n=="object"&&t.utils.tagNameLower(n)==="form"){var a=n;u=a.action;for(var f=o.length-1;f>=0;f--){var l=t.utils.getFormFields(a,o[f]);for(var c=l.length-1;c>=0;c--)s[l[c].name]=l[c].value}}r=t.utils.unwrapObservable(r);var h=document.createElement("form");h.style.display="none",h.action=u,h.method="post";for(var p in r){var d=document.createElement("input");d.name=p,d.value=t.utils.stringifyJson(t.utils.unwrapObservable(r[p])),h.appendChild(d)}e(s,function(e,t){var n=document.createElement("input");n.name=e,n.value=t,h.appendChild(n)}),document.body.appendChild(h),i.submitter?i.submitter(h):h.submit(),setTimeout(function(){h.parentNode.removeChild(h)},0)}}}(),t.exportSymbol("utils",t.utils),t.exportSymbol("utils.arrayForEach",t.utils.arrayForEach),t.exportSymbol("utils.arrayFirst",t.utils.arrayFirst),t.exportSymbol("utils.arrayFilter",t.utils.arrayFilter),t.exportSymbol("utils.arrayGetDistinctValues",t.utils.arrayGetDistinctValues),t.exportSymbol("utils.arrayIndexOf",t.utils.arrayIndexOf),t.exportSymbol("utils.arrayMap",t.utils.arrayMap),t.exportSymbol("utils.arrayPushAll",t.utils.arrayPushAll),t.exportSymbol("utils.arrayRemoveItem",t.utils.arrayRemoveItem),t.exportSymbol("utils.extend",t.utils.extend),t.exportSymbol("utils.fieldsIncludedWithJsonPost",t.utils.fieldsIncludedWithJsonPost),t.exportSymbol("utils.getFormFields",t.utils.getFormFields),t.exportSymbol("utils.peekObservable",t.utils.peekObservable),t.exportSymbol("utils.postJson",t.utils.postJson),t.exportSymbol("utils.parseJson",t.utils.parseJson),t.exportSymbol("utils.registerEventHandler",t.utils.registerEventHandler),t.exportSymbol("utils.stringifyJson",t.utils.stringifyJson),t.exportSymbol("utils.range",t.utils.range),t.exportSymbol("utils.toggleDomNodeCssClass",t.utils.toggleDomNodeCssClass),t.exportSymbol("utils.triggerEvent",t.utils.triggerEvent),t.exportSymbol("utils.unwrapObservable",t.utils.unwrapObservable),t.exportSymbol("utils.objectForEach",t.utils.objectForEach),t.exportSymbol("utils.addOrRemoveItem",t.utils.addOrRemoveItem),t.exportSymbol("unwrap",t.utils.unwrapObservable),Function.prototype.bind||(Function.prototype.bind=function(e){var t=this,n=Array.prototype.slice.call(arguments),e=n.shift();return function(){return t.apply(e,n.concat(Array.prototype.slice.call(arguments)))}}),t.utils.domData=new function(){function r(r,i){var s=r[t],o=s&&s!=="null"&&n[s];if(!o){if(!i)return undefined;s=r[t]="ko"+e++,n[s]={}}return n[s]}var e=0,t="__ko__"+(new Date).getTime(),n={};return{get:function(e,t){var n=r(e,!1);return n===undefined?undefined:n[t]},set:function(e,t,n){if(n===undefined&&r(e,!1)===undefined)return;var i=r(e,!0);i[t]=n},clear:function(e){var r=e[t];return r?(delete n[r],e[t]=null,!0):!1},nextKey:function(){return e++ +t}}},t.exportSymbol("utils.domData",t.utils.domData),t.exportSymbol("utils.domData.clear",t.utils.domData.clear),t.utils.domNodeDisposal=new function(){function i(n,r){var i=t.utils.domData.get(n,e);return i===undefined&&r&&(i=[],t.utils.domData.set(n,e,i)),i}function s(n){t.utils.domData.set(n,e,undefined)}function o(e){var n=i(e,!1);if(n){n=n.slice(0);for(var s=0;s<n.length;s++)n[s](e)}t.utils.domData.clear(e),t.utils.domNodeDisposal.cleanExternalData(e),r[e.nodeType]&&u(e)}function u(e){var t,n=e.firstChild;while(t=n)n=t.nextSibling,t.nodeType===8&&o(t)}var e=t.utils.domData.nextKey(),n={1:!0,8:!0,9:!0},r={1:!0,9:!0};return{addDisposeCallback:function(e,t){if(typeof t!="function")throw new Error("Callback must be a function");i(e,!0).push(t)},removeDisposeCallback:function(e,n){var r=i(e,!1);r&&(t.utils.arrayRemoveItem(r,n),r.length==0&&s(e))},cleanNode:function(e){if(n[e.nodeType]){o(e);if(r[e.nodeType]){var i=[];t.utils.arrayPushAll(i,e.getElementsByTagName("*"));for(var s=0,u=i.length;s<u;s++)o(i[s])}}return e},removeNode:function(e){t.cleanNode(e),e.parentNode&&e.parentNode.removeChild(e)},cleanExternalData:function(e){jQuery&&typeof jQuery["cleanData"]=="function"&&jQuery.cleanData([e])}}},t.cleanNode=t.utils.domNodeDisposal.cleanNode,t.removeNode=t.utils.domNodeDisposal.removeNode,t.exportSymbol("cleanNode",t.cleanNode),t.exportSymbol("removeNode",t.removeNode),t.exportSymbol("utils.domNodeDisposal",t.utils.domNodeDisposal),t.exportSymbol("utils.domNodeDisposal.addDisposeCallback",t.utils.domNodeDisposal.addDisposeCallback),t.exportSymbol("utils.domNodeDisposal.removeDisposeCallback",t.utils.domNodeDisposal.removeDisposeCallback),function(){function n(e){var n=t.utils.stringTrim(e).toLowerCase(),r=document.createElement("div"),i=n.match(/^<(thead|tbody|tfoot)/)&&[1,"<table>","</table>"]||!n.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!n.indexOf("<td")||!n.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||[0,"",""],s="ignored<div>"+i[1]+e+i[2]+"</div>";typeof window["innerShiv"]=="function"?r.appendChild(window.innerShiv(s)):r.innerHTML=s;while(i[0]--)r=r.lastChild;return t.utils.makeArray(r.lastChild.childNodes)}function r(e){if(jQuery.parseHTML)return jQuery.parseHTML(e)||[];var t=jQuery.clean([e]);if(t&&t[0]){var n=t[0];while(n.parentNode&&n.parentNode.nodeType!==11)n=n.parentNode;n.parentNode&&n.parentNode.removeChild(n)}return t}var e=/^(\s*)<!--(.*?)-->/;t.utils.parseHtmlFragment=function(e){return jQuery?r(e):n(e)},t.utils.setHtml=function(e,n){t.utils.emptyDomNode(e),n=t.utils.unwrapObservable(n);if(n!==null&&n!==undefined){typeof n!="string"&&(n=n.toString());if(jQuery)jQuery(e).html(n);else{var r=t.utils.parseHtmlFragment(n);for(var i=0;i<r.length;i++)e.appendChild(r[i])}}}}(),t.exportSymbol("utils.parseHtmlFragment",t.utils.parseHtmlFragment),t.exportSymbol("utils.setHtml",t.utils.setHtml),t.memoization=function(){function n(){return((1+Math.random())*4294967296|0).toString(16).substring(1)}function r(){return n()+n()}function i(e,n){if(!e)return;if(e.nodeType==8){var r=t.memoization.parseMemoText(e.nodeValue);r!=null&&n.push({domNode:e,memoId:r})}else if(e.nodeType==1)for(var s=0,o=e.childNodes,u=o.length;s<u;s++)i(o[s],n)}var e={};return{memoize:function(t){if(typeof t!="function")throw new Error("You can only pass a function to ko.memoization.memoize()");var n=r();return e[n]=t,"<!--[ko_memo:"+n+"]-->"},unmemoize:function(t,n){var r=e[t];if(r===undefined)throw new Error("Couldn't find any memo with ID "+t+". Perhaps it's already been unmemoized.");try{return r.apply(null,n||[]),!0}finally{delete e[t]}},unmemoizeDomNodeAndDescendants:function(e,n){var r=[];i(e,r);for(var s=0,o=r.length;s<o;s++){var u=r[s].domNode,a=[u];n&&t.utils.arrayPushAll(a,n),t.memoization.unmemoize(r[s].memoId,a),u.nodeValue="",u.parentNode&&u.parentNode.removeChild(u)}},parseMemoText:function(e){var t=e.match(/^\[ko_memo\:(.*?)\]$/);return t?t[1]:null}}}(),t.exportSymbol("memoization",t.memoization),t.exportSymbol("memoization.memoize",t.memoization.memoize),t.exportSymbol("memoization.unmemoize",t.memoization.unmemoize),t.exportSymbol("memoization.parseMemoText",t.memoization.parseMemoText),t.exportSymbol("memoization.unmemoizeDomNodeAndDescendants",t.memoization.unmemoizeDomNodeAndDescendants),t.extenders={throttle:function(e,n){e.throttleEvaluation=n;var r=null;return t.dependentObservable({read:e,write:function(t){clearTimeout(r),r=setTimeout(function(){e(t)},n)}})},rateLimit:function(e,t){var n,r,o;typeof t=="number"?n=t:(n=t.timeout,r=t.method),o=r=="notifyWhenChangesStop"?s:i,e.limit(function(e){return o(e,n)})},notify:function(e,t){e.equalityComparer=t=="always"?null:r}};var n={"undefined":1,"boolean":1,number:1,string:1};t.exportSymbol("extenders",t.extenders),t.subscription=function(e,n,r){this.target=e,this.callback=n,this.disposeCallback=r,this.isDisposed=!1,t.exportProperty(this,"dispose",this.dispose)},t.subscription.prototype.dispose=function(){this.isDisposed=!0,this.disposeCallback()},t.subscribable=function(){t.utils.setPrototypeOfOrExtend(this,t.subscribable.fn),this._subscriptions={}};var u="change",a={subscribe:function(e,n,r){var i=this;r=r||u;var s=n?e.bind(n):e,o=new t.subscription(i,s,function(){t.utils.arrayRemoveItem(i._subscriptions[r],o)});return i.peek&&i.peek(),i._subscriptions[r]||(i._subscriptions[r]=[]),i._subscriptions[r].push(o),o},notifySubscribers:function(e,n){n=n||u;if(this.hasSubscriptionsForEvent(n))try{t.dependencyDetection.begin();for(var r=this._subscriptions[n].slice(0),i=0,s;s=r[i];++i)s.isDisposed||s.callback(e)}finally{t.dependencyDetection.end()}},limit:function(e){var n=this,r=t.isObservable(n),i,s,o,a="beforeChange";n._origNotifySubscribers||(n._origNotifySubscribers=n.notifySubscribers,n.notifySubscribers=function(e,t){!t||t===u?n._rateLimitedChange(e):t===a?n._rateLimitedBeforeChange(e):n._origNotifySubscribers(e,t)});var f=e(function(){r&&o===n&&(o=n()),i=!1,n.isDifferent(s,o)&&n._origNotifySubscribers(s=o)});n._rateLimitedChange=function(e){i=!0,o=e,f()},n._rateLimitedBeforeChange=function(e){i||(s=e,n._origNotifySubscribers(e,a))}},hasSubscriptionsForEvent:function(e){return this._subscriptions[e]&&this._subscriptions[e].length},getSubscriptionsCount:function(){var e=0;return t.utils.objectForEach(this._subscriptions,function(t,n){e+=n.length}),e},isDifferent:function(e,t){return!this.equalityComparer||!this.equalityComparer(e,t)},extend:o};t.exportProperty(a,"subscribe",a.subscribe),t.exportProperty(a,"extend",a.extend),t.exportProperty(a,"getSubscriptionsCount",a.getSubscriptionsCount),t.utils.canSetPrototype&&t.utils.setPrototypeOf(a,Function.prototype),t.subscribable.fn=a,t.isSubscribable=function(e){return e!=null&&typeof e.subscribe=="function"&&typeof e["notifySubscribers"]=="function"},t.exportSymbol("subscribable",t.subscribable),t.exportSymbol("isSubscribable",t.isSubscribable),t.computedContext=t.dependencyDetection=function(){function i(){return++r}function s(t){e.push(n),n=t}function o(){n=e.pop()}var e=[],n,r=0;return{begin:s,end:o,registerDependency:function(e){if(n){if(!t.isSubscribable(e))throw new Error("Only subscribable things can act as dependencies");n.callback(e,e._id||(e._id=i()))}},ignore:function(e,t,n){try{return s(),e.apply(t,n||[])}finally{o()}},getDependenciesCount:function(){if(n)return n.computed.getDependenciesCount()},isInitial:function(){if(n)return n.isInitial}}}(),t.exportSymbol("computedContext",t.computedContext),t.exportSymbol("computedContext.getDependenciesCount",t.computedContext.getDependenciesCount),t.exportSymbol("computedContext.isInitial",t.computedContext.isInitial),t.observable=function(e){function r(){return arguments.length>0?(r.isDifferent(n,arguments[0])&&(r.valueWillMutate(),n=arguments[0],DEBUG&&(r._latestValue=n),r.valueHasMutated()),this):(t.dependencyDetection.registerDependency(r),n)}var n=e;return t.subscribable.call(r),t.utils.setPrototypeOfOrExtend(r,t.observable.fn),DEBUG&&(r._latestValue=n),r.peek=function(){return n},r.valueHasMutated=function(){r.notifySubscribers(n)},r.valueWillMutate=function(){r.notifySubscribers(n,"beforeChange")},t.exportProperty(r,"peek",r.peek),t.exportProperty(r,"valueHasMutated",r.valueHasMutated),t.exportProperty(r,"valueWillMutate",r.valueWillMutate),r},t.observable.fn={equalityComparer:r};var f=t.observable.protoProperty="__ko_proto__";t.observable.fn[f]=t.observable,t.utils.canSetPrototype&&t.utils.setPrototypeOf(t.observable.fn,t.subscribable.fn),t.hasPrototype=function(e,n){return e===null||e===undefined||e[f]===undefined?!1:e[f]===n?!0:t.hasPrototype(e[f],n)},t.isObservable=function(e){return t.hasPrototype(e,t.observable)},t.isWriteableObservable=function(e){return typeof e=="function"&&e[f]===t.observable?!0:typeof e=="function"&&e[f]===t.dependentObservable&&e.hasWriteFunction?!0:!1},t.exportSymbol("observable",t.observable),t.exportSymbol("isObservable",t.isObservable),t.exportSymbol("isWriteableObservable",t.isWriteableObservable),t.observableArray=function(e){e=e||[];if(typeof e=="object"&&"length"in e){var n=t.observable(e);return t.utils.setPrototypeOfOrExtend(n,t.observableArray.fn),n.extend({trackArrayChanges:!0})}throw new Error("The argument passed when initializing an observable array must be an array, or null, or undefined.")},t.observableArray.fn={remove:function(e){var n=this.peek(),r=[],i=typeof e=="function"&&!t.isObservable(e)?e:function(t){return t===e};for(var s=0;s<n.length;s++){var o=n[s];i(o)&&(r.length===0&&this.valueWillMutate(),r.push(o),n.splice(s,1),s--)}return r.length&&this.valueHasMutated(),r},removeAll:function(e){if(e===undefined){var n=this.peek(),r=n.slice(0);return this.valueWillMutate(),n.splice(0,n.length),this.valueHasMutated(),r}return e?this.remove(function(n){return t.utils.arrayIndexOf(e,n)>=0}):[]},destroy:function(e){var n=this.peek(),r=typeof e=="function"&&!t.isObservable(e)?e:function(t){return t===e};this.valueWillMutate();for(var i=n.length-1;i>=0;i--){var s=n[i];r(s)&&(n[i]._destroy=!0)}this.valueHasMutated()},destroyAll:function(e){return e===undefined?this.destroy(function(){return!0}):e?this.destroy(function(n){return t.utils.arrayIndexOf(e,n)>=0}):[]},indexOf:function(e){var n=this();return t.utils.arrayIndexOf(n,e)},replace:function(e,t){var n=this.indexOf(e);n>=0&&(this.valueWillMutate(),this.peek()[n]=t,this.valueHasMutated())}},t.utils.arrayForEach(["pop","push","reverse","shift","sort","splice","unshift"],function(e){t.observableArray.fn[e]=function(){var t=this.peek();this.valueWillMutate(),this.cacheDiffForKnownOperation(t,e,arguments);var n=t[e].apply(t,arguments);return this.valueHasMutated(),n}}),t.utils.arrayForEach(["slice"],function(e){t.observableArray.fn[e]=function(){var t=this();return t[e].apply(t,arguments)}}),t.utils.canSetPrototype&&t.utils.setPrototypeOf(t.observableArray.fn,t.observable.fn),t.exportSymbol("observableArray",t.observableArray);var l="arrayChange";t.extenders.trackArrayChanges=function(e){function o(){if(n)return;n=!0;var t=e.notifySubscribers;e.notifySubscribers=function(e,n){return(!n||n===u)&&++i,t.apply(this,arguments)};var s=[].concat(e.peek()||[]);r=null,e.subscribe(function(t){t=[].concat(t||[]);if(e.hasSubscriptionsForEvent(l)){var n=a(s,t);n.length&&e.notifySubscribers(n,l)}s=t,r=null,i=0})}function a(e,n){if(!r||i>1)r=t.utils.compareArrays(e,n,{sparse:!0});return r}if(e.cacheDiffForKnownOperation)return;var n=!1,r=null,i=0,s=e.subscribe;e.subscribe=e.subscribe=function(e,t,n){return n===l&&o(),s.apply(this,arguments)},e.cacheDiffForKnownOperation=function(e,s,o){function c(e,t,n){return u[u.length]={status:e,value:t,index:n}}if(!n||i)return;var u=[],a=e.length,f=o.length,l=0;switch(s){case"push":l=a;case"unshift":for(var h=0;h<f;h++)c("added",o[h],l+h);break;case"pop":l=a-1;case"shift":a&&c("deleted",e[l],l);break;case"splice":var p=Math.min(Math.max(0,o[0]<0?a+o[0]:o[0]),a),d=f===1?a:Math.min(p+(o[1]||0),a),v=p+f-2,m=Math.max(d,v),g=[],y=[];for(var h=p,b=2;h<m;++h,++b)h<d&&y.push(c("deleted",e[h],h)),h<v&&g.push(c("added",o[b],h));t.utils.findMovesInArrayComparison(y,g);break;default:return}r=u}},t.computed=t.dependentObservable=function(e,n,r){function l(e,t){S[t]||(S[t]=e.subscribe(h),++x)}function c(){a=!0,t.utils.objectForEach(S,function(e,t){t.dispose()}),S={},x=0,s=!1}function h(){var e=d.throttleEvaluation;e&&e>=0?(clearTimeout(T),T=setTimeout(p,e)):d._evalRateLimited?d._evalRateLimited():p()}function p(){if(o)return;if(a)return;if(w&&w()){if(!u){E();return}}else u=!1;o=!0;try{var e=S,r=x;t.dependencyDetection.begin({callback:function(t,n){a||(r&&e[n]?(S[n]=e[n],++x,delete e[n],--r):l(t,n))},computed:d,isInitial:!x}),S={},x=0;try{var c=n?f.call(n):f()}finally{t.dependencyDetection.end(),r&&t.utils.objectForEach(e,function(e,t){t.dispose()}),s=!1}d.isDifferent(i,c)&&(d.notifySubscribers(i,"beforeChange"),i=c,DEBUG&&(d._latestValue=i),(!d._evalRateLimited||d.throttleEvaluation)&&d.notifySubscribers(i))}finally{o=!1}x||E()}function d(){if(arguments.length>0){if(typeof g!="function")throw new Error("Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.");return g.apply(n,arguments),this}return s&&p(),t.dependencyDetection.registerDependency(d),i}function v(){return s&&!x&&p(),i}function m(){return s||x>0}var i,s=!0,o=!1,u=!1,a=!1,f=e;f&&typeof f=="object"?(r=f,f=r.read):(r=r||{},f||(f=r.read));if(typeof f!="function")throw new Error("Pass a function that returns the value of the ko.computed");var g=r.write,y=r.disposeWhenNodeIsRemoved||r.disposeWhenNodeIsRemoved||null,b=r.disposeWhen||r.disposeWhen,w=b,E=c,S={},x=0,T=null;n||(n=r.owner),t.subscribable.call(d),t.utils.setPrototypeOfOrExtend(d,t.dependentObservable.fn),d.peek=v,d.getDependenciesCount=function(){return x},d.hasWriteFunction=typeof r.write=="function",d.dispose=function(){E()},d.isActive=m;var N=d.limit;return d.limit=function(e){N.call(d,e),d._evalRateLimited=function(){d._rateLimitedBeforeChange(i),s=!0,d._rateLimitedChange(d)}},t.exportProperty(d,"peek",d.peek),t.exportProperty(d,"dispose",d.dispose),t.exportProperty(d,"isActive",d.isActive),t.exportProperty(d,"getDependenciesCount",d.getDependenciesCount),y&&(u=!0,y.nodeType&&(w=function(){return!t.utils.domNodeIsAttachedToDocument(y)||b&&b()})),r.deferEvaluation!==!0&&p(),y&&m()&&y.nodeType&&(E=function(){t.utils.domNodeDisposal.removeDisposeCallback(y,E),c()},t.utils.domNodeDisposal.addDisposeCallback(y,E)),d},t.isComputed=function(e){return t.hasPrototype(e,t.dependentObservable)};var c=t.observable.protoProperty;t.dependentObservable[c]=t.observable,t.dependentObservable.fn={equalityComparer:r},t.dependentObservable.fn[c]=t.dependentObservable,t.utils.canSetPrototype&&t.utils.setPrototypeOf(t.dependentObservable.fn,t.subscribable.fn),t.exportSymbol("dependentObservable",t.dependentObservable),t.exportSymbol("computed",t.dependentObservable),t.exportSymbol("isComputed",t.isComputed),function(){function n(e,t,s){s=s||new i,e=t(e);var o=typeof e=="object"&&e!==null&&e!==undefined&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof Number)&&!(e instanceof Boolean);if(!o)return e;var u=e instanceof Array?[]:{};return s.save(e,u),r(e,function(r){var i=t(e[r]);switch(typeof i){case"boolean":case"number":case"string":case"function":u[r]=i;break;case"object":case"undefined":var o=s.get(i);u[r]=o!==undefined?o:n(i,t,s)}}),u}function r(e,t){if(e instanceof Array){for(var n=0;n<e.length;n++)t(n);typeof e["toJSON"]=="function"&&t("toJSON")}else for(var r in e)t(r)}function i(){this.keys=[],this.values=[]}var e=10;t.toJS=function(r){if(arguments.length==0)throw new Error("When calling ko.toJS, pass the object you want to convert.");return n(r,function(n){for(var r=0;t.isObservable(n)&&r<e;r++)n=n();return n})},t.toJSON=function(e,n,r){var i=t.toJS(e);return t.utils.stringifyJson(i,n,r)},i.prototype={constructor:i,save:function(e,n){var r=t.utils.arrayIndexOf(this.keys,e);r>=0?this.values[r]=n:(this.keys.push(e),this.values.push(n))},get:function(e){var n=t.utils.arrayIndexOf(this.keys,e);return n>=0?this.values[n]:undefined}}}(),t.exportSymbol("toJS",t.toJS),t.exportSymbol("toJSON",t.toJSON),function(){var e="__ko__hasDomDataOptionValue__";t.selectExtensions={readValue:function(n){switch(t.utils.tagNameLower(n)){case"option":if(n[e]===!0)return t.utils.domData.get(n,t.bindingHandlers.options.optionValueDomDataKey);return t.utils.ieVersion<=7?n.getAttributeNode("value")&&n.getAttributeNode("value").specified?n.value:n.text:n.value;case"select":return n.selectedIndex>=0?t.selectExtensions.readValue(n.options[n.selectedIndex]):undefined;default:return n.value}},writeValue:function(n,r,i){switch(t.utils.tagNameLower(n)){case"option":switch(typeof r){case"string":t.utils.domData.set(n,t.bindingHandlers.options.optionValueDomDataKey,undefined),e in n&&delete n[e],n.value=r;break;default:t.utils.domData.set(n,t.bindingHandlers.options.optionValueDomDataKey,r),n[e]=!0,n.value=typeof r=="number"?r:""}break;case"select":if(r===""||r===null)r=undefined;var s=-1;for(var o=0,u=n.options.length,a;o<u;++o){a=t.selectExtensions.readValue(n.options[o]);if(a==r||a==""&&r===undefined){s=o;break}}if(i||s>=0||r===undefined&&n.size>1)n.selectedIndex=s;break;default:if(r===null||r===undefined)r="";n.value=r}}}}(),t.exportSymbol("selectExtensions",t.selectExtensions),t.exportSymbol("selectExtensions.readValue",t.selectExtensions.readValue),t.exportSymbol("selectExtensions.writeValue",t.selectExtensions.writeValue),t.expressionRewriting=function(){function r(r){if(t.utils.arrayIndexOf(e,r)>=0)return!1;var i=r.match(n);return i===null?!1:i[1]?"Object("+i[1]+")"+i[2]:r}function p(e){var n=t.utils.stringTrim(e);n.charCodeAt(0)===123&&(n=n.slice(1,-1));var r=[],i=n.match(l),s,o,u=0;if(i){i.push(",");for(var a=0,f;f=i[a];++a){var p=f.charCodeAt(0);if(p===44){if(u<=0){s&&r.push(o?{key:s,value:o.join("")}:{unknown:s}),s=o=u=0;continue}}else if(p===58){if(!o)continue}else if(p===47&&a&&f.length>1){var d=i[a-1].match(c);d&&!h[d[0]]&&(n=n.substr(n.indexOf(f)+1),i=n.match(l),i.push(","),a=-1,f="/")}else if(p===40||p===123||p===91)++u;else if(p===41||p===125||p===93)--u;else if(!s&&!o){s=p===34||p===39?f.slice(1,-1):f;continue}o?o.push(f):o=[f]}}return r}function v(e,n){function i(e,n){function f(t){return t&&t.preprocess?n=t.preprocess(n,e,i):!0}var a;if(!f(t.getBindingHandler(e)))return;d[e]&&(a=r(n))&&o.push("'"+e+"':function(_z){"+a+"=_z}"),u&&(n="function(){return "+n+" }"),s.push("'"+e+"':"+n)}n=n||{};var s=[],o=[],u=n.valueAccessors,a=typeof e=="string"?p(e):e;return t.utils.arrayForEach(a,function(e){i(e.key||e.unknown,e.value)}),o.length&&i("_ko_property_writers","{"+o.join(",")+" }"),s.join(",")}var e=["true","false","null","undefined"],n=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,i='"(?:[^"\\\\]|\\\\.)*"',s="'(?:[^'\\\\]|\\\\.)*'",o="/(?:[^/\\\\]|\\\\.)*/w*",u=",\"'{}()/:[\\]",a="[^\\s:,/][^"+u+"]*[^\\s"+u+"]",f="[^\\s]",l=RegExp(i+"|"+s+"|"+o+"|"+a+"|"+f,"g"),c=/[\])"'A-Za-z0-9_$]+$/,h={"in":1,"return":1,"typeof":1},d={};return{bindingRewriteValidators:[],twoWayBindings:d,parseObjectLiteral:p,preProcessBindings:v,keyValueArrayContainsKey:function(e,t){for(var n=0;n<e.length;n++)if(e[n]["key"]==t)return!0;return!1},writeValueToProperty:function(e,n,r,i,s){if(!e||!t.isObservable(e)){var o=n.get("_ko_property_writers");o&&o[r]&&o[r](i)}else t.isWriteableObservable(e)&&(!s||e.peek()!==i)&&e(i)}}}(),t.exportSymbol("expressionRewriting",t.expressionRewriting),t.exportSymbol("expressionRewriting.bindingRewriteValidators",t.expressionRewriting.bindingRewriteValidators),t.exportSymbol("expressionRewriting.parseObjectLiteral",t.expressionRewriting.parseObjectLiteral),t.exportSymbol("expressionRewriting.preProcessBindings",t.expressionRewriting.preProcessBindings),t.exportSymbol("expressionRewriting._twoWayBindings",t.expressionRewriting.twoWayBindings),t.exportSymbol("jsonExpressionRewriting",t.expressionRewriting),t.exportSymbol("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",t.expressionRewriting.preProcessBindings),function(){function s(t){return t.nodeType==8&&n.test(e?t.text:t.nodeValue)}function o(t){return t.nodeType==8&&r.test(e?t.text:t.nodeValue)}function u(e,t){var n=e,r=1,i=[];while(n=n.nextSibling){if(o(n)){r--;if(r===0)return i}i.push(n),s(n)&&r++}if(!t)throw new Error("Cannot find closing comment tag to match: "+e.nodeValue);return null}function a(e,t){var n=u(e,t);return n?n.length>0?n[n.length-1].nextSibling:e.nextSibling:null}function f(e){var t=e.firstChild,n=null;if(t)do if(n)n.push(t);else if(s(t)){var r=a(t,!0);r?t=r:n=[t]}else o(t)&&(n=[t]);while(t=t.nextSibling);return n}var e=document&&document.createComment("test").text==="<!--test-->",n=e?/^<!--\s*ko(?:\s+([\s\S]+))?\s*-->$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,r=e?/^<!--\s*\/ko\s*-->$/:/^\s*\/ko\s*$/,i={ul:!0,ol:!0};t.virtualElements={allowedBindings:{},childNodes:function(e){return s(e)?u(e):e.childNodes},emptyNode:function(e){if(!s(e))t.utils.emptyDomNode(e);else{var n=t.virtualElements.childNodes(e);for(var r=0,i=n.length;r<i;r++)t.removeNode(n[r])}},setDomNodeChildren:function(e,n){if(!s(e))t.utils.setDomNodeChildren(e,n);else{t.virtualElements.emptyNode(e);var r=e.nextSibling;for(var i=0,o=n.length;i<o;i++)r.parentNode.insertBefore(n[i],r)}},prepend:function(e,t){s(e)?e.parentNode.insertBefore(t,e.nextSibling):e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)},insertAfter:function(e,n,r){r?s(e)?e.parentNode.insertBefore(n,r.nextSibling):r.nextSibling?e.insertBefore(n,r.nextSibling):e.appendChild(n):t.virtualElements.prepend(e,n)},firstChild:function(e){return s(e)?!e.nextSibling||o(e.nextSibling)?null:e.nextSibling:e.firstChild},nextSibling:function(e){return s(e)&&(e=a(e)),e.nextSibling&&o(e.nextSibling)?null:e.nextSibling},hasBindingValue:s,virtualNodeBindingValue:function(t){var r=(e?t.text:t.nodeValue).match(n);return r?r[1]:null},normaliseVirtualElementDomStructure:function(e){if(!i[t.utils.tagNameLower(e)])return;var n=e.firstChild;if(n)do if(n.nodeType===1){var r=f(n);if(r){var s=n.nextSibling;for(var o=0;o<r.length;o++)s?e.insertBefore(r[o],s):e.appendChild(r[o])}}while(n=n.nextSibling)}}}(),t.exportSymbol("virtualElements",t.virtualElements),t.exportSymbol("virtualElements.allowedBindings",t.virtualElements.allowedBindings),t.exportSymbol("virtualElements.emptyNode",t.virtualElements.emptyNode),t.exportSymbol("virtualElements.insertAfter",t.virtualElements.insertAfter),t.exportSymbol("virtualElements.prepend",t.virtualElements.prepend),t.exportSymbol("virtualElements.setDomNodeChildren",t.virtualElements.setDomNodeChildren),function(){function n(e,t,n){var i=e+(n&&n.valueAccessors||"");return t[i]||(t[i]=r(e,n))}function r(e,n){var r=t.expressionRewriting.preProcessBindings(e,n),i="with($context){with($data||{}){return{"+r+"}}}";return new Function("$context","$element",i)}var e="data-bind";t.bindingProvider=function(){this.bindingCache={}},t.utils.extend(t.bindingProvider.prototype,{nodeHasBindings:function(n){switch(n.nodeType){case 1:return n.getAttribute(e)!=null;case 8:return t.virtualElements.hasBindingValue(n);default:return!1}},getBindings:function(e,t){var n=this.getBindingsString(e,t);return n?this.parseBindingsString(n,t,e):null},getBindingAccessors:function(e,t){var n=this.getBindingsString(e,t);return n?this.parseBindingsString(n,t,e,{valueAccessors:!0}):null},getBindingsString:function(n,r){switch(n.nodeType){case 1:return n.getAttribute(e);case 8:return t.virtualElements.virtualNodeBindingValue(n);default:return null}},parseBindingsString:function(e,t,r,i){try{var s=n(e,this.bindingCache,i);return s(t,r)}catch(o){throw o.message="Unable to parse bindings.\nBindings value: "+e+"\nMessage: "+o.message,o}}}),t.bindingProvider.instance=new t.bindingProvider}(),t.exportSymbol("bindingProvider",t.bindingProvider),function(){function n(e){return function(){return e}}function r(e){return e()}function i(e){return t.utils.objectMap(t.dependencyDetection.ignore(e),function(t,n){return function(){return e()[n]}})}function s(e,r,s){return typeof e=="function"?i(e.bind(null,r,s)):t.utils.objectMap(e,n)}function o(e,t){return i(this.getBindings.bind(this,e,t))}function u(e){var n=t.virtualElements.allowedBindings[e];if(!n)throw new Error("The binding '"+e+"' cannot be used with virtual elements")}function a(e,n,r){var i,s=t.virtualElements.firstChild(n),o=t.bindingProvider.instance,u=o.preprocessNode;if(u){while(i=s)s=t.virtualElements.nextSibling(i),u.call(o,i);s=t.virtualElements.firstChild(n)}while(i=s)s=t.virtualElements.nextSibling(i),f(e,i,r)}function f(n,r,i){var s=!0,o=r.nodeType===1;o&&t.virtualElements.normaliseVirtualElementDomStructure(r);var u=o&&i||t.bindingProvider.instance.nodeHasBindings(r);u&&(s=h(r,null,n,i).shouldBindDescendants),s&&!e[t.utils.tagNameLower(r)]&&a(n,r,!o)}function c(e){var n=[],r={},i=[];return t.utils.objectForEach(e,function s(o){if(!r[o]){var u=t.getBindingHandler(o);u&&(u.after&&(i.push(o),t.utils.arrayForEach(u.after,function(n){if(e[n]){if(t.utils.arrayIndexOf(i,n)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+i.join(", "));s(n)}}),i.length--),n.push({key:o,handler:u})),r[o]=!0}}),n}function h(e,n,i,s){var a=t.utils.domData.get(e,l);if(!n){if(a)throw Error("You cannot apply bindings multiple times to the same element.");t.utils.domData.set(e,l,!0)}!a&&s&&t.storedBindingContextForNode(e,i);var f;if(n&&typeof n!="function")f=n;else{var h=t.bindingProvider.instance,p=h.getBindingAccessors||o,d=t.dependentObservable(function(){return f=n?n(i,e):p.call(h,e,i),f&&i._subscribable&&i._subscribable(),f},null,{disposeWhenNodeIsRemoved:e});if(!f||!d.isActive())d=null}var v;if(f){var m=d?function(e){return function(){return r(d()[e])}}:function(e){return f[e]};function g(){return t.utils.objectMap(d?d():f,r)}g.get=function(e){return f[e]&&r(m(e))},g.has=function(e){return e in f};var y=c(f);t.utils.arrayForEach(y,function(n){var r=n.handler.init,s=n.handler.update,o=n.key;e.nodeType===8&&u(o);try{typeof r=="function"&&t.dependencyDetection.ignore(function(){var t=r(e,m(o),g,i.$data,i);if(t&&t.controlsDescendantBindings){if(v!==undefined)throw new Error("Multiple bindings ("+v+" and "+o+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");v=o}}),typeof s=="function"&&t.dependentObservable(function(){s(e,m(o),g,i.$data,i)},null,{disposeWhenNodeIsRemoved:e})}catch(a){throw a.message='Unable to process binding "'+o+": "+f[o]+'"\nMessage: '+a.message,a}})}return{shouldBindDescendants:v===undefined}}function d(e){return e&&e instanceof t.bindingContext?e:new t.bindingContext(e)}t.bindingHandlers={};var e={script:!0};t.getBindingHandler=function(e){return t.bindingHandlers[e]},t.bindingContext=function(e,n,r,i){function s(){var s=a?e():e,o=t.utils.unwrapObservable(s);return n?(n._subscribable&&n._subscribable(),t.utils.extend(u,n),l&&(u._subscribable=l)):(u.$parents=[],u.$root=o,u.ko=t),u.$rawData=s,u.$data=o,r&&(u[r]=o),i&&i(u,n,o),u.$data}function o(){return f&&!t.utils.anyDomNodeIsAttachedToDocument(f)}var u=this,a=typeof e=="function"&&!t.isObservable(e),f,l=t.dependentObservable(s,null,{disposeWhen:o,disposeWhenNodeIsRemoved:!0});l.isActive()&&(u._subscribable=l,l.equalityComparer=null,f=[],l._addNode=function(e){f.push(e),t.utils.domNodeDisposal.addDisposeCallback(e,function(e){t.utils.arrayRemoveItem(f,e),f.length||(l.dispose(),u._subscribable=l=undefined)})})},t.bindingContext.prototype.createChildContext=function(e,n,r){return new t.bindingContext(e,this,n,function(e,t){e.$parentContext=t,e.$parent=t.$data,e.$parents=(t.$parents||[]).slice(0),e.$parents.unshift(e.$parent),r&&r(e)})},t.bindingContext.prototype.extend=function(e){return new t.bindingContext(this._subscribable||this.$data,this,null,function(n,r){n.$rawData=r.$rawData,t.utils.extend(n,typeof e=="function"?e():e)})};var l=t.utils.domData.nextKey(),p=t.utils.domData.nextKey();t.storedBindingContextForNode=function(e,n){if(arguments.length!=2)return t.utils.domData.get(e,p);t.utils.domData.set(e,p,n),n._subscribable&&n._subscribable._addNode(e)},t.applyBindingAccessorsToNode=function(e,n,r){return e.nodeType===1&&t.virtualElements.normaliseVirtualElementDomStructure(e),h(e,n,d(r),!0)},t.applyBindingsToNode=function(e,n,r){var i=d(r);return t.applyBindingAccessorsToNode(e,s(n,i,e),i)},t.applyBindingsToDescendants=function(e,t){(t.nodeType===1||t.nodeType===8)&&a(d(e),t,!0)},t.applyBindings=function(e,t){!jQuery&&window.jQuery&&(jQuery=window.jQuery);if(t&&t.nodeType!==1&&t.nodeType!==8)throw new Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");t=t||window.document.body,f(d(e),t,!0)},t.contextFor=function(e){switch(e.nodeType){case 1:case 8:var n=t.storedBindingContextForNode(e);if(n)return n;if(e.parentNode)return t.contextFor(e.parentNode)}return undefined},t.dataFor=function(e){var n=t.contextFor(e);return n?n.$data:undefined},t.exportSymbol("bindingHandlers",t.bindingHandlers),t.exportSymbol("applyBindings",t.applyBindings),t.exportSymbol("applyBindingsToDescendants",t.applyBindingsToDescendants),t.exportSymbol("applyBindingAccessorsToNode",t.applyBindingAccessorsToNode),t.exportSymbol("applyBindingsToNode",t.applyBindingsToNode),t.exportSymbol("contextFor",t.contextFor),t.exportSymbol("dataFor",t.dataFor)}();var h={"class":"className","for":"htmlFor"};t.bindingHandlers.attr={update:function(e,n,r){var i=t.utils.unwrapObservable(n())||{};t.utils.objectForEach(i,function(n,r){r=t.utils.unwrapObservable(r);var i=r===!1||r===null||r===undefined;i&&e.removeAttribute(n),t.utils.ieVersion<=8&&n in h?(n=h[n],i?e.removeAttribute(n):e[n]=r):i||e.setAttribute(n,r.toString()),n==="name"&&t.utils.setElementName(e,i?"":r.toString())})}},function(){t.bindingHandlers.checked={after:["value","attr"],init:function(e,n,r){function i(){return r.has("checkedValue")?t.utils.unwrapObservable(r.get("checkedValue")):e.value}function s(){var s=e.checked,o=c?i():s;if(t.computedContext.isInitial())return;if(a&&!s)return;var u=t.dependencyDetection.ignore(n);f?l!==o?(s&&(t.utils.addOrRemoveItem(u,o,!0),t.utils.addOrRemoveItem(u,l,!1)),l=o):t.utils.addOrRemoveItem(u,o,s):t.expressionRewriting.writeValueToProperty(u,r,"checked",o,!0)}function o(){var r=t.utils.unwrapObservable(n());f?e.checked=t.utils.arrayIndexOf(r,i())>=0:u?e.checked=r:e.checked=i()===r}var u=e.type=="checkbox",a=e.type=="radio";if(!u&&!a)return;var f=u&&t.utils.unwrapObservable(n())instanceof Array,l=f?i():undefined,c=a||f;a&&!e.name&&t.bindingHandlers.uniqueName.init(e,function(){return!0}),t.computed(s,null,{disposeWhenNodeIsRemoved:e}),t.utils.registerEventHandler(e,"click",s),t.computed(o,null,{disposeWhenNodeIsRemoved:e})}},t.expressionRewriting.twoWayBindings.checked=!0,t.bindingHandlers.checkedValue={update:function(e,n){e.value=t.utils.unwrapObservable(n())}}}();var p="__ko__cssValue";t.bindingHandlers.css={update:function(e,n){var r=t.utils.unwrapObservable(n());typeof r=="object"?t.utils.objectForEach(r,function(n,r){r=t.utils.unwrapObservable(r),t.utils.toggleDomNodeCssClass(e,n,r)}):(r=String(r||""),t.utils.toggleDomNodeCssClass(e,e[p],!1),e[p]=r,t.utils.toggleDomNodeCssClass(e,r,!0))}},t.bindingHandlers.enable={update:function(e,n){var r=t.utils.unwrapObservable(n());r&&e.disabled?e.removeAttribute("disabled"):!r&&!e.disabled&&(e.disabled=!0)}},t.bindingHandlers.disable={update:function(e,n){t.bindingHandlers.enable.update(e,function(){return!t.utils.unwrapObservable(n())})}},t.bindingHandlers.event={init:function(e,n,r,i,s){var o=n()||{};t.utils.objectForEach(o,function(o){typeof o=="string"&&t.utils.registerEventHandler(e,o,function(e){var u,a=n()[o];if(!a)return;try{var f=t.utils.makeArray(arguments);i=s.$data,f.unshift(i),u=a.apply(i,f)}finally{u!==!0&&(e.preventDefault?e.preventDefault():e.returnValue=!1)}var l=r.get(o+"Bubble")!==!1;l||(e.cancelBubble=!0,e.stopPropagation&&e.stopPropagation())})})}},t.bindingHandlers.foreach={makeTemplateValueAccessor:function(e){return function(){var n=e(),r=t.utils.peekObservable(n);return!r||typeof r.length=="number"?{foreach:n,templateEngine:t.nativeTemplateEngine.instance}:(t.utils.unwrapObservable(n),{foreach:r.data,as:r.as,includeDestroyed:r.includeDestroyed,afterAdd:r.afterAdd,beforeRemove:r.beforeRemove,afterRender:r.afterRender,beforeMove:r.beforeMove,afterMove:r.afterMove,templateEngine:t.nativeTemplateEngine.instance})}},init:function(e,n,r,i,s){return t.bindingHandlers.template.init(e,t.bindingHandlers.foreach.makeTemplateValueAccessor(n))},update:function(e,n,r,i,s){return t.bindingHandlers.template.update(e,t.bindingHandlers.foreach.makeTemplateValueAccessor(n),r,i,s)}},t.expressionRewriting.bindingRewriteValidators.foreach=!1,t.virtualElements.allowedBindings.foreach=!0;var v="__ko_hasfocusUpdating",m="__ko_hasfocusLastValue";t.bindingHandlers.hasfocus={init:function(e,n,r){var i=function(i){e[v]=!0;var s=e.ownerDocument;if("activeElement"in s){var o;try{o=s.activeElement}catch(u){o=s.body}i=o===e}var a=n();t.expressionRewriting.writeValueToProperty(a,r,"hasfocus",i,!0),e[m]=i,e[v]=!1},s=i.bind(null,!0),o=i.bind(null,!1);t.utils.registerEventHandler(e,"focus",s),t.utils.registerEventHandler(e,"focusin",s),t.utils.registerEventHandler(e,"blur",o),t.utils.registerEventHandler(e,"focusout",o)},update:function(e,n){var r=!!t.utils.unwrapObservable(n());!e[v]&&e[m]!==r&&(r?e.focus():e.blur(),t.dependencyDetection.ignore(t.utils.triggerEvent,null,[e,r?"focusin":"focusout"]))}},t.expressionRewriting.twoWayBindings.hasfocus=!0,t.bindingHandlers.hasFocus=t.bindingHandlers.hasfocus,t.expressionRewriting.twoWayBindings.hasFocus=!0,t.bindingHandlers.html={init:function(){return{controlsDescendantBindings:!0}},update:function(e,n){t.utils.setHtml(e,n())}},g("if"),g("ifnot",!1,!0),g("with",!0,!1,function(e,t){return e.createChildContext(t)});var y={};t.bindingHandlers.options={init:function(e){if(t.utils.tagNameLower(e)!=="select")throw new Error("options binding applies only to SELECT elements");while(e.length>0)e.remove(0);return{controlsDescendantBindings:!0}},update:function(e,n,r){function i(){return t.utils.arrayFilter(e.options,function(e){return e.selected})}function p(e,t,n){var r=typeof t;return r=="function"?t(e):r=="string"?e[t]:n}function v(n,i,s){s.length&&(h=s[0].selected?[t.selectExtensions.readValue(s[0])]:[],d=!0);var o=e.ownerDocument.createElement("option");if(n===y)t.utils.setTextContent(o,r.get("optionsCaption")),t.selectExtensions.writeValue(o,undefined);else{var u=p(n,r.get("optionsValue"),n);t.selectExtensions.writeValue(o,t.utils.unwrapObservable(u));var a=p(n,r.get("optionsText"),u);t.utils.setTextContent(o,a)}return[o]}function m(n,r){if(h.length){var i=t.utils.arrayIndexOf(h,t.selectExtensions.readValue(r[0]))>=0;t.utils.setOptionNodeSelectionState(r[0],i),d&&!i&&t.dependencyDetection.ignore(t.utils.triggerEvent,null,[e,"change"])}}var s=e.length==0,o=!s&&e.multiple?e.scrollTop:null,u=t.utils.unwrapObservable(n()),a=r.get("optionsIncludeDestroyed"),f={},l,c,h;e.multiple?h=t.utils.arrayMap(i(),t.selectExtensions.readValue):h=e.selectedIndex>=0?[t.selectExtensions.readValue(e.options[e.selectedIndex])]:[],u&&(typeof u.length=="undefined"&&(u=[u]),c=t.utils.arrayFilter(u,function(e){return a||e===undefined||e===null||!t.utils.unwrapObservable(e._destroy)}),r.has("optionsCaption")&&(l=t.utils.unwrapObservable(r.get("optionsCaption")),l!==null&&l!==undefined&&c.unshift(y)));var d=!1;f.beforeRemove=function(t){e.removeChild(t)};var g=m;r.has("optionsAfterRender")&&(g=function(e,n){m(e,n),t.dependencyDetection.ignore(r.get("optionsAfterRender"),null,[n[0],e!==y?e:undefined])}),t.utils.setDomNodeChildrenFromArrayMapping(e,c,v,f,g),t.dependencyDetection.ignore(function(){if(r.get("valueAllowUnset")&&r.has("value"))t.selectExtensions.writeValue(e,t.utils.unwrapObservable(r.get("value")),!0);else{var n;e.multiple?n=h.length&&i().length<h.length:n=h.length&&e.selectedIndex>=0?t.selectExtensions.readValue(e.options[e.selectedIndex])!==h[0]:h.length||e.selectedIndex>=0,n&&t.utils.triggerEvent(e,"change")}}),t.utils.ensureSelectElementIsRenderedCorrectly(e),o&&Math.abs(o-e.scrollTop)>20&&(e.scrollTop=o)}},t.bindingHandlers.options.optionValueDomDataKey=t.utils.domData.nextKey(),t.bindingHandlers.selectedOptions={after:["options","foreach"],init:function(e,n,r){t.utils.registerEventHandler(e,"change",function(){var i=n(),s=[];t.utils.arrayForEach(e.getElementsByTagName("option"),function(e){e.selected&&s.push(t.selectExtensions.readValue(e))}),t.expressionRewriting.writeValueToProperty(i,r,"selectedOptions",s)})},update:function(e,n){if(t.utils.tagNameLower(e)!="select")throw new Error("values binding applies only to SELECT elements");var r=t.utils.unwrapObservable(n());r&&typeof r.length=="number"&&t.utils.arrayForEach(e.getElementsByTagName("option"),function(e){var n=t.utils.arrayIndexOf(r,t.selectExtensions.readValue(e))>=0;t.utils.setOptionNodeSelectionState(e,n)})}},t.expressionRewriting.twoWayBindings.selectedOptions=!0,t.bindingHandlers.style={update:function(e,n){var r=t.utils.unwrapObservable(n()||{});t.utils.objectForEach(r,function(n,r){r=t.utils.unwrapObservable(r),e.style[n]=r||""})}},t.bindingHandlers.submit={init:function(e,n,r,i,s){if(typeof n()!="function")throw new Error("The value for a submit binding must be a function");t.utils.registerEventHandler(e,"submit",function(t){var r,i=n();try{r=i.call(s.$data,e)}finally{r!==!0&&(t.preventDefault?t.preventDefault():t.returnValue=!1)}})}},t.bindingHandlers.text={init:function(){return{controlsDescendantBindings:!0}},update:function(e,n){t.utils.setTextContent(e,n())}},t.virtualElements.allowedBindings.text=!0,t.bindingHandlers.uniqueName={init:function(e,n){if(n()){var r="ko_unique_"+ ++t.bindingHandlers.uniqueName.currentIndex;t.utils.setElementName(e,r)}}},t.bindingHandlers.uniqueName.currentIndex=0,t.bindingHandlers.value={after:["options","foreach"],init:function(e,n,r){var i=["change"],s=r.get("valueUpdate"),o=!1;s&&(typeof s=="string"&&(s=[s]),t.utils.arrayPushAll(i,s),i=t.utils.arrayGetDistinctValues(i));var u=function(){o=!1;var i=n(),s=t.selectExtensions.readValue(e);t.expressionRewriting.writeValueToProperty(i,r,"value",s)},a=t.utils.ieVersion&&e.tagName.toLowerCase()=="input"&&e.type=="text"&&e.autocomplete!="off"&&(!e.form||e.form.autocomplete!="off");a&&t.utils.arrayIndexOf(i,"propertychange")==-1&&(t.utils.registerEventHandler(e,"propertychange",function(){o=!0}),t.utils.registerEventHandler(e,"focus",function(){o=!1}),t.utils.registerEventHandler(e,"blur",function(){o&&u()})),t.utils.arrayForEach(i,function(n){var r=u;t.utils.stringStartsWith(n,"after")&&(r=function(){setTimeout(u,0)},n=n.substring("after".length)),t.utils.registerEventHandler(e,n,r)})},update:function(e,n,r){var i=t.utils.unwrapObservable(n()),s=t.selectExtensions.readValue(e),o=i!==s;if(o)if(t.utils.tagNameLower(e)==="select"){var u=r.get("valueAllowUnset"),a=function(){t.selectExtensions.writeValue(e,i,u)};a(),!u&&i!==t.selectExtensions.readValue(e)?t.dependencyDetection.ignore(t.utils.triggerEvent,null,[e,"change"]):setTimeout(a,0)}else t.selectExtensions.writeValue(e,i)}},t.expressionRewriting.twoWayBindings.value=!0,t.bindingHandlers.visible={update:function(e,n){var r=t.utils.unwrapObservable(n()),i=e.style.display!="none";r&&!i?e.style.display="":!r&&i&&(e.style.display="none")}},d("click"),t.templateEngine=function(){},t.templateEngine.prototype.renderTemplateSource=function(e,t,n){throw new Error("Override renderTemplateSource")},t.templateEngine.prototype.createJavaScriptEvaluatorBlock=function(e){throw new Error("Override createJavaScriptEvaluatorBlock")},t.templateEngine.prototype.makeTemplateSource=function(e,n){if(typeof e=="string"){n=n||document;var r=n.getElementById(e);if(!r)throw new Error("Cannot find template with ID "+e);return new t.templateSources.domElement(r)}if(e.nodeType==1||e.nodeType==8)return new t.templateSources.anonymousTemplate(e);throw new Error("Unknown template type: "+e)},t.templateEngine.prototype.renderTemplate=function(e,t,n,r){var i=this.makeTemplateSource(e,r);return this.renderTemplateSource(i,t,n)},t.templateEngine.prototype.isTemplateRewritten=function(e,t){return this.allowTemplateRewriting===!1?!0:this.makeTemplateSource(e,t).data("isRewritten")},t.templateEngine.prototype.rewriteTemplate=function(e,t,n){var r=this.makeTemplateSource(e,n),i=t(r.text());r.text(i),r.data("isRewritten",!0)},t.exportSymbol("templateEngine",t.templateEngine),t.templateRewriting=function(){function r(e){var n=t.expressionRewriting.bindingRewriteValidators;for(var r=0;r<e.length;r++){var i=e[r].key;if(n.hasOwnProperty(i)){var s=n[i];if(typeof s=="function"){var o=s(e[r].value);if(o)throw new Error(o)}else if(!s)throw new Error("This template engine does not support the '"+i+"' binding within its templates")}}}function i(e,n,i,s){var o=t.expressionRewriting.parseObjectLiteral(e);r(o);var u=t.expressionRewriting.preProcessBindings(o,{valueAccessors:!0}),a="ko.__tr_ambtns(function($context,$element){return(function(){return{ "+u+" } })()},'"+i.toLowerCase()+"')";return s.createJavaScriptEvaluatorBlock(a)+n}var e=/(<([a-z]+\d*)(?:\s+(?!data-bind\s*=\s*)[a-z0-9\-]+(?:=(?:\"[^\"]*\"|\'[^\']*\'))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,n=/<!--\s*ko\b\s*([\s\S]*?)\s*-->/g;return{ensureTemplateIsRewritten:function(e,n,r){n.isTemplateRewritten(e,r)||n.rewriteTemplate(e,function(e){return t.templateRewriting.memoizeBindingAttributeSyntax(e,n)},r)},memoizeBindingAttributeSyntax:function(t,r){return t.replace(e,function(){return i(arguments[4],arguments[1],arguments[2],r)}).replace(n,function(){return i(arguments[1],"<!-- ko -->","#comment",r)})},applyMemoizedBindingsToNextSibling:function(e,n){return t.memoization.memoize(function(r,i){var s=r.nextSibling;s&&s.nodeName.toLowerCase()===n&&t.applyBindingAccessorsToNode(s,e,i)})}}}(),t.exportSymbol("__tr_ambtns",t.templateRewriting.applyMemoizedBindingsToNextSibling),function(){t.templateSources={},t.templateSources.domElement=function(e){this.domElement=e},t.templateSources.domElement.prototype.text=function(){var e=t.utils.tagNameLower(this.domElement),n=e==="script"?"text":e==="textarea"?"value":"innerHTML";if(arguments.length==0)return this.domElement[n];var r=arguments[0];n==="innerHTML"?t.utils.setHtml(this.domElement,r):this.domElement[n]=r};var e=t.utils.domData.nextKey()+"_";t.templateSources.domElement.prototype.data=function(n){if(arguments.length===1)return t.utils.domData.get(this.domElement,e+n);t.utils.domData.set(this.domElement,e+n,arguments[1])};var n=t.utils.domData.nextKey();t.templateSources.anonymousTemplate=function(e){this.domElement=e},t.templateSources.anonymousTemplate.prototype=new t.templateSources.domElement,t.templateSources.anonymousTemplate.prototype.constructor=t.templateSources.anonymousTemplate,t.templateSources.anonymousTemplate.prototype.text=function(){if(arguments.length==0){var e=t.utils.domData.get(this.domElement,n)||{};return e.textData===undefined&&e.containerData&&(e.textData=e.containerData.innerHTML),e.textData}var r=arguments[0];t.utils.domData.set(this.domElement,n,{textData:r})},t.templateSources.domElement.prototype.nodes=function(){if(arguments.length==0){var e=t.utils.domData.get(this.domElement,n)||{};return e.containerData}var r=arguments[0];t.utils.domData.set(this.domElement,n,{containerData:r})},t.exportSymbol("templateSources",t.templateSources),t.exportSymbol("templateSources.domElement",t.templateSources.domElement),t.exportSymbol("templateSources.anonymousTemplate",t.templateSources.anonymousTemplate)}(),function(){function n(e,n,r){var i,s=e,o=t.virtualElements.nextSibling(n);while(s&&(i=s)!==o)s=t.virtualElements.nextSibling(i),r(i,s)}function r(e,r){if(e.length){var i=e[0],s=e[e.length-1],o=i.parentNode,u=t.bindingProvider.instance,a=u.preprocessNode;if(a){n(i,s,function(e,t){var n=e.previousSibling,r=a.call(u,e);r&&(e===i&&(i=r[0]||t),e===s&&(s=r[r.length-1]||n))}),e.length=0;if(!i)return;i===s?e.push(i):(e.push(i,s),t.utils.fixUpContinuousNodeArray(e,o))}n(i,s,function(e){(e.nodeType===1||e.nodeType===8)&&t.applyBindings(r,e)}),n(i,s,function(e){(e.nodeType===1||e.nodeType===8)&&t.memoization.unmemoizeDomNodeAndDescendants(e,[r])}),t.utils.fixUpContinuousNodeArray(e,o)}}function i(e){return e.nodeType?e:e.length>0?e[0]:null}function s(n,s,o,u,a){a=a||{};var f=n&&i(n),l=f&&f.ownerDocument,c=a.templateEngine||e;t.templateRewriting.ensureTemplateIsRewritten(o,c,l);var h=c.renderTemplate(o,u,a,l);if(typeof h.length!="number"||h.length>0&&typeof h[0].nodeType!="number")throw new Error("Template engine must return an array of DOM nodes");var p=!1;switch(s){case"replaceChildren":t.virtualElements.setDomNodeChildren(n,h),p=!0;break;case"replaceNode":t.utils.replaceDomNodes(n,h),p=!0;break;case"ignoreTargetNode":break;default:throw new Error("Unknown renderMode: "+s)}return p&&(r(h,u),a.afterRender&&t.dependencyDetection.ignore(a.afterRender,null,[h,u.$data])),h}function u(e,n){var r=t.utils.domData.get(e,o);r&&typeof r.dispose=="function"&&r.dispose(),t.utils.domData.set(e,o,n&&n.isActive()?n:undefined)}var e;t.setTemplateEngine=function(n){if(!(n==undefined||n instanceof t.templateEngine))throw new Error("templateEngine must inherit from ko.templateEngine");e=n},t.renderTemplate=function(n,r,o,u,a){o=o||{};if((o["templateEngine"]||e)==undefined)throw new Error("Set a template engine before calling renderTemplate");a=a||"replaceChildren";if(u){var f=i(u),l=function(){return!f||!t.utils.domNodeIsAttachedToDocument(f)},c=f&&a=="replaceNode"?f.parentNode:f;return t.dependentObservable(function(){var e=r&&r instanceof t.bindingContext?r:new t.bindingContext(t.utils.unwrapObservable(r)),l=t.isObservable(n)?n():typeof n=="function"?n(e.$data,e):n,c=s(u,a,l,e,o);a=="replaceNode"&&(u=c,f=i(u))},null,{disposeWhen:l,disposeWhenNodeIsRemoved:c})}return t.memoization.memoize(function(e){t.renderTemplate(n,r,o,e,"replaceNode")})},t.renderTemplateForEach=function(e,n,i,o,u){var a,f=function(t,n){a=u.createChildContext(t,i.as,function(e){e.$index=n});var r=typeof e=="function"?e(t,a):e;return s(null,"ignoreTargetNode",r,a,i)},l=function(e,t,n){r(t,a),i.afterRender&&i.afterRender(t,e)};return t.dependentObservable(function(){var e=t.utils.unwrapObservable(n)||[];typeof e.length=="undefined"&&(e=[e]);var r=t.utils.arrayFilter(e,function(e){return i.includeDestroyed||e===undefined||e===null||!t.utils.unwrapObservable(e._destroy)});t.dependencyDetection.ignore(t.utils.setDomNodeChildrenFromArrayMapping,null,[o,r,f,i,l])},null,{disposeWhenNodeIsRemoved:o})};var o=t.utils.domData.nextKey();t.bindingHandlers.template={init:function(e,n){var r=t.utils.unwrapObservable(n());if(typeof r=="string"||r.name)t.virtualElements.emptyNode(e);else{var i=t.virtualElements.childNodes(e),s=t.utils.moveCleanedNodesToContainerElement(i);(new t.templateSources.anonymousTemplate(e)).nodes(s)}return{controlsDescendantBindings:!0}},update:function(e,n,r,i,s){var o=n(),a,f=t.utils.unwrapObservable(o),l=!0,c=null,h;typeof f=="string"?(h=o,f={}):(h=f.name,"if"in f&&(l=t.utils.unwrapObservable(f["if"])),l&&"ifnot"in f&&(l=!t.utils.unwrapObservable(f.ifnot)),a=t.utils.unwrapObservable(f.data));if("foreach"in f){var p=l&&f.foreach||[];c=t.renderTemplateForEach(h||e,p,f,e,s)}else if(!l)t.virtualElements.emptyNode(e);else{var d="data"in f?s.createChildContext(a,f.as):s;c=t.renderTemplate(h||e,d,f,e)}u(e,c)}},t.expressionRewriting.bindingRewriteValidators.template=function(e){var n=t.expressionRewriting.parseObjectLiteral(e);return n.length==1&&n[0].unknown?null:t.expressionRewriting.keyValueArrayContainsKey(n,"name")?null:"This template engine does not support anonymous templates nested within its templates"},t.virtualElements.allowedBindings.template=!0}(),t.exportSymbol("setTemplateEngine",t.setTemplateEngine),t.exportSymbol("renderTemplate",t.renderTemplate),t.utils.findMovesInArrayComparison=function(e,t,n){if(e.length&&t.length){var r,i,s,o,u;for(r=i=0;(!n||r<n)&&(o=e[i]);++i){for(s=0;u=t[s];++s)if(o.value===u.value){o.moved=u.index,u.moved=o.index,t.splice(s,1),r=s=0;break}r+=s}}},t.utils.compareArrays=function(){function r(t,r,s){return s=typeof s=="boolean"?{dontLimitMoves:s}:s||{},t=t||[],r=r||[],t.length<=r.length?i(t,r,e,n,s):i(r,t,n,e,s)}function i(e,n,r,i,s){var o=Math.min,u=Math.max,a=[],f,l=e.length,c,h=n.length,p=h-l||1,d=l+h+1,v,m,g,y;for(f=0;f<=l;f++){m=v,a.push(v=[]),g=o(h,f+p),y=u(0,f-1);for(c=y;c<=g;c++)if(!c)v[c]=f+1;else if(!f)v[c]=c+1;else if(e[f-1]===n[c-1])v[c]=m[c-1];else{var b=m[c]||d,w=v[c-1]||d;v[c]=o(b,w)+1}}var E=[],S,x=[],T=[];for(f=l,c=h;f||c;)S=a[f][c]-1,c&&S===a[f][c-1]?x.push(E[E.length]={status:r,value:n[--c],index:c}):f&&S===a[f-1][c]?T.push(E[E.length]={status:i,value:e[--f],index:f}):(--c,--f,s.sparse||E.push({status:"retained",value:n[c]}));return t.utils.findMovesInArrayComparison(x,T,l*10),E.reverse()}var e="added",n="deleted";return r}(),t.exportSymbol("utils.compareArrays",t.utils.compareArrays),function(){function e(e,n,r,i,s){var o=[],u=t.dependentObservable(function(){var u=n(r,s,t.utils.fixUpContinuousNodeArray(o,e))||[];o.length>0&&(t.utils.replaceDomNodes(o,u),i&&t.dependencyDetection.ignore(i,null,[r,u,s])),o.length=0,t.utils.arrayPushAll(o,u)},null,{disposeWhenNodeIsRemoved:e,disposeWhen:function(){return!t.utils.anyDomNodeIsAttachedToDocument(o)}});return{mappedNodes:o,dependentObservable:u.isActive()?u:undefined}}var n=t.utils.domData.nextKey();t.utils.setDomNodeChildrenFromArrayMapping=function(r,i,s,o,u){function E(e,n){w=f[n],d!==n&&(y[e]=w),w.indexObservable(d++),t.utils.fixUpContinuousNodeArray(w.mappedNodes,r),h.push(w),m.push(w)}function S(e,n){if(e)for(var r=0,i=n.length;r<i;r++)n[r]&&t.utils.arrayForEach(n[r].mappedNodes,function(t){e(t,r,n[r].arrayEntry)})}i=i||[],o=o||{};var a=t.utils.domData.get(r,n)===undefined,f=t.utils.domData.get(r,n)||[],l=t.utils.arrayMap(f,function(e){return e.arrayEntry}),c=t.utils.compareArrays(l,i,o.dontLimitMoves),h=[],p=0,d=0,v=[],m=[],g=[],y=[],b=[],w;for(var x=0,T,N;T=c[x];x++){N=T.moved;switch(T.status){case"deleted":N===undefined&&(w=f[p],w.dependentObservable&&w.dependentObservable.dispose(),v.push.apply(v,t.utils.fixUpContinuousNodeArray(w.mappedNodes,r)),o.beforeRemove&&(g[x]=w,m.push(w))),p++;break;case"retained":E(x,p++);break;case"added":N!==undefined?E(x,N):(w={arrayEntry:T.value,indexObservable:t.observable(d++)},h.push(w),m.push(w),a||(b[x]=w))}}S(o.beforeMove,y),t.utils.arrayForEach(v,o.beforeRemove?t.cleanNode:t.removeNode);for(var x=0,C=t.virtualElements.firstChild(r),k,L;w=m[x];x++){w.mappedNodes||t.utils.extend(w,e(r,s,w.arrayEntry,u,w.indexObservable));for(var A=0;L=w.mappedNodes[A];C=L.nextSibling,k=L,A++)L!==C&&t.virtualElements.insertAfter(r,L,k);!w.initialized&&u&&(u(w.arrayEntry,w.mappedNodes,w.indexObservable),w.initialized=!0)}S(o.beforeRemove,g),S(o.afterMove,y),S(o.afterAdd,b),t.utils.domData.set(r,n,h)}}(),t.exportSymbol("utils.setDomNodeChildrenFromArrayMapping",t.utils.setDomNodeChildrenFromArrayMapping),t.nativeTemplateEngine=function(){this.allowTemplateRewriting=!1},t.nativeTemplateEngine.prototype=new t.templateEngine,t.nativeTemplateEngine.prototype.constructor=t.nativeTemplateEngine,t.nativeTemplateEngine.prototype.renderTemplateSource=function(e,n,r){var i=!(t.utils.ieVersion<9),s=i?e.nodes:null,o=s?e.nodes():null;if(o)return t.utils.makeArray(o.cloneNode(!0).childNodes);var u=e.text();return t.utils.parseHtmlFragment(u)},t.nativeTemplateEngine.instance=new t.nativeTemplateEngine,t.setTemplateEngine(t.nativeTemplateEngine.instance),t.exportSymbol("nativeTemplateEngine",t.nativeTemplateEngine),function(){t.jqueryTmplTemplateEngine=function(){function t(){if(e<2)throw new Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.")}function n(e,t,n){return jQuery.tmpl(e,t,n)}var e=this.jQueryTmplVersion=function(){if(!jQuery||!jQuery.tmpl)return 0;try{if(jQuery.tmpl.tag.tmpl.open.toString().indexOf("__")>=0)return 2}catch(e){}return 1}();this.renderTemplateSource=function(e,r,i){i=i||{},t();var s=e.data("precompiled");if(!s){var o=e.text()||"";o="{{ko_with $item.koBindingContext}}"+o+"{{/ko_with}}",s=jQuery.template(null,o),e.data("precompiled",s)}var u=[r.$data],a=jQuery.extend({koBindingContext:r},i.templateOptions),f=n(s,u,a);return f.appendTo(document.createElement("div")),jQuery.fragments={},f},this.createJavaScriptEvaluatorBlock=function(e){return"{{ko_code ((function() { return "+e+" })()) }}"},this.addTemplate=function(e,t){document.write("<script type='text/html' id='"+e+"'>"+t+"<"+"/script>")},e>0&&(jQuery.tmpl.tag.ko_code={open:"__.push($1 || '');"},jQuery.tmpl.tag.ko_with={open:"with($1) {",close:"} "})},t.jqueryTmplTemplateEngine.prototype=new t.templateEngine,t.jqueryTmplTemplateEngine.prototype.constructor=t.jqueryTmplTemplateEngine;var e=new t.jqueryTmplTemplateEngine;e.jQueryTmplVersion>0&&t.setTemplateEngine(e),t.exportSymbol("jqueryTmplTemplateEngine",t.jqueryTmplTemplateEngine)}()})})()}(),function(e,t){function n(t,n){var i,s,o,u=t.nodeName.toLowerCase();return"area"===u?(i=t.parentNode,s=i.name,t.href&&s&&"map"===i.nodeName.toLowerCase()?(o=e("img[usemap=#"+s+"]")[0],!!o&&r(o)):!1):(/input|select|textarea|button|object/.test(u)?!t.disabled:"a"===u?t.href||n:n)&&r(t)}function r(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var i=0,s=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"1.10.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(t){return function(n,r){return"number"==typeof n?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),r&&r.call(t)},n)}):t.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var t;return t=e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(n){if(n!==t)return this.css("zIndex",n);if(this.length)for(var r,i,s=e(this[0]);s.length&&s[0]!==document;){if(r=s.css("position"),("absolute"===r||"relative"===r||"fixed"===r)&&(i=parseInt(s.css("zIndex"),10),!isNaN(i)&&0!==i))return i;s=s.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++i)})},removeUniqueId:function(){return this.each(function(){s.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return n(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var r=e.attr(t,"tabindex"),i=isNaN(r);return(i||r>=0)&&n(t,!i)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(n,r){function i(t,n,r,i){return e.each(s,function(){n-=parseFloat(e.css(t,"padding"+this))||0,r&&(n-=parseFloat(e.css(t,"border"+this+"Width"))||0),i&&(n-=parseFloat(e.css(t,"margin"+this))||0)}),n}var s="Width"===r?["Left","Right"]:["Top","Bottom"],o=r.toLowerCase(),u={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?u["inner"+r].call(this):this.each(function(){e(this).css(o,i(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return"number"!=typeof t?u["outer"+r].call(this,t):this.each(function(){e(this).css(o,i(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(n){return arguments.length?t.call(this,e.camelCase(n)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in document.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,n,r){var i,s=e.ui[t].prototype;for(i in r)s.plugins[i]=s.plugins[i]||[],s.plugins[i].push([n,r[i]])},call:function(e,t,n){var r,i=e.plugins[t];if(i&&e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType)for(r=0;i.length>r;r++)e.options[i[r][0]]&&i[r][1].apply(e.element,n)}},hasScroll:function(t,n){if("hidden"===e(t).css("overflow"))return!1;var r=n&&"left"===n?"scrollLeft":"scrollTop",i=!1;return t[r]>0?!0:(t[r]=1,i=t[r]>0,t[r]=0,i)}})}(jQuery),function(e,t){var n=0,r=Array.prototype.slice,i=e.cleanData;e.cleanData=function(t){for(var n,r=0;null!=(n=t[r]);r++)try{e(n).triggerHandler("remove")}catch(s){}i(t)},e.widget=function(n,r,i){var s,o,u,a,f={},l=n.split(".")[0];n=n.split(".")[1],s=l+"-"+n,i||(i=r,r=e.Widget),e.expr[":"][s.toLowerCase()]=function(t){return!!e.data(t,s)},e[l]=e[l]||{},o=e[l][n],u=e[l][n]=function(e,n){return this._createWidget?(arguments.length&&this._createWidget(e,n),t):new u(e,n)},e.extend(u,o,{version:i.version,_proto:e.extend({},i),_childConstructors:[]}),a=new r,a.options=e.widget.extend({},a.options),e.each(i,function(n,i){return e.isFunction(i)?(f[n]=function(){var e=function(){return r.prototype[n].apply(this,arguments)},t=function(e){return r.prototype[n].apply(this,e)};return function(){var n,r=this._super,s=this._superApply;return this._super=e,this._superApply=t,n=i.apply(this,arguments),this._super=r,this._superApply=s,n}}(),t):(f[n]=i,t)}),u.prototype=e.widget.extend(a,{widgetEventPrefix:o?a.widgetEventPrefix:n},f,{constructor:u,namespace:l,widgetName:n,widgetFullName:s}),o?(e.each(o._childConstructors,function(t,n){var r=n.prototype;e.widget(r.namespace+"."+r.widgetName,u,n._proto)}),delete o._childConstructors):r._childConstructors.push(u),e.widget.bridge(n,u)},e.widget.extend=function(n){for(var i,o,u=r.call(arguments,1),a=0,f=u.length;f>a;a++)for(i in u[a])o=u[a][i],u[a].hasOwnProperty(i)&&o!==t&&(n[i]=e.isPlainObject(o)?e.isPlainObject(n[i])?e.widget.extend({},n[i],o):e.widget.extend({},o):o);return n},e.widget.bridge=function(n,i){var o=i.prototype.widgetFullName||n;e.fn[n]=function(u){var f="string"==typeof u,l=r.call(arguments,1),c=this;return u=!f&&l.length?e.widget.extend.apply(null,[u].concat(l)):u,f?this.each(function(){var r,i=e.data(this,o);return i?e.isFunction(i[u])&&"_"!==u.charAt(0)?(r=i[u].apply(i,l),r!==i&&r!==t?(c=r&&r.jquery?c.pushStack(r.get()):r,!1):t):e.error("no such method '"+u+"' for "+n+" widget instance"):e.error("cannot call methods on "+n+" prior to initialization; "+"attempted to call method '"+u+"'")}):this.each(function(){var t=e.data(this,o);t?t.option(u||{})._init():e.data(this,o,new i(u,this))}),c}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,r){r=e(r||this.defaultElement||this)[0],this.element=e(r),this.uuid=n++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),r!==this&&(e.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===r&&this.destroy()}}),this.document=e(r.style?r.ownerDocument:r.document||r),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(n,r){var i,s,o,u=n;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof n)if(u={},i=n.split("."),n=i.shift(),i.length){for(s=u[n]=e.widget.extend({},this.options[n]),o=0;i.length-1>o;o++)s[i[o]]=s[i[o]]||{},s=s[i[o]];if(n=i.pop(),r===t)return s[n]===t?null:s[n];s[n]=r}else{if(r===t)return this.options[n]===t?null:this.options[n];u[n]=r}return this._setOptions(u),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!t).attr("aria-disabled",t),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(n,r,i){var s,o=this;"boolean"!=typeof n&&(i=r,r=n,n=!1),i?(r=s=e(r),this.bindings=this.bindings.add(r)):(i=r,r=this.element,s=this.widget()),e.each(i,function(i,u){function f(){return n||o.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof u?o[u]:u).apply(o,arguments):t}"string"!=typeof u&&(f.guid=u.guid=u.guid||f.guid||e.guid++);var l=i.match(/^(\w+)\s*(.*)$/),c=l[1]+o.eventNamespace,h=l[2];h?s.delegate(h,c,f):r.bind(c,f)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function n(){return("string"==typeof e?r[e]:e).apply(r,arguments)}var r=this;return setTimeout(n,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,n,r){var i,s,o=this.options[t];if(r=r||{},n=e.Event(n),n.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),n.target=this.element[0],s=n.originalEvent)for(i in s)i in n||(n[i]=s[i]);return this.element.trigger(n,r),!(e.isFunction(o)&&o.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,n){e.Widget.prototype["_"+t]=function(r,i,s){"string"==typeof i&&(i={effect:i});var o,u=i?i===!0||"number"==typeof i?n:i.effect||n:t;i=i||{},"number"==typeof i&&(i={duration:i}),o=!e.isEmptyObject(i),i.complete=s,i.delay&&r.delay(i.delay),o&&e.effects&&e.effects.effect[u]?r[t](i):u!==t&&r[u]?r[u](i.duration,i.easing,s):r.queue(function(n){e(this)[t](),s&&s.call(r[0]),n()})}})}(jQuery),function(e,t){var n=!1;e(document).mouseup(function(){n=!1}),e.widget("ui.mouse",{version:"1.10.0",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(n){if(!0===e.data(n.target,t.widgetName+".preventClickEvent"))return e.removeData(n.target,t.widgetName+".preventClickEvent"),n.stopImmediatePropagation(),!1}),this.document.mouseup(function(e){n=!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&e(this.document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var r=this,i=t.which===1,s=typeof this.options.cancel=="string"&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;if(!i||s||!this._mouseCapture(t))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){r.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)){this._mouseStarted=this._mouseStart(t)!==!1;if(!this._mouseStarted)return t.preventDefault(),!0}return!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return r._mouseMove(e)},this._mouseUpDelegate=function(e){return r._mouseUp(e)},e(this.document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),n=!0,!0},_mouseMove:function(t){return e.ui.ie&&(!document.documentMode||document.documentMode<9)&&!t.button?this._mouseUp(t):this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return e(this.document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(jQuery),function(e,t){function n(e,t,n){return[parseInt(e[0],10)*(p.test(e[0])?t/100:1),parseInt(e[1],10)*(p.test(e[1])?n/100:1)]}function r(t,n){return parseInt(e.css(t,n),10)||0}function i(t){var n=t[0];return n.nodeType===9?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:e.isWindow(n)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:n.preventDefault?{width:0,height:0,offset:{top:n.pageY,left:n.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()}}e.ui=e.ui||{};var s,o=Math.max,u=Math.abs,a=Math.round,f=/left|center|right/,l=/top|center|bottom/,c=/[\+\-]\d+%?/,h=/^\w+/,p=/%$/,d=e.fn.position;e.position={scrollbarWidth:function(){if(s!==t)return s;var n,r,i=e("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),o=i.children()[0];return e("body").append(i),n=o.offsetWidth,i.css("overflow","scroll"),r=o.offsetWidth,n===r&&(r=i[0].clientWidth),i.remove(),s=n-r},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width<t.element[0].scrollWidth,s=r==="scroll"||r==="auto"&&t.height<t.element[0].scrollHeight;return{width:i?e.position.scrollbarWidth():0,height:s?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var n=e(t||window),r=e.isWindow(n[0]);return{element:n,isWindow:r,offset:n.offset()||{left:0,top:0},scrollLeft:n.scrollLeft(),scrollTop:n.scrollTop(),width:r?n.width():n.outerWidth(),height:r?n.height():n.outerHeight()}}},e.fn.position=function(t){if(!t||!t.of)return d.apply(this,arguments);t=e.extend({},t);var s,p,v,m,g,y,b=e(t.of),w=e.position.getWithinInfo(t.within),E=e.position.getScrollInfo(w),S=(t.collision||"flip").split(" "),x={};return y=i(b),b[0].preventDefault&&(t.at="left top"),p=y.width,v=y.height,m=y.offset,g=e.extend({},m),e.each(["my","at"],function(){var e=(t[this]||"").split(" "),n,r;e.length===1&&(e=f.test(e[0])?e.concat(["center"]):l.test(e[0])?["center"].concat(e):["center","center"]),e[0]=f.test(e[0])?e[0]:"center",e[1]=l.test(e[1])?e[1]:"center",n=c.exec(e[0]),r=c.exec(e[1]),x[this]=[n?n[0]:0,r?r[0]:0],t[this]=[h.exec(e[0])[0],h.exec(e[1])[0]]}),S.length===1&&(S[1]=S[0]),t.at[0]==="right"?g.left+=p:t.at[0]==="center"&&(g.left+=p/2),t.at[1]==="bottom"?g.top+=v:t.at[1]==="center"&&(g.top+=v/2),s=n(x.at,p,v),g.left+=s[0],g.top+=s[1],this.each(function(){var i,f,l=e(this),c=l.outerWidth(),h=l.outerHeight(),d=r(this,"marginLeft"),y=r(this,"marginTop"),T=c+d+r(this,"marginRight")+E.width,N=h+y+r(this,"marginBottom")+E.height,C=e.extend({},g),k=n(x.my,l.outerWidth(),l.outerHeight());t.my[0]==="right"?C.left-=c:t.my[0]==="center"&&(C.left-=c/2),t.my[1]==="bottom"?C.top-=h:t.my[1]==="center"&&(C.top-=h/2),C.left+=k[0],C.top+=k[1],e.support.offsetFractions||(C.left=a(C.left),C.top=a(C.top)),i={marginLeft:d,marginTop:y},e.each(["left","top"],function(n,r){e.ui.position[S[n]]&&e.ui.position[S[n]][r](C,{targetWidth:p,targetHeight:v,elemWidth:c,elemHeight:h,collisionPosition:i,collisionWidth:T,collisionHeight:N,offset:[s[0]+k[0],s[1]+k[1]],my:t.my,at:t.at,within:w,elem:l})}),t.using&&(f=function(e){var n=m.left-C.left,r=n+p-c,i=m.top-C.top,s=i+v-h,a={target:{element:b,left:m.left,top:m.top,width:p,height:v},element:{element:l,left:C.left,top:C.top,width:c,height:h},horizontal:r<0?"left":n>0?"right":"center",vertical:s<0?"top":i>0?"bottom":"middle"};p<c&&u(n+r)<p&&(a.horizontal="center"),v<h&&u(i+s)<v&&(a.vertical="middle"),o(u(n),u(r))>o(u(i),u(s))?a.important="horizontal":a.important="vertical",t.using.call(this,e,a)}),l.offset(e.extend(C,{using:f}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,r=n.isWindow?n.scrollLeft:n.offset.left,i=n.width,s=e.left-t.collisionPosition.marginLeft,u=r-s,a=s+t.collisionWidth-i-r,f;t.collisionWidth>i?u>0&&a<=0?(f=e.left+u+t.collisionWidth-i-r,e.left+=u-f):a>0&&u<=0?e.left=r:u>a?e.left=r+i-t.collisionWidth:e.left=r:u>0?e.left+=u:a>0?e.left-=a:e.left=o(e.left-s,e.left)},top:function(e,t){var n=t.within,r=n.isWindow?n.scrollTop:n.offset.top,i=t.within.height,s=e.top-t.collisionPosition.marginTop,u=r-s,a=s+t.collisionHeight-i-r,f;t.collisionHeight>i?u>0&&a<=0?(f=e.top+u+t.collisionHeight-i-r,e.top+=u-f):a>0&&u<=0?e.top=r:u>a?e.top=r+i-t.collisionHeight:e.top=r:u>0?e.top+=u:a>0?e.top-=a:e.top=o(e.top-s,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,i=n.width,s=n.isWindow?n.scrollLeft:n.offset.left,o=e.left-t.collisionPosition.marginLeft,a=o-s,f=o+t.collisionWidth-i-s,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-i-r;if(p<0||p<u(a))e.left+=l+c+h}else if(f>0){d=e.left-t.collisionPosition.marginLeft+l+c+h-s;if(d>0||u(d)<f)e.left+=l+c+h}},top:function(e,t){var n=t.within,r=n.offset.top+n.scrollTop,i=n.height,s=n.isWindow?n.scrollTop:n.offset.top,o=e.top-t.collisionPosition.marginTop,a=o-s,f=o+t.collisionHeight-i-s,l=t.my[1]==="top",c=l?-t.elemHeight:t.my[1]==="bottom"?t.elemHeight:0,h=t.at[1]==="top"?t.targetHeight:t.at[1]==="bottom"?-t.targetHeight:0,p=-2*t.offset[1],d,v;a<0?(v=e.top+c+h+p+t.collisionHeight-i-r,e.top+c+h+p>a&&(v<0||v<u(a))&&(e.top+=c+h+p)):f>0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-s,e.top+c+h+p>f&&(d>0||u(d)<f)&&(e.top+=c+h+p))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,n,r,i,s,o=document.getElementsByTagName("body")[0],u=document.createElement("div");t=document.createElement(o?"div":"body"),r={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},o&&e.extend(r,{position:"absolute",left:"-1000px",top:"-1000px"});for(s in r)t.style[s]=r[s];t.appendChild(u),n=o||document.documentElement,n.insertBefore(t,n.firstChild),u.style.cssText="position: absolute; left: 10.7432222px;",i=e(u).offset().left,e.support.offsetFractions=i>10&&i<11,t.innerHTML="",n.removeChild(t)}()}(jQuery),function(e,t){e.widget("ui.draggable",e.ui.mouse,{version:"1.10.2",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){this.options.helper==="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var n=this.options;return this.helper||n.disabled||e(t.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(t),this.handle?(e(n.iframeFix===!0?"iframe":n.iframeFix).each(function(){e("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var n=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,n.cursorAt&&this._adjustOffsetFromHelper(n.cursorAt),n.containment&&this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,n){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute");if(!n){var r=this._uiHash();if(this._trigger("drag",t,r)===!1)return this._mouseUp({}),!1;this.position=r.position}if(!this.options.axis||this.options.axis!=="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!=="x")this.helper[0].style.top=this.position.top+"px";return e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var n,r=this,i=!1,s=!1;e.ui.ddmanager&&!this.options.dropBehaviour&&(s=e.ui.ddmanager.drop(this,t)),this.dropped&&(s=this.dropped,this.dropped=!1),n=this.element[0];while(n&&(n=n.parentNode))n===this.document.get(0)&&(i=!0);return!i&&this.options.helper==="original"?!1:(this.options.revert==="invalid"&&!s||this.options.revert==="valid"&&s||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){r._trigger("stop",t)!==!1&&r._clear()}):this._trigger("stop",t)!==!1&&this._clear(),!1)},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){return this.options.handle?!!e(t.target).closest(this.element.find(this.options.handle)).length:!0},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t])):n.helper==="clone"?this.element.clone().removeAttr("id"):this.element;return r.parents("body").length||r.appendTo(n.appendTo==="parent"?this.element[0].parentNode:n.appendTo),r[0]!==this.element[0]&&!/(fixed|absolute)/.test(r.css("position"))&&r.css("position","absolute"),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition==="absolute"&&this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()==="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition==="relative"){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,n,r,i=this.options;i.containment==="parent"&&(i.containment=this.helper[0].parentNode);if(i.containment==="document"||i.containment==="window")this.containment=[i.containment==="document"?0:e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,i.containment==="document"?0:e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(i.containment==="document"?0:e(window).scrollLeft())+e(i.containment==="document"?document:window).width()-this.helperProportions.width-this.margins.left,(i.containment==="document"?0:e(window).scrollTop())+(e(i.containment==="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(i.containment)&&i.containment.constructor!==Array){n=e(i.containment),r=n[0];if(!r)return;t=e(r).css("overflow")!=="hidden",this.containment=[(parseInt(e(r).css("borderLeftWidth"),10)||0)+(parseInt(e(r).css("paddingLeft"),10)||0),(parseInt(e(r).css("borderTopWidth"),10)||0)+(parseInt(e(r).css("paddingTop"),10)||0),(t?Math.max(r.scrollWidth,r.offsetWidth):r.offsetWidth)-(parseInt(e(r).css("borderRightWidth"),10)||0)-(parseInt(e(r).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(r.scrollHeight,r.offsetHeight):r.offsetHeight)-(parseInt(e(r).css("borderBottomWidth"),10)||0)-(parseInt(e(r).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=n}else i.containment.constructor===Array&&(this.containment=i.containment)},_convertPositionTo:function(t,n){n||(n=this.position);var r=t==="absolute"?1:-1,i=this.cssPosition!=="absolute"||this.scrollParent[0]!==document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,s=/(html|body)/i.test(i[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():s?0:i.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():s?0:i.scrollLeft())*r}},_generatePosition:function(t){var n,r,i,s,o=this.options,u=this.cssPosition!=="absolute"||this.scrollParent[0]!==document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(u[0].tagName),f=t.pageX,l=t.pageY;return this.originalPosition&&(this.containment&&(this.relative_container?(r=this.relative_container.offset(),n=[this.containment[0]+r.left,this.containment[1]+r.top,this.containment[2]+r.left,this.containment[3]+r.top]):n=this.containment,t.pageX-this.offset.click.left<n[0]&&(f=n[0]+this.offset.click.left),t.pageY-this.offset.click.top<n[1]&&(l=n[1]+this.offset.click.top),t.pageX-this.offset.click.left>n[2]&&(f=n[2]+this.offset.click.left),t.pageY-this.offset.click.top>n[3]&&(l=n[3]+this.offset.click.top)),o.grid&&(i=o.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY,l=n?i-this.offset.click.top>=n[1]||i-this.offset.click.top>n[3]?i:i-this.offset.click.top>=n[1]?i-o.grid[1]:i+o.grid[1]:i,s=o.grid[0]?this.originalPageX+Math.round((f-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX,f=n?s-this.offset.click.left>=n[0]||s-this.offset.click.left>n[2]?s:s-this.offset.click.left>=n[0]?s-o.grid[0]:s+o.grid[0]:s)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition==="fixed"?-this.scrollParent.scrollTop():a?0:u.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition==="fixed"?-this.scrollParent.scrollLeft():a?0:u.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!==this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(t,n,r){return r=r||this._uiHash(),e.ui.plugin.call(this,t,[n,r]),t==="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,n,r)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,n){var r=e(this).data("ui-draggable"),i=r.options,s=e.extend({},n,{item:r.element});r.sortables=[],e(i.connectToSortable).each(function(){var n=e.data(this,"ui-sortable");n&&!n.options.disabled&&(r.sortables.push({instance:n,shouldRevert:n.options.revert}),n.refreshPositions(),n._trigger("activate",t,s))})},stop:function(t,n){var r=e(this).data("ui-draggable"),i=e.extend({},n,{item:r.element});e.each(r.sortables,function(){this.instance.isOver?(this.instance.isOver=0,r.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,r.options.helper==="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,i))})},drag:function(t,n){var r=e(this).data("ui-draggable"),i=this;e.each(r.sortables,function(){var s=!1,o=this;this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(s=!0,e.each(r.sortables,function(){return this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this!==o&&this.instance._intersectsWith(this.instance.containerCache)&&e.contains(o.instance.element[0],this.instance.element[0])&&(s=!1),s})),s?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(i).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return n.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=r.offset.click.top,this.instance.offset.click.left=r.offset.click.left,this.instance.offset.parent.left-=r.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=r.offset.parent.top-this.instance.offset.parent.top,r._trigger("toSortable",t),r.dropped=this.instance.element,r.currentItem=r.element,this.instance.fromOutside=r),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),r._trigger("fromSortable",t),r.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(){var t=e("body"),n=e(this).data("ui-draggable").options;t.css("cursor")&&(n._cursor=t.css("cursor")),t.css("cursor",n.cursor)},stop:function(){var t=e(this).data("ui-draggable").options;t._cursor&&e("body").css("cursor",t._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,n){var r=e(n.helper),i=e(this).data("ui-draggable").options;r.css("opacity")&&(i._opacity=r.css("opacity")),r.css("opacity",i.opacity)},stop:function(t,n){var r=e(this).data("ui-draggable").options;r._opacity&&e(n.helper).css("opacity",r._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(){var t=e(this).data("ui-draggable");t.scrollParent[0]!==document&&t.scrollParent[0].tagName!=="HTML"&&(t.overflowOffset=t.scrollParent.offset())},drag:function(t){var n=e(this).data("ui-draggable"),r=n.options,i=!1;if(n.scrollParent[0]!==document&&n.scrollParent[0].tagName!=="HTML"){if(!r.axis||r.axis!=="x")n.overflowOffset.top+n.scrollParent[0].offsetHeight-t.pageY<r.scrollSensitivity?n.scrollParent[0].scrollTop=i=n.scrollParent[0].scrollTop+r.scrollSpeed:t.pageY-n.overflowOffset.top<r.scrollSensitivity&&(n.scrollParent[0].scrollTop=i=n.scrollParent[0].scrollTop-r.scrollSpeed);if(!r.axis||r.axis!=="y")n.overflowOffset.left+n.scrollParent[0].offsetWidth-t.pageX<r.scrollSensitivity?n.scrollParent[0].scrollLeft=i=n.scrollParent[0].scrollLeft+r.scrollSpeed:t.pageX-n.overflowOffset.left<r.scrollSensitivity&&(n.scrollParent[0].scrollLeft=i=n.scrollParent[0].scrollLeft-r.scrollSpeed)}else{if(!r.axis||r.axis!=="x")t.pageY-e(document).scrollTop()<r.scrollSensitivity?i=e(document).scrollTop(e(document).scrollTop()-r.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<r.scrollSensitivity&&(i=e(document).scrollTop(e(document).scrollTop()+r.scrollSpeed));if(!r.axis||r.axis!=="y")t.pageX-e(document).scrollLeft()<r.scrollSensitivity?i=e(document).scrollLeft(e(document).scrollLeft()-r.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<r.scrollSensitivity&&(i=e(document).scrollLeft(e(document).scrollLeft()+r.scrollSpeed))}i!==!1&&e.ui.ddmanager&&!r.dropBehaviour&&e.ui.ddmanager.prepareOffsets(n,t)}}),e.ui.plugin.add("draggable","snap",{start:function(){var t=e(this).data("ui-draggable"),n=t.options;t.snapElements=[],e(n.snap.constructor!==String?n.snap.items||":data(ui-draggable)":n.snap).each(function(){var n=e(this),r=n.offset();this!==t.element[0]&&t.snapElements.push({item:this,width:n.outerWidth(),height:n.outerHeight(),top:r.top,left:r.left})})},drag:function(t,n){var r,i,s,o,u,a,f,l,c,h,p=e(this).data("ui-draggable"),d=p.options,v=d.snapTolerance,m=n.offset.left,g=m+p.helperProportions.width,y=n.offset.top,b=y+p.helperProportions.height;for(c=p.snapElements.length-1;c>=0;c--){u=p.snapElements[c].left,a=u+p.snapElements[c].width,f=p.snapElements[c].top,l=f+p.snapElements[c].height;if(!(u-v<m&&m<a+v&&f-v<y&&y<l+v||u-v<m&&m<a+v&&f-v<b&&b<l+v||u-v<g&&g<a+v&&f-v<y&&y<l+v||u-v<g&&g<a+v&&f-v<b&&b<l+v)){p.snapElements[c].snapping&&p.options.snap.release&&p.options.snap.release.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=!1;continue}d.snapMode!=="inner"&&(r=Math.abs(f-b)<=v,i=Math.abs(l-y)<=v,s=Math.abs(u-g)<=v,o=Math.abs(a-m)<=v,r&&(n.position.top=p._convertPositionTo("relative",{top:f-p.helperProportions.height,left:0}).top-p.margins.top),i&&(n.position.top=p._convertPositionTo("relative",{top:l,left:0}).top-p.margins.top),s&&(n.position.left=p._convertPositionTo("relative",{top:0,left:u-p.helperProportions.width}).left-p.margins.left),o&&(n.position.left=p._convertPositionTo("relative",{top:0,left:a}).left-p.margins.left)),h=r||i||s||o,d.snapMode!=="outer"&&(r=Math.abs(f-y)<=v,i=Math.abs(l-b)<=v,s=Math.abs(u-m)<=v,o=Math.abs(a-g)<=v,r&&(n.position.top=p._convertPositionTo("relative",{top:f,left:0}).top-p.margins.top),i&&(n.position.top=p._convertPositionTo("relative",{top:l-p.helperProportions.height,left:0}).top-p.margins.top),s&&(n.position.left=p._convertPositionTo("relative",{top:0,left:u}).left-p.margins.left),o&&(n.position.left=p._convertPositionTo("relative",{top:0,left:a-p.helperProportions.width}).left-p.margins.left)),!p.snapElements[c].snapping&&(r||i||s||o||h)&&p.options.snap.snap&&p.options.snap.snap.call(p.element,t,e.extend(p._uiHash(),{snapItem:p.snapElements[c].item})),p.snapElements[c].snapping=r||i||s||o||h}}}),e.ui.plugin.add("draggable","stack",{start:function(){var t,n=this.data("ui-draggable").options,r=e.makeArray(e(n.stack)).sort(function(t,n){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(n).css("zIndex"),10)||0)});if(!r.length)return;t=parseInt(e(r[0]).css("zIndex"),10)||0,e(r).each(function(n){e(this).css("zIndex",t+n)}),this.css("zIndex",t+r.length)}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,n){var r=e(n.helper),i=e(this).data("ui-draggable").options;r.css("zIndex")&&(i._zIndex=r.css("zIndex")),r.css("zIndex",i.zIndex)},stop:function(t,n){var r=e(this).data("ui-draggable").options;r._zIndex&&e(n.helper).css("zIndex",r._zIndex)}})}(jQuery),function(e,t){function n(e,t,n){return e>t&&e<t+n}e.widget("ui.droppable",{version:"1.10.1",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t=this.options,n=t.accept;this.isover=!1,this.isout=!0,this.accept=e.isFunction(n)?n:function(e){return e.is(n)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},e.ui.ddmanager.droppables[t.scope]=e.ui.ddmanager.droppables[t.scope]||[],e.ui.ddmanager.droppables[t.scope].push(this),t.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){var t=0,n=e.ui.ddmanager.droppables[this.options.scope];for(;t<n.length;t++)n[t]===this&&n.splice(t,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,n){t==="accept"&&(this.accept=e.isFunction(n)?n:function(e){return e.is(n)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),n&&this._trigger("activate",t,this.ui(n))},_deactivate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),n&&this._trigger("deactivate",t,this.ui(n))},_over:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]===this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(n)))},_out:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]===this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(n)))},_drop:function(t,n){var r=n||e.ui.ddmanager.current,i=!1;return!r||(r.currentItem||r.element)[0]===this.element[0]?!1:(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var n=e.data(this,"ui-droppable");if(n.options.greedy&&!n.options.disabled&&n.options.scope===r.options.scope&&n.accept.call(n.element[0],r.currentItem||r.element)&&e.ui.intersect(r,e.extend(n,{offset:n.element.offset()}),n.options.tolerance,t))return i=!0,!1}),i?!1:this.accept.call(this.element[0],r.currentItem||r.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(r)),this.element):!1)},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(e,t,r,i){if(!t.offset)return!1;var s,o,u=(e.positionAbs||e.position.absolute).left,a=u+e.helperProportions.width,f=(e.positionAbs||e.position.absolute).top,l=f+e.helperProportions.height,c=t.offset.left,h=c+t.proportions.width,p=t.offset.top,d=p+t.proportions.height;switch(r){case"fit":return c<=u&&a<=h&&p<=f&&l<=d;case"intersect":return c<u+e.helperProportions.width/2&&a-e.helperProportions.width/2<h&&p<f+e.helperProportions.height/2&&l-e.helperProportions.height/2<d;case"pointer":return s=i.pageX,o=i.pageY,n(o,p,t.proportions.height)&&n(s,c,t.proportions.width);case"touch":return(f>=p&&f<=d||l>=p&&l<=d||f<p&&l>d)&&(u>=c&&u<=h||a>=c&&a<=h||u<c&&a>h);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,n){var r,i,s=e.ui.ddmanager.droppables[t.options.scope]||[],o=n?n.type:null,u=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();e:for(r=0;r<s.length;r++){if(s[r].options.disabled||t&&!s[r].accept.call(s[r].element[0],t.currentItem||t.element))continue;for(i=0;i<u.length;i++)if(u[i]===s[r].element[0]){s[r].proportions.height=0;continue e}s[r].visible=s[r].element.css("display")!=="none";if(!s[r].visible)continue;o==="mousedown"&&s[r]._activate.call(s[r],n),s[r].offset=s[r].element.offset(),s[r].proportions={width:s[r].element[0].offsetWidth,height:s[r].element[0].offsetHeight}}},drop:function(t,n){var r=!1;return e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance,n)&&(r=this._drop.call(this,n)||r),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,n))}),r},dragStart:function(t,n){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)})},drag:function(t,n){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,n),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var r,i,s,o=e.ui.intersect(t,this,this.options.tolerance,n),u=!o&&this.isover?"isout":o&&!this.isover?"isover":null;if(!u)return;this.options.greedy&&(i=this.options.scope,s=this.element.parents(":data(ui-droppable)").filter(function(){return e.data(this,"ui-droppable").options.scope===i}),s.length&&(r=e.data(s[0],"ui-droppable"),r.greedyChild=u==="isover")),r&&u==="isover"&&(r.isover=!1,r.isout=!0,r._out.call(r,n)),this[u]=!0,this[u==="isout"?"isover":"isout"]=!1,this[u==="isover"?"_over":"_out"].call(this,n),r&&u==="isout"&&(r.isout=!1,r.isover=!0,r._over.call(r,n))})},dragStop:function(t,n){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)}}}(jQuery),function(e,t){function n(e){return parseInt(e,10)||0}function r(e){return!isNaN(parseInt(e,10))}e.widget("ui.resizable",e.ui.mouse,{version:"1.10.0",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_create:function(){var t,n,r,i,s,o=this,u=this.options;this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!u.aspectRatio,aspectRatio:u.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:u.helper||u.ghost||u.animate?u.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.data("ui-resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=u.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor===String){this.handles==="all"&&(this.handles="n,e,s,w,se,sw,ne,nw"),t=this.handles.split(","),this.handles={};for(n=0;n<t.length;n++)r=e.trim(t[n]),s="ui-resizable-"+r,i=e("<div class='ui-resizable-handle "+s+"'></div>"),i.css({zIndex:u.zIndex}),"se"===r&&i.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[r]=".ui-resizable-"+r,this.element.append(i)}this._renderAxis=function(t){var n,r,i,s;t=t||this.element;for(n in this.handles){this.handles[n].constructor===String&&(this.handles[n]=e(this.handles[n],this.element).show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(r=e(this.handles[n],this.element),s=/sw|ne|nw|se|n|s/.test(n)?r.outerHeight():r.outerWidth(),i=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join(""),t.css(i,s),this._proportionallyResize());if(!e(this.handles[n]).length)continue}},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){o.resizing||(this.className&&(i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),o.axis=i&&i[1]?i[1]:"se")}),u.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){if(u.disabled)return;e(this).removeClass("ui-resizable-autohide"),o._handles.show()}).mouseleave(function(){if(u.disabled)return;o.resizing||(e(this).addClass("ui-resizable-autohide"),o._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,n=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(n(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),n(this.originalElement),this},_mouseCapture:function(t){var n,r,i=!1;for(n in this.handles){r=e(this.handles[n])[0];if(r===t.target||e.contains(r,t.target))i=!0}return!this.options.disabled&&i},_mouseStart:function(t){var r,i,s,o=this.options,u=this.element.position(),a=this.element;return this.resizing=!0,/absolute/.test(a.css("position"))?a.css({position:"absolute",top:a.css("top"),left:a.css("left")}):a.is(".ui-draggable")&&a.css({position:"absolute",top:u.top,left:u.left}),this._renderProxy(),r=n(this.helper.css("left")),i=n(this.helper.css("top")),o.containment&&(r+=e(o.containment).scrollLeft()||0,i+=e(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:r,top:i},this.size=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.originalPosition={left:r,top:i},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio=typeof o.aspectRatio=="number"?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,s=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor",s==="auto"?this.axis+"-resize":s),a.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var n,r=this.helper,i={},s=this.originalMousePosition,o=this.axis,u=this.position.top,a=this.position.left,f=this.size.width,l=this.size.height,c=t.pageX-s.left||0,h=t.pageY-s.top||0,p=this._change[o];if(!p)return!1;n=p.apply(this,[t,c,h]),this._updateVirtualBoundaries(t.shiftKey);if(this._aspectRatio||t.shiftKey)n=this._updateRatio(n,t);return n=this._respectSize(n,t),this._updateCache(n),this._propagate("resize",t),this.position.top!==u&&(i.top=this.position.top+"px"),this.position.left!==a&&(i.left=this.position.left+"px"),this.size.width!==f&&(i.width=this.size.width+"px"),this.size.height!==l&&(i.height=this.size.height+"px"),r.css(i),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(i)||this._trigger("resize",t,this.ui()),!1},_mouseStop:function(t){this.resizing=!1;var n,r,i,s,o,u,a,f=this.options,l=this;return this._helper&&(n=this._proportionallyResizeElements,r=n.length&&/textarea/i.test(n[0].nodeName),i=r&&e.ui.hasScroll(n[0],"left")?0:l.sizeDiff.height,s=r?0:l.sizeDiff.width,o={width:l.helper.width()-s,height:l.helper.height()-i},u=parseInt(l.element.css("left"),10)+(l.position.left-l.originalPosition.left)||null,a=parseInt(l.element.css("top"),10)+(l.position.top-l.originalPosition.top)||null,f.animate||this.element.css(e.extend(o,{top:a,left:u})),l.helper.height(l.size.height),l.helper.width(l.size.width),this._helper&&!f.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t,n,i,s,o,u=this.options;o={minWidth:r(u.minWidth)?u.minWidth:0,maxWidth:r(u.maxWidth)?u.maxWidth:Infinity,minHeight:r(u.minHeight)?u.minHeight:0,maxHeight:r(u.maxHeight)?u.maxHeight:Infinity};if(this._aspectRatio||e)t=o.minHeight*this.aspectRatio,i=o.minWidth/this.aspectRatio,n=o.maxHeight*this.aspectRatio,s=o.maxWidth/this.aspectRatio,t>o.minWidth&&(o.minWidth=t),i>o.minHeight&&(o.minHeight=i),n<o.maxWidth&&(o.maxWidth=n),s<o.maxHeight&&(o.maxHeight=s);this._vBoundaries=o},_updateCache:function(e){this.offset=this.helper.offset(),r(e.left)&&(this.position.left=e.left),r(e.top)&&(this.position.top=e.top),r(e.height)&&(this.size.height=e.height),r(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=this.position,n=this.size,i=this.axis;return r(e.height)?e.width=e.height*this.aspectRatio:r(e.width)&&(e.height=e.width/this.aspectRatio),i==="sw"&&(e.left=t.left+(n.width-e.width),e.top=null),i==="nw"&&(e.top=t.top+(n.height-e.height),e.left=t.left+(n.width-e.width)),e},_respectSize:function(e){var t=this._vBoundaries,n=this.axis,i=r(e.width)&&t.maxWidth&&t.maxWidth<e.width,s=r(e.height)&&t.maxHeight&&t.maxHeight<e.height,o=r(e.width)&&t.minWidth&&t.minWidth>e.width,u=r(e.height)&&t.minHeight&&t.minHeight>e.height,a=this.originalPosition.left+this.originalSize.width,f=this.position.top+this.size.height,l=/sw|nw|w/.test(n),c=/nw|ne|n/.test(n);return o&&(e.width=t.minWidth),u&&(e.height=t.minHeight),i&&(e.width=t.maxWidth),s&&(e.height=t.maxHeight),o&&l&&(e.left=a-t.minWidth),i&&l&&(e.left=a-t.maxWidth),u&&c&&(e.top=f-t.minHeight),s&&c&&(e.top=f-t.maxHeight),!e.width&&!e.height&&!e.left&&e.top?e.top=null:!e.width&&!e.height&&!e.top&&e.left&&(e.left=null),e},_proportionallyResize:function(){if(!this._proportionallyResizeElements.length)return;var e,t,n,r,i,s=this.helper||this.element;for(e=0;e<this._proportionallyResizeElements.length;e++){i=this._proportionallyResizeElements[e];if(!this.borderDif){this.borderDif=[],n=[i.css("borderTopWidth"),i.css("borderRightWidth"),i.css("borderBottomWidth"),i.css("borderLeftWidth")],r=[i.css("paddingTop"),i.css("paddingRight"),i.css("paddingBottom"),i.css("paddingLeft")];for(t=0;t<n.length;t++)this.borderDif[t]=(parseInt(n[t],10)||0)+(parseInt(r[t],10)||0)}i.css({height:s.height()-this.borderDif[0]-this.borderDif[2]||0,width:s.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var t=this.element,n=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||e("<div style='overflow:hidden;'></div>"),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++n.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var n=this.originalSize,r=this.originalPosition;return{left:r.left+t,width:n.width-t}},n:function(e,t,n){var r=this.originalSize,i=this.originalPosition;return{top:i.top+n,height:r.height-n}},s:function(e,t,n){return{height:this.originalSize.height+n}},se:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},sw:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,n,r]))},ne:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},nw:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,n,r]))}},_propagate:function(t,n){e.ui.plugin.call(this,t,[n,this.ui()]),t!=="resize"&&this._trigger(t,n,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var n=e(this).data("ui-resizable"),r=n.options,i=n._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),o=s&&e.ui.hasScroll(i[0],"left")?0:n.sizeDiff.height,u=s?0:n.sizeDiff.width,a={width:n.size.width-u,height:n.size.height-o},f=parseInt(n.element.css("left"),10)+(n.position.left-n.originalPosition.left)||null,l=parseInt(n.element.css("top"),10)+(n.position.top-n.originalPosition.top)||null;n.element.animate(e.extend(a,l&&f?{top:l,left:f}:{}),{duration:r.animateDuration,easing:r.animateEasing,step:function(){var r={width:parseInt(n.element.css("width"),10),height:parseInt(n.element.css("height"),10),top:parseInt(n.element.css("top"),10),left:parseInt(n.element.css("left"),10)};i&&i.length&&e(i[0]).css({width:r.width,height:r.height}),n._updateCache(r),n._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var t,r,i,s,o,u,a,f=e(this).data("ui-resizable"),l=f.options,c=f.element,h=l.containment,p=h instanceof e?h.get(0):/parent/.test(h)?c.parent().get(0):h;if(!p)return;f.containerElement=e(p),/document/.test(h)||h===document?(f.containerOffset={left:0,top:0},f.containerPosition={left:0,top:0},f.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(t=e(p),r=[],e(["Top","Right","Left","Bottom"]).each(function(e,i){r[e]=n(t.css("padding"+i))}),f.containerOffset=t.offset(),f.containerPosition=t.position(),f.containerSize={height:t.innerHeight()-r[3],width:t.innerWidth()-r[1]},i=f.containerOffset,s=f.containerSize.height,o=f.containerSize.width,u=e.ui.hasScroll(p,"left")?p.scrollWidth:o,a=e.ui.hasScroll(p)?p.scrollHeight:s,f.parentData={element:p,left:i.left,top:i.top,width:u,height:a})},resize:function(t){var n,r,i,s,o=e(this).data("ui-resizable"),u=o.options,a=o.containerOffset,f=o.position,l=o._aspectRatio||t.shiftKey,c={top:0,left:0},h=o.containerElement;h[0]!==document&&/static/.test(h.css("position"))&&(c=a),f.left<(o._helper?a.left:0)&&(o.size.width=o.size.width+(o._helper?o.position.left-a.left:o.position.left-c.left),l&&(o.size.height=o.size.width/o.aspectRatio),o.position.left=u.helper?a.left:0),f.top<(o._helper?a.top:0)&&(o.size.height=o.size.height+(o._helper?o.position.top-a.top:o.position.top),l&&(o.size.width=o.size.height*o.aspectRatio),o.position.top=o._helper?a.top:0),o.offset.left=o.parentData.left+o.position.left,o.offset.top=o.parentData.top+o.position.top,n=Math.abs((o._helper?o.offset.left-c.left:o.offset.left-c.left)+o.sizeDiff.width),r=Math.abs((o._helper?o.offset.top-c.top:o.offset.top-a.top)+o.sizeDiff.height),i=o.containerElement.get(0)===o.element.parent().get(0),s=/relative|absolute/.test(o.containerElement.css("position")),i&&s&&(n-=o.parentData.left),n+o.size.width>=o.parentData.width&&(o.size.width=o.parentData.width-n,l&&(o.size.height=o.size.width/o.aspectRatio)),r+o.size.height>=o.parentData.height&&(o.size.height=o.parentData.height-r,l&&(o.size.width=o.size.height*o.aspectRatio))},stop:function(){var t=e(this).data("ui-resizable"),n=t.options,r=t.containerOffset,i=t.containerPosition,s=t.containerElement,o=e(t.helper),u=o.offset(),a=o.outerWidth()-t.sizeDiff.width,f=o.outerHeight()-t.sizeDiff.height;t._helper&&!n.animate&&/relative/.test(s.css("position"))&&e(this).css({left:u.left-i.left-r.left,width:a,height:f}),t._helper&&!n.animate&&/static/.test(s.css("position"))&&e(this).css({left:u.left-i.left-r.left,width:a,height:f})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).data("ui-resizable"),n=t.options,r=function(t){e(t).each(function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};typeof n.alsoResize=="object"&&!n.alsoResize.parentNode?n.alsoResize.length?(n.alsoResize=n.alsoResize[0],r(n.alsoResize)):e.each(n.alsoResize,function(e){r(e)}):r(n.alsoResize)},resize:function(t,n){var r=e(this).data("ui-resizable"),i=r.options,s=r.originalSize,o=r.originalPosition,u={height:r.size.height-s.height||0,width:r.size.width-s.width||0,top:r.position.top-o.top||0,left:r.position.left-o.left||0},a=function(t,r){e(t).each(function(){var t=e(this),i=e(this).data("ui-resizable-alsoresize"),s={},o=r&&r.length?r:t.parents(n.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var n=(i[t]||0)+(u[t]||0);n&&n>=0&&(s[t]=n||null)}),t.css(s)})};typeof i.alsoResize=="object"&&!i.alsoResize.nodeType?e.each(i.alsoResize,function(e,t){a(e,t)}):a(i.alsoResize)},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).data("ui-resizable"),n=t.options,r=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:r.height,width:r.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof n.ghost=="string"?n.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).data("ui-resizable");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).data("ui-resizable");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t=e(this).data("ui-resizable"),n=t.options,r=t.size,i=t.originalSize,s=t.originalPosition,o=t.axis,u=typeof n.grid=="number"?[n.grid,n.grid]:n.grid,a=u[0]||1,f=u[1]||1,l=Math.round((r.width-i.width)/a)*a,c=Math.round((r.height-i.height)/f)*f,h=i.width+l,p=i.height+c,d=n.maxWidth&&n.maxWidth<h,v=n.maxHeight&&n.maxHeight<p,m=n.minWidth&&n.minWidth>h,g=n.minHeight&&n.minHeight>p;n.grid=u,m&&(h+=a),g&&(p+=f),d&&(h-=a),v&&(p-=f),/^(se|s|e)$/.test(o)?(t.size.width=h,t.size.height=p):/^(ne)$/.test(o)?(t.size.width=h,t.size.height=p,t.position.top=s.top-c):/^(sw)$/.test(o)?(t.size.width=h,t.size.height=p,t.position.left=s.left-l):(t.size.width=h,t.size.height=p,t.position.top=s.top-c,t.position.left=s.left-l)}})}(jQuery),function(e){function t(e,t,n){return e>t&&t+n>e}function n(e){return/left|right/.test(e.css("float"))||/inline|table-cell/.test(e.css("display"))}e.widget("ui.sortable",e.ui.mouse,{version:"1.10.2",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===e.axis||n(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,n){"disabled"===t?(this.options[t]=n,this.widget().toggleClass("ui-sortable-disabled",!!n)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,n){var r=null,i=!1,s=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(t),e(t.target).parents().each(function(){return e.data(this,s.widgetName+"-item")===s?(r=e(this),!1):undefined}),e.data(t.target,s.widgetName+"-item")===s&&(r=e(t.target)),r?!this.options.handle||n||(e(this.options.handle,r).find("*").addBack().each(function(){this===t.target&&(i=!0)}),i)?(this.currentItem=r,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(t,n,r){var i,s,o=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),o.containment&&this._setContainment(),o.cursor&&"auto"!==o.cursor&&(s=this.document.find("body"),this.storedCursor=s.css("cursor"),s.css("cursor",o.cursor),this.storedStylesheet=e("<style>*{ cursor: "+o.cursor+" !important; }</style>").appendTo(s)),o.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",o.opacity)),o.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",o.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!r)for(i=this.containers.length-1;i>=0;i--)this.containers[i]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!o.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){var n,r,i,s,o=this.options,u=!1;for(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<o.scrollSensitivity?this.scrollParent[0].scrollTop=u=this.scrollParent[0].scrollTop+o.scrollSpeed:t.pageY-this.overflowOffset.top<o.scrollSensitivity&&(this.scrollParent[0].scrollTop=u=this.scrollParent[0].scrollTop-o.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<o.scrollSensitivity?this.scrollParent[0].scrollLeft=u=this.scrollParent[0].scrollLeft+o.scrollSpeed:t.pageX-this.overflowOffset.left<o.scrollSensitivity&&(this.scrollParent[0].scrollLeft=u=this.scrollParent[0].scrollLeft-o.scrollSpeed)):(t.pageY-e(document).scrollTop()<o.scrollSensitivity?u=e(document).scrollTop(e(document).scrollTop()-o.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<o.scrollSensitivity&&(u=e(document).scrollTop(e(document).scrollTop()+o.scrollSpeed)),t.pageX-e(document).scrollLeft()<o.scrollSensitivity?u=e(document).scrollLeft(e(document).scrollLeft()-o.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<o.scrollSensitivity&&(u=e(document).scrollLeft(e(document).scrollLeft()+o.scrollSpeed))),u!==!1&&e.ui.ddmanager&&!o.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t)),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),n=this.items.length-1;n>=0;n--)if(r=this.items[n],i=r.item[0],s=this._intersectsWithPointer(r),s&&r.instance===this.currentContainer&&i!==this.currentItem[0]&&this.placeholder[1===s?"next":"prev"]()[0]!==i&&!e.contains(this.placeholder[0],i)&&("semi-dynamic"===this.options.type?!e.contains(this.element[0],i):!0)){if(this.direction=1===s?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(r))break;this._rearrange(t,r),this._trigger("change",t,this._uiHash());break}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,n){if(t){if(e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t),this.options.revert){var r=this,i=this.placeholder.offset(),s=this.options.axis,o={};s&&"x"!==s||(o.left=i.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),s&&"y"!==s||(o.top=i.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,e(this.helper).animate(o,parseInt(this.options.revert,10)||500,function(){r._clear(t)})}else this._clear(t,n);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},e(n).each(function(){var n=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[\-=_](.+)/);n&&r.push((t.key||n[1]+"[]")+"="+(t.key&&t.expression?n[1]:n[2]))}),!r.length&&t.key&&r.push(t.key+"="),r.join("&")},toArray:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},n.each(function(){r.push(e(t.item||this).attr(t.attribute||"id")||"")}),r},_intersectsWith:function(e){var t=this.positionAbs.left,n=t+this.helperProportions.width,r=this.positionAbs.top,i=r+this.helperProportions.height,s=e.left,o=s+e.width,u=e.top,a=u+e.height,f=this.offset.click.top,l=this.offset.click.left,c=r+f>u&&a>r+f&&t+l>s&&o>t+l;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?c:t+this.helperProportions.width/2>s&&o>n-this.helperProportions.width/2&&r+this.helperProportions.height/2>u&&a>i-this.helperProportions.height/2},_intersectsWithPointer:function(e){var n="x"===this.options.axis||t(this.positionAbs.top+this.offset.click.top,e.top,e.height),r="y"===this.options.axis||t(this.positionAbs.left+this.offset.click.left,e.left,e.width),i=n&&r,s=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return i?this.floating?o&&"right"===o||"down"===s?2:1:s&&("down"===s?2:1):!1},_intersectsWithSides:function(e){var n=t(this.positionAbs.top+this.offset.click.top,e.top+e.height/2,e.height),r=t(this.positionAbs.left+this.offset.click.left,e.left+e.width/2,e.width),i=this._getDragVerticalDirection(),s=this._getDragHorizontalDirection();return this.floating&&s?"right"===s&&r||"left"===s&&!r:i&&("down"===i&&n||"up"===i&&!n)},_getDragVerticalDirection:function(){var e=this.positionAbs.top-this.lastPositionAbs.top;return 0!==e&&(e>0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return 0!==e&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor===String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var n,r,i,s,o=[],u=[],a=this._connectWith();if(a&&t)for(n=a.length-1;n>=0;n--)for(i=e(a[n]),r=i.length-1;r>=0;r--)s=e.data(i[r],this.widgetFullName),s&&s!==this&&!s.options.disabled&&u.push([e.isFunction(s.options.items)?s.options.items.call(s.element):e(s.options.items,s.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),s]);for(u.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),n=u.length-1;n>=0;n--)u[n][0].each(function(){o.push(this)});return e(o)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var n=0;t.length>n;n++)if(t[n]===e.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var n,r,i,s,o,u,a,f,l=this.items,c=[[e.isFunction(this.options.items)?this.options.items.call(this.element[0],t,{item:this.currentItem}):e(this.options.items,this.element),this]],h=this._connectWith();if(h&&this.ready)for(n=h.length-1;n>=0;n--)for(i=e(h[n]),r=i.length-1;r>=0;r--)s=e.data(i[r],this.widgetFullName),s&&s!==this&&!s.options.disabled&&(c.push([e.isFunction(s.options.items)?s.options.items.call(s.element[0],t,{item:this.currentItem}):e(s.options.items,s.element),s]),this.containers.push(s));for(n=c.length-1;n>=0;n--)for(o=c[n][1],u=c[n][0],r=0,f=u.length;f>r;r++)a=e(u[r]),a.data(this.widgetName+"-item",o),l.push({item:a,instance:o,width:0,height:0,left:0,top:0})},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var n,r,i,s;for(n=this.items.length-1;n>=0;n--)r=this.items[n],r.instance!==this.currentContainer&&this.currentContainer&&r.item[0]!==this.currentItem[0]||(i=this.options.toleranceElement?e(this.options.toleranceElement,r.item):r.item,t||(r.width=i.outerWidth(),r.height=i.outerHeight()),s=i.offset(),r.left=s.left,r.top=s.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(n=this.containers.length-1;n>=0;n--)s=this.containers[n].element.offset(),this.containers[n].containerCache.left=s.left,this.containers[n].containerCache.top=s.top,this.containers[n].containerCache.width=this.containers[n].element.outerWidth(),this.containers[n].containerCache.height=this.containers[n].element.outerHeight();return this},_createPlaceholder:function(t){t=t||this;var n,r=t.options;r.placeholder&&r.placeholder.constructor!==String||(n=r.placeholder,r.placeholder={element:function(){var r=t.currentItem[0].nodeName.toLowerCase(),s=e(t.document[0].createElement(r)).addClass(n||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===r?s.append("<td colspan='99'>&#160;</td>"):"img"===r&&s.attr("src",t.currentItem.attr("src")),n||s.css("visibility","hidden"),s},update:function(e,o){(!n||r.forcePlaceholderSize)&&(o.height()||o.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),o.width()||o.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10)))}}),t.placeholder=e(r.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),r.placeholder.update(t,t.placeholder)},_contactContainers:function(r){var s,o,u,a,f,l,c,h,p,d,v=null,m=null;for(s=this.containers.length-1;s>=0;s--)if(!e.contains(this.currentItem[0],this.containers[s].element[0]))if(this._intersectsWith(this.containers[s].containerCache)){if(v&&e.contains(this.containers[s].element[0],v.element[0]))continue;v=this.containers[s],m=s}else this.containers[s].containerCache.over&&(this.containers[s]._trigger("out",r,this._uiHash(this)),this.containers[s].containerCache.over=0);if(v)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",r,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(u=1e4,a=null,d=v.floating||n(this.currentItem),f=d?"left":"top",l=d?"width":"height",c=this.positionAbs[f]+this.offset.click[f],o=this.items.length-1;o>=0;o--)e.contains(this.containers[m].element[0],this.items[o].item[0])&&this.items[o].item[0]!==this.currentItem[0]&&(!d||t(this.positionAbs.top+this.offset.click.top,this.items[o].top,this.items[o].height))&&(h=this.items[o].item.offset()[f],p=!1,Math.abs(h-c)>Math.abs(h+this.items[o][l]-c)&&(p=!0,h+=this.items[o][l]),u>Math.abs(h-c)&&(u=Math.abs(h-c),a=this.items[o],this.direction=p?"up":"down"));if(!a&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[m])return;a?this._rearrange(r,a,null,!0):this._rearrange(r,null,this.containers[m].element,!0),this._trigger("change",r,this._uiHash()),this.containers[m]._trigger("change",r,this._uiHash(this)),this.currentContainer=this.containers[m],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[m]._trigger("over",r,this._uiHash(this)),this.containers[m].containerCache.over=1}},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t,this.currentItem])):"clone"===n.helper?this.currentItem.clone():this.currentItem;return r.parents("body").length||e("parent"!==n.appendTo?n.appendTo:this.currentItem[0].parentNode)[0].appendChild(r[0]),r[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!r[0].style.width||n.forceHelperSize)&&r.width(this.currentItem.width()),(!r[0].style.height||n.forceHelperSize)&&r.height(this.currentItem.height()),r},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&e.ui.ie)&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,n,r,i=this.options;"parent"===i.containment&&(i.containment=this.helper[0].parentNode),("document"===i.containment||"window"===i.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e("document"===i.containment?document:window).width()-this.helperProportions.width-this.margins.left,(e("document"===i.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(i.containment)||(t=e(i.containment)[0],n=e(i.containment).offset(),r="hidden"!==e(t).css("overflow"),this.containment=[n.left+(parseInt(e(t).css("borderLeftWidth"),10)||0)+(parseInt(e(t).css("paddingLeft"),10)||0)-this.margins.left,n.top+(parseInt(e(t).css("borderTopWidth"),10)||0)+(parseInt(e(t).css("paddingTop"),10)||0)-this.margins.top,n.left+(r?Math.max(t.scrollWidth,t.offsetWidth):t.offsetWidth)-(parseInt(e(t).css("borderLeftWidth"),10)||0)-(parseInt(e(t).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,n.top+(r?Math.max(t.scrollHeight,t.offsetHeight):t.offsetHeight)-(parseInt(e(t).css("borderTopWidth"),10)||0)-(parseInt(e(t).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(t,n){n||(n=this.position);var r="absolute"===t?1:-1,i="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,s=/(html|body)/i.test(i[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():s?0:i.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():s?0:i.scrollLeft())*r}},_generatePosition:function(t){var n,r,i=this.options,s=t.pageX,o=t.pageY,u="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(u[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(s=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top)),i.grid&&(n=this.originalPageY+Math.round((o-this.originalPageY)/i.grid[1])*i.grid[1],o=this.containment?n-this.offset.click.top>=this.containment[1]&&n-this.offset.click.top<=this.containment[3]?n:n-this.offset.click.top>=this.containment[1]?n-i.grid[1]:n+i.grid[1]:n,r=this.originalPageX+Math.round((s-this.originalPageX)/i.grid[0])*i.grid[0],s=this.containment?r-this.offset.click.left>=this.containment[0]&&r-this.offset.click.left<=this.containment[2]?r:r-this.offset.click.left>=this.containment[0]?r-i.grid[0]:r+i.grid[0]:r)),{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():a?0:u.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():a?0:u.scrollLeft())}},_rearrange:function(e,t,n,r){n?n[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var i=this.counter;this._delay(function(){i===this.counter&&this.refreshPositions(!r)})},_clear:function(e,t){this.reverting=!1;var n,r=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(n in this._storedCSS)("auto"===this._storedCSS[n]||"static"===this._storedCSS[n])&&(this._storedCSS[n]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!t&&r.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||t||r.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(t||(r.push(function(e){this._trigger("remove",e,this._uiHash())}),r.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),r.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),n=this.containers.length-1;n>=0;n--)t||r.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[n])),this.containers[n].containerCache.over&&(r.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[n])),this.containers[n].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!t){for(this._trigger("beforeStop",e,this._uiHash()),n=0;r.length>n;n++)r[n].call(this,e);this._trigger("stop",e,this._uiHash())}return this.fromOutside=!1,!1}if(t||this._trigger("beforeStop",e,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!t){for(n=0;r.length>n;n++)r[n].call(this,e);this._trigger("stop",e,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){e.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(t){var n=t||this;return{helper:n.helper,placeholder:n.placeholder||e([]),position:n.position,originalPosition:n.originalPosition,offset:n.positionAbs,item:n.currentItem,sender:t?t.element:null}}})}(jQuery),function(e,t){function n(){return++i}function r(e){return e.hash.length>1&&decodeURIComponent(e.href.replace(s,""))===decodeURIComponent(location.href.replace(s,""))}var i=0,s=/#.*$/;e.widget("ui.tabs",{version:"1.10.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var t=this,n=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",n.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs(),n.active=this._initialActive(),e.isArray(n.disabled)&&(n.disabled=e.unique(n.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(n.active):e(),this._refresh(),this.active.length&&this.load(n.active)},_initialActive:function(){var n=this.options.active,r=this.options.collapsible,i=location.hash.substring(1);return null===n&&(i&&this.tabs.each(function(r,s){return e(s).attr("aria-controls")===i?(n=r,!1):t}),null===n&&(n=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===n||-1===n)&&(n=this.tabs.length?0:!1)),n!==!1&&(n=this.tabs.index(this.tabs.eq(n)),-1===n&&(n=r?!1:0)),!r&&n===!1&&this.anchors.length&&(n=0),n},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(n){var r=e(this.document[0].activeElement).closest("li"),i=this.tabs.index(r),s=!0;if(!this._handlePageNav(n)){switch(n.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:i++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:s=!1,i--;break;case e.ui.keyCode.END:i=this.anchors.length-1;break;case e.ui.keyCode.HOME:i=0;break;case e.ui.keyCode.SPACE:return n.preventDefault(),clearTimeout(this.activating),this._activate(i),t;case e.ui.keyCode.ENTER:return n.preventDefault(),clearTimeout(this.activating),this._activate(i===this.options.active?!1:i),t;default:return}n.preventDefault(),clearTimeout(this.activating),i=this._focusNextTab(i,s),n.ctrlKey||(r.attr("aria-selected","false"),this.tabs.eq(i).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",i)},this.delay))}},_panelKeydown:function(t){this._handlePageNav(t)||t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(n){return n.altKey&&n.keyCode===e.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):n.altKey&&n.keyCode===e.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):t},_findNextTab:function(t,n){function r(){return t>i&&(t=0),0>t&&(t=i),t}for(var i=this.tabs.length-1;-1!==e.inArray(r(),this.options.disabled);)t=n?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,n){return"active"===e?(this._activate(n),t):"disabled"===e?(this._setupDisabled(n),t):(this._super(e,n),"collapsible"===e&&(this.element.toggleClass("ui-tabs-collapsible",n),n||this.options.active!==!1||this._activate(0)),"event"===e&&this._setupEvents(n),"heightStyle"===e&&this._setupHeightStyle(n),t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+n()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,n=this.tablist.children(":has(a[href])");t.disabled=e.map(n.filter(".ui-state-disabled"),function(e){return n.index(e)}),this._processTabs(),t.active!==!1&&this.anchors.length?this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active):(t.active=!1,this.active=e()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(n,i){var s,o,u,a=e(i).uniqueId().attr("id"),f=e(i).closest("li"),l=f.attr("aria-controls");r(i)?(s=i.hash,o=t.element.find(t._sanitizeSelector(s))):(u=t._tabId(f),s="#"+u,o=t.element.find(s),o.length||(o=t._createPanel(u),o.insertAfter(t.panels[n-1]||t.tablist)),o.attr("aria-live","polite")),o.length&&(t.panels=t.panels.add(o)),l&&f.data("ui-tabs-aria-controls",l),f.attr({"aria-controls":s.substring(1),"aria-labelledby":a}),o.attr("aria-labelledby",a)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("<div>").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var n,r=0;n=this.tabs[r];r++)t===!0||-1!==e.inArray(r,t)?e(n).addClass("ui-state-disabled").attr("aria-disabled","true"):e(n).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var n={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,n),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var n,r=this.element.parent();"fill"===t?(n=r.height(),n-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var t=e(this),r=t.css("position");"absolute"!==r&&"fixed"!==r&&(n-=t.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){n-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,n-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===t&&(n=0,this.panels.each(function(){n=Math.max(n,e(this).height("").height())}).height(n))},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i.closest("li"),o=s[0]===r[0],u=o&&n.collapsible,a=u?e():this._getPanelForTab(s),f=r.length?this._getPanelForTab(r):e(),l={oldTab:r,oldPanel:f,newTab:u?e():s,newPanel:a};t.preventDefault(),s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||o&&!n.collapsible||this._trigger("beforeActivate",t,l)===!1||(n.active=u?!1:this.tabs.index(s),this.active=o?e():s,this.xhr&&this.xhr.abort(),f.length||a.length||e.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,l))},_toggle:function(t,n){function r(){s.running=!1,s._trigger("activate",t,n)}function i(){n.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),o.length&&s.options.show?s._show(o,s.options.show,r):(o.show(),r())}var s=this,o=n.newPanel,u=n.oldPanel;this.running=!0,u.length&&this.options.hide?this._hide(u,this.options.hide,function(){n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i()}):(n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u.hide(),i()),u.attr({"aria-expanded":"false","aria-hidden":"true"}),n.oldTab.attr("aria-selected","false"),o.length&&u.length?n.oldTab.attr("tabIndex",-1):o.length&&this.tabs.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),o.attr({"aria-expanded":"true","aria-hidden":"false"}),n.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var n,r=this._findActive(t);r[0]!==this.active[0]&&(r.length||(r=this.active),n=r.find(".ui-tabs-anchor")[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop}))},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return"string"==typeof e&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),n=t.data("ui-tabs-aria-controls");n?t.attr("aria-controls",n).removeData("ui-tabs-aria-controls"):t.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(n){var r=this.options.disabled;r!==!1&&(n===t?r=!1:(n=this._getIndex(n),r=e.isArray(r)?e.map(r,function(e){return e!==n?e:null}):e.map(this.tabs,function(e,t){return t!==n?t:null})),this._setupDisabled(r))},disable:function(n){var r=this.options.disabled;if(r!==!0){if(n===t)r=!0;else{if(n=this._getIndex(n),-1!==e.inArray(n,r))return;r=e.isArray(r)?e.merge([n],r).sort():[n]}this._setupDisabled(r)}},load:function(t,n){t=this._getIndex(t);var i=this,s=this.tabs.eq(t),o=s.find(".ui-tabs-anchor"),u=this._getPanelForTab(s),a={tab:s,panel:u};r(o[0])||(this.xhr=e.ajax(this._ajaxSettings(o,n,a)),this.xhr&&"canceled"!==this.xhr.statusText&&(s.addClass("ui-tabs-loading"),u.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){u.html(e),i._trigger("load",n,a)},1)}).complete(function(e,t){setTimeout(function(){"abort"===t&&i.panels.stop(!1,!0),s.removeClass("ui-tabs-loading"),u.removeAttr("aria-busy"),e===i.xhr&&delete i.xhr},1)})))},_ajaxSettings:function(t,n,r){var i=this;return{url:t.attr("href"),beforeSend:function(t,s){return i._trigger("beforeLoad",n,e.extend({jqXHR:t,ajaxSettings:s},r))}}},_getPanelForTab:function(t){var n=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+n))}})}(jQuery),function(e,t){var n=5;e.widget("ui.slider",e.ui.mouse,{version:"1.10.0",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},_create:function(){var t,n,r=this.options,i=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),s="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",o=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"),this.range=e([]),r.range&&(r.range===!0&&(r.values?r.values.length&&r.values.length!==2?r.values=[r.values[0],r.values[0]]:e.isArray(r.values)&&(r.values=r.values.slice(0)):r.values=[this._valueMin(),this._valueMin()]),this.range=e("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(r.range==="min"||r.range==="max"?" ui-slider-range-"+r.range:""))),n=r.values&&r.values.length||1;for(t=i.length;t<n;t++)o.push(s);this.handles=i.add(e(o.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(e){e.preventDefault()}).mouseenter(function(){r.disabled||e(this).addClass("ui-state-hover")}).mouseleave(function(){e(this).removeClass("ui-state-hover")}).focus(function(){r.disabled?e(this).blur():(e(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),e(this).addClass("ui-state-focus"))}).blur(function(){e(this).removeClass("ui-state-focus")}),this.handles.each(function(t){e(this).data("ui-slider-handle-index",t)}),this._setOption("disabled",r.disabled),this._on(this.handles,this._handleEvents),this._refreshValue(),this._animateOff=!1},_destroy:function(){this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(t){var n,r,i,s,o,u,a,f,l=this,c=this.options;return c.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),n={x:t.pageX,y:t.pageY},r=this._normValueFromMouse(n),i=this._valueMax()-this._valueMin()+1,this.handles.each(function(t){var n=Math.abs(r-l.values(t));if(i>n||i===n&&(t===l._lastChangedValue||l.values(t)===c.min))i=n,s=e(this),o=t}),u=this._start(t,o),u===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,s.addClass("ui-state-active").focus(),a=s.offset(),f=!e(t.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=f?{left:0,top:0}:{left:t.pageX-a.left-s.width()/2,top:t.pageY-a.top-s.height()/2-(parseInt(s.css("borderTopWidth"),10)||0)-(parseInt(s.css("borderBottomWidth"),10)||0)+(parseInt(s.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,r),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},n=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,n),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,n,r,i,s;return this.orientation==="horizontal"?(t=this.elementSize.width,n=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,n=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),r=n/t,r>1&&(r=1),r<0&&(r=0),this.orientation==="vertical"&&(r=1-r),i=this._valueMax()-this._valueMin(),s=this._valueMin()+r*i,this._trimAlignValue(s)},_start:function(e,t){var n={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("start",e,n)},_slide:function(e,t,n){var r,i,s;this.options.values&&this.options.values.length?(r=this.values(t?0:1),this.options.values.length===2&&this.options.range===!0&&(t===0&&n>r||t===1&&n<r)&&(n=r),n!==this.values(t)&&(i=this.values(),i[t]=n,s=this._trigger("slide",e,{handle:this.handles[t],value:n,values:i}),r=this.values(t?0:1),s!==!1&&this.values(t,n,!0))):n!==this.value()&&(s=this._trigger("slide",e,{handle:this.handles[t],value:n}),s!==!1&&this.value(n))},_stop:function(e,t){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("stop",e,n)},_change:function(e,t){if(!this._keySliding&&!this._mouseSliding){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._lastChangedValue=t,this._trigger("change",e,n)}},value:function(e){if(arguments.length){this.options.value=this._trimAlignValue(e),this._refreshValue(),this._change(null,0);return}return this._value()},values:function(t,n){var r,i,s;if(arguments.length>1){this.options.values[t]=this._trimAlignValue(n),this._refreshValue(),this._change(null,t);return}if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();r=this.options.values,i=arguments[0];for(s=0;s<r.length;s+=1)r[s]=this._trimAlignValue(i[s]),this._change(null,s);this._refreshValue()},_setOption:function(t,n){var r,i=0;e.isArray(this.options.values)&&(i=this.options.values.length),e.Widget.prototype._setOption.apply(this,arguments);switch(t){case"disabled":n?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.prop("disabled",!0)):this.handles.prop("disabled",!1);break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":this._animateOff=!0,this._refreshValue();for(r=0;r<i;r+=1)this._change(null,r);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1}},_value:function(){var e=this.options.value;return e=this._trimAlignValue(e),e},_values:function(e){var t,n,r;if(arguments.length)return t=this.options.values[e],t=this._trimAlignValue(t),t;n=this.options.values.slice();for(r=0;r<n.length;r+=1)n[r]=this._trimAlignValue(n[r]);return n},_trimAlignValue:function(e){if(e<=this._valueMin())return this._valueMin();if(e>=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,n=(e-this._valueMin())%t,r=e-n;return Math.abs(n)*2>=t&&(r+=n>0?t:-t),parseFloat(r.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,n,r,i,s,o=this.options.range,u=this.options,a=this,f=this._animateOff?!1:u.animate,l={};this.options.values&&this.options.values.length?this.handles.each(function(r){n=(a.values(r)-a._valueMin())/(a._valueMax()-a._valueMin())*100,l[a.orientation==="horizontal"?"left":"bottom"]=n+"%",e(this).stop(1,1)[f?"animate":"css"](l,u.animate),a.options.range===!0&&(a.orientation==="horizontal"?(r===0&&a.range.stop(1,1)[f?"animate":"css"]({left:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({width:n-t+"%"},{queue:!1,duration:u.animate})):(r===0&&a.range.stop(1,1)[f?"animate":"css"]({bottom:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({height:n-t+"%"},{queue:!1,duration:u.animate}))),t=n}):(r=this.value(),i=this._valueMin(),s=this._valueMax(),n=s!==i?(r-i)/(s-i)*100:0,l[this.orientation==="horizontal"?"left":"bottom"]=n+"%",this.handle.stop(1,1)[f?"animate":"css"](l,u.animate),o==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[f?"animate":"css"]({width:n+"%"},u.animate),o==="max"&&this.orientation==="horizontal"&&this.range[f?"animate":"css"]({width:100-n+"%"},{queue:!1,duration:u.animate}),o==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[f?"animate":"css"]({height:n+"%"},u.animate),o==="max"&&this.orientation==="vertical"&&this.range[f?"animate":"css"]({height:100-n+"%"},{queue:!1,duration:u.animate}))},_handleEvents:{keydown:function(t){var r,i,s,o,u=e(t.target).data("ui-slider-handle-index");switch(t.keyCode){case e.ui.keyCode.HOME:case e.ui.keyCode.END:case e.ui.keyCode.PAGE_UP:case e.ui.keyCode.PAGE_DOWN:case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:t.preventDefault();if(!this._keySliding){this._keySliding=!0,e(t.target).addClass("ui-state-active"),r=this._start(t,u);if(r===!1)return}}o=this.options.step,this.options.values&&this.options.values.length?i=s=this.values(u):i=s=this.value();switch(t.keyCode){case e.ui.keyCode.HOME:s=this._valueMin();break;case e.ui.keyCode.END:s=this._valueMax();break;case e.ui.keyCode.PAGE_UP:s=this._trimAlignValue(i+(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.PAGE_DOWN:s=this._trimAlignValue(i-(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:if(i===this._valueMax())return;s=this._trimAlignValue(i+o);break;case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(i===this._valueMin())return;s=this._trimAlignValue(i-o)}this._slide(t,u,s)},keyup:function(t){var n=e(t.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(t,n),this._change(t,n),e(t.target).removeClass("ui-state-active"))}}})}(jQuery),define("jqueryUI",function(){}),define("modules/layout-selector",["jquery","ko","jqueryUI"],function(e,t){loadLayoutSelector=function(t){createCog(e("#layout-selector-pages")),createCog(e("#layout-selector-templates")),e.ajax(Headway.ajaxURL,{type:"POST",async:!0,data:{action:"headway_visual_editor",method:"get_layout_selector_pages",security:Headway.security,currentLayout:Headway.currentLayout,mode:Headway.mode},success:function(n,r){e("#layout-selector-pages").html(n),typeof t=="function"&&t.call()}}),e.ajax(Headway.ajaxURL,{type:"POST",async:!0,data:{action:"headway_visual_editor",method:"get_layout_selector_templates",security:Headway.security,currentLayout:Headway.currentLayout,mode:Headway.mode},success:function(t,n){e("#layout-selector-templates").html(t)}})},showLayoutSelector=function(){return e("div#layout-selector-select").addClass("layout-selector-visible"),e("div#layout-selector").css({left:e("div#layout-selector-select-content").offset().left}),e(document).bind("mousedown",hideLayoutSelector),Headway.iframe.contents().bind("mousedown",hideLayoutSelector),e("div#layout-selector-select")},hideLayoutSelector=function(t){if(t&&(e(t.target).is("#layout-selector-select")||e(t.target).parents("#layout-selector-select").length===1))return;return e("div#layout-selector-select").removeClass("layout-selector-visible"),e(document).unbind("mousedown",hideLayoutSelector),Headway.iframe.contents().unbind("mousedown",hideLayoutSelector),e("div#layout-selector-select")},toggleLayoutSelector=function(){e("div#layout-selector-select").hasClass("layout-selector-visible")?hideLayoutSelector(!1):showLayoutSelector()},switchToLayout=function(t,n,r){typeof t=="object"&&!t.hasClass("layout")&&(t=t.find("> span.layout"));if(t.length!==1)return!1;changeTitle("Visual Editor: Loading"),startTitleActivityIndicator();var i=t,s=i.attr("data-layout-id"),o=Headway.mode=="grid"?Headway.homeURL:i.attr("data-layout-url"),u=i.find("strong").text();e(".layout-selected","div#layout-selector").removeClass("layout-selected"),i.parent("li").addClass("layout-selected"),Headway.currentLayout=s,Headway.currentLayoutName=u,Headway.currentLayoutTemplate=!1,Headway.currentLayoutCustomized=!1,Headway.switchedToLayout=!0,Headway.currentLayoutCustomized=i.parents("li.layout-item").first().hasClass("layout-item-customized")||i.parents("#layout-selector-templates-container").length;var a=i.find(".status-template").data("template-id");typeof a!="undefined"&&a!="none"&&(Headway.currentLayoutTemplate=a,Headway.currentLayoutTemplateName=e('span.layout[data-layout-id="template-'+a+'"]').find(".template-name").text()),window.history.pushState("","",Headway.homeURL+"/?visual-editor=true&visual-editor-mode="+Headway.mode+"&ve-layout="+Headway.currentLayout);if(typeof n=="undefined"||n==1){if(typeof r=="undefined"||r==1)headwayIframeLoadNotification="Switched to <em>"+Headway.currentLayoutName+"</em>";loadIframe(Headway.instance.iframeCallback,o)}return!0};var n={init:function(){loadLayoutSelector(),n.bind()},bind:function(){var t=e("div#layout-selector");e("div#layout-selector-select-content").click(function(){return toggleLayoutSelector(),!1}),t.tabs(),t.delegate("span.edit","click",function(t){return typeof allowVECloseSwitch!="undefined"&&allowVECloseSwitch===!1&&!confirm("You have unsaved changes, are you sure you want to switch layouts?")?!1:(showIframeLoadingOverlay(),switchToLayout(e(this).parents("span.layout")),hideLayoutSelector(),t.preventDefault(),e(this).parents("span.layout"))}),t.delegate("span.revert","click",function(t){if(!confirm("Are you sure you wish to reset this layout?  All blocks and content will be removed from this layout.\n\nPlease note: Any block that is mirroring a block on this layout will also lose its settings."))return!1;var n=e(this).parents("span.layout"),r=n.attr("data-layout-id"),i=n.find("strong").text();showIframeLoadingOverlay(),changeTitle("Visual Editor: Reverting "+i),startTitleActivityIndicator(),n.parent().removeClass("layout-item-customized");var s=e(n.parents(".layout-item-customized:not(.layout-selected)")[0]),o=s.find("> span.layout").attr("data-layout-id"),u=e(e("div#layout-selector-pages > ul > li.layout-item-customized")[0]),a=u.find("> span.layout").attr("data-layout-id"),f=o?s:u,l=o?o:a;if(typeof l=="undefined"||!l)l=Headway.frontPage=="posts"?"index":"front_page",f=e('div#layout-selector-pages > ul > li > span[data-layout-id="'+l+'"]').parent();return switchToLayout(f,!0,!1),e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"revert_layout",layout_to_revert:r},function(e){e==="success"?showNotification({id:"layout-reverted",message:"<em>"+i+"</em> successfully reverted!",success:!0}):showErrorNotification({id:"error-could-not-revert-layout",message:"Error: Could not revert layout."})}),!1}),t.delegate("span#add-template","click",function(t){var n=e("#template-name-input").val();return e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"add_template",layout:Headway.currentLayout,template_name:n},function(t){if(typeof t=="undefined"||!t)return showErrorNotification({id:"error-could-not-add-template",message:"Error: Could not add shared template."}),!1;var n=e('<li class="layout-item">                                             <span data-layout-id="template-'+t.id+'" class="layout layout-template">                                                        <strong class="template-name">'+t.name+'</strong>                                                                                                               <span class="delete-template" title="Delete Shared Layout">Delete</span>                                                                                                                <span class="status status-currently-editing">Currently Editing</span>                                                                                                                                                                  <span class="rename-template button layout-selector-button" title="Rename Shared Layout">Rename</span>                                                  <span class="assign-template button layout-selector-button">Use Layout</span>                                                   <span class="edit button layout-selector-button">Edit</span>                                            </span>                                 </li>');n.appendTo("div#layout-selector-templates ul"),e("li#no-templates:visible","div#layout-selector").hide(),showNotification({id:"template-added",message:"Shared layout added!",success:!0}),e("#template-name-input").val("")},"json"),!1}),t.delegate("span.delete-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent(),i=r.attr("data-layout-id"),s=i.replace("template-",""),o=r.find("strong").text();return confirm("Are you sure you wish to delete this template?")?(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"delete_template",template_to_delete:s},function(t){if(typeof t=="undefined"||t=="failure"||t!="success")return showErrorNotification({id:"error-could-not-deleted-template",message:"Error: Could not delete shared layout."}),!1;n.remove(),e("span.layout-template","div#layout-selector").length===0&&e("li#no-templates","div#layout-selector").show(),showNotification({id:"template-deleted",message:"Shared Layout: <em>"+o+"</em> successfully deleted!",success:!0});if(i===Headway.currentLayout){var r=Headway.frontPage=="posts"?"index":"front_page";switchToLayout(e('div#layout-selector span.layout[data-layout-id="'+r+'"]'),!0,!1)}}),!1):!1}),t.delegate("span.assign-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent().attr("data-layout-id").replace("template-","");return Headway.currentLayout.indexOf("template-")===0?(alert("You cannot assign a shared layout to another shared layout."),!1):(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"assign_template",template:r,layout:Headway.currentLayout},function(t){if(typeof t=="undefined"||t=="failure")return showErrorNotification({id:"error-could-not-assign-template",message:"Error: Could not assign shared layout."}),!1;e("li.layout-selected","div#layout-selector").removeClass("layout-item-customized"),e("li.layout-selected","div#layout-selector").addClass("layout-item-template-used"),e("li.layout-selected > span.status-template","div#layout-selector").text(t),showIframeLoadingOverlay(),changeTitle("Visual Editor: Assigning Shared Layout"),startTitleActivityIndicator(),Headway.currentLayoutTemplate="template-"+r,Headway.currentLayoutTemplateName=e('span.layout[data-layout-id="template-'+r+'"]').find(".template-name").text(),headwayIframeLoadNotification="Shared layout assigned successfully!",loadIframe(Headway.instance.iframeCallback)}),!1)}),t.delegate("span.rename-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent().attr("data-layout-id"),i=e(this).siblings(".template-name"),s=i.text(),o=prompt("Please enter new Shared Layout name",s);return e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"rename_layout_template",layout:r,newName:o},function(e){return typeof e=="undefined"||e=="failure"?(showErrorNotification({id:"error-could-not-rename-layout-template",message:"Error: Could not rename shared layout."}),!1):(i.text(o),!0)}),!1}),t.delegate("span.remove-template","click",function(t){var n=e(e(this).parents("li")[0]),r=e(this).parent().attr("data-layout-id");return confirm("Are you sure you want to remove the shared layout from "+n.find("> span.layout strong").text()+"?")?(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"remove_template_from_layout",layout:r},function(e){return typeof e=="undefined"||e=="failure"?(showErrorNotification({id:"error-could-not-remove-template-from-layout",message:"Error: Could not remove shared layout from layout."}),!1):(n.removeClass("layout-item-template-used"),e==="customized"&&n.addClass("layout-item-customized"),r==Headway.currentLayout?(showIframeLoadingOverlay(),changeTitle("Visual Editor: Removing Shared Layout From Layout"),startTitleActivityIndicator(),Headway.currentLayoutTemplate=!1,headwayIframeLoadNotification="Shared Layout removed from layout successfully!",loadIframe(Headway.instance.iframeCallback),!0):!0)}),!1):!1}),t.delegate("span","click",function(t){e(this).hasClass("layout-open")?(e(this).removeClass("layout-open"),e(this).siblings("ul").hide()):(e(this).addClass("layout-open"),e(this).siblings("ul").show())})}};return n}),jQuery.cookie=function(e,t,n){if(arguments.length>1&&String(t)!=="[object Object]"){n=jQuery.extend({},n);if(t===null||t===undefined)n.expires=-1;if(typeof n.expires=="number"){var r=n.expires,i=n.expires=new Date;i.setDate(i.getDate()+r)}return t=String(t),document.cookie=[encodeURIComponent(e),"=",n.raw?t:encodeURIComponent(t),n.expires?"; expires="+n.expires.toUTCString():"",n.path?"; path="+n.path:"",n.domain?"; domain="+n.domain:"",n.secure?"; secure":""].join("")}n=t||{};var s,o=n.raw?function(e){return e}:decodeURIComponent;return(s=(new RegExp("(?:^|; )"+encodeURIComponent(e)+"=([^;]*)")).exec(document.cookie))?o(s[1]):null},define("deps/jquery.cookie",function(){}),function(e,t,n){(function(e){typeof define=="function"&&define.amd?define("qtip",["jquery"],e):jQuery&&!jQuery.fn.qtip&&e(jQuery)})(function(r){function I(e,t,n,i){this.id=n,this.target=e,this.tooltip=o,this.elements={target:e},this._id=T+"-"+n,this.timers={img:{}},this.options=t,this.plugins={},this.cache={event:{},target:r(),disabled:s,attr:i,onTooltip:s,lastClass:""},this.rendered=this.destroyed=this.disabled=this.waiting=this.hiddenDuringWait=this.positioning=this.triggering=s}function q(e){return e===o||r.type(e)!=="object"}function R(e){return!(r.isFunction(e)||e&&e.attr||e.length||r.type(e)==="object"&&(e.jquery||e.then))}function U(e){var t,n,u,a;return q(e)?s:(q(e.metadata)&&(e.metadata={type:e.metadata}),"content"in e&&(t=e.content,q(t)||t.jquery||t.done?t=e.content={text:n=R(t)?s:t}:n=t.text,"ajax"in t&&(u=t.ajax,a=u&&u.once!==s,delete t.ajax,t.text=function(e,t){var i=n||r(this).attr(t.options.content.attr)||"Loading...",s=r.ajax(r.extend({},u,{context:t})).then(u.success,o,u.error).then(function(e){return e&&a&&t.set("content.text",e),e},function(e,n,r){if(t.destroyed||e.status===0)return;t.set("content.text",n+": "+r)});return a?i:(t.set("content.text",i),s)}),"title"in t&&(q(t.title)||(t.button=t.title.button,t.title=t.title.text),R(t.title||s)&&(t.title=s))),"position"in e&&q(e.position)&&(e.position={my:e.position,at:e.position}),"show"in e&&q(e.show)&&(e.show=e.show.jquery?{target:e.show}:e.show===i?{ready:i}:{event:e.show}),"hide"in e&&q(e.hide)&&(e.hide=e.hide.jquery?{target:e.hide}:{event:e.hide}),"style"in e&&q(e.style)&&(e.style={classes:e.style}),r.each(x,function(){this.sanitize&&this.sanitize(e)}),e)}function z(e,t){var n=0,r,i=e,s=t.split(".");while(i=i[s[n++]])n<s.length&&(r=i);return[r||e,s.pop()]}function W(e,t){var n,r,i;for(n in this.checks)for(r in this.checks[n])if(i=(new RegExp(r,"i")).exec(e))t.push(i),(n==="builtin"||this.plugins[n])&&this.checks[n][r].apply(this.plugins[n]||this,t)}function J(e){return k.concat("").join(e?"-"+e+" ":" ")}function K(n){return n&&{type:n.type,pageX:n.pageX,pageY:n.pageY,target:n.target,relatedTarget:n.relatedTarget,scrollX:n.scrollX||e.pageXOffset||t.body.scrollLeft||t.documentElement.scrollLeft,scrollY:n.scrollY||e.pageYOffset||t.body.scrollTop||t.documentElement.scrollTop}||{}}function Q(e,t){if(t>0)return setTimeout(r.proxy(e,this),t);e.call(this)}function G(e){if(this.tooltip.hasClass(P))return s;clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this.timers.show=Q.call(this,function(){this.toggle(i,e)},this.options.show.delay)}function Y(e){if(this.tooltip.hasClass(P))return s;var t=r(e.relatedTarget),n=t.closest(L)[0]===this.tooltip[0],i=t[0]===this.options.show.target[0];clearTimeout(this.timers.show),clearTimeout(this.timers.hide);if(this!==t[0]&&this.options.position.target==="mouse"&&n||this.options.hide.fixed&&/mouse(out|leave|move)/.test(e.type)&&(n||i)){try{e.preventDefault(),e.stopImmediatePropagation()}catch(o){}return}this.timers.hide=Q.call(this,function(){this.toggle(s,e)},this.options.hide.delay,this)}function Z(e){if(this.tooltip.hasClass(P)||!this.options.hide.inactive)return s;clearTimeout(this.timers.inactive),this.timers.inactive=Q.call(this,function(){this.hide(e)},this.options.hide.inactive)}function et(e){this.rendered&&this.tooltip[0].offsetWidth>0&&this.reposition(e)}function nt(e,n,i){r(t.body).delegate(e,(n.split?n:n.join(tt+" "))+tt,function(){var e=b.api[r.attr(this,C)];e&&!e.disabled&&i.apply(e,arguments)})}function rt(e,n,u){var a,f,l,c,h,p=r(t.body),d=e[0]===t?p:e,v=e.metadata?e.metadata(u.metadata):o,m=u.metadata.type==="html5"&&v?v[u.metadata.name]:o,g=e.data(u.metadata.name||"qtipopts");try{g=typeof g=="string"?r.parseJSON(g):g}catch(y){}c=r.extend(i,{},b.defaults,u,typeof g=="object"?U(g):o,U(m||v)),f=c.position,c.id=n;if("boolean"==typeof c.content.text){l=e.attr(c.content.attr);if(c.content.attr===s||!l)return s;c.content.text=l}f.container.length||(f.container=p),f.target===s&&(f.target=d),c.show.target===s&&(c.show.target=d),c.show.solo===i&&(c.show.solo=f.container.closest("body")),c.hide.target===s&&(c.hide.target=d),c.position.viewport===i&&(c.position.viewport=f.container),f.container=f.container.eq(0),f.at=new E(f.at,i),f.my=new E(f.my);if(e.data(T))if(c.overwrite)e.qtip("destroy",!0);else if(c.overwrite===s)return s;return e.attr(N,n),c.suppress&&(h=e.attr("title"))&&e.removeAttr("title").attr(B,h).attr("title",""),a=new I(e,c,n,!!l),e.data(T,a),e.one("remove.qtip-"+n+" removeqtip.qtip-"+n,function(){var e;(e=r(this).data(T))&&e.destroy(!0)}),a}function dt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function gt(e,t){var r=t.charAt(0).toUpperCase()+t.slice(1),i=(t+" "+mt.join(r+" ")+r).split(" "),s,o,u=0;if(vt[t])return e.css(vt[t]);while(s=i[u++])if((o=e.css(s))!==n)return vt[t]=s,o}function yt(e,t){return Math.ceil(parseFloat(gt(e,t)))}function xt(e,t){this._ns="tip",this.options=t,this.offset=t.offset,this.size=[t.width,t.height],this.init(this.qtip=e)}var i=!0,s=!1,o=null,u="x",a="y",f="width",l="height",c="top",h="left",p="bottom",d="right",v="center",m="flip",g="flipinvert",y="shift",b,w,E,S,x={},T="qtip",N="data-hasqtip",C="data-qtip-id",k=["ui-widget","ui-tooltip"],L="."+T,A="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),O=T+"-fixed",M=T+"-default",_=T+"-focus",D=T+"-hover",P=T+"-disabled",H="_replacedByqTip",B="oldtitle",j,F={ie:function(){var e=3,n=t.createElement("div");while(n.innerHTML="<!--[if gt IE "+ ++e+"]><i></i><![endif]-->")if(!n.getElementsByTagName("i")[0])break;return e>4?e:NaN}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||s};w=I.prototype,w._when=function(e){return r.when.apply(r,e)},w.render=function(e){if(this.rendered||this.destroyed)return this;var t=this,n=this.options,o=this.cache,u=this.elements,a=n.content.text,f=n.content.title,l=n.content.button,c=n.position,h="."+this._id+" ",p=[],d;return r.attr(this.target[0],"aria-describedby",this._id),this.tooltip=u.tooltip=d=r("<div/>",{id:this._id,"class":[T,M,n.style.classes,T+"-pos-"+n.position.my.abbrev()].join(" "),width:n.style.width||"",height:n.style.height||"",tracking:c.target==="mouse"&&c.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":s,"aria-describedby":this._id+"-content","aria-hidden":i}).toggleClass(P,this.disabled).attr(C,this.id).data(T,this).appendTo(c.container).append(u.content=r("<div />",{"class":T+"-content",id:this._id+"-content","aria-atomic":i})),this.rendered=-1,this.positioning=i,f&&(this._createTitle(),r.isFunction(f)||p.push(this._updateTitle(f,s))),l&&this._createButton(),r.isFunction(a)||p.push(this._updateContent(a,s)),this.rendered=i,this._setWidget(),r.each(x,function(e){var n;this.initialize==="render"&&(n=this(t))&&(t.plugins[e]=n)}),this._unassignEvents(),this._assignEvents(),this._when(p).then(function(){t._trigger("render"),t.positioning=s,!t.hiddenDuringWait&&(n.show.ready||e)&&t.toggle(i,o.event,s),t.hiddenDuringWait=s}),b.api[this.id]=this,this},w.destroy=function(e){function t(){if(this.destroyed)return;this.destroyed=i;var e=this.target,t=e.attr(B);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove(),r.each(this.plugins,function(e){this.destroy&&this.destroy()}),clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this._unassignEvents(),e.removeData(T).removeAttr(C).removeAttr(N).removeAttr("aria-describedby"),this.options.suppress&&t&&e.attr("title",t).removeAttr(B),this._unbind(e),this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=o,delete b.api[this.id]}return this.destroyed?this.target:(e===i&&this.triggering!=="hide"||!this.rendered?t.call(this):(this.tooltip.one("tooltiphidden",r.proxy(t,this)),!this.triggering&&this.hide()),this.target)},S=w.checks={builtin:{"^id$":function(e,t,n,o){var u=n===i?b.nextid:n,a=T+"-"+u;u!==s&&u.length>0&&!r("#"+a).length?(this._id=a,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):e[t]=o},"^prerender":function(e,t,n){n&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(e,t,n){this._updateContent(n)},"^content.attr$":function(e,t,n,r){this.options.content.text===this.target.attr(r)&&this._updateContent(this.target.attr(n))},"^content.title$":function(e,t,n){if(!n)return this._removeTitle();n&&!this.elements.title&&this._createTitle(),this._updateTitle(n)},"^content.button$":function(e,t,n){this._updateButton(n)},"^content.title.(text|button)$":function(e,t,n){this.set("content."+t,n)},"^position.(my|at)$":function(e,t,n){"string"==typeof n&&(e[t]=new E(n,t==="at"))},"^position.container$":function(e,t,n){this.rendered&&this.tooltip.appendTo(n)},"^show.ready$":function(e,t,n){n&&(!this.rendered&&this.render(i)||this.toggle(i))},"^style.classes$":function(e,t,n,r){this.rendered&&this.tooltip.removeClass(r).addClass(n)},"^style.(width|height)":function(e,t,n){this.rendered&&this.tooltip.css(t,n)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(e,t,n){this.rendered&&this.tooltip.toggleClass(M,!!n)},"^events.(render|show|move|hide|focus|blur)$":function(e,t,n){this.rendered&&this.tooltip[(r.isFunction(n)?"":"un")+"bind"]("tooltip"+t,n)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(!this.rendered)return;var e=this.options.position;this.tooltip.attr("tracking",e.target==="mouse"&&e.adjust.mouse),this._unassignEvents(),this._assignEvents()}}},w.get=function(e){if(this.destroyed)return this;var t=z(this.options,e.toLowerCase()),n=t[0][t[1]];return n.precedance?n.string():n};var X=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,V=/^prerender|show\.ready/i;w.set=function(e,t){if(this.destroyed)return this;var n=this.rendered,u=s,a=this.options,f=this.checks,l;return"string"==typeof e?(l=e,e={},e[l]=t):e=r.extend({},e),r.each(e,function(t,i){if(n&&V.test(t)){delete e[t];return}var s=z(a,t.toLowerCase()),o;o=s[0][s[1]],s[0][s[1]]=i&&i.nodeType?r(i):i,u=X.test(t)||u,e[t]=[s[0],s[1],i,o]}),U(a),this.positioning=i,r.each(e,r.proxy(W,this)),this.positioning=s,this.rendered&&this.tooltip[0].offsetWidth>0&&u&&this.reposition(a.position.target==="mouse"?o:this.cache.event),this},w._update=function(e,t,n){var u=this,a=this.cache;return!this.rendered||!e?s:(r.isFunction(e)&&(e=e.call(this.elements.target,a.event,this)||""),r.isFunction(e.then)?(a.waiting=i,e.then(function(e){return a.waiting=s,u._update(e,t)},o,function(e){return u._update(e,t)})):e===s||!e&&e!==""?s:(e.jquery&&e.length>0?t.empty().append(e.css({display:"block",visibility:"visible"})):t.html(e),this._waitForContent(t).then(function(e){e.images&&e.images.length&&u.rendered&&u.tooltip[0].offsetWidth>0&&u.reposition(a.event,!e.length)})))},w._waitForContent=function(e){var t=this.cache;return t.waiting=i,(r.fn.imagesLoaded?e.imagesLoaded():r.Deferred().resolve([])).done(function(){t.waiting=s}).promise()},w._updateContent=function(e,t){this._update(e,this.elements.content,t)},w._updateTitle=function(e,t){this._update(e,this.elements.title,t)===s&&this._removeTitle(s)},w._createTitle=function(){var e=this.elements,t=this._id+"-title";e.titlebar&&this._removeTitle(),e.titlebar=r("<div />",{"class":T+"-titlebar "+(this.options.style.widget?J("header"):"")}).append(e.title=r("<div />",{id:t,"class":T+"-title","aria-atomic":i})).insertBefore(e.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(e){r(this).toggleClass("ui-state-active ui-state-focus",e.type.substr(-4)==="down")}).delegate(".qtip-close","mouseover mouseout",function(e){r(this).toggleClass("ui-state-hover",e.type==="mouseover")}),this.options.content.button&&this._createButton()},w._removeTitle=function(e){var t=this.elements;t.title&&(t.titlebar.remove(),t.titlebar=t.title=t.button=o,e!==s&&this.reposition())},w.reposition=function(n,o){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=i;var u=this.cache,a=this.tooltip,f=this.options.position,l=f.target,m=f.my,g=f.at,y=f.viewport,b=f.container,w=f.adjust,E=w.method.split(" "),S=a.outerWidth(s),T=a.outerHeight(s),N=0,C=0,k=a.css("position"),L={left:0,top:0},A=a[0].offsetWidth>0,O=n&&n.type==="scroll",M=r(e),_=b[0].ownerDocument,D=this.mouse,P,H;if(r.isArray(l)&&l.length===2)g={x:h,y:c},L={left:l[0],top:l[1]};else if(l==="mouse"){g={x:h,y:c};if(D&&D.pageX&&(w.mouse||!n||!n.pageX))n=D;else if(!n||!n.pageX)if((!w.mouse||this.options.show.distance)&&u.origin&&u.origin.pageX)n=u.origin;else if(!n||n&&(n.type==="resize"||n.type==="scroll"))n=u.event;k!=="static"&&(L=b.offset()),_.body.offsetWidth!==(e.innerWidth||_.documentElement.clientWidth)&&(H=r(t.body).offset()),L={left:n.pageX-L.left+(H&&H.left||0),top:n.pageY-L.top+(H&&H.top||0)},w.mouse&&O&&D&&(L.left-=(D.scrollX||0)-M.scrollLeft(),L.top-=(D.scrollY||0)-M.scrollTop())}else{l==="event"?n&&n.target&&n.type!=="scroll"&&n.type!=="resize"?u.target=r(n.target):n.target||(u.target=this.elements.target):l!=="event"&&(u.target=r(l.jquery?l:this.elements.target)),l=u.target,l=r(l).eq(0);if(l.length===0)return this;l[0]===t||l[0]===e?(N=F.iOS?e.innerWidth:l.width(),C=F.iOS?e.innerHeight:l.height(),l[0]===e&&(L={top:(y||l).scrollTop(),left:(y||l).scrollLeft()})):x.imagemap&&l.is("area")?P=x.imagemap(this,l,g,x.viewport?E:s):x.svg&&l&&l[0].ownerSVGElement?P=x.svg(this,l,g,x.viewport?E:s):(N=l.outerWidth(s),C=l.outerHeight(s),L=l.offset()),P&&(N=P.width,C=P.height,H=P.offset,L=P.position),L=this.reposition.offset(l,L,b);if(F.iOS>3.1&&F.iOS<4.1||F.iOS>=4.3&&F.iOS<4.33||!F.iOS&&k==="fixed")L.left-=M.scrollLeft(),L.top-=M.scrollTop();if(!P||P&&P.adjustable!==s)L.left+=g.x===d?N:g.x===v?N/2:0,L.top+=g.y===p?C:g.y===v?C/2:0}return L.left+=w.x+(m.x===d?-S:m.x===v?-S/2:0),L.top+=w.y+(m.y===p?-T:m.y===v?-T/2:0),x.viewport?(L.adjusted=x.viewport(this,L,f,N,C,S,T),H&&L.adjusted.left&&(L.left+=H.left),H&&L.adjusted.top&&(L.top+=H.top)):L.adjusted={left:0,top:0},this._trigger("move",[L,y.elem||y],n)?(delete L.adjusted,o===s||!A||isNaN(L.left)||isNaN(L.top)||l==="mouse"||!r.isFunction(f.effect)?a.css(L):r.isFunction(f.effect)&&(f.effect.call(a,this,r.extend({},L)),a.queue(function(e){r(this).css({opacity:"",height:""}),F.ie&&this.style.removeAttribute("filter"),e()})),this.positioning=s,this):this},w.reposition.offset=function(e,n,i){function h(e,t){n.left+=t*e.scrollLeft(),n.top+=t*e.scrollTop()}if(!i[0])return n;var s=r(e[0].ownerDocument),o=!!F.ie&&t.compatMode!=="CSS1Compat",u=i[0],a,f,l,c;do(f=r.css(u,"position"))!=="static"&&(f==="fixed"?(l=u.getBoundingClientRect(),h(s,-1)):(l=r(u).position(),l.left+=parseFloat(r.css(u,"borderLeftWidth"))||0,l.top+=parseFloat(r.css(u,"borderTopWidth"))||0),n.left-=l.left+(parseFloat(r.css(u,"marginLeft"))||0),n.top-=l.top+(parseFloat(r.css(u,"marginTop"))||0),!a&&(c=r.css(u,"overflow"))!=="hidden"&&c!=="visible"&&(a=r(u)));while(u=u.offsetParent);return a&&(a[0]!==s[0]||o)&&h(a,1),n};var $=(E=w.reposition.Corner=function(e,t){e=(""+e).replace(/([A-Z])/," $1").replace(/middle/gi,v).toLowerCase(),this.x=(e.match(/left|right/i)||e.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(e.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase(),this.forceY=!!t;var n=e.charAt(0);this.precedance=n==="t"||n==="b"?a:u}).prototype;$.invert=function(e,t){this[e]=this[e]===h?d:this[e]===d?h:t||this[e]},$.string=function(){var e=this.x,t=this.y;return e===t?e:this.precedance===a||this.forceY&&t!=="center"?t+" "+e:e+" "+t},$.abbrev=function(){var e=this.string().split(" ");return e[0].charAt(0)+(e[1]&&e[1].charAt(0)||"")},$.clone=function(){return new E(this.string(),this.forceY)},w.toggle=function(e,n){var u=this.cache,a=this.options,f=this.tooltip;if(n){if(/over|enter/.test(n.type)&&/out|leave/.test(u.event.type)&&a.show.target.add(n.target).length===a.show.target.length&&f.has(n.relatedTarget).length)return this;u.event=K(n)}this.waiting&&!e&&(this.hiddenDuringWait=i);if(!this.rendered)return e?this.render(1):this;if(this.destroyed||this.disabled)return this;var l=e?"show":"hide",c=this.options[l],h=this.options[e?"hide":"show"],p=this.options.position,d=this.options.content,v=this.tooltip.css("width"),m=this.tooltip.is(":visible"),g=e||c.target.length===1,y=!n||c.target.length<2||u.target[0]===n.target,b,w,E,S,x;return(typeof e).search("boolean|number")&&(e=!m),b=!f.is(":animated")&&m===e&&y,w=b?o:!!this._trigger(l,[90]),this.destroyed?this:(w!==s&&e&&this.focus(n),!w||b?this:(r.attr(f[0],"aria-hidden",!e),e?(u.origin=K(this.mouse),r.isFunction(d.text)&&this._updateContent(d.text,s),r.isFunction(d.title)&&this._updateTitle(d.title,s),!j&&p.target==="mouse"&&p.adjust.mouse&&(r(t).bind("mousemove."+T,this._storeMouse),j=i),v||f.css("width",f.outerWidth(s)),this.reposition(n,arguments[2]),v||f.css("width",""),!c.solo||(typeof c.solo=="string"?r(c.solo):r(L,c.solo)).not(f).not(c.target).qtip("hide",r.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete u.origin,j&&!r(L+'[tracking="true"]:visible',c.solo).not(f).length&&(r(t).unbind("mousemove."+T),j=s),this.blur(n)),x=r.proxy(function(){e?(F.ie&&f[0].style.removeAttribute("filter"),f.css("overflow",""),"string"==typeof c.autofocus&&r(this.options.show.autofocus,f).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):f.css({display:"",visibility:"",opacity:"",left:"",top:""}),this._trigger(e?"visible":"hidden")},this),c.effect===s||g===s?(f[l](),x()):r.isFunction(c.effect)?(f.stop(1,1),c.effect.call(f,this),f.queue("fx",function(e){x(),e()})):f.fadeTo(90,e?1:0,x),e&&c.target.trigger("qtip-"+this.id+"-inactive"),this))},w.show=function(e){return this.toggle(i,e)},w.hide=function(e){return this.toggle(s,e)},w.focus=function(e){if(!this.rendered||this.destroyed)return this;var t=r(L),n=this.tooltip,i=parseInt(n[0].style.zIndex,10),s=b.zindex+t.length,o;return n.hasClass(_)||this._trigger("focus",[s],e)&&(i!==s&&(t.each(function(){this.style.zIndex>i&&(this.style.zIndex=this.style.zIndex-1)}),t.filter("."+_).qtip("blur",e)),n.addClass(_)[0].style.zIndex=s),this},w.blur=function(e){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass(_),this._trigger("blur",[this.tooltip.css("zIndex")],e),this)},w.disable=function(e){return this.destroyed?this:(e==="toggle"?e=this.rendered?!this.tooltip.hasClass(P):!this.disabled:"boolean"!=typeof e&&(e=i),this.rendered&&this.tooltip.toggleClass(P,e).attr("aria-disabled",e),this.disabled=!!e,this)},w.enable=function(){return this.disable(s)},w._createButton=function(){var e=this,t=this.elements,n=t.tooltip,i=this.options.content.button,o=typeof i=="string",u=o?i:"Close tooltip";t.button&&t.button.remove(),i.jquery?t.button=i:t.button=r("<a />",{"class":"qtip-close "+(this.options.style.widget?"":T+"-icon"),title:u,"aria-label":u}).prepend(r("<span />",{"class":"ui-icon ui-icon-close",html:"&times;"})),t.button.appendTo(t.titlebar||n).attr("role","button").click(function(t){return n.hasClass(P)||e.hide(t),s})},w._updateButton=function(e){if(!this.rendered)return s;var t=this.elements.button;e?this._createButton():t.remove()},w._setWidget=function(){var e=this.options.style.widget,t=this.elements,n=t.tooltip,r=n.hasClass(P);n.removeClass(P),P=e?"ui-state-disabled":"qtip-disabled",n.toggleClass(P,r),n.toggleClass("ui-helper-reset "+J(),e).toggleClass(M,this.options.style.def&&!e),t.content&&t.content.toggleClass(J("content"),e),t.titlebar&&t.titlebar.toggleClass(J("header"),e),t.button&&t.button.toggleClass(T+"-icon",!e)},w._storeMouse=function(e){(this.mouse=K(e)).type="mousemove"},w._bind=function(e,t,n,i,s){var o="."+this._id+(i?"-"+i:"");t.length&&r(e).bind((t.split?t:t.join(o+" "))+o,r.proxy(n,s||this))},w._unbind=function(e,t){r(e).unbind("."+this._id+(t?"-"+t:""))};var tt="."+T;r(function(){nt(L,["mouseenter","mouseleave"],function(e){var t=e.type==="mouseenter",n=r(e.currentTarget),i=r(e.relatedTarget||e.target),s=this.options;t?(this.focus(e),n.hasClass(O)&&!n.hasClass(P)&&clearTimeout(this.timers.hide)):s.position.target==="mouse"&&s.hide.event&&s.show.target&&!i.closest(s.show.target[0]).length&&this.hide(e),n.toggleClass(D,t)}),nt("["+C+"]",A,Z)}),w._trigger=function(e,t,n){var i=r.Event("tooltip"+e);return i.originalEvent=n&&r.extend({},n)||this.cache.event||o,this.triggering=e,this.tooltip.trigger(i,[this].concat(t||[])),this.triggering=s,!i.isDefaultPrevented()},w._bindEvents=function(e,t,n,i,s,o){if(i.add(n).length===i.length){var u=[];t=r.map(t,function(t){var n=r.inArray(t,e);if(n>-1){u.push(e.splice(n,1)[0]);return}return t}),u.length&&this._bind(n,u,function(e){var t=this.rendered?this.tooltip[0].offsetWidth>0:!1;(t?o:s).call(this,e)})}this._bind(n,e,s),this._bind(i,t,o)},w._assignInitialEvents=function(e){function l(e){if(this.disabled||this.destroyed)return s;this.cache.event=K(e),this.cache.target=e?r(e.target):[n],clearTimeout(this.timers.show),this.timers.show=Q.call(this,function(){this.render(typeof e=="object"||t.show.ready)},t.show.delay)}var t=this.options,o=t.show.target,u=t.hide.target,a=t.show.event?r.trim(""+t.show.event).split(" "):[],f=t.hide.event?r.trim(""+t.hide.event).split(" "):[];/mouse(over|enter)/i.test(t.show.event)&&!/mouse(out|leave)/i.test(t.hide.event)&&f.push("mouseleave"),this._bind(o,"mousemove",function(e){this._storeMouse(e),this.cache.onTarget=i}),this._bindEvents(a,f,o,u,l,function(){clearTimeout(this.timers.show)}),(t.show.ready||t.prerender)&&l.call(this,e)},w._assignEvents=function(){var n=this,i=this.options,s=i.position,o=this.tooltip,u=i.show.target,a=i.hide.target,f=s.container,l=s.viewport,c=r(t),h=r(t.body),p=r(e),d=i.show.event?r.trim(""+i.show.event).split(" "):[],v=i.hide.event?r.trim(""+i.hide.event).split(" "):[];r.each(i.events,function(e,t){n._bind(o,e==="toggle"?["tooltipshow","tooltiphide"]:["tooltip"+e],t,null,o)}),/mouse(out|leave)/i.test(i.hide.event)&&i.hide.leave==="window"&&this._bind(c,["mouseout","blur"],function(e){!/select|option/.test(e.target.nodeName)&&!e.relatedTarget&&this.hide(e)}),i.hide.fixed?a=a.add(o.addClass(O)):/mouse(over|enter)/i.test(i.show.event)&&this._bind(a,"mouseleave",function(){clearTimeout(this.timers.show)}),(""+i.hide.event).indexOf("unfocus")>-1&&this._bind(f.closest("html"),["mousedown","touchstart"],function(e){var t=r(e.target),n=this.rendered&&!this.tooltip.hasClass(P)&&this.tooltip[0].offsetWidth>0,i=t.parents(L).filter(this.tooltip[0]).length>0;t[0]!==this.target[0]&&t[0]!==this.tooltip[0]&&!i&&!this.target.has(t[0]).length&&n&&this.hide(e)}),"number"==typeof i.hide.inactive&&(this._bind(u,"qtip-"+this.id+"-inactive",Z),this._bind(a.add(o),b.inactiveEvents,Z,"-inactive")),this._bindEvents(d,v,u,a,G,Y),this._bind(u.add(o),"mousemove",function(e){if("number"==typeof i.hide.distance){var t=this.cache.origin||{},n=this.options.hide.distance,r=Math.abs;(r(e.pageX-t.pageX)>=n||r(e.pageY-t.pageY)>=n)&&this.hide(e)}this._storeMouse(e)}),s.target==="mouse"&&s.adjust.mouse&&(i.hide.event&&this._bind(u,["mouseenter","mouseleave"],function(e){this.cache.onTarget=e.type==="mouseenter"}),this._bind(c,"mousemove",function(e){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(P)&&this.tooltip[0].offsetWidth>0&&this.reposition(e)})),(s.adjust.resize||l.length)&&this._bind(r.event.special.resize?l:p,"resize",et),s.adjust.scroll&&this._bind(p.add(s.container),"scroll",et)},w._unassignEvents=function(){var n=[this.options.show.target[0],this.options.hide.target[0],this.rendered&&this.tooltip[0],this.options.position.container[0],this.options.position.viewport[0],this.options.position.container.closest("html")[0],e,t];this._unbind(r([]).pushStack(r.grep(n,function(e){return typeof e=="object"})))},b=r.fn.qtip=function(e,t,u){var a=(""+e).toLowerCase(),f=o,l=r.makeArray(arguments).slice(1),c=l[l.length-1],h=this[0]?r.data(this[0],T):o;if(!arguments.length&&h||a==="api")return h;if("string"==typeof e)return this.each(function(){var e=r.data(this,T);if(!e)return i;c&&c.timeStamp&&(e.cache.event=c);if(!t||a!=="option"&&a!=="options")e[a]&&e[a].apply(e,l);else{if(u===n&&!r.isPlainObject(t))return f=e.get(t),s;e.set(t,u)}}),f!==o?f:this;if("object"==typeof e||!arguments.length)return h=U(r.extend(i,{},e)),this.each(function(e){var t,n;n=r.isArray(h.id)?h.id[e]:h.id,n=!n||n===s||n.length<1||b.api[n]?b.nextid++:n,t=rt(r(this),n,h);if(t===s)return i;b.api[n]=t,r.each(x,function(){this.initialize==="initialize"&&this(t)}),t._assignInitialEvents(c)})},r.qtip=I,b.api={},r.each({attr:function(e,t){if(this.length){var n=this[0],i="title",s=r.data(n,"qtip");if(e===i&&s&&"object"==typeof s&&s.options.suppress)return arguments.length<2?r.attr(n,B):(s&&s.options.content.attr===i&&s.cache.attr&&s.set("content.text",t),this.attr(B,t))}return r.fn["attr"+H].apply(this,arguments)},clone:function(e){var t=r([]),n="title",i=r.fn["clone"+H].apply(this,arguments);return e||i.filter("["+B+"]").attr("title",function(){return r.attr(this,B)}).removeAttr(B),i}},function(e,t){if(!t||r.fn[e+H])return i;var n=r.fn[e+H]=r.fn[e];r.fn[e]=function(){return t.apply(this,arguments)||n.apply(this,arguments)}}),r.ui||(r["cleanData"+H]=r.cleanData,r.cleanData=function(e){for(var t=0,n;(n=r(e[t])).length;t++)if(n.attr(N))try{n.triggerHandler("removeqtip")}catch(i){}r["cleanData"+H].apply(this,arguments)}),b.version="2.2.0",b.nextid=0,b.inactiveEvents=A,b.zindex=15e3,b.defaults={prerender:s,id:s,overwrite:i,suppress:i,content:{text:i,attr:"title",title:s,button:s},position:{my:"top left",at:"bottom right",target:s,container:s,viewport:s,adjust:{x:0,y:0,mouse:i,scroll:i,resize:i,method:"flipinvert flipinvert"},effect:function(e,t,n){r(this).animate(t,{duration:200,queue:s})}},show:{target:s,event:"mouseenter",effect:i,delay:90,solo:s,ready:s,autofocus:s},hide:{target:s,event:"mouseleave",effect:i,delay:0,fixed:s,inactive:s,leave:"window",distance:s},style:{classes:"",widget:s,width:s,height:s,def:i},events:{render:o,move:o,show:o,hide:o,toggle:o,visible:o,hidden:o,focus:o,blur:o}};var it,st=".qtip-tip",ot="margin",ut="border",at="color",ft="background-color",lt="transparent",ct=" !important",ht=!!t.createElement("canvas").getContext,pt=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,vt={},mt=["Webkit","O","Moz","ms"];if(!ht)var bt=function(e,t,n){return"<qtipvml:"+e+' xmlns="urn:schemas-microsoft.com:vml" class="qtip-vml" '+(t||"")+' style="behavior: url(#default#VML); '+(n||"")+'" />'};else var wt=e.devicePixelRatio||1,Et=function(){var e=t.createElement("canvas").getContext("2d");return e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1}(),St=wt/Et;r.extend(xt.prototype,{init:function(e){var t,n;n=this.element=e.elements.tip=r("<div />",{"class":T+"-tip"}).prependTo(e.tooltip),ht?(t=r("<canvas />").appendTo(this.element)[0].getContext("2d"),t.lineJoin="miter",t.miterLimit=1e5,t.save()):(t=bt("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(t+t),e._bind(r("*",n).add(n),["click","mousedown"],function(e){e.stopPropagation()},this._ns)),e._bind(e.tooltip,"tooltipmove",this.reposition,this._ns,this),this.create()},_swapDimensions:function(){this.size[0]=this.options.height,this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width,this.size[1]=this.options.height},_useTitle:function(e){var t=this.qtip.elements.titlebar;return t&&(e.y===c||e.y===v&&this.element.position().top+this.size[1]/2+this.options.offset<t.outerHeight(i))},_parseCorner:function(e){var t=this.qtip.options.position.my;return e===s||t===s?e=s:e===i?e=new E(t.string()):e.string||(e=new E(e),e.fixed=i),e},_parseWidth:function(e,t,n){var r=this.qtip.elements,i=ut+dt(t)+"Width";return(n?yt(n,i):yt(r.content,i)||yt(this._useTitle(e)&&r.titlebar||r.content,i)||yt(r.tooltip,i))||0},_parseRadius:function(e){var t=this.qtip.elements,n=ut+dt(e.y)+dt(e.x)+"Radius";return F.ie<9?0:yt(this._useTitle(e)&&t.titlebar||t.content,n)||yt(t.tooltip,n)||0},_invalidColour:function(e,t,n){var r=e.css(t);return!r||n&&r===e.css(n)||pt.test(r)?s:r},_parseColours:function(e){var t=this.qtip.elements,n=this.element.css("cssText",""),i=ut+dt(e[e.precedance])+dt(at),s=this._useTitle(e)&&t.titlebar||t.content,o=this._invalidColour,u=[];return u[0]=o(n,ft)||o(s,ft)||o(t.content,ft)||o(t.tooltip,ft)||n.css(ft),u[1]=o(n,i,at)||o(s,i,at)||o(t.content,i,at)||o(t.tooltip,i,at)||t.tooltip.css(i),r("*",n).add(n).css("cssText",ft+":"+lt+ct+";"+ut+":0"+ct+";"),u},_calculateSize:function(e){var t=e.precedance===a,n=this.options.width,r=this.options.height,i=e.abbrev()==="c",s=(t?n:r)*(i?.5:1),o=Math.pow,u=Math.round,f,l,c,h=Math.sqrt(o(s,2)+o(r,2)),p=[this.border/s*h,this.border/r*h];return p[2]=Math.sqrt(o(p[0],2)-o(this.border,2)),p[3]=Math.sqrt(o(p[1],2)-o(this.border,2)),f=h+p[2]+p[3]+(i?0:p[0]),l=f/h,c=[u(l*n),u(l*r)],t?c:c.reverse()},_calculateTip:function(e,t,n){n=n||1,t=t||this.size;var r=t[0]*n,i=t[1]*n,s=Math.ceil(r/2),o=Math.ceil(i/2),u={br:[0,0,r,i,r,0],bl:[0,0,r,0,0,i],tr:[0,i,r,0,r,i],tl:[0,0,0,i,r,i],tc:[0,i,s,0,r,i],bc:[0,0,r,0,s,i],rc:[0,0,r,o,0,i],lc:[r,0,r,i,0,o]};return u.lt=u.br,u.rt=u.bl,u.lb=u.tr,u.rb=u.tl,u[e.abbrev()]},_drawCoords:function(e,t){e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(t[2],t[3]),e.lineTo(t[4],t[5]),e.closePath()},create:function(){var e=this.corner=(ht||F.ie)&&this._parseCorner(this.options.corner);if(this.enabled=!!this.corner&&this.corner.abbrev()!=="c")this.qtip.cache.corner=e.clone(),this.update();return this.element.toggle(this.enabled),this.corner},update:function(t,n){if(!this.enabled)return this;var o=this.qtip.elements,m=this.element,g=m.children(),y=this.options,b=this.size,w=y.mimic,S=Math.round,x,T,N,C,k,L,A,O,M;t||(t=this.qtip.cache.corner||this.corner),w===s?w=t:(w=new E(w),w.precedance=t.precedance,w.x==="inherit"?w.x=t.x:w.y==="inherit"?w.y=t.y:w.x===w.y&&(w[t.precedance]=t[t.precedance])),T=w.precedance,t.precedance===u?this._swapDimensions():this._resetDimensions(),x=this.color=this._parseColours(t),x[1]!==lt?(O=this.border=this._parseWidth(t,t[t.precedance]),y.border&&O<1&&!pt.test(x[1])&&(x[0]=x[1]),this.border=O=y.border!==i?y.border:O):this.border=O=0,A=this.size=this._calculateSize(t),m.css({width:A[0],height:A[1],lineHeight:A[1]+"px"}),t.precedance===a?L=[S(w.x===h?O:w.x===d?A[0]-b[0]-O:(A[0]-b[0])/2),S(w.y===c?A[1]-b[1]:0)]:L=[S(w.x===h?A[0]-b[0]:0),S(w.y===c?O:w.y===p?A[1]-b[1]-O:(A[1]-b[1])/2)],ht?(N=g[0].getContext("2d"),N.restore(),N.save(),N.clearRect(0,0,6e3,6e3),C=this._calculateTip(w,b,St),k=this._calculateTip(w,this.size,St),g.attr(f,A[0]*St).attr(l,A[1]*St),g.css(f,A[0]).css(l,A[1]),this._drawCoords(N,k),N.fillStyle=x[1],N.fill(),N.translate(L[0]*St,L[1]*St),this._drawCoords(N,C),N.fillStyle=x[0],N.fill()):(C=this._calculateTip(w),C="m"+C[0]+","+C[1]+" l"+C[2]+","+C[3]+" "+C[4]+","+C[5]+" xe",L[2]=O&&/^(r|b)/i.test(t.string())?F.ie===8?2:1:0,g.css({coordsize:A[0]+O+" "+(A[1]+O),antialias:""+(w.string().indexOf(v)>-1),left:L[0]-L[2]*Number(T===u),top:L[1]-L[2]*Number(T===a),width:A[0]+O,height:A[1]+O}).each(function(e){var t=r(this);t[t.prop?"prop":"attr"]({coordsize:A[0]+O+" "+(A[1]+O),path:C,fillcolor:x[0],filled:!!e,stroked:!e}).toggle(!!O||!!e),!e&&t.html(bt("stroke",'weight="'+O*2+'px" color="'+x[1]+'" miterlimit="1000" joinstyle="miter"'))})),e.opera&&setTimeout(function(){o.tip.css({display:"inline-block",visibility:"visible"})},1),n!==s&&this.calculate(t,A)},calculate:function(e,t){if(!this.enabled)return s;var n=this,i=this.qtip.elements,o=this.element,f=this.options.offset,l=i.tooltip.hasClass("ui-widget"),p={},d,m;return e=e||this.corner,d=e.precedance,t=t||this._calculateSize(e),m=[e.x,e.y],d===u&&m.reverse(),r.each(m,function(r,s){var o,u,l;s===v?(o=d===a?h:c,p[o]="50%",p[ot+"-"+o]=-Math.round(t[d===a?0:1]/2)+f):(o=n._parseWidth(e,s,i.tooltip),u=n._parseWidth(e,s,i.content),l=n._parseRadius(e),p[s]=Math.max(-n.border,r?u:f+(l>o?l:-o)))}),p[e[d]]-=t[d===u?0:1],o.css({margin:"",top:"",bottom:"",left:"",right:""}).css(p),p},reposition:function(e,t,r,o){function N(e,t,n,r,i){e===y&&l.precedance===t&&m[r]&&l[n]!==v?l.precedance=l.precedance===u?a:u:e!==y&&m[r]&&(l[t]=l[t]===v?m[r]>0?r:i:l[t]===r?i:r)}function C(e,t,i){l[e]===v?x[ot+"-"+t]=E[e]=S[ot+"-"+t]-m[t]:(T=S[i]!==n?[m[t],-S[t]]:[-m[t],S[t]],(E[e]=Math.max(T[0],T[1]))>T[0]&&(r[t]-=m[t],E[t]=s),x[S[i]!==n?i:t]=E[e])}if(!this.enabled)return;var f=t.cache,l=this.corner.clone(),m=r.adjusted,g=t.options.position.adjust.method.split(" "),b=g[0],w=g[1]||g[0],E={left:s,top:s,x:0,y:0},S,x={},T;this.corner.fixed!==i&&(N(b,u,a,h,d),N(w,a,u,c,p),l.string()!==f.corner.string()&&(f.cornerTop!==m.top||f.cornerLeft!==m.left)&&this.update(l,s)),S=this.calculate(l),S.right!==n&&(S.left=-S.right),S.bottom!==n&&(S.top=-S.bottom),S.user=this.offset,(E.left=b===y&&!!m.left)&&C(u,h,d),(E.top=w===y&&!!m.top)&&C(a,c,p),this.element.css(x).toggle(!(E.x&&E.y||l.x===v&&E.y||l.y===v&&E.x)),r.left-=S.left.charAt?S.user:b!==y||E.top||!E.left&&!E.top?S.left+this.border:0,r.top-=S.top.charAt?S.user:w!==y||E.left||!E.left&&!E.top?S.top+this.border:0,f.cornerLeft=m.left,f.cornerTop=m.top,f.corner=l.clone()},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns),this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}}),it=x.tip=function(e){return new xt(e,e.options.style.tip)},it.initialize="render",it.sanitize=function(e){if(e.style&&"tip"in e.style){var t=e.style.tip;typeof t!="object"&&(t=e.style.tip={corner:t}),/string|boolean/i.test(typeof t.corner)||(t.corner=i)}},S.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create(),this.qtip.reposition()},"^style.tip.(height|width)$":function(e){this.size=[e.width,e.height],this.update(),this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}},r.extend(i,b.defaults,{style:{tip:{corner:i,mimic:s,width:6,height:6,border:i,offset:0}}}),x.viewport=function(n,r,i,o,m,b,w){function z(e,t,n,i,s,o,u,a,l){var c=r[s],h=x[e],p=N[e],d=n===y,m=h===s?l:h===o?-l:-l/2,b=p===s?a:p===o?-a:-a/2,w=R[s]+U[s]-(F?0:j[s]),E=w-c,S=c+l-(u===f?I:q)-w,T=m-(x.precedance===e||h===x[t]?b:0)-(p===v?a/2:0);return d?(T=(h===s?1:-1)*m,r[s]+=E>0?E:S>0?-S:0,r[s]=Math.max(-j[s]+U[s],c-T,Math.min(Math.max(-j[s]+U[s]+(u===f?I:q),c+T),r[s],h==="center"?c-m:1e9))):(i*=n===g?2:0,E>0&&(h!==s||S>0)?(r[s]-=T+i,H.invert(e,s)):S>0&&(h!==o||E>0)&&(r[s]-=(h===v?-T:T)+i,H.invert(e,o)),r[s]<R&&-r[s]>S&&(r[s]=c,H=x.clone())),r[s]-c}var E=i.target,S=n.elements.tooltip,x=i.my,N=i.at,C=i.adjust,k=C.method.split(" "),L=k[0],A=k[1]||k[0],O=i.viewport,M=i.container,_=n.cache,D={left:0,top:0},P,H,B,j,F,I,q,R,U;if(!O.jquery||E[0]===e||E[0]===t.body||C.method==="none")return D;j=M.offset()||D,F=M.css("position")==="static",P=S.css("position")==="fixed",I=O[0]===e?O.width():O.outerWidth(s),q=O[0]===e?O.height():O.outerHeight(s),R={left:P?0:O.scrollLeft(),top:P?0:O.scrollTop()},U=O.offset()||D;if(L!=="shift"||A!=="shift")H=x.clone();return D={left:L!=="none"?z(u,a,L,C.x,h,d,f,o,b):0,top:A!=="none"?z(a,u,A,C.y,c,p,l,m,w):0},H&&_.lastClass!==(B=T+"-pos-"+H.abbrev())&&S.removeClass(n.cache.lastClass).addClass(n.cache.lastClass=B),D}})}(window,document),define("util.tooltips",["jquery","qtip"],function(e){setupTooltips=function(t){typeof t=="undefined"&&(t=!1);if(Headway.disableTooltips==1||Headway.touch)return e("div.tooltip-button").hide(),!1;var n={style:{classes:"qtip-headway"},show:{delay:10,solo:!0,event:"mouseenter"},position:{my:"bottom left",at:"top center",viewport:e(window),effect:!1},hide:{effect:!1}};if(t=="iframe"){n.position.container=$i("body"),n.position.viewport=$i("#headway-tooltip-container");var r=$i}else var r=e;r("div.tooltip-button:not([data-hasqtip]), .tooltip:not([data-hasqtip])").qtip(n),r(".tooltip-bottom-right:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"bottom right",at:"top center"}})),r(".tooltip-top-right:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"top right",at:"bottom center"}})),r(".tooltip-top-left:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"top left",at:"bottom center"},show:{delay:750}})),r(".tooltip-left:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"left center",at:"right center"}})),r(".tooltip-right:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"right center",at:"left center"}})),r(".tooltip-top:not([data-hasqtip])").qtip(e.extend(!0,{},n,{position:{my:"top center",at:"bottom center"}}));var i=function(){if($i(".qtip:visible").length===0||typeof iframeScrollTooltipRepositionFloodTimeout!="undefined")return;iframeScrollTooltipRepositionFloodTimeout=setTimeout(function(){$i(".qtip:visible").qtip("reposition"),delete iframeScrollTooltipRepositionFloodTimeout},400)};Headway.iframe.contents().unbind("scroll",i),Headway.iframe.contents().bind("scroll",i)},repositionTooltips=function(){$i(".qtip:visible").qtip("reposition")}}),function(e,t,n){function m(e,t,n){if(e.addEventListener){e.addEventListener(t,n,!1);return}e.attachEvent("on"+t,n)}function g(e){if(e.type=="keypress"){var t=String.fromCharCode(e.which);return e.shiftKey||(t=t.toLowerCase()),t}return r[e.which]?r[e.which]:i[e.which]?i[e.which]:String.fromCharCode(e.which).toLowerCase()}function y(e,t){return e.sort().join(",")===t.sort().join(",")}function b(e){e=e||{};var t=!1,n;for(n in l){if(e[n]){t=!0;continue}l[n]=0}t||(d=!1)}function w(e,t,n,r,i,s){var o,u,f=[],c=n.type;if(!a[e])return[];c=="keyup"&&k(e)&&(t=[e]);for(o=0;o<a[e].length;++o){u=a[e][o];if(!r&&u.seq&&l[u.seq]!=u.level)continue;if(c!=u.action)continue;if(c=="keypress"&&!n.metaKey&&!n.ctrlKey||y(t,u.modifiers)){var h=!r&&u.combo==i,p=r&&u.seq==r&&u.level==s;(h||p)&&a[e].splice(o,1),f.push(u)}}return f}function E(e){var t=[];return e.shiftKey&&t.push("shift"),e.altKey&&t.push("alt"),e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),t}function S(e){if(e.preventDefault){e.preventDefault();return}e.returnValue=!1}function x(e){if(e.stopPropagation){e.stopPropagation();return}e.cancelBubble=!0}function T(e,t,n,r){if(B.stopCallback(t,t.target||t.srcElement,n,r))return;e(t,n)===!1&&(S(t),x(t))}function N(e,t,n){var r=w(e,t,n),i,s={},o=0,u=!1;for(i=0;i<r.length;++i)r[i].seq&&(o=Math.max(o,r[i].level));for(i=0;i<r.length;++i){if(r[i].seq){if(r[i].level!=o)continue;u=!0,s[r[i].seq]=1,T(r[i].callback,n,r[i].combo,r[i].seq);continue}u||T(r[i].callback,n,r[i].combo)}var a=n.type=="keypress"&&p;n.type==d&&!k(e)&&!a&&b(s),p=u&&n.type=="keydown"}function C(e){typeof e.which!="number"&&(e.which=e.keyCode);var t=g(e);if(!t)return;if(e.type=="keyup"&&h===t){h=!1;return}B.handleKey(t,E(e),e)}function k(e){return e=="shift"||e=="ctrl"||e=="alt"||e=="meta"}function L(){clearTimeout(c),c=setTimeout(b,1e3)}function A(){if(!u){u={};for(var e in r){if(e>95&&e<112)continue;r.hasOwnProperty(e)&&(u[r[e]]=e)}}return u}function O(e,t,n){return n||(n=A()[e]?"keydown":"keypress"),n=="keypress"&&t.length&&(n="keydown"),n}function M(e,t,n,r){function i(t){return function(){d=t,++l[e],L()}}function s(t){T(n,t,e),r!=="keyup"&&(h=g(t)),setTimeout(b,10)}l[e]=0;for(var o=0;o<t.length;++o){var u=o+1===t.length,a=u?s:i(r||D(t[o+1]).action);P(t[o],a,r,e,o)}}function _(e){return e==="+"?["+"]:e.split("+")}function D(e,t){var n,r,i,u=[];n=_(e);for(i=0;i<n.length;++i)r=n[i],o[r]&&(r=o[r]),t&&t!="keypress"&&s[r]&&(r=s[r],u.push("shift")),k(r)&&u.push(r);return t=O(r,u,t),{key:r,modifiers:u,action:t}}function P(e,t,n,r,i){f[e+":"+n]=t,e=e.replace(/\s+/g," ");var s=e.split(" "),o;if(s.length>1){M(e,s,t,n);return}o=D(e,n),a[o.key]=a[o.key]||[],w(o.key,o.modifiers,{type:o.action},r,e,i),a[o.key][r?"unshift":"push"]({callback:t,modifiers:o.modifiers,action:o.action,seq:r,level:i,combo:e})}function H(e,t,n){for(var r=0;r<e.length;++r)P(e[r],t,n)}var r={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},i={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},s={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},o={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},u,a={},f={},l={},c,h=!1,p=!1,d=!1;for(var v=1;v<20;++v)r[111+v]="f"+v;for(v=0;v<=9;++v)r[v+96]=v;m(t,"keypress",C),m(t,"keydown",C),m(t,"keyup",C);var B={bind:function(e,t,n){return e=e instanceof Array?e:[e],H(e,t,n),this},unbind:function(e,t){return B.bind(e,function(){},t)},trigger:function(e,t){return f[e+":"+t]&&f[e+":"+t]({},e),this},reset:function(){return a={},f={},this},stopCallback:function(e,t){return(" "+t.className+" ").indexOf(" mousetrap ")>-1?!1:t.tagName=="INPUT"||t.tagName=="SELECT"||t.tagName=="TEXTAREA"||t.isContentEditable},bindEventsTo:function(e){e==n&&(e=t),m(e,"keypress",C),m(e,"keydown",C),m(e,"keyup",C)},handleKey:N};e.Mousetrap=B,typeof define=="function"&&define.amd&&define("deps/mousetrap",B)}(window,document),Mousetrap=function(e){var t={},n=e.stopCallback;return e.stopCallback=function(e,r,i,s){return t[i]||t[s]?!1:n(e,r,i)},e.bindGlobal=function(n,r,i){e.bind(n,r,i);if(n instanceof Array){for(var s=0;s<n.length;s++)t[n[s]]=!0;return}t[n]=!0},e}(Mousetrap),define("helper.ace",["jquery","deps/mousetrap"],function(e,t){Headway.aceEditors={};var n={init:function(){window.onunload=function(){e.each(Headway.aceEditors,function(e,t){typeof t.window!="undefined"&&!t.window.closed&&t.window.close()})}},showEditor:function(e,t,r,i){if(typeof Headway.aceEditors[e]!="undefined"&&!Headway.aceEditors[e].window.closed)return Headway.aceEditors[e].window.focus(),Headway.aceEditors[e];var s={width:750,height:550};return s.left=screen.width/2-s.width/2,s.top=screen.height/2-s.height/2,Headway.aceEditors[e]={window:window.open(Headway.homeURL+"/?headway-trigger=ace-editor&mode="+t,e,"width="+s.width+",height="+s.height+",top="+s.top+",left="+s.left,!0)},Headway.aceEditors[e].window.focus(),n.bindEditor(e,t,r,i),Headway.aceEditors[e]},bindEditor:function(n,r,i,s){var o=Headway.aceEditors[n].window;return e(o).bind("load",function(){t.bindEventsTo(o.document);var u=o.ace,a=Headway.headwayURL+"/library/visual-editor/"+Headway.scriptFolder+"/deps/ace/";u.config.set("basePath",a),u.config.set("modePath",a),u.config.set("workerPath",a),u.config.set("themePath",a),Headway.aceEditors[n].editor=u.edit(e(o.document).contents().find("#ace-editor").get(0)),Headway.aceEditors[n].editorSession=Headway.aceEditors[n].editor.getSession(),Headway.aceEditors[n].editor.setTheme("ace/theme/textmate"),Headway.aceEditors[n].editorSession.setMode("ace/mode/"+r),Headway.aceEditors[n].editor.setShowPrintMargin(!1),Headway.aceEditors[n].editorSession.setUseWrapMode(!0),Headway.aceEditors[n].editor.setValue(i),Headway.aceEditors[n].editor.gotoLine(0),Headway.aceEditors[n].editor.focus(),Headway.aceEditors[n].editorSession.on("change",function(e){return s(Headway.aceEditors[n].editor)})})}};return n.init(),n}),function($){function Colorpicker(){this._mainDivId=mainDivId,this._colorDivClass=colorDivClass,this._defaults={showAnim:!0,duration:200,color:"FFFFFF",allowNull:!1,realtime:!0,invertControls:!0,controlStyle:"simple",swatches:!0,alpha:!1,alphaHex:!1,beforeShow:null,onClose:null,onSelect:null,onAddSwatch:null,onDeleteSwatch:null}}function extendRemove(e,t){$.extend(e,t);for(var n in t)if(t[n]==null||t[n]==undefined)e[n]=t[n];return e}function isset(e){return e!==undefined}var PROP_NAME="css3colorpicker",mainDivId="css3colorpicker-div",colorDivClass="color",cpDiv=$('<div id="'+mainDivId+'"></div>');cpDiv.swatchContainer=$('<div id="'+mainDivId+'-swatchContainer"></div>'),cpDiv.swatches=$('<div id="'+mainDivId+'-swatches"></div>'),cpDiv.addSwatchButton=$('<div id="'+mainDivId+'-add-swatch-button" title="Add Current Color to Swatches" class="tooltip"></div>'),cpDiv.colorDiv=$('<div id="'+mainDivId+'-color" title="Choose Color and Close Color Picker" class="tooltip"></div>'),cpDiv.oldColorDiv=$('<div id="'+mainDivId+'-colorOld" title="Revert to Previous Color" class="tooltip"></div>'),cpDiv.d1Div=$('<div id="'+mainDivId+'-1d"></div>'),cpDiv.d1Div.control=$('<div id="'+mainDivId+'-1dControl"></div>'),cpDiv.d1Div.colorDiv=$('<div id="'+mainDivId+'-1dColor"></div>'),cpDiv.d1Div.gradientDiv=$('<div id="'+mainDivId+'-1dGradient"></div>'),cpDiv.d2Div=$('<div id="'+mainDivId+'-2d"></div>'),cpDiv.d2Div.control=$('<div id="'+mainDivId+'-2dControl"></div>'),cpDiv.d2Div.colorDiv=$('<div id="'+mainDivId+'-2dColor"></div>'),cpDiv.d2Div.gradientDiv=$('<div id="'+mainDivId+'-2dGradient"></div>'),cpDiv.alphaDiv=$('<div id="'+mainDivId+'-alpha"></div>'),cpDiv.alphaDiv.control=$('<div id="'+mainDivId+'-alphaControl"></div>'),cpDiv.inputContainerHSB=$('<ul id="'+mainDivId+'-inputContainer-hsv" class="css3colorpicker-inputContainer"></ul>'),cpDiv.inputContainerRGBA=$('<ul id="'+mainDivId+'-inputContainer-rgba" class="css3colorpicker-inputContainer"></ul>'),cpDiv.inputContainerHex=$('<ul id="'+mainDivId+'-inputContainer-hex" class="css3colorpicker-inputContainer"></ul>'),cpDiv.inputs={h:$('<input type="text" data-mode="h" id="'+mainDivId+'-h"/>'),s:$('<input type="text" data-mode="s" id="'+mainDivId+'-s"/>'),v:$('<input type="text" data-mode="v" id="'+mainDivId+'-v"/>'),r:$('<input type="text" id="'+mainDivId+'-r"/>'),g:$('<input type="text" id="'+mainDivId+'-g"/>'),b:$('<input type="text" id="'+mainDivId+'-b"/>'),a:$('<input type="text" id="'+mainDivId+'-a"/>'),hex:$('<input type="text" id="'+mainDivId+'-hex" maxlength="8" />')},cpDiv.append($('<div id="'+mainDivId+'-container"></div>').append($('<div id="'+mainDivId+'-colorContainer"></div>').append(cpDiv.colorDiv,cpDiv.oldColorDiv),cpDiv.d1Div.append(cpDiv.d1Div.colorDiv,cpDiv.d1Div.gradientDiv,cpDiv.d1Div.control),cpDiv.d2Div.append(cpDiv.d2Div.colorDiv,cpDiv.d2Div.gradientDiv,cpDiv.d2Div.control),cpDiv.alphaDiv.append(cpDiv.alphaDiv.control),cpDiv.inputContainerHSB.append($("<li>H <span>&deg;</span></li>").append(cpDiv.inputs.h),$("<li>S <span>%</span></li>").append(cpDiv.inputs.s),$("<li>B <span>%</span></li>").append(cpDiv.inputs.v)),cpDiv.inputContainerRGBA.append($("<li>R </li>").append(cpDiv.inputs.r),$("<li>G </li>").append(cpDiv.inputs.g),$("<li>B </li>").append(cpDiv.inputs.b),$('<li class="alpha">A <span>%</span></li>').append(cpDiv.inputs.a)),cpDiv.inputContainerHex.append($("<li># </li>").append(cpDiv.inputs.hex))),cpDiv.swatchContainer.append(cpDiv.swatches,cpDiv.addSwatchButton)),$.extend(Colorpicker.prototype,{cpDiv:cpDiv,mode:"h",markerClassName:"hasColorpicker",controlsClassPrefix:"controls-",minLum:50,swatches:[],swatchLimit:15,setDefaults:function(e){return extendRemove(this._defaults,e||{}),this},_setMode:function(e){["h","s","v"].indexOf(e)>=0&&(this.cpDiv.removeClass("mode-"+this.mode),this.cpDiv.addClass("mode-"+e),this.mode=e,$.colorpicker._updateMaps(),$.colorpicker._updateControls())},refresh:function(){return this._updateColorpicker(!0),this},color:function(e){this.r=0,this.g=0,this.b=0,this.a=1,this.h=0,this.s=0,this.v=0,this.l=0,this.hex="",this.hexa="",this.rgb="rgb(0,0,0)",this.rgba="rgba(0,0,0,1)",this._a=1,this._h=0,this._s=0,this._v=0,this.setRgb=function(e,t,n,r){this.isNull=!1,this.r=Math.max(0,Math.min(255,Math.round(e))),this.g=Math.max(0,Math.min(255,Math.round(t))),this.b=Math.max(0,Math.min(255,Math.round(n))),this._a=isset(r)?Math.max(0,Math.min(100,parseFloat(r))):this._a||100,this.a=Math.round(this._a);var i=$.colorpicker.rgbToHsv(this);this._h=i.h,this._s=i.s,this._v=i.v,this.h=Math.round(i.h),this.s=Math.round(i.s),this.v=Math.round(i.v),this.l=$.colorpicker.rgbToLum(this),this.hex=$.colorpicker.rgbToHex(this),this.hexa=$.colorpicker.rgbToHex(this),this.rgb="rgb("+this.r+","+this.g+","+this.b+")",this.rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/100+")"},this.setHsv=function(e,t,n,r){this.isNull=!1,this._h=Math.max(0,Math.min(360,parseFloat(e))),this._s=Math.max(0,Math.min(100,parseFloat(t))),this._v=Math.max(0,Math.min(100,parseFloat(n))),this.h=Math.round(this._h),this.s=Math.round(this._s),this.v=Math.round(this._v),this._a=isset(r)?Math.max(0,Math.min(100,parseFloat(r))):this._a||100,this.a=Math.round(this._a);var i=$.colorpicker.hsvToRgb(this);this.r=Math.round(i.r),this.g=Math.round(i.g),this.b=Math.round(i.b),this.l=$.colorpicker.rgbToLum(this),this.hex=$.colorpicker.rgbToHex(i),this.hexa=$.colorpicker.rgbToHex(i),this.rgb="rgb("+this.r+","+this.g+","+this.b+")",this.rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/100+")"},this.setHex=function(e){this.isNull=!1,this.hexa=$.colorpicker.validateHex(e),this.hex=$.colorpicker.validateHex(e);var t=$.colorpicker.hexToRgb(this.hexa);this.r=t.r,this.g=t.g,this.b=t.b,this._a=t.a,this.a=Math.round(t.a);var n=$.colorpicker.rgbToHsv(t);this._h=n.h,this._s=n.s,this._v=n.v,this.h=Math.round(n.h),this.s=Math.round(n.s),this.v=Math.round(n.v),this.l=$.colorpicker.rgbToLum(this),this.rgb="rgb("+this.r+","+this.g+","+this.b+")",this.rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/100+")"};if(e)if("hexa"in e)this.setHex(e.hexa);else if("hex"in e)this.setHex(e.hex);else if("rgb"in e){var t=e.rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(0?\.?\d+))?\)/i);if(t){var n=100;typeof t[4]!="undefined"&&(n*=t[4]),this.setRgb(t[1],t[2],t[3],n)}}else"r"in e?this.setRgb(e.r,e.g,e.b,e.a):"h"in e&&this.setHsv(e.h,e.s,e.v,e.a);return this},_attachColorpicker:function(target,settings){var input=$(target);if(input.hasClass(this.markerClassName))return;input.addClass(this._colorDivClass).addClass(this.markerClassName),target.id||(this.uuid+=1,target.id="cp"+this.uuid);var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("color:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var inst=this._newInst(input);inst.settings=$.extend({},settings||{},inlineSettings||{}),this._get(inst,"alpha")?input.addClass("alpha")[inst.settings.alphaHex?"addClass":"removeClass"]("alphaHex"):input.removeClass("alpha").removeClass("alphaHex"),this._setColor(inst,input.val()||input.data("color")||this._get(inst,"color"),!0);var swatches=this._get(inst,"swatches");swatches&&this.addSwatch(swatches),input.is("input")&&input.focus(function(){$.colorpicker._showColorpicker(target)}).keyup(function(){$.colorpicker._setColor(inst,this.value),$.colorpicker._updateColorpicker()}).bind("setData.colorpicker",function(e,t,n){inst.settings[t]=n}).bind("getData.colorpicker",function(e,t){return $.colorpicker._get(inst,t)}),input.click(function(){$.colorpicker._showColorpicker(target)}).bind("refresh",function(){var e=$(this),t=$.colorpicker._getInst(this);$.colorpicker._setColor(t,input.val()||input.data("color")||$.colorpicker._get(t,"color").hexa,!0),$.colorpicker._updateColorpicker()})},_setColor:function(e,t,n){if(!t||t.isNull)t=new $.colorpicker.color({hex:this._defaults.color}),t.isNull=this._get(e,"allowNull");if(typeof t=="string"||typeof t=="number")t.match(/^rgb/)?t=new $.colorpicker.color({rgb:t}):t=new $.colorpicker.color({hex:t});e.settings.color=new $.colorpicker.color({hex:t.hexa}),this._isDragging||(e.color=new $.colorpicker.color({hex:t.hexa})),e.color.isNull=e.settings.color.isNull=t.isNull,this._updateTarget(e,n);if(!this._isLastColor(t)){e.lastColor=t.isNull?null:t.hexa;var r=this._get(e,"onSelect");typeof r=="function"&&r(t.isNull?null:t,e)}},_newInst:function(e){var t=e[0].id.replace(/([^F-Za-z0-9_-])/g,"\\\\$1"),n={id:t,input:e,cpDiv:cpDiv,color:new $.colorpicker.color,lastColor:null};return e.data(PROP_NAME,n),n},_checkExternalClick:function(e){if(!$.colorpicker._curInst)return;var t=$(e.target);t[0].id!=$.colorpicker._mainDivId&&!t.is('label[for="'+$.colorpicker._curInst.input[0].id+'"]')&&t.parents("#"+$.colorpicker._mainDivId).length==0&&!t.hasClass($.colorpicker.markerClassName)&&$.colorpicker._hideColorpicker()},_optionColorpicker:function(e,t,n){var r=this._getInst(e),i=!1;if(arguments.length==2&&typeof t=="string")return t=="defaults"?$.extend({},$.colorpicker._defaults):r?t=="all"?$.extend({},r.settings):this._get(r,t):null;r&&this._curInst==r&&(this._hideColorpicker(e,!0),i=!0);var s=t||{};if(typeof t=="string"){s={};if(r&&t=="color"&&isset(n)){var o=n?new this.color({hex:n}):new this.color({hex:this._defaults.color});o.isNull=!n&&this._get(r,"allowNull"),n=o,this._setColor(r,n,!0),this.addSwatch(n,!0)}t=="swatches"&&n&&this.addSwatch(n),s[t]=n}r&&extendRemove(r.settings,s),i&&this._showColorpicker(e,!0)},_showColorpicker:function(e,t){e=e.target||e;var n=$(e);if(e.disabled)return;var r=$.colorpicker._getInst(e);this._curInst&&this._curInst!=r&&(this._triggerOnClose(),this.cpDiv.stop(!0,!0)),this._curInst=r,r.lastColor=r.color.isNull?null:r.color.hexa;var i=this._get(r,"alpha");$.colorpicker._updateColorpicker(),r.input.addClass("selected");var s=!t&&this._get(r,"showAnim"),o=this._get(r,"duration"),u=function(){$.colorpicker.cpDiv.addClass("visible")},a=$.colorpicker._get(r,"controlStyle").split(/\s+/);for(var f=0;f<a.length;f++)cpDiv.addClass(this.controlsClassPrefix+a[f]);cpDiv[i?"addClass":"removeClass"]("alphaOn"),cpDiv[this._get(r,"swatches")?"addClass":"removeClass"]("swatchesOn"),this.cpDiv.oldColorDiv.data("color",r.color.isNull?null:r.color.hexa).css("background-color",r.color[i?"rgba":"rgb"]);var l=this._get(r,"beforeShow");typeof l=="function"&&l(r.input,r),this._colorpickerShowing=!0,this.cpDiv[s?"fadeIn":"show"](s?o:null,u),s||u(),this._positionColorpicker()},_positionColorpicker:function(){var e=$.colorpicker._curInst.input,t=this.cpDiv,n=e.offset(),r=t.outerWidth(),i=t.defaultHeight+(this._get(this._getInst(e),"alpha")?t.alphaHeight:0)+(this._get(this._getInst(e),"swatches")?t.swatchHeight:0),s=$(window).width(),o=$(window).height(),u=10;i+=u,n.left+=e.outerWidth()+u,n.top+i>o&&(n.top=o-i),n.left+r>s&&(n.left=s-r),t.css({top:0,left:0}).offset(n)},_hideColorpicker:function(e,t){var n=this._curInst;if(!n||e&&n!=this._getInst(e))return;var r=function(){$.colorpicker._triggerOnClose(),$.colorpicker._curInst=null};if(this._colorpickerShowing){var i=!t&&this._get(n,"showAnim"),s=this._get(n,"duration");this.cpDiv[i?"fadeOut":"hide"](i?s:null,r),i||r(),this.cpDiv.removeClass("visible"),this._colorpickerShowing=!1;var o=this._get(n,"onClose");typeof o=="function"&&o(n.color,n)}else r()},_triggerOnClose:function(){var e=this._curInst;if(!e)return;e.input.removeClass("selected"),$.colorpicker.addSwatch(e.color,!0),this._setColor(e,e.color),cpDiv.removeClass(this.controlsClassPrefix+"invert");var t=$.colorpicker._get(e,"controlStyle").split(/\s+/);for(var n=0;n<t.length;n++)cpDiv.removeClass(this.controlsClassPrefix+t[n])},_updateColorpicker:function(e){var t=this._curInst;if(!t)return;var n=this._get(t,"alpha");this.cpDiv.colorDiv.data("color",t.color.isNull?null:t.color.hexa).css("background-color",t.color[n?"rgba":"rgb"]),cpDiv.d2Div.control.css("background-color",t.color.rgb),$.colorpicker._updateInputs(e),$.colorpicker._updateMaps(),$.colorpicker._updateControls(),this._get(t,"realtime")&&this._setColor(t,t.color,e)},_updateTarget:function(e,t){var n=this._get(e,"alpha"),r=this._get(e,"alphaHex");e.color.isNull?e.input.parent().addClass("color-null"):e.input.css({backgroundColor:e.color[n?"rgba":"rgb"],color:e.color.l<$.colorpicker.minLum?"#fff":"#000"}).parent().removeClass("color-null"),e.input.data("color",e.color.isNull?null:e.color.hexa);if(t||!e.input.is(":focus")){var i=e.input.val()||"";e.color.isNull?e.input.val(""):e.input.val(i.indexOf("#")>=0?"#"+e.color[r?"hexa":"hex"]:e.color[r?"hexa":"hex"]),i!=e.input.val()&&e.input.trigger("change")}},_updateInputs:function(e){var t=this._curInst;if(!t)return;var n=this._get(t,"alphaHex");for(var r in this.cpDiv.inputs)r&&isset(t.color[r])&&(e||!this.cpDiv.inputs[r].is(":focus"))&&(r=="hex"?this.cpDiv.inputs[r].val(t.color.isNull?"":t.color[n?"hexa":r]):this.cpDiv.inputs[r].val(t.color[r]))},_updateMaps:function(){var e=this._curInst;if(!e)return;this.cpDiv.alphaDiv.css("background-color",e.color.rgb);switch(this.mode){case"h":this.cpDiv.d1Div.gradientDiv.css("background",""),this.cpDiv.d2Div.colorDiv.css("background-color",(new this.color({h:e.color.h,s:100,v:100})).rgb),this.cpDiv.d1Div.gradientDiv.css("opacity",1-e.color.v/100),this.cpDiv.d1Div.colorDiv.css("opacity",e.color.s/100),this.cpDiv.d2Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.gradientDiv.css("opacity",1);break;case"s":this.cpDiv.d1Div.colorDiv.css("background-color",(new this.color({h:e.color.h,s:100,v:100})).rgb),this.cpDiv.d1Div.gradientDiv.css("opacity",1-e.color.v/100),this.cpDiv.d1Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.colorDiv.css("opacity",e.color.s/100),this.cpDiv.d2Div.gradientDiv.css("opacity",1);break;case"v":this.cpDiv.d1Div.gradientDiv.css("background",""),this.cpDiv.d1Div.colorDiv.css("background-color",(new this.color({h:e.color.h,s:e.color.s,v:100})).rgb),this.cpDiv.d1Div.gradientDiv.css("opacity",1),this.cpDiv.d1Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.colorDiv.css("opacity",1),this.cpDiv.d2Div.gradientDiv.css("opacity",1-e.color.v/100)}$.colorpicker._updateControl()},_updateControls:function(){if(!this._curInst||this._isDragging)return;var e=this._curInst,t,n,r,i;switch(this.mode){case"h":t=e.color._s*255/100,n=255-e.color._v*255/100,r=255-e.color._h*255/360,i=e.color._a*255/100;break;case"s":t=e.color._h*255/360,n=255-e.color._v*255/100,r=255-e.color._s*255/100,i=e.color._a*255/100;break;case"v":t=e.color._h*255/360,n=255-e.color._s*255/100,r=255-e.color._v*255/100,i=e.color._a*255/100}$.colorpicker._moveControl1d(r,!0),$.colorpicker._moveControl2d(t,n,!0),$.colorpicker._moveControlAlpha(i,!0)},_moveControl1d:function(e,t){if(!$.colorpicker._curInst)return;var n=$.colorpicker._curInst;cpDiv.d1Div.control.css({top:Math.max(0,Math.min(255,Math.round(e)))+"px"});if(!t){switch($.colorpicker.mode){case"h":e=360-e*360/256;break;case"s":case"v":e=100-e*100/256}n.color["_"+$.colorpicker.mode]=e,n.color.setHsv(n.color._h,n.color._s,n.color._v,n.color.a),$.colorpicker._updateColorpicker(!0)}},_moveControl2d:function(e,t,n){if(!$.colorpicker._curInst)return;var r=$.colorpicker._curInst;cpDiv.d2Div.control.css({left:Math.max(0,Math.min(255,Math.round(e)))+"px",top:Math.max(0,Math.min(255,Math.round(t)))+"px"});if(!n){switch($.colorpicker.mode){case"h":e=e*100/256,t=100-t*100/256,r.color._s=e,r.color._v=t;break;case"s":case"v":e=e*360/256,t=100-t*100/256,r.color._h=e,r.color[$.colorpicker.mode=="s"?"_v":"_s"]=t}r.color.setHsv(r.color._h,r.color._s,r.color._v,r.color.a),$.colorpicker._updateColorpicker(!0)}},_moveControlAlpha:function(e,t){if(!$.colorpicker._curInst)return;var n=$.colorpicker._curInst;cpDiv.alphaDiv.control.css({left:Math.max(0,Math.min(255,parseInt(e)))+"px"}),t||(e*=.390625,n.color.a=e,n.color.setHsv(n.color._h,n.color._s,n.color._v,n.color.a),$.colorpicker._updateColorpicker(!0))},_mousemoveControl1d:function(e){return $.colorpicker._moveControl1d(e.pageY-$.colorpicker.cpDiv.d1Div.offset().top),e.preventDefault(),!1},_mousemoveControl2d:function(e){var t=$.colorpicker.cpDiv.d2Div.offset();return $.colorpicker._moveControl2d(e.pageX-t.left,e.pageY-t.top),e.preventDefault(),!1},_mousemoveControlAlpha:function(e){return $.colorpicker._moveControlAlpha(e.pageX-$.colorpicker.cpDiv.alphaDiv.offset().left),e.preventDefault(),!1},_updateControl:function(){if(!this._curInst||!$.colorpicker._get(this._curInst,"invertControls"))return!1;this._curInst.color.l<$.colorpicker.minLum?cpDiv.addClass(this.controlsClassPrefix+"invert"):cpDiv.removeClass(this.controlsClassPrefix+"invert")},_submit:function(e,t){var n=this._curInst;if(!n)return;if(!isset(e))var e=n.color,r=e.isNull&&this._get(n,"allowNull");else if(!e){var r=this._get(n,"allowNull");e=this._defaults.color}typeof e=="string"||typeof e=="number"?(e=new this.color({hex:e}),this._get(n,"alpha")||(e.a=e._a=100)):e=new this.color({hex:e[this._get(n,"alpha")?"hexa":"hex"]}),e.isNull=r,this._isCurrentColor(e)?($.colorpicker._hideColorpicker(),t=!0):($.colorpicker._setColor(n,e,!0),$.colorpicker._updateColorpicker(!0)),$.colorpicker.addSwatch(e,t)},_isCurrentColor:function(e){var t=this._curInst;if(!t)return;if(!e||e.isNull)return t.settings.color.isNull&&t.color.isNull;if(typeof e=="string"||typeof e=="number")e=new this.color({hex:e});return this._get(t,"alpha")?e.hexa==t.settings.color.hexa&&e.hexa==t.color.hexa:e.hex==t.settings.color.hex&&e.hex==t.color.hex},_isLastColor:function(e){var t=this._curInst;if(!t)return;if(!e||e.isNull)return t.lastColor===null;var n=new this.color({hex:t.lastColor});if(typeof e=="string"||typeof e=="number")e=new this.color({hex:e});return this._get(t,"alpha")?e.hexa==n.hexa:e.hex==n.hex},addSwatch:function(e,t){var n=this._curInst;if(n&&!this._get(n,"swatches")||!e||e.isNull)return!1;if(typeof e=="string"||typeof e=="number")e=new this.color({hex:e});if(e.hexa){var r=this.swatches.indexOf(e.hexa);if(r<0){this.swatches.unshift(e.hexa);var i=$("<div/>").addClass("swatch").attr("title","Right-click to delete swatch").data("color",e.hexa).css({backgroundColor:e.rgb,width:0,opacity:0}).append($("<div/>").css("background",e.rgba));window.setTimeout(function(){i.css({width:"",opacity:1})},0),this.cpDiv.swatches.prepend(i)}else{if(t)return!1;this.swatches.splice(r,1),this.swatches.unshift(e.hexa),this.cpDiv.swatches.prepend(this.cpDiv.swatches.children().eq(r))}this.swatchLimit&&(this.swatches=this.swatches.slice(0,this.swatchLimit));var s=n?this._get(n,"onAddSwatch"):this._defaults.onAddSwatch;typeof s=="function"&&s(e,this.swatches)}else if(e.length&&e[0])for(var o=e.length-1;o>=0;o--)this.addSwatch(e[o]);return this},deleteSwatch:function(e){var e=$(e);if(typeof e!="object"||!e||!e.length)return!1;this.swatches.splice(this.swatches.indexOf(e.data("color")),1);var t=this._curInst,n=t?this._get(t,"onDeleteSwatch"):this._defaults.onDeleteSwatch;typeof n=="function"&&n(e.data("color"),this.swatches),e.remove()},clearSwatches:function(){return this.swatches=[],this.cpDiv.swatches.empty(),this},_useSwatch:function(e){return $.colorpicker._setColor($.colorpicker._curInst,$(this).data("color")),$.colorpicker._updateColorpicker(),e.preventDefault(),!1},_get:function(e,t){return isset(e.settings[t])?e.settings[t]:this._defaults[t]},_getInst:function(e){try{return $(e).data(PROP_NAME)}catch(t){throw"Missing instance data for this colorpicker"}},hexToRgb:function(e){e=this.validateHex(e);var t="00",n="00",r="00";return e.length==6&&(a="FF",t=e.substring(0,2),n=e.substring(2,4),r=e.substring(4,6)),e.length==8&&(a=e.substring(0,2),t=e.substring(2,4),n=e.substring(4,6),r=e.substring(6,8)),{r:this.hexToInt(t),g:this.hexToInt(n),b:this.hexToInt(r),a:100*this.hexToInt(a)/255}},_hexRegExp:/[a-f0-9]{0,2}([a-f0-9]{6})|[a-f0-9]?([a-f0-9]{3})/i,_hexaRegExp:/([a-f0-9]{8}|[a-f0-9]{6}|[a-f0-9]{4}|[a-f0-9]{3})/i,validateHex:function(e){return e?(e=(""+e).match(this._hexaRegExp),e=e?e[1]||e[2]:"00000000",e=e.toUpperCase(),e.length==3&&(e=e.split(""),e=[e[0],e[0],e[1],e[1],e[2],e[2]].join("")),e.length==4&&(e=e.split(""),e=[e[0],e[0],e[1],e[1],e[2],e[2],e[3],e[3]].join("")),e.length!=8&&(e="FF"+e),e.substring(0,2)=="FF"&&(e=e.substring(2,8)),e):!1},rgbToHex:function(e){var t=this.intToHex(Math.round(e.a*255/100));t=="FF"&&(t="");var n=this.intToHex(e.r)+this.intToHex(e.g)+this.intToHex(e.b);return t+n},intToHex:function(e){var t=parseInt(e).toString(16);return t.length==1&&(t="0"+t),t.toUpperCase()},hexToInt:function(e){return parseInt(e,16)},rgbToLum:function(e){return Math.abs(Math.round((.2126*e.r+.7152*e.g+.0722*e.b)/2.55))},rgbToHsv:function(e){var t=e.r/255,n=e.g/255,r=e.b/255;hsv={h:0,s:0,v:0,a:isset(e._a)?e._a:e.a};var i=0,s=0;return t>=n&&t>=r?(s=t,i=n>r?r:n):n>=r&&n>=t?(s=n,i=t>r?r:t):(s=r,i=n>t?t:n),hsv.v=s,hsv.s=s?(s-i)/s:0,hsv.s?(delta=s-i,t==s?hsv.h=(n-r)/delta:n==s?hsv.h=2+(r-t)/delta:hsv.h=4+(t-n)/delta,hsv.h=hsv.h*60,hsv.h<0&&(hsv.h+=360)):hsv.h=0,hsv.s=Math.abs(hsv.s*100),hsv.v=Math.abs(hsv.v*100),hsv},hsvToRgb:function(e){rgb={r:0,g:0,b:0,a:isset(e._a)?e._a:e.a};var t=isset(e._h)?e._h:e.h,n=isset(e._s)?e._s:e.s,r=isset(e._v)?e._v:e.v;if(n==0)r==0?rgb.r=rgb.g=rgb.b=0:rgb.r=rgb.g=rgb.b=Math.abs(r*255/100);else{t==360&&(t=0),t/=60,n/=100,r/=100;var i=parseInt(t),s=t-i,o=r*(1-n),u=r*(1-n*s),a=r*(1-n*(1-s));switch(i){case 0:rgb.r=r,rgb.g=a,rgb.b=o;break;case 1:rgb.r=u,rgb.g=r,rgb.b=o;break;case 2:rgb.r=o,rgb.g=r,rgb.b=a;break;case 3:rgb.r=o,rgb.g=u,rgb.b=r;break;case 4:rgb.r=a,rgb.g=o,rgb.b=r;break;case 5:rgb.r=r,rgb.g=o,rgb.b=u}rgb.r=Math.abs(Math.round(rgb.r*255)),rgb.g=Math.abs(Math.round(rgb.g*255)),rgb.b=Math.abs(Math.round(rgb.b*255))}return rgb}}),$.fn.colorpicker=function(e){if(!this.length)return this;if(!$.colorpicker.initialized){$(document).mousedown($.colorpicker._checkExternalClick).find("body").append($.colorpicker.cpDiv.hide()).find("#"+mainDivId+"-"+$.colorpicker.mode).closest("li").addClass("selected");for(var t in cpDiv.inputs)if(t){var n=$(cpDiv.inputs[t]);n.data("mode")&&n.focus(function(){var e=$(this);e.closest("li").addClass("selected").siblings(".selected").removeClass("selected"),$.colorpicker._setMode(e.data("mode"))}).closest("li").click(function(){$(this).find("input").focus()}),n.blur(function(){$.colorpicker._updateInputs()});switch(t){case"h":case"s":case"v":case"a":n.keydown(function(e){if(!$.colorpicker._curInst)return;var t=$(this),n=$.colorpicker._curInst;switch(e.keyCode){case 38:case 40:t.val(parseInt(t.val())+(e.shiftKey?10:1)*(e.keyCode==40?-1:1)),n.color.setHsv(cpDiv.inputs.h.val(),cpDiv.inputs.s.val(),cpDiv.inputs.v.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker(!0);break;case 13:$.colorpicker._submit();break;default:return}}).keyup(function(){if(!$.colorpicker._curInst)return;$.colorpicker._curInst.color.setHsv(cpDiv.inputs.h.val(),cpDiv.inputs.s.val(),cpDiv.inputs.v.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker()});break;case"r":case"g":case"b":n.keydown(function(e){if(!$.colorpicker._curInst)return;var t=$(this),n=$.colorpicker._curInst;switch(e.keyCode){case 38:case 40:t.val(parseInt(t.val())+(e.shiftKey?10:1)*(e.keyCode==40?-1:1)),n.color.setRgb(cpDiv.inputs.r.val(),cpDiv.inputs.g.val(),cpDiv.inputs.b.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker(!0);break;case 13:$.colorpicker._submit();break;default:return}}).keyup(function(){if(!$.colorpicker._curInst)return;$.colorpicker._curInst.color.setRgb(cpDiv.inputs.r.val(),cpDiv.inputs.g.val(),cpDiv.inputs.b.val(),cpDiv.inputs.a.val()),$.colorpicker._updateColorpicker()});break;case"hex":n.keydown(function(e){if(!$.colorpicker._curInst)return;switch(e.keyCode){case 13:$.colorpicker._submit();break;default:return}}).keyup(function(){var e=$.colorpicker._curInst;if(!e)return;cpDiv.inputs.hex.val()?(e.color.setHex(cpDiv.inputs.hex.val()),$.colorpicker._updateColorpicker()):(e.color=new $.colorpicker.color({hex:$.colorpicker._defaults.color}),e.color.isNull=$.colorpicker._get(e,"allowNull"),$.colorpicker._updateColorpicker())})}}cpDiv.addSwatchButton.mousedown(function(e){$.colorpicker.addSwatch($.colorpicker._curInst.color)}),cpDiv.swatches.delegate(".swatch","click",function(e){var t=$.proxy($.colorpicker._useSwatch,this);t(e),e.preventDefault()}),cpDiv.swatches.delegate(".swatch","contextmenu",function(e){return confirm("Are you sure you wish to delete this swatch?")&&$.colorpicker.deleteSwatch(this),e.preventDefault(),!1}),cpDiv.oldColorDiv.mousedown($.colorpicker._useSwatch),cpDiv.colorDiv.mousedown(function(e){return $.colorpicker._submit($(this).data("color")),e.preventDefault(),!1}),cpDiv.defaultHeight=cpDiv.outerHeight(),cpDiv.addClass("swatchesOn"),cpDiv.swatchHeight=cpDiv.outerHeight()-cpDiv.defaultHeight,cpDiv.removeClass("swatchesOn").addClass("alphaOn"),cpDiv.alphaHeight=cpDiv.outerHeight()-cpDiv.defaultHeight,cpDiv.removeClass("alphaOn"),cpDiv.d1Div.mousedown(function(e){return $.colorpicker._isDragging=!0,$.colorpicker._mousemoveControl1d(e),$(document).bind("mousemove",$.colorpicker._mousemoveControl1d),!1}),cpDiv.d2Div.mousedown(function(e){return $.colorpicker._isDragging=!0,$.colorpicker._mousemoveControl2d(e),$(document).bind("mousemove",$.colorpicker._mousemoveControl2d),!1}),cpDiv.alphaDiv.mousedown(function(e){return $.colorpicker._isDragging=!0,$.colorpicker._mousemoveControlAlpha(e),$(document).bind("mousemove",$.colorpicker._mousemoveControlAlpha),!1}),$(document).mouseup(function(){return $(document).unbind("mousemove",$.colorpicker._mousemoveControl1d).unbind("mousemove",$.colorpicker._mousemoveControl2d).unbind("mousemove",$.colorpicker._mousemoveControlAlpha),$.colorpicker._isDragging=!1,!1}),$(window).resize(function(){$.colorpicker._colorpickerShowing&&$.colorpicker._positionColorpicker()}),$.colorpicker._setMode($.colorpicker.mode),$.colorpicker.initialized=!0}var r=Array.prototype.slice.call(arguments,1);return e=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.colorpicker["_"+e+"Colorpicker"].apply($.colorpicker,[this[0]].concat(r)):this.each(function(){typeof e=="string"?$.colorpicker["_"+e+"Colorpicker"].apply($.colorpicker,[this].concat(r)):$.colorpicker._attachColorpicker(this,e)})},$.colorpicker=new Colorpicker,$.colorpicker.initialized=!1,$.colorpicker.uuid=(new Date).getTime()}(jQuery),define("deps/colorpicker",function(){}),function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=i.toString,l=i.hasOwnProperty,c=r.forEach,h=r.map,p=r.reduce,d=r.reduceRight,v=r.filter,m=r.every,g=r.some,y=r.indexOf,b=r.lastIndexOf,w=Array.isArray,E=Object.keys,S=s.bind,x=function(e){if(e instanceof x)return e;if(!(this instanceof x))return new x(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=x),exports._=x):e._=x,x.VERSION="1.6.0";var T=x.each=x.forEach=function(e,t,r){if(e==null)return e;if(c&&e.forEach===c)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}else{var o=x.keys(e);for(var i=0,s=o.length;i<s;i++)if(t.call(r,e[o[i]],o[i],e)===n)return}return e};x.map=x.collect=function(e,t,n){var r=[];return e==null?r:h&&e.map===h?e.map(t,n):(T(e,function(e,i,s){r.push(t.call(n,e,i,s))}),r)};var N="Reduce of empty array with no initial value";x.reduce=x.foldl=x.inject=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(p&&e.reduce===p)return r&&(t=x.bind(t,r)),i?e.reduce(t,n):e.reduce(t);T(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError(N);return n},x.reduceRight=x.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduceRight===d)return r&&(t=x.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=x.keys(e);s=o.length}T(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError(N);return n},x.find=x.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},x.filter=x.select=function(e,t,n){var r=[];return e==null?r:v&&e.filter===v?e.filter(t,n):(T(e,function(e,i,s){t.call(n,e,i,s)&&r.push(e)}),r)},x.reject=function(e,t,n){return x.filter(e,x.negate(t),n)},x.every=x.all=function(e,t,r){t||(t=x.identity);var i=!0;return e==null?i:m&&e.every===m?e.every(t,r):(T(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=x.some=x.any=function(e,t,r){t||(t=x.identity);var i=!1;return e==null?i:g&&e.some===g?e.some(t,r):(T(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};x.contains=x.include=function(e,t){return e==null?!1:y&&e.indexOf===y?e.indexOf(t)!=-1:C(e,function(e){return e===t})},x.invoke=function(e,t){var n=u.call(arguments,2),r=x.isFunction(t);return x.map(e,function(e){return(r?t:e[t]).apply(e,n)})},x.pluck=function(e,t){return x.map(e,x.property(t))},x.where=function(e,t){return x.filter(e,x.matches(t))},x.findWhere=function(e,t){return x.find(e,x.matches(t))},x.max=function(e,t,n){var r=-Infinity,i=-Infinity,s,o;if(!t&&x.isArray(e))for(var u=0,a=e.length;u<a;u++)s=e[u],s>r&&(r=s);else T(e,function(e,s,u){o=t?t.call(n,e,s,u):e,o>i&&(r=e,i=o)});return r},x.min=function(e,t,n){var r=Infinity,i=Infinity,s,o;if(!t&&x.isArray(e))for(var u=0,a=e.length;u<a;u++)s=e[u],s<r&&(r=s);else T(e,function(e,s,u){o=t?t.call(n,e,s,u):e,o<i&&(r=e,i=o)});return r},x.shuffle=function(e){var t,n=0,r=[];return T(e,function(e){t=x.random(n++),r[n-1]=r[t],r[t]=e}),r},x.sample=function(e,t,n){return t==null||n?(e.length!==+e.length&&(e=x.values(e)),e[x.random(e.length-1)]):x.shuffle(e).slice(0,Math.max(0,t))};var k=function(e){return e==null?x.identity:x.isFunction(e)?e:x.property(e)};x.sortBy=function(e,t,n){return t=k(t),x.pluck(x.map(e,function(e,r,i){return{value:e,index:r,criteria:t.call(n,e,r,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index-t.index}),"value")};var L=function(e){return function(t,n,r){var i={};return n=k(n),T(t,function(s,o){var u=n.call(r,s,o,t);e(i,u,s)}),i}};x.groupBy=L(function(e,t,n){x.has(e,t)?e[t].push(n):e[t]=[n]}),x.indexBy=L(function(e,t,n){e[t]=n}),x.countBy=L(function(e,t){x.has(e,t)?e[t]++:e[t]=1}),x.sortedIndex=function(e,t,n,r){n=k(n);var i=n.call(r,t),s=0,o=e.length;while(s<o){var u=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}return s},x.toArray=function(e){return e?x.isArray(e)?u.call(e):e.length===+e.length?x.map(e,x.identity):x.values(e):[]},x.size=function(e){return e==null?0:e.length===+e.length?e.length:x.keys(e).length},x.first=x.head=x.take=function(e,t,n){return e==null?void 0:t==null||n?e[0]:t<0?[]:u.call(e,0,t)},x.initial=function(e,t,n){return u.call(e,0,e.length-(t==null||n?1:t))},x.last=function(e,t,n){return e==null?void 0:t==null||n?e[e.length-1]:u.call(e,Math.max(e.length-t,0))},x.rest=x.tail=x.drop=function(e,t,n){return u.call(e,t==null||n?1:t)},x.compact=function(e){return x.filter(e,x.identity)};var A=function(e,t,n,r){if(t&&x.every(e,x.isArray))return a.apply(r,e);for(var i=0,s=e.length;i<s;i++){var u=e[i];!x.isArray(u)&&!x.isArguments(u)?n||r.push(u):t?o.apply(r,u):A(u,t,n,r)}return r};x.flatten=function(e,t){return A(e,t,!1,[])},x.without=function(e){return x.difference(e,u.call(arguments,1))},x.partition=function(e,t,n){t=k(t);var r=[],i=[];return T(e,function(e){(t.call(n,e)?r:i).push(e)}),[r,i]},x.uniq=x.unique=function(e,t,n,r){if(e==null)return[];x.isFunction(t)&&(r=n,n=t,t=!1);var i=[],s=[];for(var o=0,u=e.length;o<u;o++){var a=e[o];n&&(a=n.call(r,a,o,e));if(t?!o||s!==a:!x.contains(s,a))t?s=a:s.push(a),i.push(e[o])}return i},x.union=function(){return x.uniq(A(arguments,!0,!0,[]))},x.intersection=function(e){var t=u.call(arguments,1);return x.filter(x.uniq(e),function(e){return x.every(t,function(t){return x.contains(t,e)})})},x.difference=function(e){var t=A(u.call(arguments,1),!0,!0,[]);return x.filter(e,function(e){return!x.contains(t,e)})},x.zip=function(){var e=x.max(x.pluck(arguments,"length").concat(0)),t=new Array(e);for(var n=0;n<e;n++)t[n]=x.pluck(arguments,""+n);return t},x.object=function(e,t){if(e==null)return{};var n={};for(var r=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},x.indexOf=function(e,t,n){if(e==null)return-1;var r=0,i=e.length;if(n){if(typeof n!="number")return r=x.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(y&&e.indexOf===y)return e.indexOf(t,n);for(;r<i;r++)if(e[r]===t)return r;return-1},x.lastIndexOf=function(e,t,n){if(e==null)return-1;var r=n!=null;if(b&&e.lastIndexOf===b)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);var i=r?n:e.length;while(i--)if(e[i]===t)return i;return-1},x.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=new Array(r);while(i<r)s[i++]=e,e+=n;return s};var O=function(){};x.bind=function(e,t){var n,r;if(S&&e.bind===S)return S.apply(e,u.call(arguments,1));if(!x.isFunction(e))throw new TypeError;return n=u.call(arguments,2),r=function(){if(this instanceof r){O.prototype=e.prototype;var i=new O;O.prototype=null;var s=e.apply(i,n.concat(u.call(arguments)));return Object(s)===s?s:i}return e.apply(t,n.concat(u.call(arguments)))}},x.partial=function(e){var t=u.call(arguments,1);return function(){var n=0,r=t.slice();for(var i=0,s=r.length;i<s;i++)r[i]===x&&(r[i]=arguments[n++]);while(n<arguments.length)r.push(arguments[n++]);return e.apply(this,r)}},x.bindAll=function(e){var t=u.call(arguments,1);if(t.length===0)throw new Error("bindAll must be passed function names");return T(t,function(t){e[t]=x.bind(e[t],e)}),e},x.memoize=function(e,t){var n={};return t||(t=x.identity),function(){var r=t.apply(this,arguments);return x.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},x.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},x.defer=function(e){return x.delay.apply(x,[e,1].concat(u.call(arguments,1)))},x.throttle=function(e,t,n){var r,i,s,o=null,u=0;n||(n={});var a=function(){u=n.leading===!1?0:x.now(),o=null,s=e.apply(r,i),r=i=null};return function(){var f=x.now();!u&&n.leading===!1&&(u=f);var l=t-(f-u);return r=this,i=arguments,l<=0||l>t?(clearTimeout(o),o=null,u=f,s=e.apply(r,i),r=i=null):!o&&n.trailing!==!1&&(o=setTimeout(a,l)),s}},x.debounce=function(e,t,n){var r,i,s,o,u,a=function(){var f=x.now()-o;f<t&&f>0?r=setTimeout(a,t-f):(r=null,n||(u=e.apply(s,i),s=i=null))};return function(){s=this,i=arguments,o=x.now();var f=n&&!r;return r||(r=setTimeout(a,t)),f&&(u=e.apply(s,i),s=i=null),u}},x.once=function(e){var t=!1,n;return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},x.wrap=function(e,t){return x.partial(t,e)},x.negate=function(e){return function(){return!e.apply(this,arguments)}},x.compose=function(){var e=arguments;return function(){var t=arguments;for(var n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},x.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},x.keys=function(e){if(!x.isObject(e))return[];if(E)return E(e);var t=[];for(var n in e)x.has(e,n)&&t.push(n);return t},x.values=function(e){var t=x.keys(e),n=t.length,r=new Array(n);for(var i=0;i<n;i++)r[i]=e[t[i]];return r},x.pairs=function(e){var t=x.keys(e),n=t.length,r=new Array(n);for(var i=0;i<n;i++)r[i]=[t[i],e[t[i]]];return r},x.invert=function(e){var t={},n=x.keys(e);for(var r=0,i=n.length;r<i;r++)t[e[n[r]]]=n[r];return t},x.functions=x.methods=function(e){var t=[];for(var n in e)x.isFunction(e[n])&&t.push(n);return t.sort()},x.extend=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]=t[n]}),e},x.pick=function(e,t,n){var i={};if(x.isFunction(t))for(var s in e){var o=e[s];t.call(n,o,s,e)&&(i[s]=o)}else{var f=a.apply(r,u.call(arguments,1));for(var l=0,c=f.length;l<c;l++){var s=f[l];s in e&&(i[s]=e[s])}}return i},x.omit=function(e,t,n){var i;return x.isFunction(t)?t=x.negate(t):(i=a.apply(r,u.call(arguments,1)),t=function(e,t){return!x.contains(i,t)}),x.pick(e,t,n)},x.defaults=function(e){return T(u.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e},x.clone=function(e){return x.isObject(e)?x.isArray(e)?e.slice():x.extend({},e):e},x.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof x&&(e=e._wrapped),t instanceof x&&(t=t._wrapped);var i=f.call(e);if(i!=f.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;var o=e.constructor,u=t.constructor;if(o!==u&&!(x.isFunction(o)&&o instanceof o&&x.isFunction(u)&&u instanceof u)&&"constructor"in e&&"constructor"in t)return!1;n.push(e),r.push(t);var a=0,l=!0;if(i=="[object Array]"){a=e.length,l=a==t.length;if(l)while(a--)if(!(l=M(e[a],t[a],n,r)))break}else{for(var c in e)if(x.has(e,c)){a++;if(!(l=x.has(t,c)&&M(e[c],t[c],n,r)))break}if(l){for(c in t)if(x.has(t,c)&&!(a--))break;l=!a}}return n.pop(),r.pop(),l};x.isEqual=function(e,t){return M(e,t,[],[])},x.isEmpty=function(e){if(e==null)return!0;if(x.isArray(e)||x.isString(e))return e.length===0;for(var t in e)if(x.has(e,t))return!1;return!0},x.isElement=function(e){return!!e&&e.nodeType===1},x.isArray=w||function(e){return f.call(e)=="[object Array]"},x.isObject=function(e){return e===Object(e)},T(["Arguments","Function","String","Number","Date","RegExp"],function(e){x["is"+e]=function(t){return f.call(t)=="[object "+e+"]"}}),x.isArguments(arguments)||(x.isArguments=function(e){return!!e&&!!x.has(e,"callee")}),typeof /./!="function"&&(x.isFunction=function(e){return typeof e=="function"}),x.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},x.isNaN=function(e){return x.isNumber(e)&&e!=+e},x.isBoolean=function(e){return e===!0||e===!1||f.call(e)=="[object Boolean]"},x.isNull=function(e){return e===null},x.isUndefined=function(e){return e===void 0},x.has=function(e,t){return l.call(e,t)},x.noConflict=function(){return e._=t,this},x.identity=function(e){return e},x.constant=function(e){return function(){return e}},x.noop=function(){},x.property=function(e){return function(t){return t[e]}},x.matches=function(e){return function(t){if(t===e)return!0;for(var n in e)if(e[n]!==t[n])return!1;return!0}},x.times=function(e,t,n){var r=Array(Math.max(0,e));for(var i=0;i<e;i++)r[i]=t.call(n,i);return r},x.random=function(e,t){return t==null&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},x.now=Date.now||function(){return(new Date).getTime()};var _={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};_.unescape=x.invert(_.escape);var D={escape:new RegExp("["+x.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+x.keys(_.unescape).join("|")+")","g")};x.each(["escape","unescape"],function(e){x[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),x.result=function(e,t){if(e==null)return void 0;var n=e[t];return x.isFunction(n)?n.call(e):n},x.mixin=function(e){T(x.functions(e),function(t){var n=x[t]=e[t];x.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(x,e))}})};var P=0;x.uniqueId=function(e){var t=++P+"";return e?e+t:t},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n","    ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;x.template=function(e,t,n){var r;n=x.defaults({},n,x.templateSettings);var i=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(j,function(e){return"\\"+B[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,x);var a=function(e){return r.call(this,e,x)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},x.chain=function(e){return x(e).chain()};var F=function(e){return this._chain?x(e).chain():e};x.mixin(x),T(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];x.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),T(["concat","join","slice"],function(e){var t=r[e];x.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),x.extend(x.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),typeof define=="function"&&define.amd&&define("underscore",[],function(){return x})}.call(this),define("util.image-uploader",["jquery","underscore"],function(e,t){openImageUploader=function(t){if(!boxExists("input-image")){isNaN(Headway.currentLayout)&&(iframePostID=0);var n={id:"input-image",title:"Select an image",description:"Upload or select an image",src:Headway.homeURL+"/?headway-trigger=media-uploader",load:function(){initiateImageUploader(t)},width:e(window).width()-200,height:e(window).height()-200,center:!0,draggable:!1,deleteWhenClosed:!0,blackOverlay:!0},r=createBox(n);e("#box-input-image").css({width:"auto",height:"auto",top:"70px",left:"70px",right:"70px",bottom:"70px",margin:0})}openBox("input-image")},initiateImageUploader=function(n){if(!e("#box-input-image iframe").length||typeof e("#box-input-image iframe")[0].contentWindow.wp=="undefined"||typeof e("#box-input-image iframe")[0].contentWindow.wp.media=="undefined"||typeof e("#box-input-image iframe")[0].contentWindow.wp.media()=="undefined")return setTimeout(function(){initiateImageUploader(n)},100);wpMedia=e("#box-input-image iframe")[0].contentWindow.wp.media;var r=parent.Headway.currentLayout.split("-");return t.first(r)=="single"&&!isNaN(t.last(r))&&(wpMedia.model.settings.post.id=t.last(r)),wpMedia.frames={file_frame:wpMedia({title:"",button:{text:"Use Image"},multiple:!1})},wpMedia.frames.file_frame.on("select",function(){attachment=wpMedia.frames.file_frame.state().get("selection").first().toJSON();if(typeof e=="undefined")var e=attachment.url;var t=e.split("/")[e.split("/").length-1];n(e,t),parent.closeBox("input-image",!0)}),wpMedia.frames.file_frame.on("escape",function(){parent.closeBox("input-image",!0)}),wpMedia.frames.file_frame.open()}}),define("modules/panel.inputs",["jquery","helper.ace","deps/colorpicker","util.image-uploader"],function($,aceHelper){handleInputTogglesInContainer=function(e){e.each(function(){$(this).find('[id*="input-"]').reverse().each(function(){handleInputToggle($(this))})})},handleInputToggle=function(e,t){if(!e||!e.length||typeof e.attr("data-toggle")=="undefined")return;var n=$.parseJSON(e.attr("data-toggle")),r=".panel";if(e.parents(".repeater-group").length)var r=".repeater-group";if(typeof t=="undefined")var t=e.val().toString();e.attr("type")=="checkbox"&&(e.is(":checked")?t="true":t="false");if(t&&n&&typeof n=="object"&&n.hasOwnProperty(t)){if(typeof n[t].show=="string"){var i=e.parents(r).find(n[t].show);i.show(),i.find("*[data-toggle]").not(e).each(function(){handleInputToggle($(this))})}else typeof n[t].show=="object"&&$.each(n[t].show,function(t,n){var i=e.parents(r).find(n).show();i.show(),i.find("*[data-toggle]").not(e).each(function(){handleInputToggle($(this))})});if(typeof n[t].hide=="string"){var s=e.parents(r).find(n[t].hide);s.find("*[data-toggle]").not(e).each(function(){handleInputToggleHideAll($(this))}),s.hide()}else typeof n[t].hide=="object"&&$.each(n[t].hide,function(t,n){var i=e.parents(r).find(n);i.find("*[data-toggle]").not(e).each(function(){handleInputToggleHideAll($(this))}),i.hide()})}},handleInputToggleHideAll=function(e){if(!e||!e.length||typeof e.attr("data-toggle")=="undefined")return;var t=$.parseJSON(e.attr("data-toggle")),n=".panel";if(e.parents(".input").parent().attr("class")==="repeater-group")var n=".repeater-group";$.each(t,function(t,r){if(typeof r.hide=="undefined"||!r.hide||!r.hide.length)return;if(typeof r.hide=="string"){var i=e.parents(n).find(r.hide);i.hide()}else typeof r.hide=="object"&&$.each(r.hide,function(t,r){var i=e.parents(n).find(r);i.hide()})})};var panelInputs={delegate:function(){var context="div#panel";$(context).delegate("div.input-select select","change",function(){dataHandleInput($(this));var e=$(this),t=$(this).val();handleInputToggle(e,t)}),$(context).delegate("div.input-text input","keyup blur",function(){dataHandleInput($(this))}),$(context).delegate("div.input-textarea textarea","keyup blur",function(){dataHandleInput($(this))}),$(context).delegate("div.input-textarea span.textarea-open","click",function(){var e=$(this).siblings(".textarea-container"),t=e.find("textarea"),n=$(this).parents(".input").offset();e.css({top:n.top-e.outerHeight(!0),left:n.left}),$("div.sub-tabs-content-container").css("overflow-y","hidden"),e.data("visible")!==!0?(e.show(),e.data("visible",!0),t.trigger("focus"),$(document).bind("mousedown",{textareaContainer:e},textareaClose),Headway.iframe.contents().bind("mousedown",{textareaContainer:e},textareaClose),$(window).bind("resize",{textareaContainer:e},textareaClose)):(e.hide(),e.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",textareaClose),Headway.iframe.contents().unbind("mousedown",textareaClose),$(window).unbind("resize",textareaClose))}),textareaClose=function(e){if($(e.target).parents("div.input-textarea div.input-right").length===1)return;var t=e.data.textareaContainer;t.hide(),t.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",textareaClose),Headway.iframe.contents().unbind("mousedown",textareaClose),$(window).unbind("resize",textareaClose)},$(context).delegate("div.input-code span.code-editor-open","click",function(){var e=$(this).siblings("textarea");aceHelper.showEditor(e.attr("id"),$(this).data("editor-mode"),e.val(),function(t){e.val(t.getValue()),dataHandleInput(e)})}),inputWYSIWYGChange=function(e){dataHandleInput(this.$element,this.get())},inputWYSIWYGTextareaChange=function(){dataHandleInput($(this))},$(context).delegate("div.input-wysiwyg span.wysiwyg-open","click",function(){var e=$(this).siblings(".wysiwyg-container"),t=$(this).parents(".input").offset(),n=t.top-e.outerHeight(!0);n<50&&(n=50),e.css({top:n,left:t.left}),$("div.sub-tabs-content-container").css("overflow-y","hidden");if(e.data("visible")!==!0){e.show(),e.css("marginLeft",""),e.data("visible",!0);if($("div#side-panel-container").length)var r=$("div#side-panel-container").outerWidth()-$("div#side-panel-container").css("right").replace("px","");else var r=0;var i=$(document).width()-r-(e.offset().left+e.width());i<0&&e.css("marginLeft",i-30);var s=function(){e.find("textarea").redactor({path:Headway.headwayURL+"/library/resources/redactor/",plugins:["fontcolor","fontsize"],buttons:["html","|","formatting","|","bold","italic","deleted","|","unorderedlist","orderedlist","outdent","indent","|","table","link","|","image","|","alignleft","aligncenter","alignright","|","horizontalrule"],allowedTags:["inline","code","span","div","label","a","br","p","b","i","del","strike","u","img","video","audio","iframe","object","embed","param","blockquote","mark","cite","small","ul","ol","li","hr","dl","dt","dd","sup","sub","big","pre","code","figure","figcaption","strong","em","table","tr","td","th","tbody","thead","tfoot","h1","h2","h3","h4","h5","h6","frame","frameset","script","hgroup","form","label","input","textarea","select","fieldset","legend"],iframe:!0,css:Headway.headwayURL+"/library/resources/redactor/css/redactor-iframe.css",changeCallback:inputWYSIWYGChange,blurCallback:inputWYSIWYGChange,imageUpload:Headway.ajaxURL+"?action=headway_visual_editor&method=redactor_upload_image&security="+Headway.security,convertDivs:!1}),e.find("textarea").bind("keyup",inputWYSIWYGTextareaChange),e.find("textarea").redactor("focusEnd"),e.data("setupRedactor",!0)};if($("body").data("loadedRedactor")!==!0){var o=$("<link>").attr({rel:"stylesheet",href:Headway.headwayURL+"/library/resources/redactor/css/redactor.css",type:"text/css",media:"screen"}).appendTo($("head")),u=jQuery.ajax({dataType:"script",cache:!0,url:Headway.headwayURL+"/library/resources/redactor/redactor.min.js"}),a=jQuery.ajax({dataType:"script",cache:!0,url:Headway.headwayURL+"/library/resources/redactor/fontcolor.js"}),f=jQuery.ajax({dataType:"script",cache:!0,url:Headway.headwayURL+"/library/resources/redactor/fontsize.js"});$.when(u,a,f).then(function(){s(),$("body").data("loadedRedactor",!0)})}else $("body").data("loadedRedactor")===!0&&e.data("setupRedactor")!==!0?s():e.find("textarea").redactor("focusEnd");$(document).bind("mousedown",{wysiwygContainer:e},wysiwygClose),Headway.iframe.contents().bind("mousedown",{wysiwygContainer:e},wysiwygClose),$(window).bind("resize",{wysiwygContainer:e},wysiwygClose)}else e.hide(),e.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",wysiwygClose),Headway.iframe.contents().unbind("mousedown",wysiwygClose),$(window).unbind("resize",wysiwygClose)}),wysiwygClose=function(e){if($(e.target).parents("div.input-wysiwyg div.input-right").length===1||$(e.target).parents(".redactor_dropdown").length===1||$(e.target).parents("#redactor_modal").length===1)return;var t=e.data.wysiwygContainer;t.hide(),t.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",wysiwygClose),Headway.iframe.contents().unbind("mousedown",wysiwygClose),$(window).unbind("resize",wysiwygClose)},$(context).delegate("div.input-integer input","focus",function(){typeof originalValues!="undefined"&&delete originalValues,originalValues=new Object,originalValues[$(this).attr("name")]=$(this).val()}),$(context).delegate("div.input-integer input","keyup blur",function(e){t=$(this).val();if(e.type=="keyup"&&t=="-")return;if(isNaN(t)){t=t.replace(/[^0-9]*/ig,"");if(t==="")var t=originalValues[$(this).attr("name")];$(this).val(t)}t.length>1&&t[0]==0&&(t=t.replace(/^[0]+/g,""),$(this).val(t)),dataHandleInput($(this),t)}),$(context).delegate("div.input-checkbox input","change",function(e){var t=$(this).parents(".input-checkbox").first(),n=t.find("input"),r=t.find("label"),i=n.is(":checked");return Headway.history.add({up:function(){n.val(i),n.prop("checked",i),dataHandleInput(n,i),handleInputToggle(n,i),n.trigger("blur")},down:function(){var e=!e;n.val(e),n.prop("checked",e),dataHandleInput(n,e),handleInputToggle(n,e),n.trigger("blur")}}),allowSaving(),e.preventDefault(),e.stopPropagation(),!1}),$(context).delegate("div.input-multi-select select","click",function(){dataHandleInput($(this))}),$(context).delegate("div.input-multi-select span.multi-select-open","click",function(){var e=$(this).siblings(".multi-select-container"),t=e.find("select"),n=$(this).parents(".input").offset();e.css({top:n.top-e.outerHeight(!0),left:n.left}),$("div.sub-tabs-content-container").css("overflow-y","hidden"),e.data("visible")!==!0?(e.show(),e.data("visible",!0),$(document).bind("mousedown",{multiSelectContainer:e},multiSelectClose),Headway.iframe.contents().bind("mousedown",{multiSelectContainer:e},multiSelectClose),$(window).bind("resize",{multiSelectContainer:e},multiSelectClose)):(e.hide(),e.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",multiSelectClose),Headway.iframe.contents().unbind("mousedown",multiSelectClose),$(window).unbind("resize",multiSelectClose))}),multiSelectClose=function(e){if($(e.target).parents("div.input-multi-select div.input-right").length===1)return;var t=e.data.multiSelectContainer;t.hide(),t.data("visible",!1),$("div.sub-tabs-content-container").css("overflow-y","auto"),$(document).unbind("mousedown",multiSelectClose),Headway.iframe.contents().unbind("mousedown",multiSelectClose),$(window).unbind("resize",multiSelectClose)},$(context).delegate("div.input-image span.button","click",function(){var e=this;openImageUploader(function(t,n){$(e).siblings("input").val(t),$(e).siblings("span.src").show().text(n),$(e).siblings("span.delete-image").show(),dataHandleInput($(e).siblings("input"),t,{action:"add"})})}),$(context).delegate("div.input-image span.delete-image","click",function(){if(!confirm("Are you sure you wish to remove this image?"))return!1;$(this).siblings(".src").hide(),$(this).hide(),$(this).siblings("input").val(""),dataHandleInput($(this).siblings("input"),"",{action:"delete"})}),updateRepeaterValues=function(e){var t={};return e.find("div.repeater-group:visible").each(function(e){var n={};$(this).find("select, input, textarea").each(function(){var e=$(this).val();$(this).is('[type="checkbox"]')&&!$(this).is(":checked")&&(e=!1),n[$(this).attr("name")]=e}),t[e]=n}),dataHandleInput(e.find("input.repeater-group-input"),t)},$(context).delegate("div.repeater .add-group","click",function(){var e=$(this).parents("div.repeater"),t=$(this).parents("div.repeater-group"),n=e.find(".repeater-group-template");if(e.hasClass("limit-met"))return;var r=n.clone().hide().removeClass("repeater-group-template");r.insertAfter(t).fadeIn(300),e.find(".repeater-group-single").removeClass("repeater-group-single");var i=e.data("repeater-limit");!isNaN(i)&&i>=1&&e.find("div.repeater-group:not(.repeater-group-template):visible").length==i&&e.addClass("limit-met"),updateRepeaterValues(e)}),$(context).delegate("div.repeater .remove-group","click",function(){if(!confirm("Are you sure?"))return;var e=$(this).parents("div.repeater"),t=$(this).parents("div.repeater-group");t.fadeOut(300,function(){e.find("div.repeater-group:visible").length===1&&e.find("div.repeater-group:visible").addClass("repeater-group-single");var t=e.data("repeater-limit");!isNaN(t)&&t>=1&&e.find("div.repeater-group:not(.repeater-group-template):visible").length<t&&e.removeClass("limit-met"),updateRepeaterValues(e)})}),$(context).delegate("div.input-colorpicker div.colorpicker-box","click",function(){$("div.sub-tabs-content-container").css("overflow-y","hidden");var input=$(this).parent().siblings("input"),inputVal=input.val();inputVal=="transparent"&&(inputVal="00FFFFFF");var colorpickerHandleVal=function(color,inst){var colorValue="#"+color.hex;if(color.a!=100)var colorValue=color.rgba;input.val(colorValue),dataHandleInput(input,colorValue);var callback=eval(input.attr("data-callback"));typeof callback=="function"&&callback({input:input,value:color.rgba,colorObj:color})};$(this).colorpicker({realtime:!0,alpha:!0,alphaHex:!0,allowNull:!1,swatches:typeof Headway.colorpickerSwatches=="object"&&Headway.colorpickerSwatches.length?Headway.colorpickerSwatches:!0,color:inputVal,showAnim:!1,beforeShow:function(e,t){showIframeOverlay()},onClose:function(e,t){colorpickerHandleVal(e,t),hideIframeOverlay(),$("div.sub-tabs-content-container").css("overflow-y","auto")},onSelect:function(e,t){colorpickerHandleVal(e,t)},onAddSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)},onDeleteSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)}}),$.colorpicker._showColorpicker($(this)),setupTooltips()}),$(context).delegate("div.input-button span.button","click",function(){dataHandleInput($(this))}),$(context).delegate("div.input-import-file span.button","click",function(){$(this).siblings('input[type="file"]').trigger("click")}),$(context).delegate('div.input-import-file input[type="file"]',"change",function(e){if(e.target.files[0].name.split(".").slice(-1)[0]!="json")return $(this).val(null),alert("Invalid Headway import file.  Please be sure that the Headway import file is a valid JSON formatted file.");$(this).siblings("span.src").show().text($(this).val().split(/(\\|\/)/g).pop()),$(this).siblings("span.delete-file").show(),dataHandleInput($(this))}),$(context).delegate("div.input-import-file .delete-file","click",function(){if(!confirm("Are you sure?"))return;$(this).fadeOut(100),$(this).siblings("span.src").fadeOut(100);var fileInput=$(this).siblings('input[type="file"]'),callback=eval(fileInput.attr("data-callback"));fileInput.val(null),dataHandleInput(fileInput)})},bind:function(e){if(typeof t=="undefined")var t="div#panel";$("div.input-slider div.input-slider-bar",t).each(function(){var e=this,t=parseInt($(this).parents(".input-slider").find("input.input-slider-bar-hidden").val()),n=parseInt($(this).attr("slider_min")),r=parseInt($(this).attr("slider_max")),i=parseInt($(this).attr("slider_interval")),s=$(this).siblings("div.input-slider-bar-text").find(".input-slider-bar-input"),o=function(e,t){Headway.history.add({up:function(){$(e).val(t),$(e).prev().text(t),$(e).parents(".input-slider").find(".input-slider-bar").slider("value",t),dataHandleInput($(e).parents(".input-slider").find("input.input-slider-bar-hidden"),t)},down:function(){var t=$(e).parents(".input-slider").find("input.input-slider-bar-hidden").data("value-original");$(e).val(t),$(e).prev().text(t),$(e).parents(".input-slider").find(".input-slider-bar").slider("value",t),dataHandleInput($(e).parents(".input-slider").find("input.input-slider-bar-hidden"),t)}})};$(this).slider({range:"min",value:t,min:n,max:r,step:i,start:function(e,t){$(this).parents(".input-slider").find("input.input-slider-bar-hidden").data("value-original",t.value)},slide:function(e,t){$(this).siblings("div.input-slider-bar-text").find(".input-slider-bar-input").val(t.value),$(this).parents(".input-slider").find("input.input-slider-bar-hidden").val(t.value),dataHandleInput($(this).parents(".input-slider").find("input.input-slider-bar-hidden"),t.value)},stop:function(e,t){o(s,t.value)}}),s.on("keydown",function(e){var t=e.charCode||e.keyCode||0;return t==8||t==9||t==46||t==110||t>=35&&t<=40||t>=48&&t<=57||t>=96&&t<=105}),s.on("focus",function(e){$(this).parents(".input-slider").find("input.input-slider-bar-hidden").data("value-original",$(this).val())}),s.on("keyup change",function(e){if(e.which===13)return;if(this.value<=r&&this.value>=n){var t=this;o(this,this.value)}}),s.on("blur",function(e){var t=this.value;this.value>r?t=r:this.value<n&&(t=n),o(this,t)})}),$(".repeater-sortable",t).sortable({items:".repeater-group",containment:"parent",forcePlaceholderSize:!0,handle:".sortable-handle",stop:function(){updateRepeaterValues($(this))}}),$(".repeater",t).each(function(){var e=$(this).data("repeater-limit");!isNaN(e)&&e>=1&&$(this).find("div.repeater-group:not(.repeater-group-template):visible").length>=e&&$(this).addClass("limit-met")})}};return panelInputs}),define("modules/panel",["jquery","jqueryUI","deps/jquery.cookie","util.tooltips","modules/panel.inputs"],function(e,t,n,r,i){selectTab=function(e,t){var n=t.find(".ui-tabs-nav"),r=n.find('li[aria-controls="'+e+'"] a').length?n.find('li[aria-controls="'+e+'"] a'):n.find('li[aria-controls="'+e+'-content"] a');return r.trigger("click")},addPanelTab=function(t,n,r,i,s,o){if(e('ul#panel-top li a[href="#'+t+'-tab"]').length!==0)return!1;if(typeof i=="undefined")var i=!1;if(typeof s=="undefined")var s=!1;if(typeof o=="undefined")var o=!1;var u=e('<li><a href="#'+t+'-tab">'+n+"</a></li>").appendTo("div#panel #panel-top"),a=e('<div id="'+t+'-tab"></div>').appendTo("div#panel"),f=u.find("a");e("div#panel").tabs("refresh"),e(f).bind("click",showPanel),showPanel(),e("body").removeClass("panel-empty"),a.addClass("panel");if(typeof r=="string")a.html(r);else{var l=r.url,c=r.data||!1,h=function(){typeof r.callback=="function"&&r.callback.call()};createCog(a,!0),c.mode=Headway.mode,e("div#panel div#"+t+"-tab").load(l,c,h)}return o&&a.addClass("panel-"+o),i&&f.parent().append('<span class="close">X</span>'),f.parent().addClass("tab-close-on-layout-switch"),u},removePanelTab=function(t){var t=t.replace("-tab","");return e("#"+t+"-tab").length===0?!1:(e("#panel").find("#"+t+"-tab").remove(),e("#panel-top").find('a[href="#'+t+'-tab"]').parent().remove(),e("#panel-top").find("li").length||e("body").addClass("panel-empty"),e("div#panel").tabs("refresh"))},removeLayoutSwitchPanels=function(){e("li.tab-close-on-layout-switch").each(function(){var t=e(this).find("a").attr("href").replace("#","");removePanelTab(t)})},togglePanel=function(){return e("div#panel").hasClass("panel-hidden")?showPanel():hidePanel()},hidePanel=function(){if(e("div#panel").hasClass("panel-hidden"))return!1;var t={bottom:-e("div#panel").height()},n={bottom:e("ul#panel-top").outerHeight()};return e("div#panel").css(t).addClass("panel-hidden"),e("div#iframe-container").css(n),setTimeout(repositionTooltips,400),e("body").addClass("panel-hidden"),e("ul#panel-top-right li#minimize span").text("^"),typeof $i=="function"&&$i(".block-selected").removeClass("block-selected block-hover"),e.cookie("hide-panel",!0),!0},showPanel=function(){if(!e("div#panel").hasClass("panel-hidden"))return!1;var t={bottom:0},n={bottom:e("div#panel").outerHeight()};return e("div#panel").css(t).removeClass("panel-hidden"),e("div#iframe-container").css(n),setTimeout(repositionTooltips,400),e("body").removeClass("panel-hidden"),e("ul#panel-top-right li#minimize span").text("g"),e("ul#panel-top > li.ui-state-active a").length&&$i("#"+e("ul#panel-top > li.ui-state-active a").attr("href").replace("#","").replace("-tab","")).addClass("block-selected block-hover"),e.cookie("hide-panel",!1),!0};var s={init:function(){i.delegate(),i.bind()},getPanelMaxHeight:function(){return e(window).height()-275},resizePanel:function(t,n){var r=e("div#panel"),i=r.find("ul#panel-top");if(typeof t=="undefined"||t==0)t=e("div#panel").height();t>s.getPanelMaxHeight()&&(t=s.getPanelMaxHeight()>o?s.getPanelMaxHeight():o),t<o&&(t=o);if(typeof n!="undefined"&&n&&t<s.getPanelMaxHeight())return;r.height(t);var u=r.hasClass("panel-hidden")?i.outerHeight():r.outerHeight(),a=r.hasClass("panel-hidden")?i.outerHeight()+e("div#layout-selector-tabs").height():r.outerHeight()+e("div#layout-selector-tabs").height();e("div#iframe-container").css({bottom:u}),r.hasClass("panel-hidden")&&e("div#panel").css({bottom:-e("div#panel").height()}),e.cookie("panel-height",r.height())}};e("ul#panel-top").find("li").length||e("body").addClass("panel-empty"),e("ul#panel-top").delegate("span.close","click",function(){var t=e(this).siblings("a").attr("href").replace("#","").replace("-tab","");return removePanelTab(t)}),e("div#panel").tabs({tabTemplate:"<li><a href='#{href}'>#{label}</a></li>",add:function(t,n,r){e(n.panel).append(r)},activate:function(t,n){var r=e(n.newTab).children("a").attr("href").replace("#","").replace("-tab","");$i(".block-selected").removeClass("block-selected block-hover"),r.indexOf("block-")===0&&$i("#"+r).addClass("block-selected block-hover")}}),e("ul#panel-top li a").on("click",showPanel),e("div.sub-tab").tabs();var o=120;return e(document).ready(function(){e.cookie("panel-height")&&s.resizePanel(e.cookie("panel-height"))}),e("div#panel").resizable({maxHeight:s.getPanelMaxHeight(),minHeight:120,handles:"n",resize:function(t,n){e(this).css({width:"100%",position:"fixed",bottom:0,top:""}),e("div#iframe-container").css({bottom:e("div#panel").outerHeight()}),showIframeOverlay()},start:function(){showIframeOverlay()},stop:function(){e.cookie("panel-height",e(this).height()),hideIframeOverlay()}}),e(window).bind("resize",function(t){if(t.target!=window)return;e("div#panel").resizable("option",{maxHeight:s.getPanelMaxHeight()}),s.resizePanel(!1,!0)}),e("div#panel-top-container").bind("dblclick",function(e){if(e.target.id!="panel-top-container")return!1;togglePanel()}),e("ul#panel-top-right li#minimize").bind("click",function(e){return togglePanel(),!1}),e.cookie("hide-panel")==="true"&&hidePanel(!0),s}),define("deps/itstylesheet",function(){}),define("util.saving",["jquery","util.loader"],function(e,t){save=function(){if(typeof isSavingAllowed=="undefined"||isSavingAllowed===!1)return!1;if(typeof currentlySaving!="undefined"&&currentlySaving===!0)return!1;currentlySaving=!0,savedTitle=e("title").text(),saveButton=e("span#save-button"),saveButton.text("Saving...").addClass("active").css("cursor","wait"),changeTitle("Visual Editor: Saving"),startTitleActivityIndicator();var t=e.param(GLOBALunsavedValues);e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"save_options",options:t,layout:Headway.currentLayout,mode:Headway.mode},function(t){delete currentlySaving;if(t==="0")return saveButton.stop(!0),saveButton.text("Save"),saveButton.removeClass("active"),saveButton.css("cursor","pointer"),showErrorNotification({id:"error-wordpress-authentication",message:'<strong>Notice!</strong><br /><br />Your WordPress authentication has expired and you must log in before you can save.<br /><br /><a href="'+Headway.adminURL+'" target="_blank">Click Here to log in</a>, then switch back to the window/tab the Visual Editor is in.',closeTimer:!1,closable:!0});if(typeof t.errors!="undefined"||typeof t!="object"&&t!="success"){saveButton.stop(!0),saveButton.text("Save"),saveButton.removeClass("active"),saveButton.css("cursor","pointer");var n="There was an error while saving.  Please try again";return typeof t.errors!="undefined"&&(n+="<br /><ul>",e.each(t.errors,function(e,t){n+="<li>"+t+"</li>"}),n+="</ul>"),showErrorNotification({id:"error-invalid-save-response",message:n,closeTimer:!1,closable:!0})}hideNotification("error-wordpress-authentication"),hideNotification("error-invalid-save-response"),saveButton.animate({boxShadow:"0 0 0 #7dd1e2"},350),setTimeout(function(){saveButton.css("boxShadow",""),saveButton.stop(!0),saveButton.text("Save"),saveButton.removeClass("active"),saveButton.css("cursor","pointer"),typeof t["block-id-mapping"]!="undefined"&&e.each(t["block-id-mapping"],function(t,n){var r=$i('.block[data-temp-id="'+t+'"]');r.attr("id","block-"+n).data("id",n).attr("data-id",n).removeAttr("data-temp-id").removeAttr("data-desired-id").removeData("duplicateOf").removeData("temp-id").removeData("desired-id"),updateBlockContentCover(r);if(e("#block-"+t+"-tab").length){var i=e("#block-"+t+"-tab").find(".sub-tabs .ui-tabs-active").attr("aria-controls");removePanelTab("block-"+t),openBlockOptions(r,i)}}),typeof t["wrapper-id-mapping"]!="undefined"&&e.each(t["wrapper-id-mapping"],function(t,n){var r=$i('.wrapper[data-temp-id="'+t+'"]');r.attr("id","wrapper-"+n).data("id",n).attr("data-id",n).removeData("temp-id").removeData("desired-id"),e("#wrapper-"+t+"-tab").length&&(removePanelTab("wrapper-"+t),openWrapperOptions(n))}),clearUnsavedValues(),typeof t.snapshot!="undefined"&&typeof t.snapshot.timestamp!="undefined"&&(showNotification({id:"snapshot-saved",message:"Snapshot automatically saved.",success:!0}),Headway.viewModels.snapshots.snapshots.unshift({id:t.snapshot.id,timestamp:t.snapshot.timestamp,comments:t.snapshot.comments})),e("li.layout-selected").addClass("layout-item-customized"),disallowSaving(),setTimeout(function(){stopTitleActivityIndicator(),changeTitle(savedTitle),showNotification({id:"saving-complete",message:"Saving Complete!",closeTimer:3500,success:!0})},150)},350),allowVEClose()})},clearUnsavedValues=function(){delete GLOBALunsavedValues},allowSaving=function(){if(Headway.mode=="grid"&&$i(".block").length===0||typeof Headway.overlappingBlocks!="undefined"&&Headway.overlappingBlocks)return disallowSaving();if(typeof isSavingAllowed!="undefined"&&isSavingAllowed===!0)return;return e("body").addClass("allow-saving"),isSavingAllowed=!0,prohibitVEClose(),!0},disallowSaving=function(){return isSavingAllowed=!1,e("body").removeClass("allow-saving"),(typeof Headway.overlappingBlocks=="undefined"||!Headway.overlappingBlocks)&&allowVEClose(),!0}}),function(e){typeof define=="function"&&define.amd?define("deps/jquery.ui.touchpunch",["jquery"],e):e(jQuery)}(function(e){function s(e){var t=window.pageXOffset,n=window.pageYOffset,r=e.clientX,i=e.clientY;if(e.pageY===0&&Math.floor(i)>Math.floor(e.pageY)||e.pageX===0&&Math.floor(r)>Math.floor(e.pageX))r-=t,i-=n;else if(i<e.pageY-n||r<e.pageX-t)r=e.pageX-t,i=e.pageY-n;return{clientX:r,clientY:i}}function o(e,n){if(!t&&e.originalEvent.touches&&e.originalEvent.touches.length>1||t&&!e.isPrimary)return;e.preventDefault();var r;t?r=e.originalEvent:e.originalEvent.changedTouches?r=e.originalEvent.changedTouches[0]:r=e,simulatedEvent=document.createEvent("MouseEvents"),coord=s(r),simulatedEvent.initMouseEvent(n,!0,!0,window,1,r.screenX,r.screenY,coord.clientX,coord.clientY,!1,!1,!1,!1,0,null),e.target.dispatchEvent(simulatedEvent)}var t=window.navigator.pointerEnabled||window.navigator.msPointerEnabled;e.support.touch=e.support.touch||(typeof Modernizr!="undefined"?Modernizr.touch:"ontouchend"in document||"createTouch"in document||t);if(!e.support.touch&&!navigator.msPointerEnabled)return;var n=e.ui.mouse.prototype,r=n._mouseInit,i;n._touchStart=function(e){var n=this;if(i||!t&&!n._mouseCapture(e.originalEvent.changedTouches[0]))return;i=!0,n._touchMoved=!1,o(e,"mouseover"),o(e,"mousemove"),o(e,"mousedown")},n._touchMove=function(e){if(!i)return;this._touchMoved=!0,o(e,"mousemove")},n._touchEnd=function(e){if(!i)return;o(e,"mouseup"),o(e,"mouseout"),this._touchMoved||o(e,"click"),i=!1},n._mouseInit=function(){var n=this;n.element.off("touchstart").off("touchmove").off("touchend"),t?n.element.on("pointerDown",e.proxy(n,"_touchStart")).on("pointerMove",e.proxy(n,"_touchMove")).on("pointerUp",e.proxy(n,"_touchEnd")).on("MSPointerDown",e.proxy(n,"_touchStart")).on("MSPointerMove",e.proxy(n,"_touchMove")).on("MSPointerUp",e.proxy(n,"_touchEnd")):(n.element.on(navigator.msPointerEnabled?"MSPointerDown":"touchstart",e.proxy(n,"_touchStart")).on(navigator.msPointerEnabled?"MSPointerMove":"touchmove",e.proxy(n,"_touchMove")).on(navigator.msPointerEnabled?"MSPointerUp":"touchend",e.proxy(n,"_touchEnd")),n.element.css({msTouchAction:"none"})),r.call(n)}}),function(e){function n(e){var n=jQuery(this);settings=jQuery.extend({},t,e.data);if(typeof n.data("events")!="undefined"&&typeof n.data("events").click!="undefined"){for(var r in n.data("events").click)if(n.data("events").click[r].namespace==""){var i=n.data("events").click[r].handler;n.data("taphold_click_handler",i),n.unbind("click",i);break}}else typeof settings.clickHandler=="function"&&n.data("taphold_click_handler",settings.clickHandler);n.data("taphold_triggered",!1),n.data("taphold_clicked",!1),n.data("taphold_cancelled",!1),n.data("taphold_timer",setTimeout(function(){!n.data("taphold_cancelled")&&!n.data("taphold_clicked")&&(n.trigger(jQuery.extend(e,jQuery.Event("taphold"))),n.data("taphold_triggered",!0))},settings.duration))}function r(e){var t=jQuery(this);if(t.data("taphold_cancelled"))return;clearTimeout(t.data("taphold_timer")),!t.data("taphold_triggered")&&!t.data("taphold_clicked")&&(typeof t.data("taphold_click_handler")=="function"&&t.data("taphold_click_handler")(jQuery.extend(e,jQuery.Event("click"))),t.data("taphold_clicked",!0))}function i(t){e(this).data("taphold_cancelled",!0)}var t={duration:1e3,clickHandler:null},s="ontouchstart"in window||"onmsgesturechange"in window,o=e.event.special.taphold={setup:function(t){e(this).bind(s?"touchstart":"mousedown",t,n).bind(s?"touchend":"mouseup",r).bind(s?"touchmove":"mouseleave",i)},teardown:function(t){e(this).unbind(s?"touchstart":"mousedown",n).unbind(s?"touchend":"mouseup",r).unbind(s?"touchmove":"mouseleave",i)}}}(jQuery),define("deps/jquery.taphold",function(){}),define("util.usability",["jquery","deps/mousetrap"],function(e,t){prohibitVEClose=function(){window.onbeforeunload=function(){return"You have unsaved changes.  Are you sure you wish to leave the Visual Editor?"},allowVECloseSwitch=!1},allowVEClose=function(){window.onbeforeunload=function(){return null},allowVECloseSwitch=!0},disableBadKeys=function(){var t=function(t){var n=e(t.target);if(t.which===8&&!n.is("input")&&!n.is("textarea")&&!n.hasClass("allow-backspace-key")&&!n.parents(".wysiwyg-container").length)return t.preventDefault(),!1;if(t.which===9&&!n.is("input")&&!n.is("textarea")&&!n.hasClass("allow-tab-key")&&!n.parents(".wysiwyg-container").length)return t.preventDefault(),!1;if(t.which==13&&!n.is("textarea")&&!n.hasClass("allow-enter-key")&&!n.parents(".wysiwyg-container").length)return t.preventDefault(),!1};e(document).bind("keypress",t),e(document).bind("keydown",t),$i("html").bind("keypress",t),$i("html").bind("keydown",t)},bindKeyShortcuts=function(){t.bindEventsTo($i("body").get(0));var n=function(t){if(!e(".qtip-tour").is(":visible"))return;e(document.body).qtip("hide")};t.bind("esc",n),t.bindGlobal(["ctrl+s","command+s"],function(e){return save(),!1}),t.bind(["ctrl+p","command+p"],function(e){return togglePanel(),!1}),t.bind("ctrl+l",toggleLayoutSelector),typeof designEditor!="undefined"&&typeof designEditor.processElementCopy=="function"&&(t.bind(["ctrl+c","command+c"],designEditor.processElementCopy),t.bind(["ctrl+v","command+v"],designEditor.processElementPaste),t.bind("ctrl+e",function(){boxOpen("live-css")?closeBox("live-css"):e("#open-live-css").trigger("click")}),t.bind("ctrl+i",toggleInspector),t.bind("tab",toggleDesignEditor))},Headway.touch&&require(["deps/jquery.ui.touchpunch","deps/jquery.taphold"],function(){})}),define("modules/iframe",["jquery","deps/itstylesheet","util.saving","util.usability","util.tooltips"],function(e,t,n){$i=function(t){return typeof Headway.iframe=="undefined"||typeof Headway.iframe.contents()=="undefined"?e():Headway.iframe.contents().find(t)},$iDocument=function(){return e(Headway.iframe.contents())},loadIframe=function(e,t){if(typeof t=="undefined"||!t)var t=Headway.homeURL;var n=Headway.iframe;startTitleActivityIndicator(),showIframeLoadingOverlay(),closeBox("grid-wizard"),iframeURL=t,iframeURL=updateQueryStringParameter(iframeURL,"ve-iframe","true"),iframeURL=updateQueryStringParameter(iframeURL,"ve-layout",Headway.currentLayout),iframeURL=updateQueryStringParameter(iframeURL,"ve-iframe-mode",Headway.mode),iframeURL=updateQueryStringParameter(iframeURL,"rand",Math.floor(Math.random()*100000001)),n.contents().find(".ui-headway-grid").length&&typeof n.contents().find(".ui-headway-grid").headwayGrid!="undefined"&&n.contents().find(".ui-headway-grid").headwayGrid("destroy"),n.contents().find("*").unbind().remove(),n[0].src=iframeURL,waitForIframeLoad(e,n)},waitForIframeLoad=function(e,t){if(typeof t=="undefined"||!t)var t=Headway.iframe;return typeof iframeTimeout=="undefined"&&(iframeTimeout=setTimeout(r.loadTimeout,4e4)),typeof t=="undefined"||t.contents().find("body.iframe-loaded").length!=1?setTimeout(function(){waitForIframeLoad(e,t)},100):(clearTimeout(iframeTimeout),r.loadCallback(e))},showIframeOverlay=function(){var t=e("div#iframe-overlay");t.show()},hideIframeOverlay=function(t){if(typeof t!="undefined"&&t==0)return e("div#iframe-overlay").hide();setTimeout(function(){e("div#iframe-overlay").hide()},250)},showIframeLoadingOverlay=function(){return e("div#iframe-container").css("overflow","hidden"),e("div#iframe-loading-overlay").css({top:e("div#iframe-container").scrollTop()}),e("div#iframe-loading-overlay").is(":visible")||(createCog(e("div#iframe-loading-overlay"),!0),e("div#iframe-loading-overlay").show()),e("div#iframe-loading-overlay")},hideIframeLoadingOverlay=function(){e("div#iframe-container").css("overflow","auto"),e("div#iframe-loading-overlay").hide().html("")};var r={init:function(){e(document).ready(function(){Headway.iframe=e("iframe#content"),r.bindFocusBlur()})},bindFocusBlur:function(){Headway.iframe.on("mouseleave",function(){e(this).trigger("blur"),$i("[data-hasqtip]").qtip("disable",!0)}),Headway.iframe.on("mouseenter mousedown",function(){if(e("textarea:focus, input:focus").length===1)return;$i("[data-hasqtip]").qtip("enable"),e(this).trigger("focus")})},loadCallback:function(t){return clearUnsavedValues(),typeof t=="function"&&t(),r.defaultLoadCallback(),r.stopFirefoxLoadingIndicator(),e("body").triggerHandler("headwayIframeLoad"),!0},defaultLoadCallback:function(){stopTitleActivityIndicator(),changeTitle("Visual Editor: "+Headway.currentLayoutName),e("span#current-layout").text(Headway.currentLayoutName),setupTooltips(),setupTooltips("iframe"),stylesheet=new ITStylesheet({document:Headway.iframe.contents()[0],href:Headway.homeURL+"/?headway-trigger=compiler&file=general-design-editor"},"find"),css=new ITStylesheet({document:Headway.iframe.contents()[0]},"load"),hideIframeOverlay(!1),Headway.currentLayoutTemplate&&(showIframeOverlay(),$i("body").prepend('<div id="no-edit-notice"><div><h1>To edit this layout, remove the shared layout from this layout.</h1></div></div>')),disableBadKeys(),bindKeyShortcuts(),$i("html, body").bind("keydown",function(t){e(document).trigger(t),t.stopPropagation()}),$i("html, body").bind("keypress",function(t){e(document).trigger(t),t.stopPropagation()}),$i("html, body").bind("keyup",function(t){e(document).trigger(t),t.stopPropagation()}),Headway.touch&&Headway.iframe.contents().find("body").css("-webkit-touch-callout","none"),Headway.iframe.contents().find("body").delegate('a, input[type="submit"], button',"click",function(t){if(e(this).hasClass("allow-click"))return;return t.preventDefault(),!1}),typeof headwayIframeLoadNotification!="undefined"&&(showNotification({id:"iframe-load-notification",message:headwayIframeLoadNotification,overwriteExisting:!0}),delete headwayIframeLoadNotification),removeLayoutSwitchPanels();var t=e('div#layout-selector span.layout[data-layout-id="'+Headway.currentLayout+'"]'),n=t.parent();!$i(".block").length&&(!Headway.currentLayoutCustomized||Headway.currentLayout.indexOf("template-")===0)&&!Headway.currentLayoutTemplate&&Headway.mode=="grid"?(hidePanel(),e(document).ready(function(){openBox("grid-wizard")})):closeBox("grid-wizard"),hideIframeLoadingOverlay()},loadTimeout:function(){iframeTimeout=!0,stopTitleActivityIndicator(),changeTitle("Visual Editor: Error!"),e("#iframe-container, #menu, #panel, #layout-selector-offset").hide(),alert("ERROR: There was a problem while loading the visual editor.\n\nYour browser will automatically refresh to attempt loading again."),document.location.reload(!0)},stopFirefoxLoadingIndicator:function(){if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){var e;e==null&&(e=document.createElement("iframe"),e.style.display="none"),document.body.appendChild(e),document.body.removeChild(e)}}};return r}),function(e,t,n){function s(t,n){this.name=r,this.el=t,this.$el=e(t),this.options=e.extend({},i,n),this.$document=e(this.$el[0].ownerDocument),this.$body=this.$document.find("body"),this.moveTrigger="MSPointerMove touchmove mousemove",this.startTrigger="MSPointerDown touchstart mousedown",this.stopTrigger="MSPointerUp touchend mouseup",this.startTriggerArray=this.startTrigger.split(" "),this.moveTriggerArray=this.moveTrigger.split(" "),this.stopTriggerArray=this.stopTrigger.split(" "),this.stopEvents=[this.stopTrigger,this.options.stopEvents].join(" "),this.options.constrainTo==="window"?this.$container=this.$document:this.options.constrainTo&&this.options.constrainTo!=="parent"?this.$container=e(this.options.constrainTo):this.$container=this.$el.parent(),this.isPointerEventCompatible()&&this.applyMSDefaults(),this.CSSEaseHash=this.getCSSEaseHash(),this.scale=1,this.started=!1,this.disabled=!1,this.resetVelocityQueue(),this.init()}var r="pep",i={initiate:function(){},start:function(){},drag:function(){},stop:function(){},rest:function(){},moveTo:!1,callIfNotStarted:["stop","rest"],startThreshold:[0,0],grid:[1,1],debug:!1,activeClass:"pep-active",multiplier:1,velocityMultiplier:2.5,shouldPreventDefault:!0,allowDragEventPropagation:!0,stopEvents:"",hardwareAccelerate:!0,useCSSTranslation:!0,disableSelect:!0,cssEaseString:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",cssEaseDuration:1e3,shouldEase:!0,droppable:!1,droppableActiveClass:"pep-dpa",overlapFunction:!1,constrainTo:!1,removeMargins:!0,place:!0,deferPlacement:!1,axis:null,forceNonCSS3Movement:!1,elementsWithInteraction:"input",revert:!1,revertAfter:"stop",revertIf:function(){return!0}};s.prototype.init=function(){this.options.debug&&this.buildDebugDiv(),this.options.disableSelect&&this.disableSelect(),this.options.place&&!this.options.deferPlacement&&(this.positionParent(),this.placeObject()),this.ev={},this.pos={},this.subscribe()},s.prototype.subscribe=function(){var e=this;this.$el.on(this.startTrigger,function(t){e.handleStart(t)}),this.$el.on(this.startTrigger,this.options.elementsWithInteraction,function(e){e.stopPropagation()}),this.$document.on(this.stopEvents,function(t){e.handleStop(t)}),this.$document.on(this.moveTrigger,function(t){e.moveEvent=t})},s.prototype.handleStart=function(t){var n=this;if(this.isValidMoveEvent(t)&&!this.disabled){this.isPointerEventCompatible()&&t.preventManipulation&&t.preventManipulation(),t=this.normalizeEvent(t),this.options.place&&this.options.deferPlacement&&(this.positionParent(),this.placeObject()),this.log({type:"event",event:t.type}),this.options.hardwareAccelerate&&!this.hardwareAccelerated&&(this.hardwareAccelerate(),this.hardwareAccelerated=!0);var r=this.options.initiate.call(this,t,this);if(r===!1)return;clearTimeout(this.restTimeout),this.$el.addClass(this.options.activeClass),this.removeCSSEasing(),this.startX=this.ev.x=t.pep.x,this.startY=this.ev.y=t.pep.y,this.initialPosition=this.initialPosition||this.$el.position(),this.startEvent=this.moveEvent=t,this.active=!0,this.options.shouldPreventDefault&&t.preventDefault(),this.options.allowDragEventPropagation||t.stopPropagation(),function i(){if(!n.active)return;n.handleMove(),n.requestAnimationFrame(i)}(e,n)}},s.prototype.handleMove=function(){if(typeof this.moveEvent=="undefined")return;var n=this.normalizeEvent(this.moveEvent),r=t.parseInt(n.pep.x/this.options.grid[0])*this.options.grid[0],i=t.parseInt(n.pep.y/this.options.grid[1])*this.options.grid[1];this.addToLIFO({time:n.timeStamp,x:r,y:i});var s,o;e.inArray(n.type,this.startTriggerArray)>-1?(s=0,o=0):(s=r-this.ev.x,o=i-this.ev.y),this.dx=s,this.dy=o,this.ev.x=r,this.ev.y=i;if(s===0&&o===0){this.log({type:"event",event:"** stopped **"});return}var u=Math.abs(this.startX-r),a=Math.abs(this.startY-i);!this.started&&(u>this.options.startThreshold[0]||a>this.options.startThreshold[1])&&(this.started=!0,this.$el.addClass("pep-start"),this.options.start.call(this,this.startEvent,this)),this.options.droppable&&this.calculateActiveDropRegions();var f=this.options.drag.call(this,n,this);if(f===!1){this.resetVelocityQueue();return}this.log({type:"event",event:n.type}),this.log({type:"event-coords",x:this.ev.x,y:this.ev.y}),this.log({type:"velocity"});var l=this.handleConstraint(s,o),c,h;typeof this.options.moveTo=="function"?(c=s>=0?"+="+Math.abs(s/this.scale)*this.options.multiplier:"-="+Math.abs(s/this.scale)*this.options.multiplier,h=o>=0?"+="+Math.abs(o/this.scale)*this.options.multiplier:"-="+Math.abs(o/this.scale)*this.options.multiplier,this.options.constrainTo&&(c=l.x!==!1?l.x:c,h=l.y!==!1?l.y:h),this.options.axis==="x"&&(h=l.y),this.options.axis==="y"&&(c=l.x),this.options.moveTo.call(this,c,h)):this.shouldUseCSSTranslation()?(s=s/this.scale*this.options.multiplier,o=o/this.scale*this.options.multiplier,this.options.constrainTo&&(s=l.x===!1?s:0,o=l.y===!1?o:0),this.options.axis==="x"&&(o=0),this.options.axis==="y"&&(s=0),this.moveToUsingTransforms(s,o)):(c=s>=0?"+="+Math.abs(s/this.scale)*this.options.multiplier:"-="+Math.abs(s/this.scale)*this.options.multiplier,h=o>=0?"+="+Math.abs(o/this.scale)*this.options.multiplier:"-="+Math.abs(o/this.scale)*this.options.multiplier,this.options.constrainTo&&(c=l.x!==!1?l.x:c,h=l.y!==!1?l.y:h),this.options.axis==="x"&&(h=l.y),this.options.axis==="y"&&(c=l.x),this.moveTo(c,h))},s.prototype.handleStop=function(t){if(!this.active)return;this.log({type:"event",event:t.type}),this.active=!1,this.$el.removeClass("pep-start").addClass("pep-ease"),this.options.droppable&&this.calculateActiveDropRegions(),(this.started||!this.started&&e.inArray("stop",this.options.callIfNotStarted)>-1)&&this.options.stop.call(this,t,this),this.options.shouldEase?this.ease(t,this.started):this.removeActiveClass(),this.options.revert&&(this.options.revertAfter==="stop"||!this.options.shouldEase)&&this.options.revertIf&&this.options.revertIf()&&this.revert(),this.started=!1,this.resetVelocityQueue()},s.prototype.ease=function(t,n){var r=this.$el.position(),i=this.velocity(),s=this.dt,o=i.x/this.scale*this.options.multiplier,u=i.y/this.scale*this.options.multiplier,a=this.handleConstraint(o,u,!0);this.cssAnimationsSupported()&&this.$el.css(this.getCSSEaseHash());var f=i.x>0?"+="+o:"-="+Math.abs(o),l=i.y>0?"+="+u:"-="+Math.abs(u);this.options.constrainTo&&(f=a.x!==!1?a.x:f,l=a.y!==!1?a.y:l),this.options.axis==="x"&&(l="+=0"),this.options.axis==="y"&&(f="+=0");var c=!this.cssAnimationsSupported()||this.options.forceNonCSS3Movement;typeof this.options.moveTo=="function"?this.options.moveTo.call(this,f,l):this.moveTo(f,l,c);var h=this;this.restTimeout=setTimeout(function(){h.options.droppable&&h.calculateActiveDropRegions(),(n||!n&&e.inArray("rest",h.options.callIfNotStarted)>-1)&&h.options.rest.call(h,t,h),h.options.revert&&h.options.revertAfter==="ease"&&h.options.shouldEase&&h.options.revertIf&&h.options.revertIf()&&h.revert(),h.removeActiveClass()},this.options.cssEaseDuration)},s.prototype.normalizeEvent=function(e){return e.pep={},this.isPointerEventCompatible()||!this.isTouch(e)?(e.pageX?(e.pep.x=e.pageX,e.pep.y=e.pageY):(e.pep.x=e.originalEvent.pageX,e.pep.y=e.originalEvent.pageY),e.pep.type=e.type):(e.pep.x=e.originalEvent.touches[0].pageX,e.pep.y=e.originalEvent.touches[0].pageY,e.pep.type=e.type),e},s.prototype.resetVelocityQueue=function(){this.velocityQueue=new Array(5)},s.prototype.moveTo=function(e,t,n){this.log({type:"delta",x:e,y:t}),n?this.$el.animate({top:t,left:e},this.options.cssEaseDuration/2,"easeOutQuad",{queue:!1}):this.$el.stop(!0,!1).css({top:t,left:e})},s.prototype.moveToUsingTransforms=function(e,t){var n=this.matrixToArray(this.matrixString());this.cssX||(this.cssX=this.xTranslation(n)),this.cssY||(this.cssY=this.yTranslation(n)),this.cssX=this.cssX+e,this.cssY=this.cssY+t,this.log({type:"delta",x:e,y:t}),n[4]=this.cssX,n[5]=this.cssY,this.translation=this.arrayToMatrix(n),this.transform(this.translation)},s.prototype.transform=function(e){this.$el.css({"-webkit-transform":e,"-moz-transform":e,"-ms-transform":e,"-o-transform":e,transform:e})},s.prototype.xTranslation=function(e){return e=e||this.matrixToArray(this.matrixString()),parseInt(e[4],10)},s.prototype.yTranslation=function(e){return e=e||this.matrixToArray(this.matrixString()),parseInt(e[5],10)},s.prototype.matrixString=function(){var e=function(e){return!(!e||e==="none"||e.indexOf("matrix")<0)},t="matrix(1, 0, 0, 1, 0, 0)";return e(this.$el.css("-webkit-transform"))&&(t=this.$el.css("-webkit-transform")),e(this.$el.css("-moz-transform"))&&(t=this.$el.css("-moz-transform")),e(this.$el.css("-ms-transform"))&&(t=this.$el.css("-ms-transform")),e(this.$el.css("-o-transform"))&&(t=this.$el.css("-o-transform")),e(this.$el.css("transform"))&&(t=this.$el.css("transform")),t},s.prototype.matrixToArray=function(e){return e.split("(")[1].split(")")[0].split(",")},s.prototype.arrayToMatrix=function(e){return"matrix("+e.join(",")+")"},s.prototype.addToLIFO=function(e){var t=this.velocityQueue;t=t.slice(1,t.length),t.push(e),this.velocityQueue=t},s.prototype.velocity=function(){var e=0,t=0;for(var n=0;n<this.velocityQueue.length-1;n++)this.velocityQueue[n]&&(e+=this.velocityQueue[n+1].x-this.velocityQueue[n].x,t+=this.velocityQueue[n+1].y-this.velocityQueue[n].y,this.dt=this.velocityQueue[n+1].time-this.velocityQueue[n].time);return{x:e*this.options.velocityMultiplier,y:t*this.options.velocityMultiplier}},s.prototype.revert=function(){this.shouldUseCSSTranslation()&&this.moveToUsingTransforms(-this.xTranslation(),-this.yTranslation()),this.moveTo(this.initialPosition.left,this.initialPosition.top)},s.prototype.requestAnimationFrame=function(e){return t.requestAnimationFrame&&t.requestAnimationFrame(e)||t.webkitRequestAnimationFrame&&t.webkitRequestAnimationFrame(e)||t.mozRequestAnimationFrame&&t.mozRequestAnimationFrame(e)||t.oRequestAnimationFrame&&t.mozRequestAnimationFrame(e)||t.msRequestAnimationFrame&&t.msRequestAnimationFrame(e)||t.setTimeout(e,1e3/60)},s.prototype.positionParent=function(){if(!this.options.constrainTo||this.parentPositioned)return;this.parentPositioned=!0,this.options.constrainTo==="parent"?this.$container.css({position:"relative"}):this.options.constrainTo==="window"&&this.$container.get(0).nodeName!=="#document"&&this.$container.css("position")!=="static"&&this.$container.css({position:"static"})},s.prototype.placeObject=function(){if(this.objectPlaced)return;this.objectPlaced=!0,this.offset=this.options.constrainTo==="parent"||this.hasNonBodyRelative()?this.$el.position():this.$el.offset(),parseInt(this.$el.css("left"),10)&&(this.offset.left=this.$el.css("left")),parseInt(this.$el.css("top"),10)&&(this.offset.top=this.$el.css("top")),this.options.removeMargins&&this.$el.css({margin:0}),this.$el.css({position:"absolute",top:this.offset.top,left:this.offset.left})},s.prototype.hasNonBodyRelative=function(){return this.$el.parents().filter(function(){var t=e(this);return t.is("body")||t.css("position")==="relative"}).length>1},s.prototype.setScale=function(e){this.scale=e},s.prototype.setMultiplier=function(e){this.options.multiplier=e},s.prototype.removeCSSEasing=function(){this.cssAnimationsSupported()&&this.$el.css(this.getCSSEaseHash(!0))},s.prototype.disableSelect=function(){this.$el.css({"-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"})},s.prototype.removeActiveClass=function(){this.$el.removeClass([this.options.activeClass,"pep-ease"].join(" "))},s.prototype.handleConstraint=function(t,r,i){var s=this,o=this.$el.position();this.pos.x=o.left,this.pos.y=o.top;var u={x:!1,y:!1},a,f,l,c;this.log({type:"pos-coords",x:this.pos.x,y:this.pos.y});if(e.isArray(this.options.constrainTo))this.options.constrainTo[3]!==n&&this.options.constrainTo[1]!==n&&(f=this.options.constrainTo[1]===!1?Infinity:this.options.constrainTo[1],l=this.options.constrainTo[3]===!1?-Infinity:this.options.constrainTo[3]),this.options.constrainTo[0]!==!1&&this.options.constrainTo[2]!==!1&&(a=this.options.constrainTo[2]===!1?Infinity:this.options.constrainTo[2],c=this.options.constrainTo[0]===!1?-Infinity:this.options.constrainTo[0]),this.pos.x+t<l&&(u.x=l),this.pos.y+r<c&&(u.y=c);else if(typeof this.options.constrainTo=="string"){l=0,c=0,f=this.$container.width()-this.$el.outerWidth(),a=this.$container.height()-this.$el.outerHeight(),this.$el.each(function(){e(this).position().left+t<0&&(u.x=0),e(this).position().top+r<0&&(u.y=0)});var h=this.$container[0].getBoundingClientRect(),p=this.ev.x>h.left&&this.ev.x<h.right&&this.ev.y>h.top+e(this.$el[0].ownerDocument).scrollTop()&&this.ev.y<h.bottom+e(this.$el[0].ownerDocument).scrollTop();p||(u.x=l,u.y=c)}return this.$el.each(function(){f=s.$container.width()-e(this).outerWidth(),a=s.$container.height()-e(this).outerHeight(),e(this).position().left+t>f&&(u.x=f),e(this).position().top+r>a&&(u.y=a)}),this.shouldUseCSSTranslation()&&i&&(u.x===l&&this.xTranslation()&&(u.x=l-this.xTranslation()),u.x===f&&this.xTranslation()&&(u.x=f-this.xTranslation()),u.y===c&&this.yTranslation()&&(u.y=c-this.yTranslation()),u.y===a&&this.yTranslation()&&(u.y=a-this.yTranslation())),u},s.prototype.getCSSEaseHash=function(e){typeof e=="undefined"&&(e=!1);var t;if(e)t="";else{if(this.CSSEaseHash)return this.CSSEaseHash;t=["all",this.options.cssEaseDuration+"ms",this.options.cssEaseString].join(" ")}return{"-webkit-transition":t,"-moz-transition":t,"-ms-transition":t,"-o-transition":t,transition:t}},s.prototype.calculateActiveDropRegions=function(){var t=this;this.activeDropRegions=[],e.each(e(this.options.droppable),function(n,r){var i=e(r);t.isOverlapping(i,t.$el)?(i.addClass(t.options.droppableActiveClass),t.activeDropRegions.push(i)):i.removeClass(t.options.droppableActiveClass)})},s.prototype.isOverlapping=function(e,t){if(this.options.overlapFunction)return this.options.overlapFunction(e,t);var n=e[0].getBoundingClientRect(),r=t[0].getBoundingClientRect();return!(n.right<r.left||n.left>r.right||n.bottom<r.top||n.top>r.bottom)},s.prototype.isTouch=function(e){return e.type.search("touch")>-1},s.prototype.isPointerEventCompatible=function(){return"MSPointerEvent"in t},s.prototype.applyMSDefaults=function(e){this.$el.css({"-ms-touch-action":"none","touch-action":"none","-ms-scroll-chaining":"none","-ms-scroll-limit":"0 0 0 0"})},s.prototype.isValidMoveEvent=function(e){return!this.isTouch(e)||this.isTouch(e)&&e.originalEvent.touches&&e.originalEvent.touches.length===1},s.prototype.shouldUseCSSTranslation=function(){if(typeof this.useCSSTranslation!="undefined")return this.useCSSTranslation;var e=!1;return!this.options.useCSSTranslation||typeof Modernizr!="undefined"&&!Modernizr.csstransforms?e=!1:e=!0,this.useCSSTranslation=e,e},s.prototype.cssAnimationsSupported=function(){if(typeof this.cssAnimationsSupport!="undefined")return this.cssAnimationsSupport;if(typeof Modernizr!="undefined"&&Modernizr.cssanimations)return this.cssAnimationsSupport=!0,!0;var e=!1,t=document.createElement("div"),r="animation",i="",s="Webkit Moz O ms Khtml".split(" "),o="";t.style.animationName&&(e=!0);if(e===!1)for(var u=0;u<s.length;u++)if(t.style[s[u]+"AnimationName"]!==n){o=s[u],r=o+"Animation",i="-"+o.toLowerCase()+"-",e=!0;break}return this.cssAnimationsSupport=e,e},s.prototype.hardwareAccelerate=function(){this.$el.css({"-webkit-perspective":1e3,perspective:1e3,"-webkit-backface-visibility":"hidden","backface-visibility":"hidden"})},s.prototype.getMovementValues=function(){return{ev:this.ev,pos:this.pos,velocity:this.velocity()}},s.prototype.buildDebugDiv=function(){var t;e("#pep-debug").length===0&&(t=e("<div></div>"),t.attr("id","pep-debug").append("<div style='font-weight:bold; background: red; color: white;'>DEBUG MODE</div>").append("<div id='pep-debug-event'>no event</div>").append("<div id='pep-debug-ev-coords'>event coords: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").append("<div id='pep-debug-pos-coords'>position coords: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").append("<div id='pep-debug-velocity'>velocity: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").append("<div id='pep-debug-delta'>&Delta; movement: <span class='pep-x'>-</span>, <span class='pep-y'>-</span></div>").css({position:"fixed",bottom:5,right:5,zIndex:99999,textAlign:"right",fontFamily:"Arial, sans",fontSize:10,border:"1px solid #DDD",padding:"3px",background:"white",color:"#333"}));var n=this;setTimeout(function(){n.debugElements={$event:e("#pep-debug-event"),$velocityX:e("#pep-debug-velocity .pep-x"),$velocityY:e("#pep-debug-velocity .pep-y"),$dX:e("#pep-debug-delta .pep-x"),$dY:e("#pep-debug-delta .pep-y"),$evCoordsX:e("#pep-debug-ev-coords .pep-x"),$evCoordsY:e("#pep-debug-ev-coords .pep-y"),$posCoordsX:e("#pep-debug-pos-coords .pep-x"),$posCoordsY:e("#pep-debug-pos-coords .pep-y")}},0),e("body").append(t)},s.prototype.log=function(e){if(!this.options.debug)return;switch(e.type){case"event":this.debugElements.$event.text(e.event);break;case"pos-coords":this.debugElements.$posCoordsX.text(e.x),this.debugElements.$posCoordsY.text(e.y);break;case"event-coords":this.debugElements.$evCoordsX.text(e.x),this.debugElements.$evCoordsY.text(e.y);break;case"delta":this.debugElements.$dX.text(e.x),this.debugElements.$dY.text(e.y);break;case"velocity":var t=this.velocity();this.debugElements.$velocityX.text(Math.round(t.x)),this.debugElements.$velocityY.text(Math.round(t.y))}},s.prototype.toggle=function(e){typeof e=="undefined"?this.disabled=!this.disabled:this.disabled=!e},e.extend(e.easing,{easeOutQuad:function(e,t,n,r,i){return-r*(t/=i)*(t-2)+n},easeOutCirc:function(e,t,n,r,i){return r*Math.sqrt(1-(t=t/i-1)*t)+n},easeOutExpo:function(e,t,n,r,i){return t===i?n+r:r*(-Math.pow(2,-10*t/i)+1)+n}}),e.fn[r]=function(t){return this.each(function(){if(!e.data(this,"plugin_"+r)){var n=new s(this,t);e.data(this,"plugin_"+r,n),e.pep.peps.push(n)}})},e.pep={},e.pep.peps=[],e.pep.toggleAll=function(t){e.each(this.peps,function(e,n){n.toggle(t)})},e.pep.unbind=function(e){var t=e.data("plugin_"+r);if(typeof t=="undefined")return;t.toggle(!1),e.removeData("plugin_"+r)}}(jQuery,window),define("deps/jquery.pep",function(){}),define("helper.boxes",["modules/iframe","deps/jquery.pep"],function(iframe){createBox=function(e){var t={},n={id:null,title:null,description:null,content:null,src:null,load:null,width:500,height:300,center:!0,closable:!0,resizable:!1,draggable:!0,deleteWhenClosed:!1,blackOverlay:!1,blackOverlayOpacity:.6,blackOverlayIframe:!1};$.extend(t,n,e);var r=$('<div class="box" id="box-'+t.id+'"><div class="box-top"></div><div class="box-content-bg"><div class="box-content"></div></div></div>');return r.attr("black_overlay",t.blackOverlay),r.attr("black_overlay_opacity",t.blackOverlayOpacity),r.attr("black_overlay_iframe",t.blackOverlayIframe),r.attr("load_with_ajax",!1),r.appendTo("div#boxes"),typeof t.src!="string"?r.find(".box-content").html(t.content):(r.find(".box-content").addClass("box-content-with-iframe"),r.find(".box-content").html('<iframe src="'+t.src+'"></iframe>'),typeof t.load=="function"&&r.find(".box-content iframe").bind("load",t.load)),r.find(".box-top").append("<strong>"+t.title+"</strong>"),typeof t.description=="string"&&r.find(".box-top").append("<span>"+t.description+"</span>"),setupBox(t.id,t),r},setupBox=function(e,t){var n={},r={width:600,height:300,center:!0,closable:!0,deleteWhenClosed:!1,draggable:!1,resizable:!1};$.extend(n,r,t);var i=$("div#box-"+e);n.draggable&&(i.draggable({handle:i.find(".box-top"),start:showIframeOverlay,stop:hideIframeOverlay,shouldEase:!1}),i.find(".box-top").css("cursor","move")),n.closable&&(i.find(".box-top").append('<span class="box-close">X</span>'),i.find(".box-close").bind("click",function(){closeBox(e,n.deleteWhenClosed)})),n.resizable&&i.resizable({start:showIframeOverlay,stop:hideIframeOverlay,handles:"n, e, s, w, ne, se, sw, nw",minWidth:n.minWidth,minHeight:n.minHeight}),i.css({width:n.width,height:n.height});if(n.center){var s=-(i.width()/2),o=-(i.height()/2);i.css({top:"50%",left:"50%",marginLeft:s,marginTop:o})}},setupStaticBoxes=function(){$("div.box").each(function(){var e=hwBoolean($(this).attr("draggable")),t=hwBoolean($(this).attr("closable")),n=hwBoolean($(this).attr("resizable")),r=hwBoolean($(this).attr("center")),i=$(this).attr("width"),s=$(this).attr("height"),o=$(this).attr("min_width"),u=$(this).attr("min_height"),a=$(this).attr("id").replace("box-","");setupBox(a,{draggable:e,closable:t,resizable:n,center:r,width:i,height:s,minWidth:o,minHeight:u}),$(this).attr("draggable",null),$(this).attr("closable",null),$(this).attr("resizable",null),$(this).attr("center",null),$(this).attr("width",null),$(this).attr("height",null),$(this).attr("min_width",null),$(this).attr("min_height",null)})},openBox=function(id){var id=id.replace("box-",""),box=$("div#box-"+id);if(box.length===0)return!1;var blackOverlay=hwBoolean(box.attr("black_overlay")),blackOverlayOpacity=box.attr("black_overlay_opacity"),blackOverlayIframe=hwBoolean(box.attr("black_overlay_iframe")),loadWithAjax=hwBoolean(box.attr("load_with_ajax"));if(blackOverlay&&!boxOpen(id)){var overlay=$('<div class="black-overlay"></div>').hide().attr("id","black-overlay-box-"+id).appendTo("#boxes");blackOverlayIframe===!0&&overlay.css("zIndex",4),isNaN(blackOverlayOpacity)||overlay.css("background","rgba(0, 0, 0, "+blackOverlayOpacity+")"),overlay.show()}return loadWithAjax&&!box.data("currently-ajax-loading")&&(box.find("*").removeData(),box.find(".box-content *").remove(),createCog(box.find(".box-content"),!0),box.data("currently-ajax-loading",!0),box.find(".box-content").load(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"load_box_ajax_content",box_id:id,layout:Headway.currentLayout},function(){var loadWithAjaxCallback=eval(box.attr("load_with_ajax_callback"));loadWithAjaxCallback.call(),box.removeData("currently-ajax-loading")})),box.show()},closeBox=function(e,t){var e=e.replace("box-",""),n=$("div#box-"+e);return n.hide(),typeof t!="undefined"&&t==1&&n.remove(),$("div#black-overlay-box-"+e).remove(),!0},boxOpen=function(e){return $("div#box-"+e).is(":visible")},boxExists=function(e){return $("div#box-"+e).length===1?!0:!1},toggleBox=function(e){boxOpen(e)?closeBox(e):openBox(e)},setupStaticBoxes(),$("#boxes").on("click","div.black-overlay",function(){var e=$(this).attr("id").replace("black-overlay-","");if($("#"+e).length===0)return;if($(".qtip-tour").is(":visible"))return;closeBox(e)})}),define("helper.history",["jquery","modules/iframe","deps/mousetrap"],function(e,t,n){var r=function(e){this.settings={limit:20,call:!0},this.set(e),this.clear()};r.prototype.set=function(e){for(var t in e)this.settings[t]=e[t];return this},r.prototype.add=function(e){return this.redos=[],!e instanceof r.Occurence&&(e=new r.Occurence(e)),this.undos.unshift(e),(e.call===!0||typeof e.call=="undefined"&&this.settings.call===!0)&&e.up(),this.settings.limit&&this.undos.splice(this.settings.limit),typeof this.settings.onAdd=="function"&&this.settings.onAdd(e),this},r.prototype.clear=function(){return this.redos=[],this.undos=[],typeof this.settings.onClear=="function"&&this.settings.onClear(),this},r.prototype.revert=function(){var e;while(e=this.undos.shift())e.down();return this.clear()},r.prototype.undo=function(){var e;if(e=this.undos.shift())this.redos.unshift(e),e.down(),typeof this.settings.onUndo=="function"&&this.settings.onUndo(e),this.undos.length==0&&typeof this.settings.onBegin=="function"&&this.settings.onBegin(e);return this},r.prototype.redo=function(){var e;if(e=this.redos.shift())this.undos.unshift(e),e.up(),typeof this.settings.onRedo=="function"&&this.settings.onRedo(e),this.redos.length==0&&typeof this.settings.onEnd=="function"&&this.settings.onEnd(e);return this},r.Occurence=function(e){e=e||{},this.up=e.up||function(){},this.down=e.down||function(){}};var i={init:function(){Headway.history=new r({limit:0}),i.bind()},bind:function(){n.bind(["ctrl+z","command+z"],function(e){return Headway.history.undo(),!1}),n.bind(["ctrl+y","command+y"],function(e){return Headway.history.redo(),!1})}};return i}),define("helper.blocks",["modules/panel.inputs","helper.history"],function(panelInputs,history){getBlockByID=function(e){var e=e.toString().replace("block-","");return $i('.block[data-id="'+e+'"]')},getBlock=function(e){return $(e).length===0?$():($(e).hasClass("block")?block=$(e):$(e).parents(".block").length===1?block=$(e).parents(".block"):block=!1,block)},getBlockID=function(e){var t=getBlock(e);return t?t.data("id"):!1},getBlockWrapper=function(e){var t=getBlock(e);return t.closest(".wrapper")},getBlockType=function(e){var t=getBlock(e);return t?t.data("type"):!1},getBlockTypeNice=function(e){return typeof e!="string"?!1:getBlockTypeObject(e).name},getBlockTypeIcon=function(e,t){return typeof t=="undefined"&&(t=!1),typeof Headway.allBlockTypes[e]!="object"?null:t===!0?Headway.blockTypeURLs[e]+"/icon-white.png":Headway.blockTypeURLs[e]+"/icon.png"},getBlockTypeObject=function(e){var t=Headway.allBlockTypes;return typeof t[e]=="undefined"?{"fixed-height":!1}:t[e]},getBlockGridWidth=function(e){var t=getBlock(e);return t?t.attr("data-width"):!1},setBlockGridWidth=function(e,t){var n=getBlock(e);if(!n)return!1;var r=n.attr("data-width");return r&&n.removeClass("grid-width-"+r),n.css("width",""),n.addClass("grid-width-"+t),n.attr("data-width",String(t).replace("grid-width-","")),n},getBlockGridLeft=function(e){var t=getBlock(e);return t?t.attr("data-grid-left"):!1},setBlockGridLeft=function(e,t){var n=getBlock(e);if(!n)return!1;var r=getBlockGridLeft(n);return r&&n.removeClass("grid-left-"+r),n.addClass("grid-left-"+t),n.attr("data-grid-left",String(t).replace("grid-left-","")),n},getBlockDimensions=function(e){var t=getBlock(e);return t?{width:getBlockGridWidth(t),height:t.attr("data-height")}:!1},getBlockDimensionsPixels=function(e){var t=getBlock(e);return t?{width:t.width(),height:t.height()}:!1},getBlockPosition=function(e){var t=getBlock(e);return t?{left:getBlockGridLeft(t),top:t.attr("data-grid-top")}:!1},getBlockPositionPixels=function(e){var t=getBlock(e);return t?{left:t.position().left,top:t.position().top}:!1},isBlockMirrored=function(e){var t=getBlock(e);return t.hasClass("block-mirrored")},getBlockMirrorOrigin=function(e){var t=getBlock(e);return isBlockMirrored(t)?t.data("block-mirror"):!1},getBlockMirrorLayoutName=function(e){var t=getBlock(e);return isBlockMirrored(t)?t.data("block-mirror-layout-name"):!1},updateBlockContentCover=function(e){if(Headway.mode!="grid")return!1;e.children(".block-content-cover").remove();var t=getBlockType(e),n=getBlockTypeNice(t),r="";return e.data("temp-id")&&(r=" <span>Unsaved</span>"),n||(n="Select Block Type"),e.data("alias")&&(n=e.data("alias")+" - "+n),e.append('                              <div class="block-content-cover">                                       <svg xmlns="http://www.w3.org/2000/svg" version="1.1">                                          <line class="x-line" x1="0" y1="0" x2="100%" y2="100%" />                                               <line class="x-line" x1="0" y1="100%" x2="100%" y2="0" />                                       </svg>                                                                          <span class="block-type-and-id">'+n+r+"</span>                          </div>                  "),e.find("div.block-content-cover")},loadBlockContent=function(e){var t={},n={blockElement:!1,blockSettings:{},blockOrigin:!1,blockDefault:!1,callback:function(e){},callbackArgs:null};$.extend(t,n,e);var r=t.blockElement.find("div.block-content"),i=getBlockType(t.blockElement);return Headway.gridSafeMode==1?r.html('<div class="alert alert-red block-safe-mode"><p>Grid Safe mode enabled.  Block content not outputted.</p></div>'):Headway.mode=="grid"&&!getBlockTypeObject(i)["show-content-in-grid"]?(typeof t.callback=="function"&&t.callback(t.callbackArgs),r.html("")):(createCog(r,!0,!0,Headway.iframe.contents(),1),$.ajax({url:Headway.ajaxURL,cache:!1,type:"POST",dataType:"text",data:{security:Headway.security,action:"headway_visual_editor",method:"load_block_content",unsaved_block_settings:t.blockSettings,block_origin:t.blockOrigin,block_default:t.blockDefault,layout:Headway.currentLayout,mode:Headway.mode}}).done(function(e){typeof t.callback=="function"&&t.callback(t.callbackArgs);if(Headway.mode=="grid"){var e=e.replace(/script/g,"SCRIPTTOCHECK"),n=$($.parseHTML(e));n.find("SCRIPTTOCHECK").remove()}else var n=$(e);return typeof window.frames["content"].jQuery!="undefined"&&window.frames.content.jQuery("#block-"+getBlockID(t.blockElement)).html(n).length?(Headway.mode=="design"&&refreshInspector(),window.frames.content.jQuery("#block-"+getBlockID(t.blockElement))):(r.html(n),Headway.mode=="design"&&refreshInspector(),r)}))},refreshBlockContent=function(e,t,n,r){if(typeof e=="undefined"||!e)return!1;if(typeof r=="undefined")var r=!0;var i=function(){var r=$i('.block[data-id="'+e+'"]'),i=GLOBALunsavedValues.blocks[e].settings,s=r.data("duplicateOf")?r.data("duplicateOf"):e;loadBlockContent({blockElement:r,blockSettings:{settings:i,dimensions:getBlockDimensions(r),position:getBlockPosition(r)},blockOrigin:s,blockDefault:{type:getBlockType(r),id:0,layout:Headway.currentLayout},callback:t,callbackArgs:n})};if(!r)return i();typeof updateBlockContentFloodTimeoutAfter!="undefined"&&clearTimeout(updateBlockContentFloodTimeoutAfter),typeof updateBlockContentFloodTimeout=="undefined"?(i.call(),updateBlockContentFloodTimeout=setTimeout(function(){delete updateBlockContentFloodTimeout},500)):updateBlockContentFloodTimeoutAfter=setTimeout(function(){i.call(),delete updateBlockContentFloodTimeoutAfter},600)},setupBlockContextMenu=function(e){if(typeof e=="undefined")var e=!0;setupContextMenu({id:"block",elements:".block:visible",title:function(e){var t=getBlock(e.currentTarget),n=getBlockID(t),r=getBlockType(t),i=r?getBlockTypeNice(r)+" ":"",s=getBlockTypeIcon(r,!0),o=s?' style="background-image:url('+s+');"':null;return'<span class="type type-'+r+'" '+o+"></span>"+i+"Block"},contentsCallback:function(e){var t=$(this),n=getBlock(e.currentTarget),r=getBlockID(n),i=getBlockType(n),s=getBlockTypeNice(i),o=Headway.touch?"tap":"click";$('<li class="context-menu-block-options"><span>Open Block Options</span></li>').appendTo(t).on(o,function(){openBlockOptions(n)}),Headway.mode=="grid"&&$('<li class="context-menu-block-switch-type"><span>Switch Block Type</span></li>').appendTo(t).on(o,function(){openBlockTypeSelector(n)}),Headway.mode=="grid"&&$('<li class="context-menu-block-duplicate"><span>Duplicate Block</span></li>').appendTo(t).on(o,function(){duplicateBlock(n)}),$('<li class="context-menu-set-alias"><span>Set Block Alias</span></li>').appendTo(t).on(o,function(){var e=prompt("Please enter the desired block alias.",n.data("alias"));if(!e)return;dataSetBlockOption(getBlockID(n),"alias",e),n.data("alias",e),updateBlockContentCover(n)}),isBlockMirrored(n)&&$('<li class="context-menu-block-unmirror"><span>Unmirror Block</span></li>').appendTo(t).on(o,function(){if(!confirm("Are you sure you want to unmirror this block?\n\nIt will no longer copy the options and styling from the block it is currently mirroring."))return;updateBlockMirrorStatus(!1,n,""),dataSetBlockOption(getBlockID(n),"mirror-block",""),reloadBlockOptions(getBlockID(n))}),Headway.mode=="grid"&&$('<li class="context-menu-block-delete"><span>Delete Block</span></li>').appendTo(t).on(o,function(e){if(!confirm("Are you sure you want to delete this block?"))return!1;deleteBlock(n)})}})},bindBlockDimensionsTooltip=function(){if(Headway.touch)return!1;$i("body").delegate(".block","mouseenter",function(e){var t=this,n=typeof $(this).data("qtip")=="undefined"?!0:!1;if(typeof Headway.disableBlockDimensions!="undefined"&&Headway.disableBlockDimensions)return!1;n&&(addBlockDimensionsTooltip($(this)),$(this).data("hoverWaitTimeout",setTimeout(function(){$(t).qtip("reposition"),$(t).qtip("show"),typeof $(t).data("qtip")!="undefined"&&$i("#qtip-"+$(t).data("qtip").id).show()},300)))}),$i("body").delegate(".block","mouseleave",function(e){clearTimeout($(this).data("hoverWaitTimeout"))})},addBlockDimensionsTooltip=function(e){return Headway.touch?!1:($(e).qtip({style:{classes:"qtip-headway qtip-block-dimensions"},position:{my:"top center",at:"bottom center",container:$i("body"),viewport:$i("#headway-tooltip-container"),effect:!1},show:{delay:300,solo:!0,effect:!1},hide:{delay:25,effect:!1},content:{text:blockDimensionsTooltipContent}}),$(e).qtip("api"))},blockDimensionsTooltipContent=function(e){var t=getBlock(this),n=getBlockID(t),r=getBlockDimensionsPixels(t).width,i=getBlockDimensionsPixels(t).height,s=getBlockType(t);if(typeof s!="undefined")var o=getBlockTypeNice(s),u=getBlockTypeIcon(s,!0),a=u?' style="background-image:url('+u+');"':null,f=t.data("alias")?": "+t.data("alias"):"",l=getBlockMirrorLayoutName(t)?" from "+getBlockMirrorLayoutName(t):"",c=isBlockMirrored(t)?'<span class="block-info-mirroring">Mirroring'+l+"</span>":"",h=isBlockMirrored(t)?"main-block-info main-block-info-mirrored":"main-block-info",p='<div class="block-info"><span class="block-info-type" '+a+"></span>"+'<span class="'+h+'">'+o+" "+f+"</span>"+c+"</div>";else var p="";if(getBlockTypeObject(s)["fixed-height"])var i=i,d="Height";else var i=Headway.mode=="grid"?i:t.css("minHeight").replace("px",""),d="Min. Height";var v='<span class="block-height"><strong>'+d+":</strong> "+i+"<small>px</small></span>",m='<span class="block-width"><strong>Width:</strong> '+r+"<small>px</small></span>";if($("#input-enable-responsive-grid label.checkbox-checked").length==1||Headway.mode!="grid"&&Headway.responsiveGrid)var m='<span class="block-width"><strong>Max Width:</strong> <small>~</small>'+r+"<small>px</small></span>";var g=getBlockTypeObject(s)["fixed-height"]?"":'<span class="block-fluid-height-message">Height will auto-expand</span>';return p+m+' <span class="block-dimensions-separator">&#9747;</span> '+v+g+'<span class="right-click-message">Right-click to open block options</span>'},openBlockOptions=function(block,subTab){if(typeof block.target!="undefined"||!block)var block=getBlock(this);if(typeof subTab=="undefined")var subTab=null;if(!block||block.hasClass("block-type-unknown"))return!1;var blockID=getBlockID(block),blockType=getBlockType(block),blockTypeName=getBlockTypeNice(blockType),readyTabs=function(){var tab=$("div#block-"+blockID+"-tab");tab.tabs(),panelInputs.bind("div#block-"+blockID+"-tab"),setupTooltips();var callback=eval(tab.find("ul.sub-tabs").attr("data-open-js-callback"));typeof callback=="function"&&callback({block:block,blockID:blockID,blockType:blockType}),handleInputTogglesInContainer(tab.find("div.sub-tabs-content")),subTab&&selectTab(subTab,$("div#block-"+blockID+"-tab")),$("div#block-"+blockID+"-tab").find("select#input-"+blockID+"-mirror-block").val()!=""&&($("div#block-"+blockID+"-tab ul.sub-tabs li:not(#sub-tab-config)").hide(),selectTab("sub-tab-config",$("div#block-"+blockID+"-tab")))},blockTypeIconURL=getBlockTypeIcon(blockType,!0),blockTypeIconStyle=blockTypeIconURL?"background-image:url("+blockTypeIconURL+");":null,blockTabName=blockTypeName+" Block";block.data("alias")&&block.data("alias").length&&(blockTabName=block.data("alias")),addPanelTab("block-"+blockID,'<span class="block-type-icon" style="'+blockTypeIconStyle+'"></span>'+blockTabName,{url:Headway.ajaxURL,data:{security:Headway.security,action:"headway_visual_editor",method:"load_block_options",block_type:blockType,block_id:blockID,duplicate_of:block.data("duplicateOf"),unsaved_block_options:getUnsavedBlockOptionValues(blockID),layout:Headway.currentLayout},callback:readyTabs},!0,!0,"block-type-"+blockType),$("div#panel").tabs("option","active",$("#panel-top").children('li[role="tab"]').index($('[aria-controls="block-'+blockID+'-tab"]')))},reloadBlockOptions=function(e,t){if(!$("ul#panel-top").find('[aria-controls="block-'+e+'-tab"]').length)return;if(typeof e=="undefined"||!e)var e=$("ul#panel-top > li.ui-state-active").attr("aria-controls").replace("block-","").replace("-tab","");if($("ul#panel-top > li.ui-state-active").attr("aria-controls").indexOf("block-")!==0)return!1;if(typeof t=="undefined"||!t)var t=$("div#block-"+e+"-tab ul.sub-tabs .ui-state-active a").attr("href").replace("#","");return removePanelTab("block-"+e),openBlockOptions(getBlockByID(e),t)},getUnsavedBlockOptionValues=function(e){if(typeof GLOBALunsavedValues=="object"&&typeof GLOBALunsavedValues["blocks"]=="object"&&typeof GLOBALunsavedValues["blocks"][e]=="object"&&typeof GLOBALunsavedValues["blocks"][e]["settings"]=="object")var t=GLOBALunsavedValues.blocks[e].settings;return typeof t=="object"&&Object.keys(t).length>0?t:null},openBlockTypeSelector=function(e){var t=getBlockID(e);removePanelTab("block-"+t),addPanelTab("block-"+t,"Select Block Type","",!0,!0);var n=$("#block-"+t+"-tab"),r=$(".block-type-selector-original").clone().removeClass("block-type-selector-original").appendTo(n).show();r.find("div.block-type").addClass("tooltip"),setupTooltips(),r.find("div.block-type").bind("click",function(n){var r=$(this).attr("id").replace("block-type-","");if(e.hasClass("blank-block"))e.parents(".wrapper").headwayGrid("setupBlankBlock",r);else if(confirm("Are you sure you wish to switch block types?  All settings for this block will be lost.")){var i=switchBlockType(e,r);t=i}$(".qtip").qtip("hide"),removePanelTab("block-"+t),openBlockOptions(getBlockByID(t))}),e.hasClass("blank-block")&&($(".wrapper").bind("mousedown",{block:e},hideBlankBlockTypeSelector),$(document).bind("keyup.esc",{block:e},hideBlankBlockTypeSelector),$i("html").bind("keyup.esc",{block:e},hideBlankBlockTypeSelector),$('ul#panel-top li a[href="#block-'+t+'-tab"]').siblings("span.close").bind("mouseup",{block:e},hideBlankBlockTypeSelector)),$("div#panel").tabs("option","active",$("#panel-top").children('li[role="tab"]').index($('[aria-controls="block-'+t+'-tab"]')));return},hideBlankBlockTypeSelector=function(e){var t=e.data.block;return t.hasClass("blank-block")&&$(e.target).parents(".block").first().get(0)!=$(t).get(0)&&(removePanelTab("block-"+getBlockID(t)),t.remove(),$(".wrapper").unbind("mousedown",hideBlankBlockTypeSelector),$(document).unbind("keyup.esc",hideBlankBlockTypeSelector),$i("html").unbind("keyup.esc",hideBlankBlockTypeSelector)),!0},switchBlockType=function(e,t,n){var r=getBlockTypeIcon(t,!0),i=getBlockType(e),s=getBlockID(e);e.removeClass("block-type-"+i),e.addClass("block-type-"+t),e.data("type",t),(typeof n=="undefined"||n)&&loadBlockContent({blockElement:e,blockOrigin:{type:t,id:0,layout:Headway.currentLayout},blockSettings:{dimensions:getBlockDimensions(e),position:getBlockPosition(e)}}),getBlockTypeObject(t)["fixed-height"]===!0?(e.removeClass("block-fluid-height"),e.addClass("block-fixed-height"),e.css("min-height").replace("px","")!="0"&&e.css({height:e.css("min-height")})):(e.removeClass("block-fixed-height"),e.addClass("block-fluid-height"),e.css("height").replace("px","")!="auto"&&e.css({height:e.css("height")})),getBlockTypeObject(t)["show-content-in-grid"]?e.removeClass("hide-content-in-grid"):e.addClass("hide-content-in-grid"),e.removeClass("block-type-unknown"),oldBlockID=s;var o=Math.ceil(Math.random()*1e9);return e.attr("id","block-"+o).attr("data-id",o).attr("data-temp-id",o).data("id",o).data("temp-id",o),removePanelTab("block-"+oldBlockID),dataDeleteBlock(oldBlockID),dataAddBlock(e),dataSetBlockPosition(o,getBlockPosition(e)),dataSetBlockDimensions(o,getBlockDimensions(e)),dataSetBlockWrapper(o,getBlockWrapper(e).attr("id")),updateBlockContentCover(e),updateBlockMirrorStatus(!1,e,"",!1),allowSaving(),$(".qtip").qtip("hide"),o},duplicateBlock=function(e){if(!$(e).length)return!1;var t=getBlockWrapper(e),n=getBlockPosition(e),r=getBlockDimensions(e),i=e.data("alias")?e.data("alias")+" Copy":"",s=e.data("duplicateOf")?e.data("duplicateOf"):getBlockID(e),o={type:getBlockType(e),top:parseInt(n.top)+20,left:n.left,width:r.width,height:r.height,settings:{duplicateOf:s,alias:i}},u=t.data("ui-headwayGrid").addBlock(o);return t.data("ui-headwayGrid").sendBlockToTop(u),i&&(u.data("alias",i),updateBlockContentCover(u)),u},blockIntersectCheck=function(e,t){if(typeof t=="undefined"||!t)var t=block.parents(".grid-container").first();var n=blockIntersectCheckCallback(e,t.find(".block"));if(n.length>1){n.addClass("block-error");var r=!1}else{var i=0;t.find(".block-error").each(function(){var e=blockIntersectCheckCallback(this,t.find(".block"));e.length===1||!e?$(this).removeClass("block-error"):i++});var r=i===0?!0:!1}return r?(Headway.overlappingBlocks=!1,hideNotification("overlapping-blocks")):(Headway.overlappingBlocks=!0,showErrorNotification({id:"overlapping-blocks",message:"There are <strong>overlapping blocks</strong>.<br />Please separate them before saving.",closeTimer:!1})),r},blockIntersectCheckCallback=function(e,t){if(e==0||t==0||!$(e).is(":visible"))return!1;var n=[],r=5,i=$(e),s=i.offset(),o=[s.left,s.left+i.outerWidth()],u=[s.top,s.top+i.outerHeight()];return $(t).each(function(){var e=$(this);if(!e.is(":visible"))return;var t=e.offset(),i=[t.left,t.left+e.outerWidth()],s=[t.top,t.top+e.outerHeight()];o[0]+r<i[1]&&o[1]-r>i[0]&&u[0]<s[1]&&u[1]>s[0]&&n.push(this)}),$(n)},deleteBlock=function(e){if(typeof e!="object")var e=$i('.block[data-id="'+e+'"]');var t=getBlockID(e),n=getBlock(e),r=n.parents(".grid-container");Headway.history.add({description:"Deleted block",up:function(){n.hide(),removePanelTab("block-"+t),dataDeleteBlock(t),blockIntersectCheck(!1,r)},down:function(){n.show(),typeof GLOBALunsavedValues["blocks"][getBlockID(n)]["delete"]!="undefined"&&delete GLOBALunsavedValues.blocks[getBlockID(n)]["delete"],blockIntersectCheck(n,r)}}),allowSaving()},exportBlockSettingsButtonCallback=function(e){var t={security:Headway.security,action:"headway_visual_editor",method:"export_block_settings","block-id":e.blockID},n=Headway.ajaxURL+"?"+$.param(t);return window.open(n)},initiateBlockSettingsImport=function(e){var t=e.input,n=e.blockID,r=$(t).parents(".ui-tabs-panel").first().find('input[name="block-import-settings-file"]'),i=hwBoolean($(t).parents(".ui-tabs-panel").first().find('input[name="block-import-settings-include-options"]').val()),s=hwBoolean($(t).parents(".ui-tabs-panel").first().find('input[name="block-import-settings-include-design"]').val());if(!r.val())return alert("You must select a block settings export file before importing.");if(!i&&!s)return alert("You must import at least the options or design when importing block settings.");var o=r.get(0).files[0];if(o&&typeof o.name!="undefined"&&typeof o.type!="undefined"){var u=new FileReader;u.onload=function(e){var t=e.target.result,r=JSON.parse(t);if(r["data-type"]!="block-settings")return alert("Cannot load block settings.  Please insure that the block settings are a proper Headway block settings export.");if(getBlockType(getBlockByID(n))!=r["type"])return alert("Block type mismatch.  Be sure that the block settings export is the same type of block type that you're importing to.");typeof r["image-definitions"]!="undefined"&&Object.keys(r["image-definitions"]).length?(showNotification({id:"importing-images",message:"Currently importing images.",closeTimer:1e4}),$.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"import_images",importFile:r},function(e){var t=e;if(typeof t["error"]!="undefined")return alert("Error while importing images for block: "+t.error);importBlockSettingsAJAXCallback(n,t,i,s)})):importBlockSettingsAJAXCallback(n,r,i,s)},u.readAsText(o)}else alert("Cannot load block settings.  Please insure that the block settings are a proper Headway block settings export.")},importBlockSettingsAJAXCallback=function(e,t,n,r){if(n){var e=switchBlockType(getBlockByID(e),getBlockType(getBlockByID(e)));importBlockSettings(t.settings,e),removePanelTab("block-"+e),openBlockOptions(getBlockByID(e))}r&&typeof t["styling"]!="undefined"&&typeof t["id"]!="undefined"&&(dataPrepareDesignEditor(),$.each(t.styling,function(n,r){var i=t.id,s=e,n=n.replace("block-"+i,"block-"+s);$.each(r.properties,function(e,t){dataSetDesignEditorProperty({element:r.element,property:e,value:t!==null?t.toString():null,specialElementType:"instance",specialElementMeta:n})})}),showNotification({id:"block-design-imported-"+e,message:"Block design successfully imported",closeTimer:6e3,success:!0})),allowSaving()},importBlockSettings=function(e,t){dataPrepareBlock(t),GLOBALunsavedValues.blocks[t].settings=e,refreshBlockContent(t),showNotification({id:"block-settings-imported-"+t,message:"Block settings successfully imported",closeTimer:6e3,success:!0})},updateBlockMirrorStatus=function(e,t,n,r){if(typeof e=="undefined"||e==0)e=$();typeof r=="undefined"&&(r=!0);if(typeof t!="object")var t=getBlock($i('.block[data-id="'+t+'"]'));typeof n=="undefined"||n==""?(e.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").show(),t.attr("id","block-"+t.data("id")),t.data("block-mirror",!1),t.removeClass("block-mirrored")):(e.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").hide(),t.attr("id","block-"+n),t.data("block-mirror",n),t.addClass("block-mirrored"))},updateBlockCustomClasses=function(e,t,n){return Headway.mode!="design"?!1:(typeof t!="object"&&(t=getBlock($i('.block[data-id="'+t+'"]'))),t.length?(t.removeClass(t.data("custom-classes")),t.data("custom-classes",n),t.addClass(n),t):!1)}}),define("util.custommouse",["jquery","jqueryUI"],function(e){e.widget("ui.custommouse",e.ui.mouse,{options:{mouseStart:function(e){},mouseDrag:function(e){},mouseStop:function(e){},mouseCapture:function(e){return!0}},_mouseStart:function(e){return this.options.mouseStart(e)},_mouseDrag:function(e){return this.options.mouseDrag(e)},_mouseStop:function(e){return this.options.mouseStop(e)},_mouseCapture:function(e){return this.options.mouseCapture(e)},widgetEventPrefix:"custommouse",_init:function(){return this._mouseInit()},_create:function(){return this.element.addClass("ui-custommouse")},_destroy:function(){return this._mouseDestroy(),this.element.removeClass("ui-custommouse")}})}),define("helper.data",["underscore"],function(_){dataHandleInput=function(input,value,additionalCallbackArgs){var input=$(input);if(!input.length)return!1;if(typeof value=="undefined")var value=input.val();var optionID=input.attr("name").toLowerCase(),optionGroup=input.attr("data-group").toLowerCase(),callback=eval(input.attr("data-callback")),dataHandlerOverrideCallback=eval(input.attr("data-data-handler-callback"))||null,panelArgs=input.parents(".sub-tabs-content-container").first().data("panel-args")||{},callbackArgs=$.extend({},{input:input,value:value},panelArgs);typeof additionalCallbackArgs=="object"&&(callbackArgs=$.extend({},callbackArgs,additionalCallbackArgs)),allowSaving();if(!input.hasClass("repeater-group-input")&&input.parents(".repeater-group").length)return updateRepeaterValues(input.parents(".repeater")),typeof callback=="function"&&callback(callbackArgs),input.parents(".repeater-group");if(input.attr("data-no-save"))return typeof callback=="function"&&callback(callbackArgs),input;if(typeof dataHandlerOverrideCallback=="function")dataHandlerOverrideCallback(callbackArgs);else{if(typeof panelArgs.block!="undefined"&&panelArgs.block){var blockID=panelArgs.blockID;return dataSetBlockOption(blockID,optionID,value),refreshBlockContent(blockID,callback,callbackArgs),input}typeof panelArgs.wrapper!="undefined"&&panelArgs.wrapper?dataSetWrapperOption(panelArgs.wrapper.id,optionID,value):dataSetOption(optionGroup,optionID,value)}return typeof callback=="function"&&callback(callbackArgs),input},dataSetOption=function(e,t,n){return dataPrepareOptionGroup(e),GLOBALunsavedValues.options[e][t]=n,allowSaving(),GLOBALunsavedValues.options[e]},dataPrepareOptionGroup=function(e){return typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["options"]!="object"&&(GLOBALunsavedValues.options={}),typeof GLOBALunsavedValues["options"][e]!="object"&&(GLOBALunsavedValues.options[e]={}),GLOBALunsavedValues.options[e]},dataSetBlockOption=function(e,t,n){return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].settings[t]=n,allowSaving(),GLOBALunsavedValues.blocks[e]},dataSetBlockPosition=function(e,t){if(typeof e=="string"&&e.indexOf("block-")!==-1)var e=e.replace("block-","");var t=t.left+","+t.top;return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].position=t,allowSaving(),GLOBALunsavedValues.blocks[e]},dataSetBlockDimensions=function(e,t){if(typeof e=="string"&&e.indexOf("block-")!==-1)var e=e.replace("block-","");var t=t.width+","+t.height;return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].dimensions=t,allowSaving(),GLOBALunsavedValues.blocks[e]},dataSetBlockWrapper=function(e,t){return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e].wrapper=t.toString().replace("wrapper-",""),allowSaving(),GLOBALunsavedValues.blocks[e]},dataDeleteBlock=function(e){if(typeof e=="string"&&e.indexOf("block-")!==-1)var e=e.replace("block-","");return dataPrepareBlock(e),GLOBALunsavedValues.blocks[e]["delete"]=!0,allowSaving(),GLOBALunsavedValues.blocks[e]},dataAddBlock=function(e){var t,n;return typeof e=="string"&&t.indexOf("block-")!==-1?t=e.replace("block-",""):t=getBlockID(e),n=getBlockType(e),dataPrepareBlock(t),GLOBALunsavedValues.blocks[t]["new"]=n,GLOBALunsavedValues.blocks[t].insert_id=e.data("desired-id"),delete GLOBALunsavedValues.blocks[t]["delete"],allowSaving(),GLOBALunsavedValues.blocks[t]},dataPrepareBlock=function(e){return typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["blocks"]!="object"&&(GLOBALunsavedValues.blocks={}),typeof GLOBALunsavedValues["blocks"][e]!="object"&&(GLOBALunsavedValues.blocks[e]={}),typeof GLOBALunsavedValues["blocks"][e]["settings"]!="object"&&(GLOBALunsavedValues.blocks[e].settings={}),GLOBALunsavedValues.blocks[e]},dataSetWrapperOption=function(e,t,n){return e=String(e).replace("wrapper-",""),dataPrepareWrapper(e),GLOBALunsavedValues.wrappers[e].settings[t]=n,allowSaving(),GLOBALunsavedValues.wrappers[e]},dataAddWrapper=function(e,t,n){return wrapperID=String(e.attr("id")).replace("wrapper-",""),dataPrepareWrapper(wrapperID),GLOBALunsavedValues.wrappers[wrapperID]={"new":!0,insert_id:e.data("desired-id"),position:n,settings:jQuery.extend({},{columns:Headway.defaultGridColumnCount,"column-width":Headway.globalGridColumnWidth,"gutter-width":Headway.globalGridGutterWidth},t)},dataSortWrappers(),allowSaving(),GLOBALunsavedValues.wrappers[wrapperID]},dataDeleteWrapper=function(e){return e=String(e).replace("wrapper-",""),dataPrepareWrapper(e),GLOBALunsavedValues.wrappers[e]["delete"]=!0,allowSaving(),GLOBALunsavedValues.wrappers[e]},dataSetWrapperWidth=function(e,t){var n=t=="fluid";return dataSetWrapperOption(e,"fluid",n)},dataSetWrapperGridWidth=function(e,t){var n=t=="fluid";return dataSetWrapperOption(e,"fluid-grid",n)},dataSortWrappers=function(){$i(".wrapper:visible").each(function(){var e=$(this).data("id");dataPrepareWrapper(e),GLOBALunsavedValues.wrappers[e].position=$i(".wrapper").index(this)})},dataPrepareWrapper=function(e){e=String(e).replace("wrapper-",""),typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["wrappers"]=="undefined"&&(GLOBALunsavedValues.wrappers={}),typeof GLOBALunsavedValues["wrappers"][e]=="undefined"&&(GLOBALunsavedValues.wrappers[e]={}),typeof GLOBALunsavedValues["wrappers"][e]["settings"]=="undefined"&&(GLOBALunsavedValues.wrappers[e].settings={})},dataHandleDesignEditorInput=function(e){var t=$(e.hiddenInput),n=e.value;if(!t.length)return!1;if(t.parents("li.uncustomized-property").length==1)return!1;var r=t.attr("element").toLowerCase(),i=t.attr("property").toLowerCase(),s=t.attr("element_selector")||!1,o=t.attr("special_element_type").toLowerCase()||!1,u=t.attr("special_element_meta").toLowerCase()||!1;e.unit=t.siblings(".property-unit-select").find("select").val(),dataSetDesignEditorProperty({element:r,property:i,value:n,specialElementType:o,specialElementMeta:u,unit:e.unit});if(n==="null"||n=="DELETE")n=null;return t.val(n),$("#design-editor-element-selector-container").find("li#element-"+r).addClass("customized-element").attr("title","You have customized a property in this property group."),$("#design-editor-main-elements").find(".ui-state-active").length&&$("#design-editor-sub-elements").find(".ui-state-active").length&&$("#design-editor-main-elements").find(".ui-state-active").addClass("has-customized-children"),t.parents(".design-editor-box").first().addClass("design-editor-box-customized"),t.parents(".design-editor-box").first().find(".design-editor-box-title").attr("title","You have customized a property in this property group."),dataDesignEditorPropertyFeedback({element:r,property:i,value:n,specialElementType:o,specialElementMeta:u,unit:e.unit})},dataDesignEditorPropertyFeedback=function(args){var element=args.element.toLowerCase(),property=args.property.toLowerCase(),value=args.value,specialElementType=args.specialElementType||!1,specialElementMeta=args.specialElementMeta||!1;if(value==="null"||value=="DELETE")args.value=null,value=null;if(!specialElementType||specialElementType=="layout")var selector=Headway.elements[element].selector;else var selector=Headway.elements[element][specialElementType+"s"][specialElementMeta].selector;if(Headway.designEditorProperties.hasOwnProperty(property)){var callback=eval("(function(params){"+Headway.designEditorProperties[property]["js-callback"]+"})");args.selector=selector,args.element=$i(selector),typeof args["unit"]=="undefined"&&(args.unit=""),callback(args)}return value==null&&selector&&property&&stylesheet.delete_rule_property(selector,property),selector},dataSetDesignEditorProperty=function(e){var t=e.element.toLowerCase(),n=e.property.toLowerCase(),r=e.value,i=e.unit,s=e.specialElementType||!1,o=e.specialElementMeta||!1;i&&i.length&&r!="null"&&r!="DELETE"&&(r+=i),dataPrepareDesignEditor(),typeof GLOBALunsavedValues["design-editor"][t]!="object"&&(GLOBALunsavedValues["design-editor"][t]={});if(s==0||o==0)typeof GLOBALunsavedValues["design-editor"][t]["properties"]!="object"&&(GLOBALunsavedValues["design-editor"][t].properties=new Object),GLOBALunsavedValues["design-editor"][t].properties[n]=r,typeof Headway.elementData!="object"&&(Headway.elementData=new Object),typeof Headway.elementData[t]=="undefined"&&(Headway.elementData[t]={properties:{}}),typeof Headway.elementData[t]["properties"]=="undefined"&&(Headway.elementData[t].properties={}),Headway.elementData[t].properties[n]=r;else{typeof GLOBALunsavedValues["design-editor"][t]["special-element-"+s]!="object"&&(GLOBALunsavedValues["design-editor"][t]["special-element-"+s]=new Object),typeof GLOBALunsavedValues["design-editor"][t]["special-element-"+s][o]!="object"&&(GLOBALunsavedValues["design-editor"][t]["special-element-"+s][o]=new Object),GLOBALunsavedValues["design-editor"][t]["special-element-"+s][o][n]=r,typeof Headway.elementData!="object"&&(Headway.elementData=new Object),typeof Headway.elementData[t]!="object"&&(Headway.elementData[t]=new Object),typeof Headway.elementData[t]["special-element-"+s]!="object"&&(Headway.elementData[t]["special-element-"+s]=new Object);if(!_.isObject(Headway.elementData[t]["special-element-"+s][o])||_.isArray(Headway.elementData[t]["special-element-"+s][o]))Headway.elementData[t]["special-element-"+s][o]=new Object;Headway.elementData[t]["special-element-"+s][o][n]=r}if(typeof designEditor!="undefined"){var u=$('ul#design-editor-element-selector li.element[data-element-id="'+t+'"]');s=="instance"?u=u.filter('[data-instance-id="'+o+'"]'):s=="state"&&(u=u.filter('[data-state-id="'+o+'"]')),designEditor.showElementPropertiesThrottled(u)}return allowSaving(),!0},dataPrepareDesignEditor=function(){return typeof GLOBALunsavedValues!="object"&&(GLOBALunsavedValues={}),typeof GLOBALunsavedValues["design-editor"]!="object"&&(GLOBALunsavedValues["design-editor"]={}),GLOBALunsavedValues["design-editor"]}}),wrapperOptionCallbackIndependentGrid=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;var i=r.data("ui-headwayGrid");i.options.useIndependentGrid=t,i.updateGridCSS()},wrapperOptionCallbackColumnCount=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;if(r.find(".block:visible").length)return alert("This wrapper must be empty of blocks before you can change the number of columns.\n\nEither drag the blocks to another wrapper or delete them if they are no longer needed."),!1;var i=r.data("ui-headwayGrid");i.options.columns=t,i.addColumnGuides(),i.updateGridCSS()},wrapperOptionCallbackColumnWidth=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;var i=r.data("ui-headwayGrid");i.options.columnWidth=t,i.updateGridCSS()},wrapperOptionCallbackGutterWidth=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;var i=r.data("ui-headwayGrid");i.options.gutterWidth=t,i.updateGridCSS()},wrapperOptionCallbackMarginTop=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;r.css({marginTop:t}),wrapperMarginFeedbackCreator(r,"top")},wrapperOptionCallbackMarginBottom=function(e,t){var n=e.parents("[data-panel-args]").data("panel-args").wrapper.id.replace("wrapper-",""),r=$i('.wrapper[data-id="'+n+'"]');if(typeof r=="undefined"||!r.length)return!1;r.css({marginBottom:t}),wrapperMarginFeedbackCreator(r,"bottom")},wrapperMarginFeedbackCreator=function(e,t){e.find(".wrapper-margin-feedback").length&&(clearTimeout(e.find(".wrapper-margin-feedback").data("fadeout-timeout")),e.find(".wrapper-margin-feedback").remove());var n=$('<div class="wrapper-margin-feedback"></div>').prependTo(e),r=parseInt(e.css("margin"+t.capitalize()).replace("px","")),i={position:"absolute",width:e.outerWidth(),left:0,height:r,backgroundColor:"rgba(255, 127, 0, .35)"};return i[t]="-"+r+"px",n.css(i),n.data("fadeout-timeout",setTimeout(function(){n.fadeOut(200)},400)),n},updateGridWidthInput=function(e){var t=$(e).find('input[name="columns"]').val(),n=$(e).find('input[name="column-width"]').val(),r=$(e).find('input[name="gutter-width"]').val(),i=n*t+(t-1)*r;return $(e).find('input[name="grid-width"]').val(i)},define("modules/grid/wrapper-inputs",function(){}),define("modules/grid/wrappers",["util.custommouse","qtip","helper.data","modules/grid/wrapper-inputs"],function(){setupWrapperSortables=function(){return $i("#whitewrap").sortable({items:"div.wrapper",handle:"div.wrapper-drag-handle",axis:"y",tolerance:"intersect",placeholder:"wrapper-sortable-placeholder",start:function(e,t){$i(".wrapper").each(function(){$(this).data("current-height",$(this).height())}),$(t.item).hasClass("wrapper-fixed-grid")&&$(t.item).css({left:"50%",marginLeft:"-"+$(t.item).outerWidth()/2+"px"}),t.placeholder.css({width:t.item.outerWidth(),height:t.item.outerHeight(),marginTop:t.item.css("marginTop"),marginBottom:t.item.css("marginBottom")}),Headway.iframe.data("maximumScrollTop",Headway.iframe.contents().height()),$(this).sortable("refreshPositions")},sort:function(e,t){e.clientY<100?(typeof wrapperDraggableScrollDownInterval=="number"&&(clearInterval(wrapperDraggableScrollDownInterval),delete wrapperDraggableScrollDownInterval),typeof wrapperDraggableScrollUpInterval=="undefined"&&(wrapperDraggableScrollUpInterval=setInterval(function(){Headway.iframe.contents().scrollTop(Headway.iframe.contents().scrollTop()-8)},5))):Headway.iframe.height()-e.clientY<100?(typeof wrapperDraggableScrollUpInterval=="number"&&(clearInterval(wrapperDraggableScrollUpInterval),delete wrapperDraggableScrollUpInterval),typeof wrapperDraggableScrollDownInterval=="undefined"&&(wrapperDraggableScrollDownInterval=setInterval(function(){var e=Headway.iframe.contents().scrollTop()+8;Headway.iframe.height()+e>=Headway.iframe.data("maximumScrollTop")&&(e=Headway.iframe.data("maximumScrollTop")-Headway.iframe.height()),Headway.iframe.contents().scrollTop(e)},5))):(typeof wrapperDraggableScrollDownInterval=="number"&&(clearInterval(wrapperDraggableScrollDownInterval),delete wrapperDraggableScrollDownInterval),typeof wrapperDraggableScrollUpInterval=="number"&&(clearInterval(wrapperDraggableScrollUpInterval),delete wrapperDraggableScrollUpInterval))},stop:function(e,t){$i(".wrapper").css({marginLeft:"",left:""}),$i(".wrapper").each(function(){$(this).headwayGrid("updateGridContainerHeight")}),typeof wrapperDraggableScrollDownInterval=="number"&&(clearInterval(wrapperDraggableScrollDownInterval),delete wrapperDraggableScrollDownInterval),typeof wrapperDraggableScrollUpInterval=="number"&&(clearInterval(wrapperDraggableScrollUpInterval),delete wrapperDraggableScrollUpInterval),dataSortWrappers()}})},setupWrapperResizable=function(e){if(typeof e=="undefined")var e=$i(".wrapper");e.each(function(){var e=parseInt($(this).css("minHeight").replace("px",""));$(this).resizable({handles:"n, s",grid:5,minHeight:e,start:function(t,n){$(t.toElement).hasClass("ui-resizable-n")?$(this).data("resizing-position","n"):$(this).data("resizing-position","s");if($(this).find(".block").length){var r=0,i=null;$(this).find(".block:visible").each(function(){var e=$(this).position().top,t=$(this).outerHeight()+e;t>r&&(r=t);if(e<i||i===null)i=e;$(this).data("resize-original-block-top",$(this).position().top)});if($(this).data("resizing-position")=="n")var s=r-i;else var s=r}else var s=e;$(this).resizable("option","minHeight",s)},resize:function(e,t){var n=t.originalSize.height-t.size.height,r=t.size.height;$(this).find(".grid-container").height(r),$(this).css({top:"",height:""});if($(this).data("resizing-position")=="n"){var i=!1;$(this).find(".block").each(function(){if($(this).data("resize-original-block-top")-n<0)return i=!0,!1}),i||$(this).find(".block").each(function(){$(this).css({top:$(this).data("resize-original-block-top")-n})})}},stop:function(){$(this).find(".block").each(function(){var e=$(this),t=getBlockID(e);e.attr("data-grid-top",e.position().top),dataSetBlockPosition(t,getBlockPosition(e))}),$(this).data("resizing-position",null)}})})},stopWrapperResizable=function(e){if(!e.length||!e.resizable)return!1;e.resizable("destroy"),setupWrapperResizable(e)},addEdgeInsertWrapperButtons=function(){var e='<div class="add-wrapper-button-fixed tooltip" title="Add Wrapper">+</div>';$('<div class="add-wrapper-buttons add-wrapper-buttons-top">'+e+"</div>").data("position","top").prependTo($i("body")),$('<div class="add-wrapper-buttons add-wrapper-buttons-bottom">'+e+"</div>").data("position","bottom").appendTo($i("body"))},setupWrapperContextMenu=function(){setupContextMenu({id:"wrapper",elements:".wrapper",title:function(e){var t=$(e.currentTarget),n=getWrapperID(t);return"Wrapper"},contentsCallback:function(e){var t=$(this),n=$(e.currentTarget),r=getWrapperID(n);$('<li class="context-menu-wrapper-options"><span>Open Wrapper Options</span></li>').appendTo(t).on("click",function(){openWrapperOptions(r)}),n.hasClass("wrapper-fluid")&&Headway.mode=="grid"?($('<li class="context-menu-wrapper-to-fixed"><span>Change Wrapper to Fixed</span></li>').appendTo(t).find("span").on("click",function(){n.removeClass("wrapper-fluid"),n.removeClass("wrapper-fluid-grid"),n.addClass("wrapper-fixed"),n.addClass("wrapper-fixed-grid"),dataSetWrapperWidth(getWrapperID(n),"fixed"),dataSetWrapperGridWidth(getWrapperID(n),"fixed"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()}),n.hasClass("wrapper-fixed-grid")?$('<li class="context-menu-wrapper-grid-to-fluid"><span>Change Grid to Fluid</span></li>').appendTo(t).find("span").on("click",function(){n.removeClass("wrapper-fixed-grid"),n.addClass("wrapper-fluid-grid"),dataSetWrapperWidth(getWrapperID(n),"fluid"),dataSetWrapperGridWidth(getWrapperID(n),"fluid"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()}):n.hasClass("wrapper-fluid-grid")&&$('<li class="context-menu-wrapper-grid-to-fixed"><span>Change Grid to Fixed</span></li>').appendTo(t).find("span").on("click",function(){n.removeClass("wrapper-fluid-grid"),n.addClass("wrapper-fixed-grid"),dataSetWrapperWidth(getWrapperID(n),"fluid"),dataSetWrapperGridWidth(getWrapperID(n),"fixed"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()})):n.hasClass("wrapper-fixed")&&Headway.mode=="grid"&&$('<li class="context-menu-wrapper-to-fluid"><span>Change Wrapper to Fluid</span></li>').appendTo(t).on("click",function(){n.removeClass("wrapper-fixed"),n.addClass("wrapper-fluid"),n.addClass("wrapper-fixed-grid"),dataSetWrapperWidth(getWrapperID(n),"fluid"),dataSetWrapperGridWidth(getWrapperID(n),"fixed"),n.data("ui-headwayGrid").resetGridCalculations(),n.data("ui-headwayGrid").alignAllBlocksWithGuides(),n.data("ui-headwayGrid").updateGridContainerHeight()}),$('<li class="context-menu-set-alias"><span>Set Wrapper Alias</span></li>').appendTo(t).on("click",function(){var e=prompt("Please enter the desired wrapper alias.",n.data("alias"));if(!e)return;dataSetWrapperOption(getWrapperID(n),"alias",e),n.data("alias",e)}),$i(".wrapper:visible").length>=2&&Headway.mode=="grid"&&$('<li class="context-menu-wrapper-delete"><span>Delete Wrapper</span></li>').appendTo(t).on("click",function(){deleteWrapper(r)})}})},bindWrapperButtons=function(){$i("body").delegate(".add-wrapper-button-fixed","click",function(){return addWrapper($(this).parents(".add-wrapper-buttons").data("position"),{fluid:!1})}),$i("body").delegate(".add-wrapper-fluid-fixed-grid","click",function(){return addWrapper($(this).parents(".add-wrapper-buttons").data("position"),{fluid:!0})}),$i("body").delegate(".add-wrapper-fluid-fluid-grid","click",function(){return addWrapper($(this).parents(".add-wrapper-buttons").data("position"),{fluid:!0,"fluid-grid":!0})}),$i("body").delegate(".wrapper-buttons .wrapper-options","click",function(){return openWrapperOptions(getWrapperID($(this).closest(".wrapper")))}),bindWrapperMarginButtons($i(".wrapper-buttons .wrapper-margin-handle"))},addWrapper=function(e,t,n){typeof t.id!="undefined"&&delete t.id;var t=$.extend({},{fluid:!1,"fluid-grid":!1,"use-independent-grid":!1},t);typeof t["fluid"]!="boolean"&&(t.fluid=hwBoolean(t.fluid)),typeof t["fluid-grid"]!="boolean"&&(t["fluid-grid"]=hwBoolean(t["fluid-grid"]));var r=Math.ceil(Math.random()*1e9),i=$('<div class="wrapper"><div class="grid-container"></div></div>');i.attr("id","wrapper-"+r).attr("data-id",r).attr("data-temp-id",r).attr("data-desired-id",t.id?t.id:null).data("id",r).data("temp-id",r).data("desired-id",t.id?t.id:null),i.prepend('<div class="wrapper-mirror-overlay"></div>'),i.find(".grid-container").append('                                           <div class="wrapper-mirror-notice">                                                     <div>                                                   <h2>Wrapper Mirrored</h2>                                                       <p>This wrapper is mirroring blocks from another wrapper.</p>                                                   <small>Mirroring can be disabled via Wrapper Options in the right-click menu</small>                                                    </div>                                          </div><!-- .wrapper-mirror-notice -->                                   '),addWrapperButtons(i),t.fluid?i.addClass("wrapper-fluid"):i.addClass("wrapper-fixed"),t["fluid-grid"]?i.addClass("wrapper-fluid-grid"):i.addClass("wrapper-fixed-grid");switch(e){case"top":i.prependTo($i("#whitewrap"));break;case"bottom":i.insertBefore($i("#wrapper-buttons-template"))}t.fluid&&(i.css("margin"+e.capitalize(),0),dataSetDesignEditorProperty({element:"wrapper",property:"margin-"+e,value:0,specialElementType:"instance",specialElementMeta:"wrapper-"+r})),dataAddWrapper(i,t,$i(".wrapper").index(i)),allowSaving(),i.find(".grid-container").height(100),i.data("wrapper-settings",t),i.headwayGrid(),setupWrapperResizable(i),bindWrapperMarginButtons(i.find(".wrapper-margin-handle"));var s=t.fluid?"Fluid":"Fixed";return(typeof n=="undefined"||!n)&&showNotification({id:"wrapper-created-"+r,message:s+" wrapper created.",closable:!0,closeTimer:5e3}),setupTooltips("iframe"),i},deleteWrapper=function(e,t){var n=$i('.wrapper[data-id="'+e+'"]');return n.length&&(t||confirm("Are you sure you want to remove this wrapper?  All blocks inside the wrapper will be deleted as well."))?(dataDeleteWrapper(e),n.find(".block").each(function(){deleteBlock($(this))}),n.remove()):!1},addWrapperButtons=function(e){e.each(function(){if($(this).find(".wrapper-buttons").length)return;var e=$i("#wrapper-buttons-template").first().clone().attr("id","").addClass("wrapper-buttons");return e.prependTo($(this))})},bindWrapperMarginButtons=function(e){var t=function(e){var t=$(e.target);t.length||(t=$i(".wrapper-handle[data-dragging]").first());var n=t.closest(".wrapper"),r=t.hasClass("wrapper-top-margin-handle")?"Top":"Bottom",i='<span style="opacity: .8;">'+r+" Margin:</span> "+n.css("margin"+r),s=t.data("dragging")?"":"Drag to change wrapper's <strong>"+r.toLowerCase()+" margin</strong><br />";return s+i};e.qtip({content:{text:t},style:{classes:"qtip-headway"},show:{delay:10,event:"mouseenter"},position:{my:"right center",at:"left center",container:Headway.iframe.contents().find("body"),viewport:$("#iframe-container"),effect:!1}}),e.custommouse({mouseStart:function(e){this.handle=$(e.currentTarget).hasClass("wrapper-margin-handle")?$(e.currentTarget):$(e.currentTarget).parents(".wrapper-margin-handle").first(),this.dragStart={left:e.pageX,top:e.pageY},this.marginToChange=this.handle.hasClass("wrapper-top-margin-handle")?"marginTop":"marginBottom",this.wrapper=$(e.currentTarget).closest(".wrapper"),this.originalWrapperMargin=parseInt(this.wrapper.css(this.marginToChange).replace("px","")),this.handle.siblings(".wrapper-handle[data-hasqtip], .wrapper-options[data-hasqtip]").each(function(){var e=$(this).qtip("api");typeof e!="undefined"&&e.rendered&&(e.disable(),e.hide())}),this.wrapper.addClass("wrapper-handle-in-use")},mouseDrag:function(e){var n=e.pageY-this.dragStart.top,r=2,i=Math.round(n/r),s=this.originalWrapperMargin+i;s<0&&(s=0),this.handle.attr("data-dragging",!0),this.handle.qtip("show"),this.handle.qtip("reposition"),this.handle.qtip("option","content.text",t),this.wrapper.css(this.marginToChange,s),dataSetDesignEditorProperty({element:"wrapper",property:"margin-"+this.marginToChange.replace("margin","").toLowerCase(),value:s.toString(),specialElementType:"instance",specialElementMeta:"wrapper-"+getWrapperID(this.wrapper)})},mouseStop:function(e){this.handle.removeAttr("data-dragging"),this.handle.data("dragging",!1);var t=this.handle.qtip("api");t.hide(),$i("#qtip-"+t.id).hide(),this.handle.siblings(".wrapper-handle, .wrapper-options").qtip("enable"),this.wrapper.removeClass("wrapper-handle-in-use")}})},populateWrapperMirrorNotice=function(e){var t=getWrapperMirror(getWrapperID(e));if(!t)return;e.find(".wrapper-mirror-notice-id").text(t.replace("wrapper-","")),e.find(".wrapper-mirror-notice-layout").hide()},assignDefaultWrapperID=function(){if($i("#wrapper-default").length){var e=Math.ceil(Math.random()*1e9),t=$i("#wrapper-default");t.attr("id","wrapper-"+e).attr("data-id",e).attr("data-temp-id",e).attr("data-desired-id",null).data("id",e).data("temp-id",e).data("desired-id",null),dataAddWrapper(t,{fluid:!1,"fluid-grid":!1},$i(".wrapper").index(t)),t.find(".block").each(function(){dataSetBlockWrapper(getBlockID($(this)),e)})}}}),define("modules/design/mode-design",["jquery","underscore","deps/colorpicker","helper.blocks","modules/grid/wrappers"],function(e,t){designEditorRequestElements=function(t){return Headway.elementsRequest&&(!t||typeof t=="undefined")?Headway.elementsRequest:(Headway.elementsRequest=e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"get_design_editor_elements",layout:Headway.currentLayout},function(t){Headway.elementGroups=e.extend({},t.groups),delete t.groups,Headway.elements=t},"json"),Headway.elementsRequest)},designEditorRequestElementData=function(t){return Headway.elementDataRequest&&(!t||typeof t=="undefined")?Headway.elementDataRequest:(Headway.elementDataRequest=e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"get_design_editor_element_data",layout:Headway.currentLayout},function(e){Headway.elementData=e},"json"),Headway.elementDataRequest)},designEditorTabEditor=function(){var n=this;this._init=function(){createCog(e("#design-editor-element-selector")),e.when(designEditorRequestElements(),designEditorRequestElementData()).then(this.setupElementSelector),this.bindElementSelector(),this.setupTabs(),this.setupBoxes(),this.bindDesignEditorInfo()},this.setupTabs=function(){e("#side-panel-top").tabs()},this.setupBoxes=function(){designEditorBindPropertyBoxToggle()},this.setupElementSelector=function(){e("#design-editor-element-selector").empty(),e.each(Headway.elementGroups,function(t,n){var r=e('<li id="element-group-'+t+'" class="element-group has-children">                                                                                     <span class="element-group-name">'+n.name+'</span>                                                                                      <span class="element-expander"></span>                                                                                  <ul class="group-elements"></ul>                                                                                </li>');typeof n.description!="undefined"&&n.description&&r.find(".element-group-name").after('<small class="description">'+n.description+"</small>"),r.appendTo("#design-editor-element-selector")}),e.each(Headway.elements,designEditor.addElementToSelector),e("#design-editor-element-selector li.element").each(function(){var t=e(this).data("parent");if(!t)return;var n=e("#design-editor-element-selector li#element-"+t);n.hasClass("has-children")||(n.addClass("has-children"),n.prepend('<span class="element-expander"></span>'),n.append('<ul class="children-elements"></ul>')),e(this).appendTo(n.find("> ul.children-elements")),e(this).hasClass("customized-element")&&n.addClass("had-customized-children")}),e("#design-editor-element-selector li.element").each(function(){designEditor.addElementStates(e(this)),designEditor.addElementInstances(e(this))}),e("body").bind("headwayIframeLoad",function(){designEditor.showOnlyLayoutElements()})},this.showAllElements=function(t){e("#design-editor-element-selector-container").removeClass("show-only-layout-elements"),e("#design-editor-element-selector li.not-on-layout").each(function(){e(this).show().removeClass("not-on-layout")})},this.showOnlyLayoutElements=function(){e("#design-editor-element-selector-container").addClass("show-only-layout-elements"),e("#design-editor-element-selector li.element").each(function(){if(!e(this).data("selector"))return;!$i(e(this).data("selector")).length&&!e(this).data("state-id")?e(this).hide().addClass("not-on-layout"):e(this).show().removeClass("not-on-layout")})},this.bindElementSelector=function(){var t=e("ul#design-editor-element-selector"),n=e("ul#design-editor-styles");t.on("click",designEditor.processNoElementClick),t.on("mouseenter","li span.element-name",designEditor.processElementMouseEnter),t.on("mouseleave","li span.element-name",designEditor.processElementMouseLeave),t.on("click","li span.element-name",designEditor.processElementClick),t.on("click","li span.element-expander",designEditor.processElementExpanderClick),t.on("click","li span.element-name span.element-name-button-layout-specific",designEditor.processElementNameLayoutSpecific),t.on("click","li span.element-name span.element-name-button-live-css",designEditor.processElementNameLiveCSS),n.on("click","li.property .property-value",designEditor.processPropertyValueClick),n.on("click","li.property .property-delete",designEditor.processPropertyDeleteClick),e("#side-panel-collapse-arrow").on("click",toggleDesignEditor),e("#element-selector-show-current-layout-elements").on("click",designEditor.showOnlyLayoutElements),e("#element-selector-show-all-elements").on("click",designEditor.showAllElements)},this.addElementToSelector=function(t,n){var r=n.description?'<small class="description">'+n.description+"</small>":"",i=e('<li id="element-'+t+'" data-element-id="'+t+'" class="element" data-selector="'+n.selector+'">                                                                                          <span class="element-name">'+n.name+"</span>                                                                                            "+r+"                                                                                   </li>");i.data({group:n.group,parent:n.parent,selector:n.selector,id:t}),n.customized&&i.addClass("customized-element"),i.appendTo(e("li#element-group-"+n.group+" ul.group-elements"))},this.addElementInstances=function(n){var r=n.data("element-id"),i=designEditorGetElementObject(r,!1).instances;if(t.isEmpty(i))return!1;var s=e.map(i,function(e,t){return[e]});s.sort(function(e,t){return e.name<t.name?-1:e.name>t.name?1:0}),n.hasClass("has-children")||(n.addClass("has-children"),n.prepend('<span class="element-expander"></span>'),n.append('<ul class="children-elements"></ul>')),n.children(".children-elements").prepend('                                                       <li id="element-'+r+'-instances" class="element element-instances-container has-children">                                                              <span class="element-expander"></span>                                                          <span class="element-name">Instances</span>                                                             <ul class="children-elements"></ul>                                                     </li>                                           '),n.addClass("instances-visible"),e.each(s,function(t,i){var s=i.id,o=i.name;typeof i["state-of"]!="undefined"&&i["state-of"]&&(o="  -- "+i["state-name"]);var u=e('<li id="element-instance-'+s+'" data-element-id="'+r+'" data-instance-id="'+s+'" data-selector="'+i.selector+'" class="element element-instance">                                                                          <span class="element-name">'+o+'</span>                                                                         <small class="description">'+i["layout-name"]+"</small>                                                                 </li>").appendTo(n.find("> ul.children-elements > li.element-instances-container > ul.children-elements"));u.data({selector:i.selector}),typeof i["customized"]!="undefined"&&i.customized&&u.addClass("customized-element")})},this.addElementStates=function(n){var r=n.data("element-id"),i=designEditorGetElementObject(r).states;if(t.isEmpty(i))return!1;n.hasClass("has-children")||(n.addClass("has-children"),n.prepend('<span class="element-expander"></span>'),n.append('<ul class="children-elements"></ul>')),n.children(".children-elements").prepend('                                                  <li id="element-'+r+'-states" class="element element-states-container has-children">                                                            <span class="element-expander"></span>                                                          <span class="element-name">States</span>                                                                <ul class="children-elements"></ul>                                                     </li>                                           '),n.addClass("states-visible"),e.each(i,function(t,i){var s=e('<li id="element-state-'+t+"-for-"+r+'" data-element-id="'+r+'" data-state-id="'+t+'" data-selector="'+i.selector+'" class="element element-state">                                                                              <span class="element-name">'+i.name+"</span>                                                                    </li>").appendTo(n.find("> ul.children-elements > li.element-states-container > ul.children-elements"));s.data({selector:i.selector})})},this.showElementProperties=function(r){if(typeof r!="object")var r=e(this);var i=r.data("element-id");e("ul#design-editor-styles").empty().show(),e(".design-editor-styles-message").hide();if(t.isEmpty(Headway.elementData[i])){e("ul#design-editor-styles").empty(),e("#design-editor-styles-no-styles").show(),e("#design-editor-styles-nothing-selected").hide();return}e("ul#design-editor-styles").prepend("<h2>"+r.children(".element-name").first().text()+"</h2>");var s=Headway.elementData[i],o=e('<li class="properties"><ul></ul></li>'),u=e("ul#design-editor-styles");t.isEmpty(Headway.elementData[i].properties)||e.each(Headway.elementData[i].properties,function(e,t){n.addElementProperty(u,e,t)});var a=["instance","state","layout"];return e.each(a,function(r,s){t.isEmpty(Headway.elementData[i]["special-element-"+s])||e.each(Headway.elementData[i]["special-element-"+s],function(r,o){if(s=="layout")var a=e('#layout-selector span[data-layout-id="'+r+'"] strong').text(),f="";else{if(!!t.isUndefined(designEditorGetElementObject(i,!1)[s+"s"][r]))return;var a=designEditorGetElementObject(i,!1)[s+"s"][r].name;if(typeof designEditorGetElementObject(i,false)[s+"s"][r]["layout-name"]!="undefined")var f=" &ndash; Layout: "+designEditorGetElementObject(i,!1)[s+"s"][r]["layout-name"];else var f=""}e.each(o,function(e,t){n.addElementProperty(u,e,t,{type:s,id:r,name:a,layoutName:f})})})}),setupTooltips(),o},this.showElementPropertiesThrottled=t.throttle(this.showElementProperties,300),this.addElementProperty=function(n,r,i,s){if(i=="DELETE")return!1;if(typeof Headway.designEditorProperties[r]=="undefined")return!1;var o,u=Headway.designEditorProperties[r],a=u.group.toLowerCase().replace(" ","-");n.find('.property-value-group-name[data-property-group-id="'+a+'"]').length||(n.append('<li class="property-value-group-name" data-property-group-id="'+a+'">'+u.group+"</strong></li>"),n.append('<ul data-property-group-id="'+a+'"></ul>'));if(t.isEmpty(i))o="Inheriting";else if(u["type"]=="color"){var f=i.replace("#","");f.length==6&&(f="#"+f),o='                                                                       <div class="colorpicker-box-container">                                                                         <div style="background-color: '+f+'" class="colorpicker-box"></div>                                                                     </div>',i.replace("#","").toUpperCase().length==6&&(o+='<span style="font-family:monospace;">#'+i.replace("#","").toUpperCase()+"</span>")}else if(u["type"]=="image")o='                                                                       <span class="tooltip tooltip-left" title="&lt;img src=\''+i+"' style='max-width:300px;height:auto;' /&gt;\" >Preview</span>                                                             ";else if(u.unit&&i){if(typeof u["unit"]!="object")var l=u.unit;else{var l=i.replace(/^[+-]?\d+(\.\d+)?/g,"");l||(u.unit["default"]||(u.unit["default"]="px"),l=u.unit["default"]),i=i.replace(l,"")}o=i+'<span class="unit">'+l+"</span>"}else if(u["type"]=="font-family-select"){var c=i.split("|"),h=t.first(c)=="google"?!0:!1;if(h){var p=c[1];webFontQuickLoad(i)}else var p=i;o='<span style="font-family:'+p+';">'+p.capitalize()+"</span>"}else t.isString(i)&&(o=i.capitalize());if(typeof s=="undefined"){var d=e('                                                                         <li class="property" data-property-id="'+r+'" data-property-group-id="'+a+'">                                                                                   <strong title="'+u.name+'">'+u.name+'</strong>                                                                                  <span class="property-delete"></span>                                                                                   <span class="property-value" title="Click to Edit">'+o+"</span>                                                                         </li>                                                                   ");d.appendTo(n.find('ul[data-property-group-id="'+a+'"]'))}else{n.find('[data-property-id="'+r+'"]:not([data-special-element-type])').length||n.find('ul[data-property-group-id="'+a+'"]').append('                                                                                            <li class="property" data-property-id="'+r+'" data-property-group-id="'+a+'">                                                                                                   <strong>'+u.name+"</strong>                                                                                             </li>                                                                                   ");var d=e('                                                                            <li class="property" data-property-id="'+r+'" data-property-group-id="'+a+'" data-special-element-type="'+s.type+'" data-special-element-id="'+s.id+'">                                                                                 <strong title="'+s.name.split(" &ndash; ")[0]+s.layoutName+'">'+s.name.split(" &ndash; ")[0]+'</strong>                                                                                         <span class="property-delete"></span>                                                                                   <span class="property-value" title="Click to Edit">'+o+"</span>                                                                         </li>                                                                   ");n.find('[data-property-id="'+r+'"]').not("[data-special-element-type]").last().addClass("has-special-element-properties"),d.insertAfter(n.find('[data-property-id="'+r+'"]').last())}},this.processPropertyValueClick=function(){var n=e("ul#design-editor-element-selector li.ui-state-active").first(),r=n.data("element-id"),i=e(this).parents("li.property").first(),s=i.data("special-element-type"),o=i.data("special-element-id");return t.isEmpty(s)?n.children("span.element-name").trigger("click",[i.data("property-group-id")]):designEditor.selectSpecialElement(r,s,o,i.data("property-group-id"))},this.processPropertyDeleteClick=function(){var n=e("ul#design-editor-element-selector li.ui-state-active").first(),r=designEditorGetElementObject(n.data("element-id"),!1),i=e(this).parents("li.property").first(),s=i.data("property-id"),o=i.data("special-element-type"),u=i.data("special-element-id");if(t.isEmpty(o))var a=r.selector;else if(o=="layout")var a=("body.layout-using-"+u+" "+r.selector).replace(" body","");else var a=r[o+"s"][u].selector;stylesheet.delete_rule_property(a,s),i.remove(),n.find("> .children-elements > .properties ul li").length||(n.find("> .children-elements > .properties").remove(),n.removeClass("properties-visible"),n.find("> .children-elements li").length||(n.find("> .children-elements, > .element-expander").remove(),n.removeClass("has-children").removeClass("children-visible"))),dataSetDesignEditorProperty({element:r.id,property:s,value:"DELETE",specialElementType:o,specialElementMeta:u})},this.processNoElementClick=function(t){if(e(t.target).is("span"))return;e("body").removeClass("design-editor-element-selected"),e("ul#design-editor-element-selector").find(".ui-state-active").addClass("element-just-selected").removeClass("ui-state-active"),removeInspectorVisibleBoxModal(),setSelectedElement({}),$i(".inspector-element-selected").removeClass("inspector-element-selected"),e("#design-editor-styles-no-styles").hide(),e("#design-editor-styles-nothing-selected").show(),e("ul#design-editor-styles").empty().hide()},this.processElementExpanderClick=function(t){e(this).parent().toggleClass("children-visible")},this.processElementMouseEnter=function(t){var n=e(this).parent();if(n.hasClass("element-group")||n.hasClass("element-instances-container")||n.hasClass("element-states-container"))return;var r=n.data("element-id"),i=designEditorGetElementObject(r,!1);e(".element-just-selected").removeClass("element-just-selected"),$i(".inspector-element-hover").removeClass("inspector-element-hover"),$i(n.data("selector")).addClass("inspector-element-hover");if(!n.hasClass("element-name-has-buttons")){var s=n.children(".element-name");!n.hasClass("element-instance")&&!n.hasClass("element-state")&&s.append('<span class="element-name-button element-name-button-layout-specific tooltip" title="Edit Element Only On This Layout"></span>'),s.append('<span class="element-name-button element-name-button-live-css tooltip" title="Edit in Live CSS"></span>'),s.find(".tooltip").qtip({style:{classes:"qtip-headway qtip-headway-element-selector",tip:!1},position:{my:"bottom left",at:"top center",viewport:e(window),adjust:{y:-5,method:"flipinvert"}}}),n.addClass("element-name-has-buttons")}},this.processElementMouseLeave=function(t){var n=e(this).parent();if(n.hasClass("element-group")||n.hasClass("ui-state-active")||n.hasClass("element-instances-container"))return;var r=n.data("element-id"),i=designEditorGetElementObject(r);$i(n.data("selector")).removeClass("inspector-element-hover"),n.children(".element-name").find(".element-name-button").each(function(){e(this).qtip("api").destroy(!0),e(this).remove()}),n.removeClass("element-name-has-buttons")},this.processElementClick=function(t,n){var r=e(this).parent();if(e(t.target).hasClass("element-name-button")||r.hasClass("element-instances-container"))return;if(r.hasClass("element-group"))return;if(r.hasClass("element-instance"))return designEditor.selectSpecialElement(r.data("element-id"),"instance",r.data("instance-id"),n);if(r.hasClass("element-state"))return designEditor.selectSpecialElement(r.data("element-id"),"state",r.data("state-id"),n);var i=getElementNodeName(r),s=r.data("element-id"),o=designEditorGetElementObject(s,!1);e("body").addClass("design-editor-element-selected"),r.hasClass("has-children")&&r.addClass("children-visible"),e(this).parents("li.has-children").addClass("children-visible"),e("div#design-editor-element-selector-container").animate({scrollTop:r.offset().top-(150-e("div#design-editor-element-selector-container").scrollTop())},300),e("div.design-editor-info span.customize-for-regular-element").hide(),e("div.design-editor-info span.customize-element-for-layout").show(),inspectorSelectElement(o.selector),setSelectedElement({id:s,name:i,object:o}),designEditorShowCog(),e.when(designEditor.loadElementInputs(s)).then(function(){designEditorShowContent(n)}),e("ul#design-editor-element-selector").find(".ui-state-active").removeClass("ui-state-active"),r.addClass("ui-state-active"),designEditor.showElementProperties(r)},this.processElementNameLayoutSpecific=function(){var t=e(this).parents("li.element").first(),n=t.data("element-id");designEditor.selectSpecialElement(n,"layout",Headway.currentLayout)},this.processElementNameLiveCSS=function(){var t=e(this).parents("li.element").first(),n=t.data("selector"),r=typeof liveCSSEditor=="undefined"||!liveCSSEditor?e("textarea#live-css").val():liveCSSEditor.getValue(),i=r?"\n\n":"";e("textarea#live-css").val(r+i+n+" {\n\n}"),e("#open-live-css").trigger("click");if(typeof liveCSSEditor!="undefined"){liveCSSEditor.setValue(e("textarea#live-css").val());var s=liveCSSEditor.session.getLength();liveCSSEditor.gotoLine(s-1),liveCSSEditor.focus()}},this.processElementCopy=function(n){var r=getSelectedElement();if(!r)return;var i=typeof r.specialElementName!="undefined"?r.specialElementName:r.name;if(!t.isEmpty(Headway.elementData[r.id]))if(r.specialElementType&&!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType])){if(!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]))var s=Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]}else if(!t.isEmpty(Headway.elementData[r.id].properties))var s=Headway.elementData[r.id].properties;if(typeof s=="undefined"||t.isEmpty(s))return!1;showNotification({id:"copied-design-properties",message:"Copied properties from <strong>"+i+"</strong>",closeTimer:2e3,overwriteExisting:!0}),Headway.designEditorClipboard=e.extend({},s)},this.processElementPaste=function(n){var r=getSelectedElement();if(!r||typeof Headway.designEditorClipboard=="undefined")return;var i=typeof r.specialElementName!="undefined"?r.specialElementName:r.name;if(!t.isEmpty(Headway.elementData[r.id]))if(r.specialElementType&&!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType])){if(!t.isEmpty(Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]))var s=Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID]}else if(!t.isEmpty(Headway.elementData[r.id].properties))var s=Headway.elementData[r.id].properties;if(typeof s=="undefined")var s={};e.each(s,function(e,t){dataSetDesignEditorProperty({element:r.id,property:e,value:"DELETE",specialElementType:r.specialElementType,specialElementMeta:r.specialElementID})}),e.each(Headway.designEditorClipboard,function(e,t){typeof Headway.designEditorProperties[e]["unit"]!="undefined"&&!isNaN(t)&&(typeof Headway.designEditorProperties[e]["unit"]=="string"?t+=Headway.designEditorProperties[e].unit:typeof Headway.designEditorProperties[e]["unit"]["default"]!="undefined"&&(t+=Headway.designEditorProperties[e].unit["default"])),dataSetDesignEditorProperty({element:r.id,property:e,value:t,specialElementType:r.specialElementType,specialElementMeta:r.specialElementID})});if(r.specialElementType)var s=Headway.elementData[r.id]["special-element-"+r.specialElementType][r.specialElementID];else var s=Headway.elementData[r.id].properties;e.each(s,function(e,t){dataDesignEditorPropertyFeedback({element:r.id,property:e,value:t,specialElementType:r.specialElementType,specialElementMeta:r.specialElementID})}),showNotification({id:"copied-design-properties",message:"Pasted properties onto <strong>"+i+"</strong>",closeTimer:2e3,overwriteExisting:!0,success:!0})},this.loadElementInputs=function(t,n){var r={security:Headway.security,action:"headway_visual_editor",method:"get_element_inputs",unsavedValues:designEditorGetUnsavedValues(t),element:designEditorGetElementObject(t)};if(typeof n=="object"){var i=Object.keys(n)[0],s=n[i];r.specialElementType=i,r.specialElementMeta=s,r.unsavedValues=designEditorGetUnsavedValues(t,i,s),i=="instance"&&(r.element=designEditorGetElementObject(t,!0,s))}return e.post(Headway.ajaxURL,r).success(function(n){var r=e("div.design-editor-options");r.html(n),e("div.design-editor-options").data({element:t,specialElementType:!1,specialElementMeta:!1}),e("div.design-editor-options").find(".property-font-family-select").each(function(){webFontQuickLoad(e(this).find("span.font-name").data("webfont-value"))}),Headway.iframe.focus()})},this.bindDesignEditorInfo=function(){e("span.customize-element-for-layout").bind("click",function(){var e=designEditor.getCurrentElement(),t=e.data("element-id");designEditor.selectSpecialElement(t,"layout",Headway.currentLayout)}),e("span.customize-for-regular-element").bind("click",function(){designEditor.getCurrentElement().find("> span.element-name").trigger("click")})},this.selectSpecialElement=function(t,n,r,i){var s=e("ul#design-editor-element-selector li.element-"+n).filter("[data-"+n+'-id="'+r+'"]').filter('[data-element-id="'+t+'"]');s.length||(s=e('ul#design-editor-element-selector li.element[data-element-id="'+t+'"]').first());var o=designEditorGetElementObject(t,!1),u=n!="layout"?o[n+"s"][r].name:Headway.currentLayoutName,a=n!="layout"?o[n+"s"][r].selector:o.selector;e("body").addClass("design-editor-element-selected"),s.parents("li").addClass("children-visible"),e("div#design-editor-element-selector-container").animate({scrollTop:s.offset().top-(e("div#design-editor-element-selector-container").height()/1.5-e("div#design-editor-element-selector-container").scrollTop())},300),designEditor.showElementProperties(s),n=="layout"?(e("div.design-editor-info span.customize-for-regular-element").show(),e("div.design-editor-info span.customize-element-for-layout").hide()):(e("div.design-editor-info span.customize-for-regular-element").hide(),e("div.design-editor-info span.customize-element-for-layout").hide()),inspectorSelectElement(a);var f={},l={};f[n]=u,l[n]=r,setSelectedElement({id:t,selector:a,name:o.name,specialElementType:n,specialElementID:r,specialElementName:u,object:o});if(typeof loadInputs=="undefined"||loadInputs)designEditorShowCog(),e.when(designEditor.loadElementInputs(t,l)).then(function(){designEditorShowContent(i)});e("ul#design-editor-element-selector").find(".ui-state-active").removeClass("ui-state-active"),s.addClass("ui-state-active")},this.getCurrentElement=function(){return e("ul#design-editor-element-selector li.ui-state-active")},this.switchLayout=function(){if(typeof Headway.switchedToLayout=="undefined"||!Headway.switchedToLayout)return;e.when(designEditorRequestElements(!0)).then(function(){designEditor.setupElementSelector.apply(designEditor),e("div.design-editor-options").hide()})}},toggleDesignEditor=function(){return e("body").hasClass("side-panel-hidden")?showDesignEditor():hideDesignEditor()},hideDesignEditor=function(){return e("body").hasClass("side-panel-hidden")?!1:(e("body").addClass("side-panel-hidden"),setTimeout(repositionTooltips,400),e("#design-editor-toggle span").text("eee"),e.cookie("hide-design-editor",!0),!0)},showDesignEditor=function(){return e("body").hasClass("side-panel-hidden")?(e("body").removeClass("side-panel-hidden"),setTimeout(repositionTooltips,400),e("#design-editor-toggle span").text("iii"),e.cookie("hide-design-editor",!1),!0):!1},designEditorShowCog=function(){e("div#side-panel").addClass("properties-loading"),e("div.design-editor-info").hide(),e("div.design-editor-options").hide(),createCog(e("div#side-panel-bottom"),!0,!0)},designEditorShowContent=function(n){e("div#side-panel-bottom").find(".cog-container").remove(),e("div.design-editor-info").show(),e("div.design-editor-options").show(),e("div#side-panel").removeClass("properties-loading"),t.isEmpty(n)||e(".design-editor-box-"+n).find(".design-editor-box-title").trigger("click"),setupTooltips()},designEditorGetElementObject=function(t,n,r){var i=e("ul#design-editor-element-selector").find("#element-"+t),s=i.data("group"),o=i.data("parent");if(typeof n=="undefined")var n=!0;var t=jQuery.extend(!0,{},Headway.elements[t]);return n&&(typeof r!="undefined"&&r?e.each(t.instances,function(e,n){e!=r&&delete t.instances[e]}):delete t.instances),t},designEditorGetUnsavedValues=function(e,n,r){if(typeof n=="undefined")var n=!1;if(typeof r=="undefined")var r=!1;if(typeof GLOBALunsavedValues=="undefined"||typeof GLOBALunsavedValues["design-editor"]=="undefined"||typeof GLOBALunsavedValues["design-editor"][e]=="undefined")return null;if(!n||!r){if(typeof GLOBALunsavedValues["design-editor"][e]["properties"]=="undefined")return null;var i=GLOBALunsavedValues["design-editor"][e].properties}else{if(typeof GLOBALunsavedValues["design-editor"][e]["special-element-"+n]=="undefined")return null;if(typeof GLOBALunsavedValues["design-editor"][e]["special-element-"+n][r]=="undefined")return null;var i=GLOBALunsavedValues["design-editor"][e]["special-element-"+n][r]}return t.isEmpty(i)?null:i},designEditorBindPropertyBoxToggle=function(){e("div.design-editor-options").delegate("span.design-editor-box-title","click",function(){var t=e(this).parents("div.design-editor-box"),n=t.hasClass("design-editor-box-open");e("div.design-editor-options div.design-editor-box-open").removeClass("design-editor-box-open"),!t.hasClass("design-editor-box-open")&&!n&&t.addClass("design-editor-box-open")})},designEditorBindPropertyInputs=function(){e(".design-editor-options-container").delegate("div.customize-property","click",function(){var t=e(this).parents("li").first();if(t.hasClass("lockable-property")&&t.parents(".box-model-inputs").hasClass("box-model-inputs-locked"))var t=e(this).parents(".box-model-inputs").find("> li.lockable-property");t.each(function(){e(this).find(".customize-property").fadeOut(150),e(this).removeClass("uncustomized-property"),e(this).addClass("customized-property-by-user"),e(this).attr("title","You have customized this property.");var t=e(this).find("input.property-hidden-input"),n=t.parent().find("select, input:not(.property-hidden-input)").first();!t.val()&&n.length&&t.val(n.val()),dataHandleDesignEditorInput({hiddenInput:t,value:t.val()})})}),e(".design-editor-options-container").delegate("span.uncustomize-property","click",function(){if(!confirm("Are you sure you wish to delete this customization?"))return!1;var t=e(this).parents("li").first();if(t.hasClass("lockable-property")&&t.parents(".box-model-inputs").hasClass("box-model-inputs-locked"))var t=e(this).parents(".box-model-inputs").find("> li.lockable-property");t.each(function(){var t=e(this).find("input.property-hidden-input");e(this).find("div.customize-property").fadeIn(150),dataHandleDesignEditorInput({hiddenInput:t,value:"DELETE",unit:""}),e(this).addClass("uncustomized-property",150),e(this).removeClass("customized-property-by-user"),e(this).attr("title","You have set this property to inherit.")})}),e(".design-editor-options-container").delegate(".design-editor-property-font-family span.open-font-browser","click",function(){typeof fontBrowserOpen=="function"&&fontBrowserOpen.apply(this)}),e(".design-editor-options-container").delegate("span.design-editor-lock-sides","click",function(){e(this).parent().hasClass("box-model-inputs-locked")?e(this).attr("data-locked",!1).attr("title","Unlock sides").parent().removeClass("box-model-inputs-locked"):e(this).attr("data-locked",!0).attr("title","Lock sides").parent().addClass("box-model-inputs-locked")}),e(".design-editor-options-container").delegate('.box-model-inputs-locked li.lockable-property input[type="number"]',"keyup blur change",function(t,n){if(typeof n!="undefined"&&n)return;e(this).parents(".box-model-inputs-locked").find(".lockable-property").removeClass("uncustomized-property"),e(this).parents(".box-model-inputs-locked").find('li.lockable-property input[type="number"]').not(e(this)).val(e(this).val()).trigger("change",[!0])}),e(".design-editor-options-container").delegate(".box-model-inputs-locked li.lockable-property select","change",function(t,n){if(typeof n!="undefined"&&n)return;e(this).parents(".box-model-inputs-locked").find(".lockable-property").removeClass("uncustomized-property"),e(this).parents(".box-model-inputs-locked").find("li.lockable-property select").not(e(this)).val(e(this).val()).trigger("change",[!0])}),e(".design-editor-options-container").delegate("div.property-select select","change",designEditorInputSelect),e(".design-editor-options-container").delegate("div.property-integer input","focus",designEditorInputIntegerFocus),e(".design-editor-options-container").delegate("div.property-integer input","keyup blur change",designEditorInputIntegerChange),e(".design-editor-options-container").delegate("div.property-integer .property-unit-select select","change",designEditorInputIntegerUnitChange),e(".design-editor-options-container").delegate("div.property-image span.button","click",designEditorInputImageUpload),e(".design-editor-options-container").delegate("div.property-image span.delete-image","click",designEditorInputImageUploadDelete),e(".design-editor-options-container").delegate("div.property-color div.colorpicker-box","click",designEditorInputColor)},designEditorInputSelect=function(t){var n=e(this).parent().siblings("input.property-hidden-input");dataHandleDesignEditorInput({hiddenInput:n,value:e(this).val()})},designEditorInputIntegerFocus=function(t){typeof originalValues!="undefined"&&delete originalValues,originalValues=new Object;var n=e(this).siblings("input.property-hidden-input"),r=n.attr("selector")+"-"+n.attr("property");originalValues[r]=e(this).val()},designEditorInputIntegerUnitChange=function(t){e(this).parents(".property-integer").find('input[type="number"]').trigger("change")},designEditorInputIntegerChange=function(t){var n=e(this).siblings("input.property-hidden-input"),r=e(this).val();if(t.type=="keyup"&&r=="-")return;if(isNaN(r)){r=r.replace(/[^0-9]*/ig,"");if(r==="")var i=n.attr("selector")+"-"+n.attr("property"),r=originalValues[i];e(this).val(r)}r.length>1&&r[0]==0&&(r=r.replace(/^[0]+/g,""),e(this).val(r)),dataHandleDesignEditorInput({hiddenInput:n,value:e(this).val()})},designEditorInputImageUpload=function(t){var n=this;openImageUploader(function(t,r){var i=e(n).siblings("input");e(n).siblings(".image-input-controls-container").find("span.src").text(r),e(n).siblings(".image-input-controls-container").show(),dataHandleDesignEditorInput({hiddenInput:i,value:t})})},designEditorInputImageUploadDelete=function(t){if(!confirm("Are you sure you wish to remove this image?"))return!1;e(this).parent(".image-input-controls-container").hide(),e(this).hide();var n=e(this).parent().siblings("input");dataHandleDesignEditorInput({hiddenInput:n,value:"none"})},designEditorInputColor=function(t){e("div.design-editor-options-container").css("overflow-y","hidden");var n=e(this).parent().siblings("input"),r=n.val();r=="transparent"&&(r="00FFFFFF");var i=function(e,t){var r="#"+e.hex;if(e.a!=100)var r=e.rgba;dataHandleDesignEditorInput({hiddenInput:n,value:r})};e(this).colorpicker({realtime:!0,alpha:!0,alphaHex:!0,allowNull:!1,showAnim:!1,swatches:typeof Headway.colorpickerSwatches=="object"&&Headway.colorpickerSwatches.length?Headway.colorpickerSwatches:!0,color:r,beforeShow:function(e,t){showIframeOverlay()},onClose:function(t,n){i(t,n),hideIframeOverlay(),e("div.design-editor-options-container").css("overflow-y","auto")},onSelect:function(e,t){i(e,t)},onAddSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)},onDeleteSwatch:function(e,t){dataSetOption("general","colorpicker-swatches",t)}}),e.colorpicker._showColorpicker(e(this)),setupTooltips()},propertyInputCallbackFontFamily=function(t){var n=t.selector,r=t.value,i=t.element,s=t.stack?t.stack:t.value;if(!r){stylesheet.delete_rule_property(n,"font-family");return}if(!r.match(/\|/g)){stylesheet.update_rule(n,{"font-family":s});return}var o=r.split("|"),u={},a="";typeof o[2]!="undefined"&&o[2]&&(a=":"+o[2]),u[o[0]]={families:[o[1]+a]};var s=o[1];stylesheet.update_rule(n,{"font-family":s}),typeof e("iframe#content").get(0).contentWindow.WebFont=="object"&&e("iframe#content").get(0).contentWindow.WebFont.load(u)},propertyInputCallbackBackgroundImage=function(e){var t=e.selector,n=e.value,r=e.element;n!="none"?stylesheet.update_rule(t,{"background-image":"url("+n+")"}):n=="none"&&stylesheet.update_rule(t,{"background-image":"none"})},propertyInputCallbackFontStyling=function(e){var t=e.selector,n=e.value,r=e.element;n==="normal"?stylesheet.update_rule(t,{"font-style":"normal","font-weight":"normal"}):n==="bold"?stylesheet.update_rule(t,{"font-style":"normal","font-weight":"bold"}):n==="light"?stylesheet.update_rule(t,{"font-style":"normal","font-weight":"lighter"}):n==="italic"?stylesheet.update_rule(t,{"font-style":"italic","font-weight":"normal"}):n==="bold-italic"?stylesheet.update_rule(t,{"font-style":"italic","font-weight":"bold"}):n===null&&(stylesheet.delete_rule_property(t,"font-style"),stylesheet.delete_rule_property(t,"font-weight"))},propertyInputCallbackCapitalization=function(e){var t=e.selector,n=e.value,r=e.element;n==="none"||n==null?stylesheet.update_rule(t,{"text-transform":"none","font-variant":"normal"}):n==="small-caps"?stylesheet.update_rule(t,{"text-transform":"none","font-variant":"small-caps"}):stylesheet.update_rule(t,{"text-transform":n,"font-variant":"normal"})},propertyInputCallbackShadow=function(t){var n=t.selector,r=t.value,i=t.element,s=t.property,o=s.indexOf("box-shadow")===0?"box-shadow":"text-shadow",u=$i(n).css(o)||!1;if(u==0||u=="none")u="rgba(0, 0, 0, 0) 0 0 0";var a=u.replace(/, /g,",").replace(/px/g,"").split(" "),f=e('li[data-property-id="'+o+"-color"+'"] input').val()||a[0],l=e('li[data-property-id="'+o+"-horizontal-offset"+'"] input').val()||a[1],c=e('li[data-property-id="'+o+"-vertical-offset"+'"] input').val()||a[2],h=e('li[data-property-id="'+o+"-blur"+'"] input').val()||a[3],p=e('li[data-property-id="'+o+"-position"+'"] input').val()||a[4];switch(s){case o+"-horizontal-offset":l=r||0;break;case o+"-vertical-offset":c=r||0;break;case o+"-blur":h=r||0;break;case o+"-inset":p=r;break;case o+"-color":f=r}if(!f)return stylesheet.delete_rule_property(n,o);p=="inset"?p=" inset":p="";var d=f+" "+l+"px "+c+"px "+h+"px"+p,v={};v[o]=d,stylesheet.update_rule(n,v),updateInspectorVisibleBoxModal()},addInspector=function(t){if(typeof Headway.elements=="undefined")return e.when(designEditorRequestElements()).then(addInspector);e.each(Headway.elements,function(e,t){if(!t.inspectable)return;addInspectorProcessElement(t)}),(typeof t=="undefined"||t!==!0)&&$i("body").qtip({id:"",style:{classes:"qtip-headway qtip-inspector-tooltip"},position:{target:[-9999,-9999],my:"bottom left",at:"top right",container:$i("body"),viewport:$i("#headway-tooltip-container"),effect:!1,adjust:{x:0,y:0,method:"flipinvert"}},content:{text:"Hover over an element."},show:{event:!1,ready:!0},hide:!1,events:{render:function(t,n){delete inspectorElement,delete inspectorTooltip,delete inspectorElementOptions,inspectorTooltip=n,e("#toggle-inspector").hasClass("inspector-disabled")?disableInspector():enableInspector()}}})},refreshInspector=function(){return addInspector(!0)},addInspectorProcessElement=function(t){if(t["group"]=="default-elements")return;if(!$i(t.selector).length)return;t["selector"].indexOf(":")==-1&&($i(t.selector).data({inspectorElementOptions:t}),$i(t.selector).addClass("inspector-element")),e.each(t.instances,function(n,r){if(r["selector"].indexOf(":")!=-1)return;if(!$i(r.selector).length)return;var i=jQuery.extend(!0,{},t);i.parentName=t.name,i.instance=r.id,i.name=r.name,i.selector=r.selector,i.instances={},e.each(t.instances,function(e,t){t["state-of"]==n&&(i.instances[e]=t)}),e.each(i.selector.split(","),function(e,t){if(t.indexOf(":")!=-1)return;$i(t).data({inspectorElementOptions:i}),$i(t).addClass("inspector-element")})})},enableInspector=function(){if(Headway.mode!="design"||!Headway.designEditorSupport)return!1;Headway.inspectorDisabled=!1,Headway.disableBlockDimensions=!0,$i("body").addClass("disable-block-hover").removeClass("inspector-disabled"),$i(".block[data-hasqtip]").each(function(){var t=e(this).qtip("api");t.destroy()}),inspectorTooltip.show();var t=Headway.touch?"tap":"mousemove";$i("html").bind(t,inspectorMouseMove),setupInspectorContextMenu(),deactivateContextMenu("block"),deactivateContextMenu("wrapper"),Headway.iframe.contents().find("body").bind("keydown",inspectorNudging),Headway.iframe.bind("keydown",inspectorNudging),Headway.iframe.bind("mouseover",function(){Headway.iframe.focus()}),showNotification({id:"inspector",message:"<strong>Right-click</strong> highlighted elements to style them.<br /><br />Once an element is selected, you may nudge it using your arrow keys.<br /><br />The faded orange and purple are the margins and padding.  These colors are only visible when the inspector is active.",closeConfirmMessage:"Please be sure you understand how the Design Editor inspector works before hiding this message.",closeTimer:!1,closable:!0,doNotShowAgain:!0}),updateInspectorVisibleBoxModal(),e("#toggle-inspector").removeClass("inspector-disabled")},disableInspector=function(){if(Headway.mode!="design"||!Headway.designEditorSupport)return!1;Headway.inspectorDisabled=!0,delete Headway.disableBlockDimensions,delete inspectorElement,$i(".inspector-element-hover").removeClass("inspector-element-hover"),$i("body").removeClass("disable-block-hover").addClass("inspector-disabled"),$i(".block").qtip("enable"),e(inspectorTooltip.elements.tooltip).hide(),hideNotification("inspector"),$i("html").unbind("mousemove",inspectorMouseMove),deactivateContextMenu("inspector"),setupBlockContextMenu(),setupWrapperContextMenu(),Headway.iframe.contents().find("body").unbind("keydown",inspectorNudging),Headway.iframe.unbind("keydown",inspectorNudging),removeInspectorVisibleBoxModal(),e("#toggle-inspector").addClass("inspector-disabled")},toggleInspector=function(){if(Headway.mode!="design"||!Headway.designEditorSupport)return!1;if(e("#toggle-inspector").hasClass("inspector-disabled"))return enableInspector();disableInspector()},inspectorSelectElement=function(t){$i(".inspector-element-selected").each(function(){e(this).removeClass("inspector-element-selected"),removeInspectorVisibleBoxModal(e(this))}),$i(t).addClass("inspector-element-selected"),updateInspectorVisibleBoxModal()},removeInspectorVisibleBoxModal=function(t){if(typeof t=="undefined")var t=$i(".inspector-element-selected");return e(t).data("previousBoxShadow")?(e(t).data("previousBoxShadow",null),e(t).css("boxShadow","")):!1},updateInspectorVisibleBoxModal=function(){if(typeof Headway.inspectorDisabled!="undefined"&&Headway.inspectorDisabled)return;$i(".inspector-element-selected").each(function(){removeInspectorVisibleBoxModal(e(this));var t=this,n=e(this).css("box-shadow"),r=n!="none"?n.split(","):[];e(this).data("previousBoxShadow",n),e.each(["paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft"],function(n,i){var s=e(t).css(i).replace(/^[+-]?\d+(\.\d+)?/g,""),o=e(t).css(i).replace(s,"");if(o=="auto")return;var u=i.indexOf("padding")!==-1?"rgba(0, 0, 255, .15)":"rgba(255, 127, 0, .15)",a="",f="";if(i=="paddingRight"||i=="paddingBottom"||i=="marginLeft"||i=="marginTop")a="-";var l=a+o+s;if(i.toLowerCase().indexOf("left")!==-1||i.toLowerCase().indexOf("right")!==-1)var c=l+" 0";else var c="0 "+l;i.indexOf("padding")!==-1&&(f="inset "),r.push(f+c+" 0 0 "+u)}),e(this).css({boxShadow:r.join(",")})})},inspectorMouseMove=function(t){if(Headway.inspectorDisabled)return;var n=e(t.target);n.hasClass("inspector-element")||(n=n.parents(".inspector-element").first());if(typeof inspectorElement=="undefined"||!n.is(inspectorElement)){inspectorElement=e(t.target),inspectorElement.hasClass("inspector-element")||(inspectorElement=inspectorElement.parents(".inspector-element").first());var r=inspectorElement.data("inspectorElementOptions");if(typeof r=="object"){$i(".inspector-element-hover").removeClass("inspector-element-hover"),$i(r.selector).addClass("inspector-element-hover");var i=e("#design-editor-element-selector").find("li#element-"+r.id),s=i.children(".element-name").text(),o='<span class="inspector-tooltip-element-path">',u=[];i.parents("li").reverse().each(function(){u.push(e(this).children(".element-group-name, .element-name").first().text())});var a="";typeof r.instance!="undefined"&&(r.name.indexOf(" &ndash; ")!==-1?a='<span class="inspector-tooltip-instance">Inside <strong>'+r.name.split(" &ndash; ")[0]+"</strong></span>":s=r.name);if(u.join(" > ").length+s.length>40)while(u.join(" > ").length+s.length>40&&s.length<40)u.shift(),tooltipElementPathStr='<span class="ellipsis">...</span> '+u.join(" &rsaquo; ");else tooltipElementPathStr=u.join(" &rsaquo; ");o+=tooltipElementPathStr,o+=" &rsaquo; <strong>"+s+"</strong></span>",o+=a,o+='<small class="right-click-message">Right-click to style</small>',inspectorTooltip.set("content.text",o)}}inspectorTooltip.show(),inspectorTooltip.set("position.target","mouse")},setupInspectorContextMenu=function(){return setupContextMenu({id:"inspector",elements:"body",title:function(e){return inspectorElement.data("inspectorElementOptions").name},onShow:inspectorContextMenuOnShow,onHide:function(){inspectorTooltip.show(),Headway.inspectorDisabled=!1},onItemClick:inspectorContextMenuItemClick,contentsCallback:inspectorContextMenuContents})},inspectorContextMenuOnShow=function(t){e(this).data("element-options",inspectorElement.data("inspectorElementOptions")),e(inspectorTooltip.elements.tooltip).hide(),Headway.inspectorDisabled=!0},inspectorContextMenuItemClick=function(t,n){if(e(this).hasClass("group-title")&&!e(this).hasClass("group-title-clickable"))return;if(e(this).parents("li").first().hasClass("inspector-context-menu-block-options"))openBlockOptions(getBlock(e(inspectorElement)));else{var r=t.data("element-options"),i=e(this).parents("li").first().data("instance-id"),s=e(this).parents("li").first().data("state-id");inspectorTooltip.show(),Headway.inspectorDisabled=!1,e("#design-editor-element-selector-container .ui-state-active").removeClass("ui-state-active"),typeof i!="undefined"?designEditor.selectSpecialElement(r.id,"instance",i):typeof s!="undefined"?designEditor.selectSpecialElement(r.id,"state",s):e(this).parents("li").first().hasClass("inspector-context-menu-parent")||e("ul#design-editor-element-selector li#element-"+r.id).find("> span").trigger("click"),e(this).parents("li").first().hasClass("inspector-context-menu-edit-for-layout")&&designEditor.selectSpecialElement(r.id,"layout",Headway.currentLayout)}},inspectorContextMenuContents=function(n){var r=e(this),i=r.data("element-options"),s=typeof i.instance!="undefined"&&i.instance,o=r;if(s){r.append('<li class="inspector-context-menu-edit-instance" data-instance-id="'+i.instance+'"><span>Edit This Instance</span></li>');var o=e('<li class="inspector-context-menu-edit-normal"><span class="group-title group-title-clickable">Edit Regular Element<small>'+i.parentName+"</small></span><ul></ul></li>").appendTo(r);o=o.find("ul").first()}else o.append('<li class="inspector-context-menu-edit-normal"><span>Edit</span></li>');o.append('<li class="inspector-context-menu-edit-for-layout"><span>Edit For This Layout</span></li>');if(!t.isEmpty(i.states)){var u=e('<li class="inspector-context-menu-states"><span class="group-title">States</span><ul></ul></li>').appendTo(o);e.each(i.states,function(e,t){u.find("ul").append('<li data-state-id="'+e+'"><span>Edit '+t.name+"</span></li>")})}if(!t.isEmpty(i.instances)){if(typeof i.instance=="undefined"||!i.instance)var a=e('<li class="inspector-context-menu-instances"><span class="group-title">Instances</span><ul></ul></li>').appendTo(r);else var a=!1;e.each(i.instances,function(t,n){n["state-of"]==i.instance&&(r.find("> li.inspector-context-menu-instance-states").length||e('<li class="inspector-context-menu-instance-states"><span class="group-title">Instance States</span><ul></ul></li>').insertAfter(r.find("li.inspector-context-menu-edit-instance")),r.find("> li.inspector-context-menu-instance-states ul").append('<li data-instance-id="'+t+'"><span>Edit '+n["state-name"]+"</span></li>"))}),a&&!a.find("ul li").length&&a.remove()}if(inspectorElement.parents(".inspector-element").length){var f=e('<li class="inspector-context-menu-parents"><span class="group-title">Parents</span><ul></ul></li>').appendTo(r);inspectorElement.parents(".inspector-element").each(function(){var t=e(this);e('<li class="inspector-context-menu-parent" data-parent-id="'+e(this).data("inspectorElementOptions").id+'"><span>'+e(this).data("inspectorElementOptions").name+"</span></li>").appendTo(f.find("ul")).bind("click",function(){inspectorElement=t;var e=typeof n.data!="undefined"?n.data.x:n.originalEvent.clientX,r=typeof n.data!="undefined"?n.data.y:n.originalEvent.clientY;t.trigger("contextmenu",{x:e,y:r})})})}if(getBlock(inspectorElement))var l=getBlock(inspectorElement),c=getBlockID(l),h=getBlockTypeNice(getBlockType(l)),p=e('<li class="inspector-context-menu-block-options"><span>Open Block Options</span></li>').appendTo(r)},inspectorNudging=function(t){var n=t.keyCode;if(n<37||n>40||!$i(".inspector-element-selected").length||$i(".inspector-element-selected").is("body"))return;var r=t.shiftKey?5:1,i=e(".design-editor-box-nudging .design-editor-property-position select",".design-editor-options-container"),s=i.parents(".design-editor-property-position").find('input[type="hidden"]'),o=s.attr("element_selector");e(".design-editor-box-nudging .uncustomized-property .customize-property span",".design-editor-options-container").trigger("click");if($i(".inspector-element-selected").css("position")!="static"){var u=$i(".inspector-element-selected").css("position");$i(".inspector-element-selected").css({position:u}),i.val(u).trigger("change")}else{var u="relative";$i(".inspector-element-selected").css({position:u}),i.val(u).trigger("change")}switch(n){case 37:var a=parseInt($i(".inspector-element-selected").css("left"));if(isNaN(a))var a=0;stylesheet.update_rule(o,{left:a-r+"px"});var f=$i(".inspector-element-selected").css("left").replace("px","");e('.design-editor-box-nudging .design-editor-property-left input[type="number"]',".design-editor-options-container").val(f).trigger("change");break;case 38:var l=parseInt($i(".inspector-element-selected").css("top"));isNaN(l)&&(l=0),stylesheet.update_rule(o,{top:l-r+"px"});var c=$i(".inspector-element-selected").css("top").replace("px","");e('.design-editor-box-nudging .design-editor-property-top input[type="number"]',".design-editor-options-container").val(c).trigger("change");break;case 39:var a=parseInt($i(".inspector-element-selected").css("left"));if(isNaN(a))var a=0;stylesheet.update_rule(o,{left:a+r+"px"});var f=$i(".inspector-element-selected").css("left").replace("px","");e('.design-editor-box-nudging .design-editor-property-left input[type="number"]',".design-editor-options-container").val(f).trigger("change");break;case 40:var l=parseInt($i(".inspector-element-selected").css("top"));isNaN(l)&&(l=0),stylesheet.update_rule(o,{top:l+r+"px"});var c=$i(".inspector-element-selected").css("top").replace("px","");e('.design-editor-box-nudging .design-editor-property-top input[type="number"]',".design-editor-options-container").val(c).trigger("change")}return t.preventDefault(),!1},getElementNodeName=function(e){var t=e.clone();return t.find("> span").children().remove().end().text()},getSelectedElement=function(){return typeof Headway.designEditorCurrentElement!="undefined"?Headway.designEditorCurrentElement:null},setSelectedElement=function(e){Headway.designEditorCurrentElement=e;if(t.isEmpty(e))return;var n={};typeof e.specialElementType!="undefined"&&(n[e.specialElementType]=e.specialElementName),setSelectedElementDetails(n,e.object)},setSelectedElementDetails=function(n,r){var n=e.extend({},{instance:r.name,layout:"all layouts",state:"all states"},n),i=e("span.design-editor-selection-details");i.find(".design-editor-selected-element").html(n.instance),i.find("strong.design-editor-selection-details-layout").html(n.layout),typeof r.states=="undefined"||t.isEmpty(r.states)?i.find("span.design-editor-selection-details-state-container").hide():(i.find("span.design-editor-selection-details-state-container").show(),n.state=="all states"?i.find(".design-editor-selection-details-state-before").text("and"):i.find(".design-editor-selection-details-state-before").text("when"),n.state=="Hover"&&(n.state="hovered"),i.find("strong.design-editor-selection-details-state").html(n.state.toLowerCase()));var s=e(".design-editor-info").outerHeight();return e(".design-editor-info").css("marginTop","-"+s+"px"),e("#side-panel-bottom").css("paddingTop",s+"px"),e("span.design-editor-selection-details")},sanitizeElementName=function(t){return e.trim(t.escapeHTML())};var n={init:function(){designEditor=new designEditorTabEditor,designEditor._init(),n.bind(),designEditorBindPropertyInputs();try{e.getScript(Headway.headwayURL+"/library/visual-editor/"+Headway.scriptFolder+"/util.fonts-browser.js"),e.getScript("//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js")}catch(t){}e.cookie("hide-design-editor")==="true"&&hideDesignEditor()},bind:function(){e("#toggle-inspector").bind("click",toggleInspector)},iframeCallback:function(){bindBlockDimensionsTooltip(),addInspector(),designEditor.switchLayout()}};return n}),define("util.tour",["jquery","util.tooltips","helper.boxes","modules/panel"],function(e,t,n){return tourStepsGrid=[{beginning:!0,title:"Welcome to the Headway Visual Editor!",content:"<p>If this is your first time in the Headway Visual Editor, <strong>we recommend following this tour so you can get the most out of Headway</strong>.</p><p>Or, if you're experienced or want to dive in right away, just click the close button in the top right at any time.</p>"},{target:e("li#mode-grid"),title:"Mode Selector",content:"<p>The Headway Visual Editor is split up into 2 modes.</p><p><ul><li><strong>Grid</strong> &ndash; Build your layouts</li><li><strong>Design</strong> &ndash; Add colors, customize fonts, and more!</li></ul></p>",position:{my:"top left",at:"bottom center"}},{target:e("#layout-selector-select-content"),title:"Layout Selector",content:'<p style="font-size:12px;">Since you may not want every page to be the same, you may use the Layout Selector to select which page, post, or archive to edit.</p><p style="font-size:12px;">The Layout Selector is based off of inheritance.  For example, you can customize the "Page" layout and all pages will follow that layout.  Plus, you can customize a specific page and it\'ll be different than all other pages.</p><p style="font-size:12px;">The layout selector will allow you to be as precise or broad as you wish.  It\'s completely up to you!</p>',position:{my:"top center",at:"bottom center"}},{target:e("div#box-grid-wizard"),title:"The Headway Grid",content:'<p>Now we\'re ready to get started with the Headway Grid.  In other words, the good stuff.</p><p>To build your first layout, please select a preset to the right to pre-populate the grid.  Or, you may select "Use Empty Grid" to start with a completely blank grid.</p><p>Once you have a preset selected, click "Finish".</p>',position:{my:"right top",at:"left center"},nextHandler:{showButton:!1,clickElement:"#grid-wizard-button-preset-use-preset, span.grid-wizard-use-empty-grid",message:'Please click <strong>"Finish"</strong> or <strong>"Use Empty Grid"</strong> to continue.'}},{iframeTarget:"div.grid-container",title:"Adding Blocks",content:"<p>To add a block, simply place your mouse into the grid then click at where you'd like the top-left point of the block to be.</p><p>Drag your mouse and the block will appear!  Once the block appears, you may choose the block type.</p><p>Hint: Don't worry about being precise, you may always move or resize the block.</p>",position:{my:"right top",at:"left top",adjustY:100},maxWidth:280},{iframeTarget:"div.grid-container",title:"Modifying Blocks",content:'                                        <p style="font-size:12px;">After you\'ve added the desired blocks to your layout, you may move, resize, delete, or change the options of the block at any time.</p>                                     <ul style="font-size:12px;">                                            <li><strong>Moving Blocks</strong> &ndash; Click and drag the block.  If you wish to move multiple blocks simultaneously, double-click on a block to enter <em>Mass Block Selection Mode</em>.</li>                                             <li><strong>Resizing Blocks</strong> &ndash; Grab the border or corner of the block and drag your mouse.</li>                                           <li><strong>Block Options (e.g. header image)</strong> &ndash; Hover over the block then click the block options icon in the top-right.</li>                                            <li><strong>Deleting Blocks</strong> &ndash; Move your mouse over the desired block, then click the <em>X</em> icon in the top-right.</li>                                      </ul>',position:{my:"right top",at:"left top",adjustY:100},maxWidth:280},{target:e("#save-button-container"),title:"Saving",content:"<p>Now that you hopefully have a few changes to be saved, you can save using this spiffy Save button.</p><p>For those of you who like hotkeys, use <strong>Ctrl + S</strong> to save.</p>",position:{my:"top right",at:"bottom center"},tip:"top right"},{target:e("li#mode-design a"),title:"Design Mode",content:"<p>Thanks for sticking with us!</p><p>Now that you have an understanding of the Grid Mode, we hope you stick with us and head on over to the Design Mode.</p>",position:{my:"top left",at:"bottom center",adjustY:5},tip:"top left",buttonText:"Continue to Design Mode",buttonCallback:function(){e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"ran_tour",mode:"grid",complete:function(){Headway.ranTour.grid=!0,e("li#mode-design a").trigger("click"),window.location=e("li#mode-design a").attr("href")}})}}],tourStepsDesign=[{beginning:!0,title:"Welcome to the Headway Design Editor!",content:"<p>In the <strong>Design Editor</strong>, you can style your elements however you'd like.</p><p>Whether it's fonts, colors, padding, borders, shadows, or rounded corners, you can use the design editor.</p><p>Stick around to learn more!</p>"},{target:"#side-panel-top",title:"Element Selector",content:"<p>The element selector allows you choose which element to edit.</p>",position:{my:"right top",at:"left center"},callback:function(){e("li#element-block-header > span.element-name").trigger("click")}},{target:"#toggle-inspector",title:"Inspector",content:"                                     <p>Instead of using the <em>Element Selector</em>, let the Inspector do the work for you.</p>                                   <p><strong>Try it out!</strong> Point and right-click on the element you wish to edit and it will become selected!</p>                          ",position:{my:"top right",at:"bottom center",adjustX:10,adjustY:5}},{target:"window",title:"Have fun building with Headway!",content:'<p>We hope you find Headway to the most powerful and easy-to-use WordPress framework around.</p><p>If you have any questions, please don\'t hesitate to visit the <a href="http://support.headwaythemes.com/?utm_source=visualeditor&utm_medium=headway&utm_campaign=tour" target="_blank">support forums</a>.</p>',end:!0}],{start:function(){if(Headway.mode=="grid"){var t=tourStepsGrid;hidePanel(),openBox("grid-wizard")}else{if(Headway.mode!="design")return;var t=tourStepsDesign;showPanel(),require(["modules/design/mode-design"],function(){showDesignEditor()}),typeof e("div#panel").data("ui-tabs")!="undefined"&&selectTab("editor-tab",e("div#panel"))}e('<div class="black-overlay"></div>').hide().attr("id","black-overlay-tour").css("zIndex",15).appendTo("body").fadeIn(500),e(document.body).qtip({id:"tour",content:{text:t[0].content+'<div id="tour-next-container"><span id="tour-next" class="tour-button button button-blue">Continue Tour <span class="arrow">&rsaquo;</span></span></div>',title:{text:t[0].title,button:"Skip Tour"}},style:{classes:"qtip-tour",tip:{width:18,height:10,mimic:"center",offset:10}},position:{my:"center",at:"center",target:e(window),viewport:e(window),adjust:{y:5,method:"shift shift"}},show:{event:!1,ready:!0,effect:function(){e(this).fadeIn(500)}},hide:!1,events:{render:function(n,r){var i=r.elements.tooltip;r.step=0,i.bind("next",function(n){e(window).trigger("resize"),r.step+=1,r.step=Math.min(t.length-1,Math.max(0,r.step)),currentTourStep=t[r.step],e("div#black-overlay-tour").fadeOut(100,function(){e(this).remove()}),typeof currentTourStep.callback=="function"&&currentTourStep.callback.apply(r),currentTourStep.target=="window"?currentTourStep.target=e(window):typeof currentTourStep.target=="string"?currentTourStep.target=e(currentTourStep.target):typeof currentTourStep.iframeTarget=="string"&&(currentTourStep.target=$i(currentTourStep.iframeTarget).first()),r.set("position.target",currentTourStep.target),typeof currentTourStep.maxWidth!="undefined"&&window.innerWidth<1440?e(".qtip-tour").css("maxWidth",currentTourStep.maxWidth):e(".qtip-tour").css("maxWidth",350);var i="Next";if(typeof currentTourStep.buttonText=="string")var i=currentTourStep.buttonText;if(typeof currentTourStep.end!="undefined"&&currentTourStep.end===!0)var s='<div id="tour-next-container"><span id="tour-finish" class="tour-button button button-blue">Close Tour <span class="arrow">&rsaquo;</span></div>';else if(typeof currentTourStep.nextHandler=="undefined"||currentTourStep.nextHandler.showButton)var s='<div id="tour-next-container"><span id="tour-next" class="tour-button button button-blue">'+i+' <span class="arrow">&rsaquo;</span></div>';else var s='<div id="tour-next-container"><p>'+currentTourStep.nextHandler.message+"</p></div>";if(typeof currentTourStep.nextHandler!="undefined"&&e(currentTourStep.nextHandler.clickElement)){var o=function(t){e(".qtip-tour").triggerHandler("next"),t.preventDefault(),e(this).unbind("click",o)};e(currentTourStep.nextHandler.clickElement).bind("click",o)}r.set("content.text",currentTourStep.content+s),r.set("content.title",currentTourStep.title),typeof currentTourStep.end=="undefined"?(typeof currentTourStep.position!="undefined"?(r.set("position.my",currentTourStep.position.my),r.set("position.at",currentTourStep.position.at),typeof currentTourStep.position.adjustX!="undefined"?r.set("position.adjust.x",currentTourStep.position.adjustX):r.set("position.adjust.x",0),typeof currentTourStep.position.adjustY!="undefined"?r.set("position.adjust.y",currentTourStep.position.adjustY):r.set("position.adjust.y",0)):(r.set("position.my","top center"),r.set("position.at","bottom center")),typeof currentTourStep.tip!="undefined"&&r.set("style.tip.corner",currentTourStep.tip)):(r.set("position.my","center"),r.set("position.at","center"))}),e("div.qtip-tour").on("click","span#tour-next",function(t){typeof currentTourStep=="object"&&typeof currentTourStep.buttonCallback=="function"&&currentTourStep.buttonCallback.call(),e(".qtip-tour").triggerHandler("next"),t.preventDefault()}),e("div.qtip-tour").on("click","span#tour-finish",function(t){e(".qtip-tour").qtip("hide")})},hide:function(t,n){e("div#tour-overlay").remove(),e("div#black-overlay-tour").fadeOut(100,function(){e(this).remove()}),e(".qtip-tour").fadeOut(100,function(){e(this).qtip("destroy")}),Headway.ranTour[Headway.mode]==0&&Headway.ranTour.legacy!=1&&(e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"ran_tour",mode:Headway.mode}),Headway.ranTour[Headway.mode]=!0)}}})}}}),define("modules/menu",["jquery","util.tour","helper.ace"],function(e,t,n){var r={init:function(){r.bind()},bind:function(){e("ul#modes li").on("click",function(){e(this).siblings("li").removeClass("active"),e(this).addClass("active")}),e("ul#modes li a").bind("click",function(){e(this).attr("href",e(this).attr("href")+"&ve-layout="+Headway.currentLayout)}),e("#menu-link-view-site a").bind("click",function(){e(this).attr("href",Headway.homeURL+"/?headway-trigger=layout-redirect&layout="+Headway.currentLayout)}),e("span#save-button").click(function(){return save(),!1}),e("#snapshots-button").bind("click",function(){openBox("snapshots")}),e("#tools-tour").bind("click",t.start),e("#tools-grid-wizard").bind("click",function(){hidePanel(),openBox("grid-wizard")}),e("#open-live-css").bind("click",function(){n.showEditor("live-css","css",e("textarea#live-css").val(),function(t){var n=t.getValue(),r=e("textarea#live-css");r.val(n),dataHandleInput(r),$i("style#live-css-holder").html(n),allowSaving()})}),e("#tools-clear-cache").bind("click",function(){var t={security:Headway.security,action:"headway_visual_editor",method:"clear_cache"};e.post(Headway.ajaxURL,t,function(e){e==="success"?showNotification({id:"cache-cleared",message:"The cache was successfully cleared!",success:!0}):showErrorNotification({id:"error-could-not-clear-cache",message:"Error: Could not clear cache."})})})}};return r}),define("modules/snapshots",["jquery","ko"],function(e,t){var n={init:function(){n.bind(),n.setupViewModel()},setupViewModel:function(){Headway.viewModels.snapshots={snapshots:t.observableArray(Headway.snapshots),formatSnapshotDatetime:function(e){var t=e.split(/[- :]/);return(new Date(Date.UTC(t[0],t[1]-1,t[2],t[3],t[4],t[5]))).toLocaleString()},rollbackToSnapshot:function(t,n){if(!confirm("Are you sure you wish to rollback?\n\nYou will lose all between this snapshot and now unless you save another snapshot."))return!1;var r=e(n.target);if(r.attr("disabled"))return!1;r.attr("disabled",!0),r.addClass("button-depressed"),r.text("Rolling Back.."),e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"rollback_to_snapshot",layout:Headway.currentLayout,snapshot_id:t.id,mode:Headway.mode},function(e){if(typeof e.error!="undefined")return;showNotification({id:"rolled-back-successfully",message:"Successfully rolled back to snapshot.<br /><br /><strong>Refreshing Visual Editor in 3 seconds</strong>.",success:!0}),r.text("Rolled Back!"),setTimeout(function(){allowVEClose(),document.location.reload(!0)},1e3)})},deleteSnapshot:function(t,n){if(!confirm("Are you sure you wish to delete this snapshot?\n\nYou cannot undo this or restore another snapshot to bring this snapshot back."))return!1;var r=e(n.target);if(r.hasClass("deletion-in-progress"))return!1;r.addClass("deletion-in-progress"),e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"delete_snapshot",layout:Headway.currentLayout,snapshot_id:t.id,mode:Headway.mode},function(e){if(typeof e.error!="undefined")return;showNotification({id:"deleted-snapshot-successfully",message:"Successfully deleted snapshot.",success:!0}),Headway.viewModels.snapshots.snapshots.remove(t)})},saveSnapshot:function(t,n){var r=e(n.target);if(r.attr("disabled"))return!1;r.attr("disabled",!0),r.text("Saving Snapshot..."),r.siblings(".spinner").show();var i=prompt("(Optional)\n\nEnter name or description of the changes in this snapshot.");e.post(Headway.ajaxURL,{security:Headway.security,action:"headway_visual_editor",method:"save_snapshot",layout:Headway.currentLayout,mode:Headway.mode,snapshot_comments:i},function(e){if(typeof e.timestamp=="undefined")return;showNotification({id:"snapshot-saved",message:"Snapshot saved.",success:!0}),Headway.viewModels.snapshots.snapshots.unshift({id:e.id,timestamp:e.timestamp,comments:e.comments}),r.text("Save Snapshot"),r.removeAttr("disabled"),r.siblings(".spinner").hide()})}},e(document).ready(function(){t.applyBindings(Headway.viewModels.snapshots,e("#box-snapshots").get(0))})},bind:function(){}};return n}),define("helper.wrappers",["modules/panel.inputs"],function(e){getWrapperID=function(e){return!$(e).length||!$(e).data("id")?null:$(e).data("id").toString().replace("wrapper-","")},openWrapperOptions=function(t){var t="wrapper-"+t,n=function(){var n=$("div#"+t+"-tab");n.tabs(),e.bind("div#"+t+"-tab"),handleInputTogglesInContainer(n.find("div.sub-tabs-content")),setupTooltips(),updateGridWidthInput($("div#"+t+"-tab")),$("div#"+t+"-tab").find('select[name="mirror-wrapper"]').val()&&($("div#"+t+"-tab ul.sub-tabs li:not(#sub-tab-config)").hide(),selectTab("sub-tab-config",$("div#"+t+"-tab")))},r=t.replace("wrapper-",""),i="Wrapper";typeof $i("#"+t).data("alias")!="undefined"&&$i("#"+t).data("alias")&&(i+=" ("+$i("#"+t).data("alias")+")"),addPanelTab(t,i,{url:Headway.ajaxURL,data:{security:Headway.security,action:"headway_visual_editor",method:"load_wrapper_options",wrapper_id:t.replace("wrapper-",""),unsaved_wrapper_options:getUnsavedWrapperOptionValues(t),layout:Headway.currentLayout},callback:n},!0,!0,"wrapper-options"),$("div#panel").tabs("option","active",$("#panel-top").children('li[role="tab"]').index($('[aria-controls="'+t+'-tab"]')))},getUnsavedWrapperOptionValues=function(e){if(typeof GLOBALunsavedValues=="object"&&typeof GLOBALunsavedValues["wrappers"]=="object"&&typeof GLOBALunsavedValues["wrappers"][e]=="object")var t=GLOBALunsavedValues.wrappers[e];return typeof t=="object"&&Object.keys(t).length>0?t:null},getWrapperMirror=function(e){return $i('.wrapper[data-id="'+e.replace("wrapper-","")+'"]').data("mirror-wrapper")},updateWrapperMirrorStatus=function(e,t,n){var e=e.replace("wrapper-",""),r=$i('.wrapper[data-id="'+e+'"]');populateWrapperMirrorNotice($i('.wrapper[data-id="'+e+'"]'));if(t){var t=t.replace("wrapper-","");r.addClass("wrapper-mirrored"),r.headwayGrid("disable"),typeof n!="undefined"&&n.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").hide()}else r.removeClass("wrapper-mirrored"),r.headwayGrid("enable"),typeof n!="undefined"&&n.parents(".panel").find("ul.sub-tabs li:not(#sub-tab-config)").show();r.data("ui-headwayGrid").updateGridContainerHeight(),r.data("ui-headwayGrid").resetGridCalculations(),r.data("ui-headwayGrid").alignAllBlocksWithGuides()},updateWrapperCustomClasses=function(e,t){if(Headway.mode!="design")return!1;var n=$i('.wrapper[data-id="'+e+'"]');return n.length?(n.removeClass(n.data("custom-classes")),n.data("custom-classes",t),n.addClass(t),n):!1}}),setupContextMenu=function(e){if(typeof e!="object")return!1;var e=$.extend(!0,{},{isIframeElement:!0},e);deactivateContextMenu(e.id);var t=Headway.touch?"taphold.contextMenu"+e.id:"contextmenu.contextMenu"+e.id;e.isIframeElement?$iDocument().on(t,e.elements,function(t,n){t.data=n,contextMenuCreator(e,t,!0)}):$(document).on(t,e.elements,function(t,n){t.data=n,contextMenuCreator(e,t,!1)});var n=function(t){if(t.which!==0&&t.which!==1||$(t.originalEvent.target).parents("#context-menu-"+e.id).length)return;var n=$("#context-menu-"+e.id);typeof e.onHide=="function"&&e.onHide.apply(n),n.remove()},r=Headway.touch?"touchstart":"click";$("body").on(r+".contextMenu"+e.id,n),$i("body").on(r+".contextMenu"+e.id,n)},deactivateContextMenu=function(e){return $(document).off(".contextMenu"+e),$iDocument().off(".contextMenu"+e),$("body").off(".contextMenu"+e),$i("body").off(".contextMenu"+e),!0},contextMenuCreator=function(e,t,n){t.stopPropagation();if(typeof e!="object")return!1;$(".context-menu").remove();var r=typeof e.title=="function"?e.title.apply(undefined,[t]):e.title,i=$('<ul id="context-menu-'+e.id+'" class="context-menu"><h3>'+r+"</h3></ul>");typeof e.onShow=="function"&&e.onShow.apply(i,[t]),e.contentsCallback.apply(i,[t]);var s=t,o=function(t){typeof e.onItemClick=="function"&&e.onItemClick.apply(this,[i,s]),typeof e.onHide=="function"&&e.onHide.apply(i),i.remove()},u=Headway.touch?"tap":"click";i.delegate("span",u,o);if(typeof t.originalEvent!="undefined"&&typeof t.originalEvent.clientX!="undefined")var a=t.originalEvent.clientX,f=t.originalEvent.clientY+40;else var a=t.data.x,f=t.data.y+40;i.css({left:a,top:f}),i.delegate("li:has(ul) span","hover",function(){var e=$(this).siblings("ul"),t=e.offset();if(!t||e.offset().left+e.outerWidth()<$("iframe.content").width())return;e.css("right",e.css("left")),e.css("left","auto"),e.css("width","190px"),e.css("zIndex","999999")}),i.appendTo($("body"));if(a+i.outerWidth()>$(window).width()){var l=$(window).width()-(a+i.outerWidth());i.css("left",a+l-20)}if(f+i.outerHeight()>$(window).height()){var l=$(window).height()-(f+i.outerHeight());i.css("top",f+l-20)}return t.preventDefault(),!1},define("helper.context-menus",function(){}),showNotification=function(e){var e=$.extend({},{id:null,message:null,error:!1,success:!1,closeTimer:3e3,closable:!1,closeOnEscKey:!1,closeCallback:function(){},closeConfirmMessage:null,fadeInDuration:350,timerFadeOutDuration:1500,closeFadeOutDuration:350,doNotShowAgain:!1,overwriteExisting:!1,opacity:1},e);if(e.doNotShowAgain&&$.cookie("headway-hide-notification-"+e.id))return;if($("#notification-"+e.id).length){if(!e.overwriteExisting)return $("#notification-"+e.id).fadeIn(e.fadeInDuration);hideNotification(e.id)}var t=$('<div class="notification"><p>'+e.message+"</p></div>");t.attr("id","notification-"+e.id),e.error&&t.addClass("notification-error"),e.success&&t.addClass("notification-success"),e.closable&&t.addClass("notification-closable"),t.css("opacity",e.notification).hide(),t.data("notification-args",e);if(e.closable){var n=$('<span class="close">Close</span>'),r=function(){if(e.closeConfirmMessage&&!confirm(e.closeConfirmMessage))return!1;hideNotification(e.id),$(document).unbind(".notification_"+e.id),$i("html").unbind(".notification_"+e.id)};n.appendTo(t),n.on("click",r),e.closeOnEscKey&&($(document).bind("keyup.notification_"+e.id,r),$i("html").bind("keyup.notification_"+e.id,r))}return e.closeTimer&&setTimeout(function(){t.fadeOut(e.timerFadeOutDuration,function(){$(this).remove()})},e.closeTimer),t.appendTo("#notification-center").fadeIn(350),t},showErrorNotification=function(e){var e=$.extend({},{error:!0,closeTimer:6e3},e);return showNotification(e)},hideNotification=function(e,t){var n=$("#notification-"+e);if(!n||!n.length)return!1;var r=n.data("notification-args");return typeof r.closeCallback=="function"&&r.closeCallback.apply(n),typeof t=="undefined"||t?n.fadeOut(r.closeFadeOutDuration,function(){$(this).remove(),r.doNotShowAgain&&$.cookie("headway-hide-notification-"+r.id,!0)}):(n.remove(),r.doNotShowAgain&&$.cookie("headway-hide-notification-"+r.id,!0)),n},updateNotification=function(e,t){var n=$("#notification-"+e);return n.find("p").html(t)},define("helper.notifications",function(){}),define("modules/grid/grid",["jquery","helper.history","helper.data"],function(e,t){e.widget("ui.headwayGrid",e.ui.mouse,{options:{useIndependentGrid:!1,columns:Headway.defaultGridColumnCount,columnWidth:Headway.defaultGridColumnWidth,gutterWidth:Headway.defaultGridGutterWidth,yGridInterval:5,minBlockHeight:10,selectedBlocksContainerClass:"selected-blocks-container",defaultBlockClass:"block",defaultBlockContentClass:"block-content"},_create:function(){this.wrapper=this.element,this.container=this.wrapper.find(".grid-container"),this.iframe=e(Headway.iframe),this.contents=e(this.iframe).contents(),this.document=e(this.iframe).contents(),this.options.useIndependentGrid=this.wrapper.data("wrapper-settings")["use-independent-grid"],this.wrapper.data("wrapper-settings").columns&&(this.options.columns=this.wrapper.data("wrapper-settings").columns),this.wrapper.data("wrapper-settings")["column-width"]&&(this.options.columnWidth=this.wrapper.data("wrapper-settings")["column-width"]),this.wrapper.data("wrapper-settings")["gutter-width"]&&(this.options.gutterWidth=this.wrapper.data("wrapper-settings")["gutter-width"]),this.addColumnGuides(),this.updateGridCSS(),this.helperTemplate=e('<div class="ui-grid-helper block"></div>'),this.offset=this.container.offset(),this.wrapper.addClass("ui-headway-grid"),this.wrapper.disableSelection(),this._mouseInit(),this._on(this.wrapper,{mousedown:"wrapperMouseDown"}),this._on(this.contents,{mousedown:"iframeMouseDown",mouseup:"iframeMouseUp"}),this._on(this.iframe,{mouseleave:"iframeMouseLeave"}),this._on(this.contents,{mousemove:"iframeMouseMove"}),this._on(e(window),{resize:"resetGridCalculations"}),this._on(e(window),{resize:"alignAllBlocksWithGuides"}),this.initResizable(this.container.children("."+this.options.defaultBlockClass.replace(".",""))),this.initDraggable(this.container.children("."+this.options.defaultBlockClass.replace(".",""))),this.updateGridContainerHeight(),this.container.delegate("."+this.options.defaultBlockClass.replace(".",""),"dblclick",function(t){var n=e(this).parents(".ui-headway-grid").data("ui-headwayGrid");e(this).hasClass("grouped-block")&&n.container.find(".grouped-block").length===1?(e(this).removeClass("grouped-block"),n.container.removeClass("grouping-active"),hideNotification("mass-block-selection")):e(this).hasClass("grouped-block")?e(this).removeClass("grouped-block"):(e(this).addClass("grouped-block"),n.container.addClass("grouping-active"),showNotification({id:"mass-block-selection",message:"Mass Block Selection Mode",closable:!0,closeOnEscKey:!0,closeTimer:!1,opacity:.8,closeCallback:function(){$i(".grouped-block").removeClass("grouped-block"),n.container.removeClass("grouping-active")}}))}),this.alignAllBlocksWithGuides()},resetGridCalculations:function(){this.grid={columns:this.container.find(".grid-guide").length,columnWidth:parseInt(this.container.find(".grid-guide:eq(1)").outerWidth()),gutterWidth:parseInt(this.container.find(".grid-guide:eq(1)").css("marginLeft").replace("px",""))};var t=this;this.wrapper.find(".block:visible").each(function(){e(this).data("plugin_pep")&&(e(this).data("plugin_pep").options.grid=[t.grid.columnWidth+t.grid.gutterWidth,t.options.yGridInterval]),e(this).data("ui-resizable")&&(e(this).resizable("option","grid",[t.grid.columnWidth+t.grid.gutterWidth,t.options.yGridInterval]),e(this).resizable("option","maxWidth",t.grid.columns*(t.grid.columnWidth+t.grid.gutterWidth)))})},_destroy:function(){return this.element.resizable("destroy"),this.element.removeClass("ui-grid ui-grid-disabled").removeData("grid").unbind(".grid"),this._mouseDestroy(),this.element.find(".ui-resizable").resizable("destroy"),this},disable:function(){this.element.resizable("disable"),this.element.find(".ui-resizable").resizable("disable")},enable:function(){this.element.resizable("enable"),this.element.find(".ui-resizable").resizable("enable")},iframeMouseDown:function(t){this._iframeMouseDownEvent=t,this._iframeMouseDownEventElement=e(t.originalEvent.target)},iframeMouseUp:function(e){delete this._iframeMouseDownEvent,delete this._iframeMouseDownEventElement},iframeMouseLeave:function(e){$iDocument().trigger("mouseup")},iframeMouseMove:function(t){if(typeof this._iframeMouseDownEvent!="undefined"||typeof this._doingHoverBlockToTop!="undefined"||!Headway.touch)return;this._doingHoverBlockToTop=!0,setTimeout(e.proxy(function(){var n=[],r=t.pageX,i=t.pageY;e(this.container).find(".block").each(function(){var t=e(this),s=t.offset(),o=s.left,u=s.top,a=o+t.width(),f=u+t.height();if(r<o||r>a)return;if(i<u||i>f)return;n.push(t)}),n.sort(function(e,t){return t.width()*t.height()>e.width()*e.height()?1:0}),this.sendBlockToTop(e(n.pop())),delete this._doingHoverBlockToTop},this),50)},wrapperMouseDown:function(t){if(!t||this.container.hasClass("grouping-active")||getBlock(t.target))return;$i(".blank-block").each(function(){removePanelTab("block-"+getBlockID(e(this))),e(this).remove()})},_mouseStart:function(t){this.mouseStartPosition=[t.pageX-this.container.offset().left,t.pageY-this.container.offset().top];var n=e(t.target);return!t||t.ctrlKey||this.container.hasClass("grouping-active")||getBlock(t.target)||n.hasClass("wrapper-handle")||n.parents(".wrapper-handle").length||n.hasClass("ui-resizable-handle")&&n.parent().hasClass("wrapper")||this.wrapper.hasClass("wrapper-mirrored")?!0:(this._trigger("start",t),this.helper=e(this.helperTemplate).clone().appendTo(this.container),this.helper.css({width:this.grid.columnWidth,height:0,top:0,left:0,display:"none"}),this.wrapper.hasClass("wrapper-fluid")&&this.wrapper.find(".wrapper-buttons").hide(),this.draggingOnWrapper=!0,addBlockDimensionsTooltip(this.helper),!0)},_mouseDrag:function(t){var n=e(t.target);if(!t||!this.helper||t.ctrlKey||this.container.hasClass("grouping-active")||!this.helper&&getBlock(t.target)||n.hasClass("wrapper-handle")||n.parents(".wrapper-handle").length||n.hasClass("ui-resizable-handle")&&n.parent().hasClass("wrapper")||!this.draggingOnWrapper||typeof this.draggingOnWrapper=="undefined"||this.wrapper.hasClass("wrapper-mirrored"))return;var r=e(this.container),i=r.offset(),s=this.mouseStartPosition[0],o=this.mouseStartPosition[1],u=t.pageX-i.left,a=t.pageY-i.top;if(s>u){var f=u;u=s,s=f}if(o>a){var f=a;a=o,o=f}var l=i.left,c=i.top,h=r.height(),p=r.width();if(u>=p&&s>=p)return;if(a>=h&&o>=h)return;s<0&&(s=0),o<0&&(o=0),a>h&&(a=h);var d=s.toNearest(this.grid.columnWidth+this.grid.gutterWidth),v=o.toNearest(this.options.yGridInterval),m=u.toNearest(this.grid.columnWidth+this.grid.gutterWidth)-d-this.grid.gutterWidth,g=a.toNearest(this.options.yGridInterval)-o.toNearest(this.options.yGridInterval);Headway.blankBlockOptions={display:"block",left:d,top:v,width:m,height:g},d+m>this.grid.columns*(this.grid.columnWidth+this.grid.gutterWidth)&&(Headway.blankBlockOptions.width=p-Headway.blankBlockOptions.left),t.pageY>c+h&&(Headway.blankBlockOptions.height=h-v),this.helper.css(Headway.blankBlockOptions);var y=Math.round((Headway.blankBlockOptions.width+this.grid.gutterWidth)/(this.grid.columnWidth+this.grid.gutterWidth)),b=Math.round(Headway.blankBlockOptions.left/(this.grid.columnWidth+this.grid.gutterWidth));return y==0&&(y=1),y&&setBlockGridWidth(this.helper,y),b&&setBlockGridLeft(this.helper,b),this.alignBlockWithGuides(this.helper),Headway.blankBlockOptions.height<this.options.minBlockHeight?this.helper.addClass("block-error"):this.helper.hasClass("block-error")&&this.helper.removeClass("block-error"),e.support.touch||(this.helper.qtip("option","hide.delay",1e4),this.helper.qtip("option","show.delay",10),this.helper.qtip("show"),this.helper.qtip("option","content.text",blockDimensionsTooltipContent),this.helper.qtip("reposition")),this._trigger("drag",t),this.draggingOnWrapper=!0,!1},_mouseStop:function(e){if(!e||e.ctrlKey||this.container.hasClass("grouping-active")||!this.helper||this.wrapper.hasClass("wrapper-mirrored"))return;return this._trigger("stop",e),Headway.blankBlockOptions={width:getBlockGridWidth(this.helper),left:getBlockGridLeft(this.helper),pixelWidth:this.helper.width(),pixelLeft:this.helper.position().left,height:this.helper.height(),top:this.helper.position().top},this.helper.qtip("api")&&this.helper.qtip("api").destroy(!0),this.wrapper.find(".wrapper-buttons").show(),this.helper.remove(),delete this.helper,Headway.blankBlockOptions.pixelWidth<this.grid.columnWidth||Headway.blankBlockOptions.height<this.options.minBlockHeight?!1:(this.addBlankBlock(Headway.blankBlockOptions),this.mouseStartPosition=!1,delete this.draggingOnWrapper,!1)},initResizable:function(t){if(typeof t=="string")var t=e(t);t.resizable({handles:"n, e, s, w, ne, se, sw, nw",grid:[this.grid.columnWidth+this.grid.gutterWidth,this.options.yGridInterval],containment:this.container,minHeight:this.options.minBlockHeight,maxWidth:this.grid.columns*(this.grid.columnWidth+this.grid.gutterWidth),start:this.resizableStart,resize:this.resizableResize,stop:this.resizableStop})},resizableStart:function(t,n){var r=getBlock(n.element),i=r.parents(".ui-headway-grid").data("ui-headwayGrid"),s=parseInt(r.css("minHeight").replace("px","")),o=r.height();s<=o&&r.css("minHeight",0),r.addClass("block-hover"),r.qtip("option","hide.delay",1e4),r.qtip("show"),r.qtip("reposition"),e(r).data("old-position",getBlockPosition(r)),e(r).data("old-position-pixels",getBlockPositionPixels(r)),e(r).data("old-dimensions",getBlockDimensions(r)),e(r).data("old-dimensions-pixels",getBlockDimensionsPixels(r)),i.wrapper.hasClass("wrapper-fluid")&&i.wrapper.find(".wrapper-buttons").hide()},resizableResize:function(e,t){var n=getBlock(t.element),r=n.parents(".ui-headway-grid").data("ui-headwayGrid"),i=Math.round((n.width()+r.grid.gutterWidth)/(r.grid.columnWidth+r.grid.gutterWidth)),s=Math.round(n.position().left/(r.grid.columnWidth+r.grid.gutterWidth));setBlockGridWidth(n,i),setBlockGridLeft(n,s),r.alignBlockWithGuides(n);var o=n.data("qtip");$i("#qtip-"+o.id).remove(),o.rendered=!1,o.render(),o.show()},resizableStop:function(e,t){var n=getBlock(t.element),r=n.parents(".ui-headway-grid").data("ui-headwayGrid"),i=n.data("old-position"),s=n.data("old-dimensions"),o={left:Math.round(n.position().left/(r.grid.columnWidth+r.grid.gutterWidth)),top:getBlockPositionPixels(n).top},u={width:Math.ceil(n.width()/(r.grid.columnWidth+r.grid.gutterWidth)),height:getBlockDimensionsPixels(n).height};r.wrapper.find(".wrapper-buttons").show();var a=function(e,t){setBlockGridWidth(n,e.width),setBlockGridLeft(n,t.left),n.height(e.height),n.css("top",t.top+"px"),n.attr({"data-grid-top":t.top,"data-height":e.height}),f()},f=function(){n.css("width",""),n.css("left",""),r.alignBlockWithGuides(n),dataSetBlockDimensions(getBlockID(n),getBlockDimensions(n)),dataSetBlockPosition(getBlockID(n),getBlockPosition(n)),blockIntersectCheck(n)?allowSaving():disallowSaving(),n.qtip("option","show.delay",300),n.qtip("option","hide.delay",25),n.qtip("show"),n.qtip("reposition"),n.removeClass("block-hover")};Headway.history.add({description:"Resized block",up:function(){a(u,o)},down:function(){a(s,i)}})},initDraggable:function(t){typeof t=="string"&&(t=e(t)),t.css("cursor","move").pep({grid:[this.grid.columnWidth+this.grid.gutterWidth,this.options.yGridInterval],constrainTo:"parent",shouldEase:!1,start:this.draggableStart,stop:this.draggableStop,drag:this.draggableDrag})},draggableStart:function(t,n){if(t.ctrlKey)return!1;if(e(t.target).hasClass("ui-resizable-handle"))return e(n.el).trigger("stop"),!1;var r=n.el,i=getBlock(r).parents(".ui-headway-grid").data("ui-headwayGrid");blockGroupingOriginals={},blockGroupingOriginals[getBlockID(r)]={top:getBlockPositionPixels(r).top,left:getBlockPositionPixels(r).left},e(r).hasClass("grouped-block")?(e(r).data("plugin_pep").$el=i.container.find(".grouped-block"),i.container.find(".grouped-block").each(function(t){e(this).data("old-position",getBlockPosition(e(this))),e(this).data("old-position-pixels",getBlockPositionPixels(e(this)))}),i.sendBlockToTop(i.container.find(".grouped-block"))):(i.container.removeClass("grouping-active"),i.container.find(".grouped-block").removeClass("grouped-block"),hideNotification("mass-block-selection"),i.sendBlockToTop(e(r)),e(r).data("plugin_pep").$el=e(r),e(r).data("old-position",getBlockPosition(r)),e(r).data("old-position-pixels",getBlockPositionPixels(r))),i.wrapper.hasClass("wrapper-fluid")&&i.wrapper.find(".wrapper-buttons").hide(),e(getBlock(n.el)).qtip("hide"),e(getBlock(n.el)).qtip("disable")},draggableDrag:function(t,n){if(e(n.startEvent.target).hasClass("ui-resizable-handle"))return!1;var r=n.el,i=e(r),s,o=getBlock(e(r)).parents(".grid-container"),u=getBlock(e(r)).parents(".ui-headway-grid").data("ui-headwayGrid"),a=getBlock(e(r)).parents(".wrapper");$i(".grid-container").length>1&&!u.container.find(".grouped-block").length&&($i(".grid-container").not(o).each(function(){var n=e(this).closest(".wrapper")[0].getBoundingClientRect(),i=e(this)[0].getBoundingClientRect();s=t.pageX>n.left&&t.pageX<n.right&&t.pageY>n.top+$iDocument().scrollTop()&&t.pageY<n.bottom+$iDocument().scrollTop(),s?e(this).addClass("ui-state-hover"):e(this).removeClass("ui-state-hover");if(s){var o=e(r).data("wrapper-droppable-clone"),a={top:t.pageY-i.top-$iDocument().scrollTop(),left:t.pageX-i.left};if(!o){var o=e(r).clone().css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"",left:e(r).position().left.toNearest(u.grid.columnWidth+u.grid.gutterWidth)}).appendTo(e(this));o.data("left-difference",a.left-e(r).position().left.toNearest(u.grid.columnWidth+u.grid.gutterWidth)),e(r).data("ghost-position",e(r).position()).css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""}).addClass("block-ghost"),e(r).data("wrapper-droppable-clone",o),delete e(r).data("plugin_pep").translation,delete e(r).data("plugin_pep").cssX,delete e(r).data("plugin_pep").cssY}else e(o).closest(e(this)).length||e(o).appendTo(e(this));var f=parseInt(a.top).toNearest(u.options.yGridInterval),l=parseInt(a.left-o.data("left-difference")).toNearest(u.grid.columnWidth+u.grid.gutterWidth);return parseInt(l)+parseInt(e(r).width())>e(this).width()&&(l=e(this).width()-e(r).width()),e(r).height()+f>e(this).height()&&(f=e(this).height()-e(r).height()),f<0&&(f=0),l<0&&(l=0),e(r).height()>e(this).height()&&(e(this).attr("data-original-height")||e(this).attr("data-original-height",e(this).height()),e(this).height(e(r).height())),e(o).css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":"",top:parseInt(f).toNearest(u.options.yGridInterval),left:parseInt(l).toNearest(u.grid.columnWidth+u.grid.gutterWidth)}),!1}}),s||($i(".block-ghost").each(function(){e(this).data("wrapper-droppable-clone").remove(),e(this).removeData("wrapper-droppable-clone"),e(this).removeClass("block-ghost"),e(this).css({left:e(this).data("ghost-position").left,top:e(this).data("ghost-position").top,transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""})}),$i("[data-original-height]").each(function(){e(this).height(e(this).data("original-height")),e(this).removeAttr("data-original-height")})));if(s)return!1;e(getBlock(n.helper)).qtip("hide")},draggableStop:function(t,n){if(e(n.startEvent.target).hasClass("ui-resizable-handle"))return!1;var r=e(n.el),i=getBlock(e(r)).parents(".grid-container"),s=getBlock(e(r)).parents(".ui-headway-grid").data("ui-headwayGrid"),o,u;$i(".grid-container").length>1&&!s.container.find(".grouped-block").length&&$i(".grid-container").not(i).each(function(){var n=e(this).closest(".wrapper")[0].getBoundingClientRect();o=t.pageX>n.left&&t.pageX<n.right&&t.pageY>n.top+$iDocument().scrollTop()&&t.pageY<n.bottom+$iDocument().scrollTop();if(o||!t.originalEvent&&e(this).find(e(r).data("wrapper-droppable-clone")).length)return o=!0,u=e(this),!1;u=!1}),$i(".grid-container.ui-state-hover").removeClass("ui-state-hover");if(o&&$i(".grid-container").length>1){var a=u.parents(".wrapper").data("ui-headwayGrid"),f=r.parents(".grid-container");u.append(r),e(r).css(e(r).data("wrapper-droppable-clone").position()),e(r).css("transform",""),e(r).data("wrapper-droppable-clone").remove(),e(r).removeClass("block-ghost").removeData("wrapper-droppable-clone"),setBlockGridLeft(r,Math.round(e(r).position().left/(s.grid.columnWidth+s.grid.gutterWidth))),$i("[data-original-height]").removeAttr("data-original-height"),r.resizable("destroy"),u.parents(".wrapper").headwayGrid("initResizable",r),e.pep.unbind(r),u.parents(".wrapper").headwayGrid("initDraggable",r),blockIntersectCheck(!1,f),blockIntersectCheck(!1,u),dataSetBlockPosition(getBlockID(r),getBlockPosition(r)),dataSetBlockWrapper(getBlockID(r),getBlockWrapper(r).attr("id")),r.parents(".ui-headway-grid").first().data("ui-headwayGrid").alignBlockWithGuides(r)}if(s.container.find(".grouped-block").length)var l=s.container.find(".grouped-block");else var l=getBlock(n.el);s.wrapper.find(".wrapper-buttons").show();var c=[];if(l.length===1)var h="Moved block";else var h="Mass Moved Blocks: ";l.each(function(){c.push({block:e(this),newPosition:{left:Math.round(e(this).position().left/(s.grid.columnWidth+s.grid.gutterWidth)),top:getBlockPositionPixels(e(this)).top},newPositionPixels:getBlockPositionPixels(e(this)),oldPosition:e(this).data("old-position"),oldPositionPixels:e(this).data("old-position-pixels")}),l.length>1&&(h+=", ")}),l.length>1&&(h=h.substring(0,h.length-2));var p=function(e,t){var n=e.block,r=e.newPosition.left,i=e.newPosition.top,s=e.newPositionPixels.left;t&&(r=e.oldPosition.left,i=e.oldPosition.top,s=e.oldPositionPixels.left),setBlockGridLeft(n,r),n.attr({"data-grid-top":i}),n.css("top",i+"px"),n.css("left",s+"px"),n.css({transform:"","-webkit-transform":"","-moz-transform":"","-ms-transform":"","-o-transform":""}),delete n.data("plugin_pep").translation,delete n.data("plugin_pep").cssX,delete n.data("plugin_pep").cssY,dataSetBlockPosition(getBlockID(n),getBlockPosition(n)),dataSetBlockWrapper(getBlockID(n),getBlockWrapper(n).attr("id")),blockIntersectCheck(n)?allowSaving():disallowSaving()};Headway.history.add({description:h,up:function(){jQuery.each(c,function(e,t){p(t,!1)})},down:function(){jQuery.each(c,function(e,t){p(t,!0)})}}),e(document).focus(),e(getBlock(n.el)).qtip("enable"),e(getBlock(n.el)).qtip("show"),e(r).data("hoverWaitTimeout",setTimeout(function(){e(getBlock(n.el)).qtip("reposition"),e(getBlock(n.el)).qtip("show")},300))},addBlankBlock:function(t,n){var r={top:0,left:0,width:140,height:this.options.minBlockHeight,id:null};t=e.extend({},r,t);if(typeof i=="undefined")var i=!0;typeof n=="undefined"&&(n=!1);var s=Math.ceil(Math.random()*1e9);Headway.blankBlock=e('<div><div class="block-content-fade block-content"></div></div>').attr("id","block-"+s).attr("data-id",s).attr("data-temp-id",s).attr("data-desired-id",t.id?t.id:null).data("id",s).data("temp-id",s).data("desired-id",t.id?t.id:null).addClass(this.options.defaultBlockClass.replace(".","")).addClass("blank-block").addClass("hide-content-in-grid"),updateBlockContentCover(Headway.blankBlock);var o=Headway.blankBlock;return o.css({height:parseInt(t.height),top:parseInt(t.top),position:"absolute",visibility:"hidden",left:"",width:""}),setBlockGridLeft(o,t.left),setBlockGridWidth(o,t.width),o.attr({"data-height":parseInt(t.height),"data-grid-top":parseInt(t.top)}),o.appendTo(this.container),this.alignBlockWithGuides(o),o.css("visibility","visible"),n==0&&openBlockTypeSelector(e(Headway.blankBlock)),this.initResizable(o),this.initDraggable(o),blockIntersectCheck(o),o},setupBlankBlock:function(e,t,n){if(typeof n=="undefined")var n=!0;if(typeof t=="undefined")var t=!1;Headway.blankBlock.removeClass("blank-block"),Headway.blankBlock.addClass("block-type-"+e),Headway.blankBlock.data("type",e),n&&loadBlockContent({blockElement:Headway.blankBlock,blockOrigin:{type:e,id:0,layout:Headway.currentLayout},blockSettings:{dimensions:getBlockDimensions(Headway.blankBlock),position:getBlockPosition(Headway.blankBlock)}}),getBlockTypeObject(e)["fixed-height"]===!0?Headway.blankBlock.addClass("block-fixed-height"):Headway.blankBlock.addClass("block-fluid-height"),getBlockTypeObject(e)["show-content-in-grid"]&&Headway.blankBlock.removeClass("hide-content-in-grid"),dataAddBlock(Headway.blankBlock),dataSetBlockPosition(getBlockID(Headway.blankBlock),getBlockPosition(Headway.blankBlock)),dataSetBlockDimensions(getBlockID(Headway.blankBlock),getBlockDimensions(Headway.blankBlock)),dataSetBlockWrapper(getBlockID(Headway.blankBlock),Headway.blankBlock.closest(".wrapper").attr("id")),blockIntersectCheck(Headway.blankBlock)?allowSaving():disallowSaving(),updateBlockContentCover(Headway.blankBlock);var r=Headway.blankBlock;return Headway.history.add({description:"Added "+getBlockTypeNice(e)+" block",up:function(){r.show(),typeof GLOBALunsavedValues["blocks"][getBlockID(r)]["delete"]!="undefined"&&delete GLOBALunsavedValues.blocks[getBlockID(r)]["delete"],blockIntersectCheck(r,r.parents(".grid-container"))},down:function(){r.hide(),removePanelTab("block-"+getBlockID(r)),dataDeleteBlock(getBlockID(r)),blockIntersectCheck(!1,r.parents(".grid-container"))}}),delete Headway.blankBlock,delete Headway.blankBlockOptions,r},addBlock:function(t){var n={top:0,left:0,width:1,height:this.options.minBlockHeight,type:null,id:null,settings:[]},t=e.extend({},n,t);if(this.addBlankBlock(t,!0)){var r=this.setupBlankBlock(t.type,!0,!1),i=getBlockID(r);return e.each(t.settings,function(e,t){dataSetBlockOption(i,e,t),e=="mirror-block"&&updateBlockMirrorStatus(!1,r,t,!1)}),typeof t.settings.duplicateOf!="undefined"&&r.data("duplicateOf",t.settings.duplicateOf),refreshBlockContent(i,!1,!1,!1),this.updateGridContainerHeight(),r}return!1},sendBlockToTop:function(e){if(typeof e=="string")var e=getBlock(e);if(!e||!e.length)return;$i(".block").css("zIndex",1),e.css("zIndex",2)},updateGridContainerHeight:function(){var t=this.container,n=this.wrapper;t.css("height",this.wrapper.height());if(t.find(".block:visible").length){var r=0;t.find(".block:visible").each(function(){var t=e(this).outerHeight()+e(this).position().top;t>r&&(r=t)}),t.height(r)}},addColumnGuides:function(){var t=this.container;t.find(".grid-guides").remove();var n=e('<div class="grid-guides grid-guides-grey"></div><!-- #grid -->');for(i=1;i<=this.options.columns;i++)n.append('<div class="grid-guide grid-width-1 grid-guide-'+i+'"></div>');n.prependTo(t)},alignBlockWithGuides:function(t){var n=this.container.children(".grid-guides:visible");if(!n.length)return;var r=parseInt(getBlockGridLeft(t)),i=parseInt(getBlockGridWidth(t));if(typeof r=="undefined"||isNaN(r)||r<0)r=0;if(typeof i=="undefined"||isNaN(i)||i==0)i=1;var s=r+1<this.grid.columns?r+1:this.grid.columns,o=n.find(".grid-guide-"+s),u=r+i<this.grid.columns?r+i:this.grid.columns,a=n.find(".grid-guide-"+u);a.length||(a=o);if(r+1<=r+i){var f=parseInt(o.css("marginLeft").replace("px","")),l=parseInt(a.css("marginLeft").replace("px","")),c=o.position().left+f,h=a.position().left+a.outerWidth()-o.position().left-1;r==0&&(h+=l),t.css({top:e(t).position().top,transform:"",left:Math.ceil(c)+"px",width:Math.ceil(h)+"px"})}},alignAllBlocksWithGuides:function(){var t=this;this.container.find(".block:visible").each(function(){t.alignBlockWithGuides(e(this))})},updateGridCSS:function(){var t=this,n=this.wrapper,r=e("div#wrapper-"+getWrapperID(n)+"-tab"),i="div#"+n.attr("id");return n.attr("data-temp-id")&&(i='div.wrapper[data-temp-id="'+n.attr("data-temp-id")+'"]'),typeof this.options.useIndependentGrid!="undefined"&&this.options.useIndependentGrid===!0||typeof this.options.useIndependentGrid=="string"&&hwBoolean(this.options.useIndependentGrid)?updateGridCSS(i,this.options.columns,this.options.columnWidth,this.options.gutterWidth,r):updateGridCSS(i,this.options.columns,Headway.globalGridColumnWidth,Headway.globalGridGutterWidth,r),this.resetGridCalculations(),e($iDocument()).ready(function(){t.alignAllBlocksWithGuides()}),n}}),e.extend(e.ui.headwayGrid,{version:"2.1"})}),bindGridWizard=function(){var e={"right-sidebar":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:18,height:320,type:"content"},{top:190,left:18,width:6,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:520,left:0,width:24,height:70,type:"footer"}],"left-sidebar":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:6,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:190,left:6,width:18,height:320,type:"content"},{top:520,left:0,width:24,height:70,type:"footer"}],"two-right":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:16,height:320,type:"content"},{top:190,left:16,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:190,left:20,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-2"},{top:520,left:0,width:24,height:70,type:"footer"}],"two-both":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-1"},{top:190,left:4,width:16,height:320,type:"content"},{top:190,left:20,width:4,height:270,type:"widget-area",mirroringOrigin:"sidebar-2"},{top:520,left:0,width:24,height:70,type:"footer"}],"all-content":[{top:0,left:0,width:24,height:130,type:"header"},{top:140,left:0,width:24,height:40,type:"navigation"},{top:190,left:0,width:24,height:320,type:"content"},{top:520,left:0,width:24,height:70,type:"footer"}]};$("div#boxes").delegate("div#box-grid-wizard span.layout-preset","mousedown",function(){$("div#box-grid-wizard span.layout-preset-selected").removeClass("layout-preset-selected"),$(this).addClass("layout-preset-selected")}),$("div#boxes").delegate("span#grid-wizard-button-preset-next","click",function(){var e=$("div#box-grid-wizard span.layout-preset-selected").attr("id").replace("layout-","");switch(e){case"right-sidebar":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").hide(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Right Sidebar");break;case"left-sidebar":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").hide(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Left Sidebar");break;case"two-right":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Left Sidebar"),$("div#grid-wizard-presets-mirroring-select-sidebar-2 h5").text("Right Sidebar");break;case"two-both":$("div#grid-wizard-presets-mirroring-select-sidebar-1").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").show(),$("div#grid-wizard-presets-mirroring-select-sidebar-1 h5").text("Left Sidebar"),$("div#grid-wizard-presets-mirroring-select-sidebar-2 h5").text("Right Sidebar");break;case"all-content":$("div#grid-wizard-presets-mirroring-select-sidebar-1").hide(),$("div#grid-wizard-presets-mirroring-select-sidebar-2").hide()}$(this).hide(),$("span#grid-wizard-button-preset-previous").show(),$("span#grid-wizard-button-preset-use-preset").show(),$("div#grid-wizard-presets-step-1").hide(),$("div#grid-wizard-presets-step-2").show()}),$("div#boxes").delegate("span#grid-wizard-button-preset-previous","click",function(){$(this).hide(),$("span#grid-wizard-button-preset-use-preset").hide(),$("span#grid-wizard-button-preset-next").show(),$("div#grid-wizard-presets-step-2").hide(),$("div#grid-wizard-presets-step-1").show()}),$("div#boxes").delegate("span#grid-wizard-button-preset-use-preset","click",function(){var t=$("div#box-grid-wizard span.layout-preset-selected").attr("id").replace("layout-","");return $i(".block").each(function(){deleteBlock(this)}),$.each(e[t],function(){var e=this;delete e.mirroringOrigin;var t=typeof this.mirroringOrigin!="undefined"?this.mirroringOrigin:this.type,n=$("div#grid-wizard-presets-mirroring-select-"+t+" select").val();n!==""&&(e.settings={},e.settings["mirror-block"]=n),$i(".ui-headway-grid").first().data("ui-headwayGrid").addBlock(e)}),closeBox("grid-wizard")}),$("div#boxes").delegate("span#grid-wizard-button-clone-page","click",function(){var e=$("select#grid-wizard-pages-to-clone").val();if(e===""||!e)return alert("Please select a page to clone.");if($(this).hasClass("button-depressed"))return;$(this).text("Cloning...").addClass("button-depressed").css("cursor","default");var t=$.ajax(Headway.ajaxURL,{type:"POST",async:!0,data:{action:"headway_visual_editor",method:"get_layout_blocks_in_json",security:Headway.security,layout:e},success:function(e,t){if(t==0)return!1;$i(".wrapper").each(function(){deleteWrapper(getWrapperID($(this)),!0)});var n=e.wrappers,r=e.blocks,i={};return $.each(n,function(e,t){var n=t.styling;delete t.styling;var r=addWrapper("bottom",t.settings,!0),s=getWrapperID(r);i[e.replace("wrapper-","")]=s,typeof t["mirror_id"]!="undefined"&&(updateWrapperMirrorStatus(s,t.mirror_id),dataSetWrapperOption(s,"mirror-wrapper",t.mirror_id)),$.each(n,function(e,t){dataSetDesignEditorProperty({element:"wrapper",property:e,value:t!==null?t.toString():null,specialElementType:"instance",specialElementMeta:"wrapper-"+s});if(e.indexOf("margin")===0){var n=e.replace("margin-","").capitalize();r.css("margin"+n,t+"px")}else if(e.indexOf("padding")===0){var i=e.replace("padding-","").capitalize();r.css("padding"+i,t+"px")}})}),$.each(r,function(){var e=this.mirror_id?this.mirror_id:this.id,t={type:this.type,top:this.position.top,left:this.position.left,width:this.dimensions.width,height:this.dimensions.height,settings:$.extend({},this.settings,{"mirror-block":e})},n=typeof this.wrapper_id!="undefined"&&this.wrapper_id?this.wrapper_id:"default";if(typeof i[n.replace("wrapper-","")]!="undefined")var r="#wrapper-"+i[n.replace("wrapper-","")],s=$i(".ui-headway-grid").filter(r).first();else var s=$i(".ui-headway-grid").last();var o=s.data("ui-headwayGrid").addBlock(t),u=getBlockID(o),a=this.id;typeof this.styling!="undefined"&&this.styling&&$.each(this.styling,function(e,t){var e=e.replace("block-"+a,"block-"+u);$.each(t.properties,function(n,r){dataSetDesignEditorProperty({group:"blocks",element:t.element,property:n,value:r!==null?r.toString():null,specialElementType:"instance",specialElementMeta:e})})})}),closeBox("grid-wizard")}})}),$("div#boxes").delegate("span#grid-wizard-button-assign-template","click",function(){var e=$("select#grid-wizard-assign-template").val().replace("template-","");return e===""?alert("Please select a shared layout to assign."):($.post(Headway.ajaxURL,{action:"headway_visual_editor",method:"assign_template",security:Headway.security,template:e,layout:Headway.currentLayout},function(t){if(typeof t=="undefined"||t=="failure")return showErrorNotification({id:"error-could-not-assign-template",message:"Error: Could not assign shared layout."}),!1;$("div#layout-selector li.layout-selected").removeClass("layout-item-customized"),$("div#layout-selector li.layout-selected").addClass("layout-item-template-used"),$("div#layout-selector li.layout-selected span.status-template").text(t),showIframeLoadingOverlay(),changeTitle("Visual Editor: Assigning Template"),startTitleActivityIndicator(),Headway.currentLayoutTemplate="template-"+e,Headway.currentLayoutTemplateName=$('span.layout[data-layout-id="template-'+e+'"]').find(".template-name").text(),headwayIframeLoadNotification="Template assigned successfully!",loadIframe(Headway.instance.iframeCallback)}),closeBox("grid-wizard"))}),$("div#boxes").delegate("span.grid-wizard-use-empty-grid","click",function(){$i(".block").each(function(){deleteBlock(this)}),closeBox("grid-wizard")}),initiateLayoutImport=function(e){var t=e;if(!t.val())return alert("You must select a Headway layout file before importing.");var n=t.get(0).files[0];if(n&&typeof n.name!="undefined"&&typeof n.type!="undefined"){var r=new FileReader;r.onload=function(e){var t=e.target.result,n=JSON.parse(t);if(n["data-type"]!="layout")return alert("Cannot load layout file.  Please insure that the selected file is a valid Headway layout export.");typeof n["image-definitions"]!="undefined"&&Object.keys(n["image-definitions"]).length?(showNotification({id:"importing-images",message:"Currently importing images.",closeTimer:1e4}),$.post(Headway.ajaxURL,{action:"headway_visual_editor",method:"import_images",security:Headway.security,importFile:n},function(e){var t=e;if(typeof t["error"]!="undefined")return alert("Error while importing images for layout: "+t.error);importLayout(t)})):importLayout(n)},r.readAsText(n)}else alert("Cannot load layout file.  Please insure that the selected file is a valid Headway layout export.")},importLayout=function(e){$i(".wrapper").each(function(){deleteWrapper(getWrapperID(this),!0)});var t=e.blocks,n=e.wrappers,r={};return $.each(n,function(e,t){var n=t.styling||{};delete t.styling;var i=addWrapper("bottom",t.settings,!0),s=getWrapperID(i);r[e.replace("wrapper-","")]=s,typeof t["mirror_id"]!="undefined"&&(updateWrapperMirrorStatus(s,t.mirror_id),dataSetWrapperOption(s,"mirror-wrapper",t.mirror_id)),$.each(n,function(e,t){dataSetDesignEditorProperty({element:"wrapper",property:e,value:t!==null?t.toString():null,specialElementType:"instance",specialElementMeta:"wrapper-"+s});if(e.indexOf("margin")===0){var n=e.replace("margin-","").capitalize();i.css("margin"+n,t+"px")}else if(e.indexOf("padding")===0){var r=e.replace("padding-","").capitalize();i.css("padding"+r,t+"px")}})}),$.each(t,function(){var e={type:this.type,top:this.position.top,left:this.position.left,width:this.dimensions.width,height:this.dimensions.height,settings:$.extend({},this.settings,{"mirror-block":this.mirror_id})},t=typeof this.wrapper_id!="undefined"&&this.wrapper_id?this.wrapper_id:"default";if(typeof r[t.replace("wrapper-","")]!="undefined")var n="#wrapper-"+r[t.replace("wrapper-","")],i=$i(".ui-headway-grid").filter(n).first();else var i=$i(".ui-headway-grid").last();var s=i.data("ui-headwayGrid").addBlock(e),o=getBlockID(s),u=this.id;typeof this.styling!="undefined"&&this.styling&&$.each(this.styling,function(e,t){var e=e.replace("block-"+u,"block-"+o);$.each(t.properties,function(n,r){dataSetDesignEditorProperty({group:"blocks",element:t.element,property:n,value:r!==null?r.toString():null,specialElementType:"instance",specialElementMeta:e})})})}),showNotification({id:"layout-successfully-imported",message:"Layout successfully imported.<br /><br />Remember to save if you wish to keep the layout.",closeTimer:!1,closable:!0,success:!0}),closeBox("grid-wizard"),allowSaving(),!0},$("div#boxes").delegate("#grid-wizard-import-select-file","click",function(){$(this).siblings('input[type="file"]').trigger("click")}),$("div#boxes").delegate('#grid-wizard-import input[type="file"]',"change",function(e){if(e.target.files[0].name.split(".").slice(-1)[0]!="json")return $(this).val(null),alert("Invalid layout file.  Please be sure that the layout is a valid JSON formatted file.");initiateLayoutImport($(this))}),$("div#boxes").delegate("#grid-wizard-export-download-file","click",function(){var e={action:"headway_visual_editor",security:Headway.security,method:"export_layout",layout:Headway.currentLayout},t=Headway.ajaxURL+"?"+$.param(e);return window.open(t)})},define("modules/grid/grid-wizard",function(){}),define("modules/grid/mode-grid",["jquery","modules/grid/grid","deps/itstylesheet","modules/grid/wrappers","modules/grid/grid-wizard","deps/jquery.pep","helper.blocks","helper.wrappers"],function(e,t,n){var r={init:function(){bindGridWizard()},iframeCallback:function(){$i(".block").each(function(){updateBlockContentCover(e(this)),loadBlockContent({blockElement:e(this),blockOrigin:getBlockID(e(this))})}),gridStylesheet=new ITStylesheet({document:Headway.iframe.contents()[0],href:"/?headway-trigger=compiler&file=ve-iframe-grid-dynamic"},"find"),addEdgeInsertWrapperButtons(),addWrapperButtons($i("div.wrapper")),bindWrapperButtons(),setupWrapperSortables(),setupWrapperResizable(),setupWrapperContextMenu(),assignDefaultWrapperID(),$i(".grid-container").length===1&&!$i(".block").length&&$i(".grid-container").height(500),$i("div.wrapper").headwayGrid(),$i("div.wrapper-mirrored").headwayGrid("disable"),updateGridWidthInput("#sub-tab-grid-content"),setupBlockContextMenu(),bindBlockDimensionsTooltip()}};return updateGridCSS=function(e,t,n,r,s){var o=n*t+(t-1)*r,u=n*t/o,a=r*t/o,f=100/t*u,l=100/t*a,c=9,h=e+" ";gridStylesheet.update_rule(h+".grid-guides .grid-guide",{margin:"0 0 0 "+Math.round(l,c)+"%"});for(i=1;i<=t;i++)gridStylesheet.update_rule(h+".grid-width-"+i,{width:Math.round(f*i+(i-1)*l,c)+"%"}),gridStylesheet.update_rule(h+".grid-left-"+i,{left:"0 0 0 "+Math.round((f+l)*i,c)+"%"});gridStylesheet.update_rule(h+"div.grid-container",{width:o+1+"px"}),gridStylesheet.update_rule(e+".wrapper-fixed",{width:o+"px"}),typeof s!="undefined"&&s.length&&updateGridWidthInput(s)},r}),require.config({paths:{ko:"deps/knockout",underscore:"deps/underscore",jqueryUI:"deps/jquery.ui",qtip:"deps/jquery.qtip"},shim:{underscore:{exports:"_"}}}),require(["jquery","util.loader"],function(e){startTitleActivityIndicator(),Headway.blockTypeURLs=e.parseJSON(Headway.blockTypeURLs.replace(/&quot;/g,'"')),Headway.allBlockTypes=e.parseJSON(Headway.allBlockTypes.replace(/&quot;/g,'"')),Headway.ranTour=e.parseJSON(Headway.ranTour.replace(/&quot;/g,'"')),Headway.designEditorProperties=e.parseJSON(Headway.designEditorProperties.replace(/&quot;/g,'"')),require(["modules/layout-selector"],function(e){e.init()}),require(["modules/panel","modules/iframe"],function(e,t){e.init(),t.init()}),require(["modules/menu"],function(e){e.init()}),require(["modules/snapshots"],function(e){e.init()}),require(["util.tour"],function(e){Headway.ranTour[Headway.mode]==0&&Headway.ranTour.legacy==0&&e.start()}),require(["helper.data","helper.blocks","helper.wrappers","helper.context-menus","helper.notifications","helper.boxes","helper.history"],function(e,t,n,r,i,s,o){o.init()});switch(Headway.mode){case"grid":require(["modules/grid/mode-grid","modules/iframe"],function(e){Headway.instance=e,e.init(),waitForIframeLoad(e.iframeCallback)});break;case"design":require(["modules/design/mode-design","modules/iframe"],function(e){Headway.instance=e,e.init(),waitForIframeLoad(e.iframeCallback)})}e(document).ready(function(){e("body").addClass("show-ve")}),e(window).bind("load",function(){setTimeout(function(){e("div#ve-loading-overlay").remove()},1e3)})}),define("app",function(){});
\ No newline at end of file
index 656d738..c13a26a 100644 (file)
@@ -1,7 +1,7 @@
 /*
 THEME NAME:Headway Base
 THEME URI:http://www.headwaythemes.com
-VERSION:3.7.9
+VERSION:3.7.10
 AUTHOR:Headway Themes
 AUTHOR URI:http://www.headwaythemes.com
 DESCRIPTION:Headway is a feature-packed theme with drag and drop layout editing, point and click design capabilities, powerful search engine optimization and much more.  For help, you can <a href="http://support.headwaythemes.com" target="_blank">access our support</a> or go to the <a href="http://docs.headwaythemes.com/" target="_blank">Headway documentation</a>.