﻿var _errBub_Dismiss_Id=-1,_pmnu_open=!1,_tmnu_open=!1,_pmnu_twoCol_open=!1,_tmnu_twoCol_open=!1,_homePageUrl="/home/";function GetRedirectLoc(){var o="/",n=$("#redirect").val();return"undefined"!=typeof __redirectTo&&null!=typeof __redirectTo&&"string"==typeof __redirectTo&&0<__redirectTo.length&&(o=__redirectTo),(o=null!=n&&0<n.length?n:o)+window.location.hash.replace(/#/g,"9E0")}function dismissErr(){$("#errBub").animate({top:"45px"},"fast"),_errBub_Dismiss_Id=-1}function attemptSignIn(){$("#loginForm").submit()}$(window).resize(function(){null!=$("#profileIconTwoCol").position()&&$(".dropContainerTwoCol").css("left",$("#profileIconTwoCol").position().left+"px"),null!=$("#profileIcon").position()&&$(".dropContainer").css("left",$("#profileIcon").position().left+"px")}),$(document).one("widgetsloaded",function(){0<window.location.search.indexOf("redir").length||0<window.location.search.indexOf("ret").length||(_fbTarget=GetRedirectLoc()),$(this).click(function(o){var n=o.target.className,o=o.target.id;"profileIconTwoCol"!==n&&"myTeamsCtaTwoCol"!==n&&"myTeamsLinkTwo"!=o&&"myTeamsTxt"!=o&&(_pmnu_twoCol_open?($("#profileOptionsTwoCol").animate({top:"-45px"},500,"swing",function(){$(".dropContainerTwoCol").hide()}),_pmnu_twoCol_open=!_pmnu_twoCol_open):_tmnu_twoCol_open&&($("#myTeamsOptionTwoCol").animate({top:"-300px"},500,"swing",function(){$(".dropContainerTwoCol").hide()}),_tmnu_twoCol_open=!_tmnu_twoCol_open)),"profileIcon"!==n&&"myTeamsCta"!==n&&"myTeamsLinkOne"!=o&&"myTeamsTxt"!=o&&(_pmnu_open?($("#profileOptions").animate({top:"-85px"},500,"swing",function(){$(".dropContainer").hide()}),_pmnu_open=!_pmnu_open):_tmnu_open&&($("#myTeamsOption").animate({top:"-300px"},500,"swing",function(){$(".dropContainer").hide()}),_tmnu_open=!_tmnu_open))}),$("#logo_imageL, #logo_image").click(function(){window.location=_homePageUrl}),$(".formButtons").hover(function(){$(this).fadeTo("fast",.5),$(this).stop(!0,!1)},function(){$(this).fadeTo("fast",1)}),$("#signInBtn").click(function(){attemptSignIn()}),$("#pword").keydown(function(o){"13"==o.keyCode&&attemptSignIn()}),$("#errDis").click(function(){-1<_errBub_Dismiss_Id&&clearTimeout(_errBub_Dismiss_Id),dismissErr()}),$(".emailInput").focus(function(){$(this).css({"background-image":"url(/images/emailBgTyping.png)","background-position":"1px 3px"}),""!==$(".pwordInput").val()&&$(".pwordInput").css({"background-image":"url(/images/pwordBgTyping.png)","background-position":"2px 2px"})}),$(".emailInput").blur(function(){$(this).val().length<=0&&$(this).css({"background-image":"url(/images/emailBg.png)","background-position":"0px 2px"})}),$(".pwordInput").focus(function(){$(this).css({"background-image":"url(/images/pwordBgTyping.png)","background-position":"2px 2px"}),""!==$(".emailInput").val()&&$(".emailInput").css({"background-image":"url(/images/emailBgTyping.png)","background-position":"1px 3px"})}),$(".pwordInput").blur(function(){$(this).val().length<=0&&$(this).css({"background-image":"url(/images/pwordBg.png)","background-position":"2px 2px"})}),$(".teamContainer").click(function(){window.location="/team/news/"+$(this).attr("id").split("_")[1]+"/home/"}),$("#profileIcon").click(function(){$("#profileOptions").stop(!0,!1),_pmnu_open=!_pmnu_open,$(".dropContainer").css("left",$("#profileIcon").position().left+"px"),_tmnu_open&&($("#myTeamsOption").animate({top:"-300px"}),_tmnu_open=!_tmnu_open),_pmnu_open?($(".dropContainer").show(),$("#primaryNav").css({"box-shadow":"0px 2px 7px #000000"}),$("#profileOptions").animate({top:"0px"})):($("#primaryNav").css({"box-shadow":"0px 0px 0px #000000"}),$("#profileOptions").animate({top:"-45px"},500,"swing",function(){$(".dropContainer").hide()}))}),$("#myTeamsCta,#myTeamsLinkOne").click(function(){$("#myTeamsOption").stop(!0,!1),_tmnu_open=!_tmnu_open,$(".dropContainer").css("left",$("#myTeamsLinkOne").position().left+"px"),_pmnu_open&&($("#profileOptions").animate({top:"-45px"}),_pmnu_open=!_pmnu_open),_tmnu_open?($(".dropContainer").show(),$("#primaryNav").css({"box-shadow":"0px 2px 7px #000000"}),$("#myTeamsOption").animate({top:"-45px"})):($("#primaryNav").css({"box-shadow":"0px 0px 0px #000000"}),$("#myTeamsOption").animate({top:"-300px"},500,"swing",function(){$(".dropContainer").hide()})),""==$.trim($(".myTeamsOption").text())&&$(".myTeamsOption").html("<div class='teamAlert'>You currently do not have any teams linked. Click <a title='Find Team' class='emptyTeamLink' href='/team/search/'>Find a Team</a> to start adding teams.</div>")}),$("#profileIconTwoCol").click(function(){$("#profileOptionsTwoCol").stop(!0,!1),_pmnu_twoCol_open=!_pmnu_twoCol_open,$(".dropContainerTwoCol").css("left",$("#profileIconTwoCol").position().left+"px"),_tmnu_twoCol_open&&($("#myTeamsOptionTwoCol").animate({top:"-300px"}),_tmnu_twoCol_open=!_tmnu_twoCol_open),_pmnu_twoCol_open?($(".dropContainerTwoCol").show(),$("#primaryNav").css({"box-shadow":"0px 2px 7px #000000"}),$("#profileOptionsTwoCol").animate({top:"40px"})):($("#primaryNav").css({"box-shadow":"0px 0px 0px #000000"}),$("#profileOptionsTwoCol").animate({top:"-45px"},500,"swing",function(){$(".dropContainerTwoCol").hide()}))}),$("#myTeamsCtaTwoCol,#myTeamsLinkTwo").click(function(){$("#myTeamsOptionTwoCol").stop(!0,!1),_tmnu_twoCol_open=!_tmnu_twoCol_open,$(".dropContainerTwoCol").css("left",$("#myTeamsLinkTwo").position().left+"px"),_pmnu_twoCol_open&&($("#profileOptionsTwoCol").animate({top:"-45px"}),_pmnu_twoCol_open=!_pmnu_twoCol_open),_tmnu_twoCol_open?($(".dropContainerTwoCol").show(),$("#primaryNav").css({"box-shadow":"0px 2px 7px #000000"}),$("#myTeamsOptionTwoCol").animate({top:"-45px"})):($("#primaryNav").css({"box-shadow":"0px 0px 0px #000000"}),$("#myTeamsOptionTwoCol").animate({top:"-300px"},500,"swing",function(){$(".dropContainerTwoCol").hide()})),""==$.trim($(".myTeamsOptionTwoCol").text())&&$(".myTeamsOptionTwoCol").html("<div class='teamAlert'>You currently do not have any teams linked. Click <a title='Find Team' class='emptyTeamLink' href='/team/search/'>Find a Team</a> to start adding teams.</div>")}),$("#signInBtn").hover(function(){$(this).fadeTo("fast",.5),$(this).css({cursor:"pointer"}),$(this).stop(!0,!1)},function(){$(this).fadeTo("fast",1)})});
﻿PopupDialog=function(){if(this._popupId="",this._suppressAlertErrors=!1,this._customControls=new Array,this._debug=!1,"function"!=typeof _MTS_JQUERY)return this._Alert("You must use jQuery!"),null},PopupDialog.prototype={_RandomIdString:function(t){for(var e,p="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",o="",n=0;n<t;n++)e=Math.floor(Math.random()*p.length),o+=p.substring(e,e+1);return o.toString()},_Alert:function(t){this._debug&&alert(t)},_IsValidParams:function(t,e){return"string"!=typeof t||null==t?(this._Alert("You must specify a valid message!"),!1):"string"==typeof e&&null!=e||(this._Alert("You must specify a valid title!"),!1)},_IsValidJsonControl:function(t){return"object"==typeof t&&null!=t&&("string"==typeof t.id&&null!=t.id&&("string"==typeof t.type&&null!=t.type&&("string"==typeof t.name&&null!=t.name&&("string"==typeof t.text&&null!=t.text&&!(t.id.length<=0||t.type.length<=0||t.name.length<=0)))))},_StandardWireups:function(){_MTS_JQUERY(".popUpDialogButton").hover(function(){_MTS_JQUERY(this).fadeTo("fast",.5),_MTS_JQUERY(this).css({cursor:"pointer"}),_MTS_JQUERY(this).stop(!0,!1)},function(){_MTS_JQUERY(this).fadeTo("fast",1)})},_CreateElement:function(t,e,p){var o=null;return"string"!=typeof t||null==t||"object"!=typeof(o=document.createElement(t))||null==o?null:("string"==typeof e&&null!=e&&(o.id=e),"string"==typeof p&&null!=p&&(o.className=p),o)},_AddCloser:function(t,e,p){var o=this;_MTS_JQUERY("#popUpClose_"+this._popupId).click(function(){"boolean"==typeof p&&null!=p&&p&&o.Hide(),"function"==typeof t&&null!=t&&t(o,e)})},NewDialog:function(){var t,e,p,o=_MTS_JQUERY("body")[0];"object"!=typeof o&&null==o||("object"==typeof(p=_MTS_JQUERY("#popUpDialog_"+this._popupId)[0])&&null!=p&&o.removeChild(p),this._customControls=new Array,this._popupId=this._RandomIdString(15),p=this._CreateElement("i","popUpClose_"+this._popupId,"fas fa-times popUpClose"),(t=this._CreateElement("div","popUpHeader_"+this._popupId,"popUpHeader")).appendChild(this._CreateElement("div","popUpHeading_"+this._popupId,"popUpHeading")),(e=this._CreateElement("div","popUpContainer_"+this._popupId,"popUpContainer")).appendChild(p),e.appendChild(t),e.appendChild(this._CreateElement("div","popUpDescription_"+this._popupId,"popUpDescription")),e.appendChild(this._CreateElement("div","popUpControls_"+this._popupId,"popUpControls")),e.appendChild(this._CreateElement("div","popUpElements_"+this._popupId,"popUpElements")),e.appendChild(this._CreateElement("div","popUpErrors_"+this._popupId,"popUpErrors")),e.appendChild(this._CreateElement("div","popUpButtons_"+this._popupId,"popUpButtons")),e.appendChild(this._CreateElement("div","popUpFooter_"+this._popupId,"popUpFooter")),(p=this._CreateElement("div","popUpDialog_"+this._popupId,"popUpDialog")).setAttribute("style","display: none;"),p.appendChild(e),p.appendChild(this._CreateElement("div","popUpBackground_"+this._popupId,"popUpBackground")),o.appendChild(p))},Show:function(){_MTS_JQUERY("#popUpDialog_"+this._popupId).css({visibility:"hidden"}),_MTS_JQUERY("#popUpDialog_"+this._popupId).show();_MTS_JQUERY("#popUpContainer_"+this._popupId);_MTS_JQUERY("#popUpDialog_"+this._popupId).css({visibility:"visible"}),_MTS_JQUERY(function(){_MTS_JQUERY.chosen&&_MTS_JQUERY("#popUpDialog_"+this._popupId+" select").chosen()})},Hide:function(){_MTS_JQUERY("#popUpDialog_"+this._popupId).hide()},CheckContainer:function(t){return"string"!=typeof t||null==t?(this._Alert("Container must be a string!"),!1):t.length<=0?(this._Alert("You must provide a value!"),!1):"."!==t.substr(0,1)&&"#"!==t.substr(0,1)?(this._Alert("Your container must begin with either a dot (.) or a pound symbol (#)!"),!1):"object"!=typeof(t=_MTS_JQUERY(t))||null==t?(this._Alert("The specified container does not exist!"),!1):!(t.length<=0)||(this._Alert("The specified container is invalid!"),!1)},GetPopupId:function(){return this._popupId},AppendError:function(t){var e=this._RandomIdString(8),p=null;"string"==typeof t&&null!=t&&"object"==typeof(p=document.getElementById("popUpErrors_"+this._popupId))&&null!=p&&(p.appendChild(this._CreateElement("div","popUpError_"+this._popupId+"_"+e,"popUpError")),_MTS_JQUERY("#popUpError_"+this._popupId+"_"+e).html(t))},ClearErrors:function(){_MTS_JQUERY("#popUpErrors_"+this._popupId).html("")},GetControlData:function(){for(var t,e=this._customControls,p={},o=0;o<e.length;o++){if(t=e[o],!this._IsValidJsonControl(t))return null;switch(p[t.name]={id:t.id,type:t.type,text:t.text,value:""},t.type){case"checkbox":p[t.name].value=_MTS_JQUERY("#"+t.id).prop("checked").toString();break;case"radio":case"text":case"password":case"email":case"textarea":case"select":p[t.name].value=_MTS_JQUERY("#"+t.id).val().toString();break;default:return null}}return p},AddButton:function(t,e,p){var o=document.getElementById("popUpButtons_"+this._popupId),n="";if("object"!=typeof o||null==o)return this._Alert("You must create a new dialog before adding buttons! "),null;if("string"!=typeof t||null==t)return this._Alert("Invalid button value!"),null;if(t.length<=0)return this._Alert("You must provide a value when adding buttons!"),null;n+="popUpButton_"+this._popupId+"_"+this._RandomIdString(8),o.appendChild(this._CreateElement("div",n,"mts_cc_button popUpButton")),_MTS_JQUERY("#"+n).html(t),this._StandardWireups();var i=this;return _MTS_JQUERY("#"+n).click(function(){"function"==typeof e&&null!=e&&e(i,i.GetControlData(),p)}),_MTS_JQUERY("#"+n)},AddControl:function(t,e,p,o,n,a,i){var l,s=document.getElementById("popUpControls_"+this._popupId),r=null,u=null;if("object"==typeof s&&null!=s)if("string"==typeof t&&null!=t)if("string"==typeof e&&null!=e)if(e.length<=0)this._Alert("You must provide a control name when adding controls!");else{switch("string"==typeof p&&null!=p||(p=""),"string"==typeof o&&null!=o||(o=""),l="control_"+this._popupId+"_"+this._RandomIdString(8),(r=this._CreateElement("div","popUpControl_"+l,"popupControl")).appendChild(this._CreateElement("div","popUpControlText_"+l,"popUpControlText")),t){case"checkbox":(u=this._CreateElement("input",l,null)).setAttribute("type","checkbox"),u.setAttribute("name",e),u.setAttribute("class","popUpControlCheckbox");break;case"radio":(u=this._CreateElement("input",l,null)).setAttribute("type","radio"),u.setAttribute("name",e),u.setAttribute("value",p),u.setAttribute("class","popUpControlRadio");break;case"text":(u=this._CreateElement("input",l,null)).setAttribute("type","text"),u.setAttribute("name",e),u.setAttribute("value",p),u.setAttribute("class","popUpControlText");break;case"password":(u=this._CreateElement("input",l,null)).setAttribute("type","password"),u.setAttribute("name",e),u.setAttribute("value",p),u.setAttribute("class","popUpControlPassword");break;case"email":(u=this._CreateElement("input",l,null)).setAttribute("type","email"),u.setAttribute("name",e),u.setAttribute("value",p),u.setAttribute("class","popUpControlEmail");break;case"textarea":(u=this._CreateElement("textarea",l,null)).setAttribute("class","popUpControlTextArea");break;case"select":(u=this._CreateElement("select",l,null)).setAttribute("name",e),u.setAttribute("class",null===i||""===i?"popUpControlSelect":i);break;default:return void this._Alert("The specified control type is not valid!")}this._customControls.push({id:l,type:t,name:e,text:o}),"object"==typeof u&&null!=u&&r.appendChild(u),s.appendChild(r),_MTS_JQUERY("#popUpControlText_"+l).html(o),"textarea"===t&&_MTS_JQUERY("#"+l).html(p),"function"==typeof n&&null!=n&&n(_MTS_JQUERY("#popUpControls_"+this._popupId),_MTS_JQUERY("#"+l),_MTS_JQUERY("#popUpControlText_"+l),a)}else this._Alert("Invalid control name!");else this._Alert("Invalid control value!");else this._Alert("You must create a new dialog before adding controls! ")},AddElement:function(t,e,p,o,n){var i,l=document.getElementById("popUpElements_"+this._popupId),s=null;if("object"==typeof l&&null!=l)if("string"==typeof t&&null!=t)if("string"==typeof e&&null!=e){switch(i="popUpElement_"+this._popupId+"_"+this._RandomIdString(8),t){case"div":s=this._CreateElement("div",i,"popupElement");break;case"divWithClass":s=this._CreateElement("div",i,n);break;default:return void this._Alert("The specified element type is not valid!")}l.appendChild(s),_MTS_JQUERY("#"+i).html(e),"function"==typeof p&&null!=p&&p(_MTS_JQUERY("#popUpElements_"+this._popupId),_MTS_JQUERY("#"+i),o)}else this._Alert("Invalid element data!");else this._Alert("Invalid element type!");else this._Alert("You must create a new dialog before adding elements! ")},AddFooter:function(t,e,p,o){var n,i=document.getElementById("popUpFooter_"+this._popupId),l=null;"object"==typeof i&&null!=i?"string"==typeof t&&null!=t?"string"==typeof e&&null!=e?(n="popUpFooter_"+this._popupId+"_"+this._RandomIdString(8),"div"===t?(l=this._CreateElement("div",n,"popUpFooter"),i.appendChild(l),_MTS_JQUERY("#"+n).html(e),"function"==typeof p&&null!=p&&p(_MTS_JQUERY("#popUpFooter_"+this._popupId),_MTS_JQUERY("#"+n),o)):this._Alert("The specified element type is not valid!")):this._Alert("Invalid element data!"):this._Alert("Invalid element type!"):this._Alert("You must create a new dialog before adding elements! ")},NewCustomDialog:function(t,e,p,o,n){this._IsValidParams(t,e)&&(this.NewDialog(),_MTS_JQUERY("#popUpHeading_"+this._popupId).html(e),_MTS_JQUERY("#popUpDescription_"+this._popupId).html(t),this._AddCloser(o,n,!1),this._StandardWireups(),"function"==typeof p&&null!=p&&p())},NewOkayAlert:function(t,e,p,o,n,i){var l=this;this._IsValidParams(t,e)&&(this.NewDialog(),_MTS_JQUERY("#popUpHeading_"+this._popupId).html(e),_MTS_JQUERY("#popUpDescription_"+this._popupId).html(t),e=this.AddButton("Okay",function(){l.Hide(),"function"==typeof o&&null!=o&&o(l,n)},null),this._AddCloser(o,n,!0),this._StandardWireups(),(i="boolean"!=typeof i||null==i?!0:i)&&this.Show(),"function"==typeof p&&null!=p&&p(_MTS_JQUERY("#popUpContainer_"+this._popupId.toString()),_MTS_JQUERY("#popUpDescription_"+this._popupId),e))},NewYesNoPrompt:function(t,e,p,o,n,i){var l=this;this._IsValidParams(t,e)&&(this.NewDialog(),_MTS_JQUERY("#popUpHeading_"+this._popupId).html(e),_MTS_JQUERY("#popUpDescription_"+this._popupId).html(t),this.AddButton("Yes",function(){l.Hide(),"function"==typeof o&&null!=o&&o(!0,l,n)},null),this.AddButton("No",function(){l.Hide(),"function"==typeof o&&null!=o&&o(!1,l,n)},null),this._AddCloser(function(){"function"==typeof o&&null!=o&&o(!1,l,n)},null,!0),l._StandardWireups(),(i="boolean"!=typeof i||null==i?!0:i)&&l.Show(),"function"==typeof p&&null!=p&&p())}};
﻿var tTimer,tRefresh;function refreshSession(){$.post("/api/refreshSession.aspx",null,function(e){"success"==e&&(tRefresh=setTimeout("refreshSession()",_timeout))}).fail(function(){$("#tStatus").html(),$("#timeout").slideDown("fast"),startCountdown(_sessionTimeout-_timeout)})}function startCountdown(e){0<e?tTimer=setTimeout(function(){$("#tTimer").html(e/1e3),startCountdown(e-1e3)},1e3):$(".tText").html("Your session has expired and any changes made may not be saved.")}$(document).one("widgetsloaded",function(){$(".myProfile").click(function(){window.location="/user/edit/"}),$("#navReg").click(function(){location="/user/register/"}),$("#tRenew").click(function(){var t=$("#tStatus");t.html(""),$.post("/api/refreshSession.aspx",null,function(e){"success"==e&&(window.clearTimeout(tRefresh),window.clearTimeout(tTimer),tRefresh=setTimeout("refreshSession()",_timeout),t.html("Success!"),t.css("color","green"),setTimeout(function(){$("#timeout").css("display","none")},600))}).fail(function(){t.html("Failed!"),t.css("color","red")})}),tRefresh=setTimeout("refreshSession()",_timeout)});
﻿_MTS_JQUERY(document).one("widgetsloaded",function(){var o,_,s,e,t=_MTS_JQUERY(".msw");0<t.length&&(o=t.position().top,_MTS_JQUERY(window).scroll(function(){_MTS_JQUERY(window).scrollTop()>=o?t.addClass("snapIt"):t.removeClass("snapIt")}),_=_MTS_JQUERY(".msScroller"),s=_MTS_JQUERY(".msBtn"),e=0,_MTS_JQUERY(".msgr").css({left:_MTS_JQUERY(window).width()-20+"px"}),s.each(function(){e+=_MTS_JQUERY(this).outerWidth()}),_.width(e+"px"),$(window).resize(function(){_.width(e+"px")}),_MTS_JQUERY(".mobileSelectors").scroll(function(){var o,_;_MTS_JQUERY(".mobileSelectors").scrollLeft()>_MTS_JQUERY(".msBtn").outerWidth()?(o=_MTS_JQUERY(".msgl")).show():(o=_MTS_JQUERY(".msgl")).hide(),_MTS_JQUERY(".mobileSelectors").scrollLeft()+$(".mobileSelectors").outerWidth()==$(".msScroller").outerWidth()?(_=_MTS_JQUERY(".msgr"),o=_MTS_JQUERY(".msgl"),_.hide(),o.show()):(_=_MTS_JQUERY(".msgr")).show()}))});
﻿function trackItem(a,n){var e=[];e.push({name:"id",value:a}),e.push({name:"tagType",value:n}),ajax("/api/tracking.aspx",e,function(){})}
﻿function trackItem(a,n){var e=[];e.push({name:"id",value:a}),e.push({name:"tagType",value:n}),ajax("/api/tracking.aspx",e,function(){})}
﻿var _loadedCat=[],_wiredUp=!1,_maxResults=15,_currentSeed=0,_currentSearchVal="",_selectedMenu="",_searched=[],_searchInProgress=!1,_curPage=0,_searchedEv=[],_searchEvProgress=!1,_curEvPage=0,_searchId=-1,_declinedTags=[],_slideTimeout=null,_isSliding=!1;function initTag(){if(!_hasJQuery||!_hasCal)return!1;_wiredUp||(wireSelect(),_cal.initialize())}function wireSelect(){_wiredUp=!0,_MTS_JQUERY(document).on("click",".fullLink",function(e){var t,a=_MTS_JQUERY(this).parents(".result");a.hasClass("highlightTag")||(a.addClass("highlightTag"),_isSliding||(_isSliding=!0,(t=a.parents(".search_widget").find(".tagConfirmation")).slideToggle(400,function(){_slideTimeout=null,_slideTimeout=setTimeout(function(){t.slideToggle(),_isSliding=!1},2e3)})))}),_MTS_JQUERY(document).on(_event,".tagSelect, .teamTagSelect",function(e){e.stopPropagation();var e=this.id.split("_")[0]+"_",t=_MTS_JQUERY.trim(this.innerHTML);if(null!=(r=GetIdFrom(e,this.id)))switch(e){case"entry_":selectTag(_MTS_SITEURL+"team/schedule/details/"+_teamId+"/"+_teamUrlName+"/"+r+"/",t,r,"ScheduleEvent");break;case"team_":var a=_MTS_JQUERY(this).parents(".typeSelect");"typeTeam"==a.attr("id")?selectTag(_MTS_SITEURL+"teamProfile.aspx?id="+r,t,r,"Team"):(_searchId=r,(n=[]).push({name:"teamId",value:r}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/getSchoolSportByTeam.aspx",n,function(e){e.ok&&(_schoolUrlName=e.schoolUrlName,_sportUrlName=e.sportUrlName,toggleNext(a[0]))}));break;case"Sports_":selectTag(_MTS_SITEURL+"?m=1&sm="+r,t,r,"Sport");break;case"Schools_":selectTag(_MTS_SITEURL+"school/"+r+"/"+$.urlName(t)+"/",t,r,"School");break;case"Leagues_":selectTag(_MTS_SITEURL+"league/"+r+"/"+$.urlName(t)+"/",t,r,"League");break;case"event_":var n=r.split("_")[1],r=r.split("_")[0];1==n?selectTag(_MTS_SITEURL+"master/event/"+r+"/",t,r,"MasterEvent"):selectTag(_MTS_SITEURL+"event/"+r+"/",t,r,"PortalEvent");break;case"sch_":selectSch(_MTS_JQUERY(this));break;case"Roster_":selectTag(_MTS_SITEURL+"roster/player/"+_schoolUrlName+"-"+_sportUrlName+"/"+$.urlName(t)+"/"+_searchId+"/"+r,t,r,"Roster");break;case"Videos_":selectTag(_MTS_SITEURL+"team/photos/"+_searchId+"/team/",t,r,"Video");break;case"pv_":selectTag(_MTS_SITEURL+"video/player/"+r+"/"+$.urlName(t),t,r,"PortalVideo");break;case"pl_":selectSch(_MTS_JQUERY(this));break;case"Albums_":selectTag(_MTS_SITEURL+"albums/"+$.urlName(t)+"/"+r+"/",t,r,"PhotoAlbum");break;case"Categories_":selectTag("javascript:void(0);",t,r,"Category");break;case"Subcategories_":selectTag("javascript:void(0);",t,r,"Subcategory")}}),_MTS_JQUERY(document).on(_event,".tagBtn",function(e){e.stopPropagation(),toggleBack(this)}),_MTS_JQUERY(document).on(_event,".typeSelect",function(e){e.stopPropagation();e=this;"none"!=_MTS_JQUERY(e).find(".tTitle").css("display")&&(_selectedMenu=e.id,"Existing Photos"!=_MTS_JQUERY(e).children(".tTitle").html()&&(_MTS_JQUERY(".typeSelect").hide(),_MTS_JQUERY(e).show()),"typePhoto"!=e.id?toggleNext(e):togglePhoto())}),_MTS_JQUERY(document).on("mouseenter mouseleave",".tagSelect",function(){var e;this.clientWidth<this.scrollWidth&&(e="<div class='eHover'>"+_MTS_JQUERY.trim(this.innerHTML)+"</div>",_MTS_JQUERY(this).parent().append(e),_MTS_JQUERY(".eHover").css({top:this.offsetTop+40+"px",left:this.offsetLeft+40+"px"}))}).on("mouseout",".tagSelect",function(){_MTS_JQUERY(".eHover").remove()}),_MTS_JQUERY(document).delegate("#searchBar","keyup",function(){performSearch()}),_MTS_JQUERY(document).delegate(".sDateInput, .eDateInput","click",function(){var n=this;_MTS_JQUERY(n).val(""),GetMiniCalendar("select","Date Range",function(e,t,a){_MTS_JQUERY(n).val(e.toString()+"/"+t.toString()+"/"+a.toString())})}),_MTS_JQUERY(document).delegate("#searchTeams","click",function(){SearchByTeam(0,_MTS_JQUERY(this).parents(".finalSelectContainer"))}),_MTS_JQUERY(document).delegate(".tNext","click",function(){SearchByTeam(_curPage+1,_MTS_JQUERY(this).parents(".finalSelectContainer"))}),_MTS_JQUERY(document).delegate(".tPrev","click",function(){0<_curPage&&SearchByTeam(_curPage-1,_MTS_JQUERY(this).parents(".finalSelectContainer"))}),_MTS_JQUERY(document).delegate("#searchEvents","click",function(){SearchByEvent(0,_MTS_JQUERY(this).parents(".finalSelectContainer"))}),_MTS_JQUERY(document).delegate("#eNext","click",function(){SearchByEvent(_curEvPage+1,_MTS_JQUERY(this).parents(".finalSelectContainer"))}),_MTS_JQUERY(document).delegate("#ePrev","click",function(){0<_curEvPage&&SearchByEvent(_curEvPage-1,_MTS_JQUERY(this).parents(".finalSelectContainer"))})}function SearchByEvent(a,t){if(0==_searchEvProgress){_searchEvProgress=!0,_curEvPage=a,_MTS_JQUERY("#searchActiveEv").show();var n="typeEvent",r=_MTS_JQUERY("#eventSportFilter").val(),i=_MTS_JQUERY("#eventLevelFilter").val(),l=_MTS_JQUERY("#eventLeagueFilter").val(),s=_MTS_JQUERY("#searchBar").val(),c=_MTS_JQUERY("input[name=genderEv]:checked").val(),_=_MTS_JQUERY(".sDateInput").val(),o=_MTS_JQUERY(".eDateInput").val(),d=_MTS_JQUERY("#homeTeamFilter").val(),h=_MTS_JQUERY("#awayTeamFilter").val(),t=t.parents(".typeSelect").attr("id"),e=FindSearchEv(n,r,i,l,s,c,_,o,d,h,a);if(0<=e&&(CacheSearch(n),0<=(e=_searchedEv[e].end?FindSearchEv(n,r,i,l,s,c,_,o,d,h,a-1):e)))return LoadBySearched(e,n,t),_searchEvProgress=!1,_MTS_JQUERY("#searchActiveEv").hide(),!1;e=[];e.push({name:"type",value:n}),e.push({name:"sport",value:r}),e.push({name:"level",value:i}),e.push({name:"league",value:l}),e.push({name:"name",value:s}),e.push({name:"gender",value:c}),e.push({name:"from",value:0<a?15*a:1}),e.push({name:"to",value:15*a+(0<a?14:15)}),e.push({name:"homeTeam",value:d}),e.push({name:"awayTeam",value:h}),e.push({name:"start",value:_}),e.push({name:"end",value:o}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/getTagSelectCat.aspx",e,function(e){var t;e.ok&&(CacheSearch(n),t=!1,0<=e.tagSelect.indexOf("No Results Found")&&(t=!0),_MTS_JQUERY("<div id='"+n+"_"+_searchedEv.length+"' class='cache'>"+e.tagSelect+"</div>").insertBefore(_MTS_JQUERY("#"+n).find(".finalSelectContainer .buttonContainer")),_searchedEv.push({type:n,sport:r,level:i,league:l,phrase:s,gender:c,dtStart:_,dtEnd:o,homeTeam:d,awayTeam:h,page:a,end:t})),_searchEvProgress=!1,_MTS_JQUERY("#searchActiveEv").hide()})}}function SearchByTeam(n,e){if(0==_searchInProgress){_searchInProgress=!0,_curPage=n;var r="typeTeam",i=e.parents(".typeSelect").attr("id"),l=i.substr(4),s=e.find("#sportFilter").val(),c=e.find("#levelFilter").val(),_=e.find("#leagueFilter").val(),o=_MTS_JQUERY("#searchBar").val(),d=_MTS_JQUERY("input[name=gender"+l+"]:checked").val(),e=(_MTS_JQUERY("#searchActive"+l).show(),FindSearch(r,s,c,_,o,d,n));if(0<=e&&(CacheSearch(i),0<=(e=_searched[e].end?FindSearch(r,s,c,_,o,d,n-1):e)))return LoadBySearched(e,r,i),_searchInProgress=!1,_MTS_JQUERY("#searchActive"+l).hide(),!1;e=[];e.push({name:"type",value:r},{name:"sport",value:s},{name:"level",value:c},{name:"league",value:_},{name:"name",value:o},{name:"gender",value:d},{name:"from",value:0<n?15*n:1},{name:"to",value:15*n+(0<n?14:15)}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/getTagSelectCat.aspx",e,function(e){var t,a;e.ok&&(CacheSearch(i),t=!1,""==e.tagSelect?(t=!0,0<=(a=FindSearch(r,s,c,_,o,d,n-1))&&LoadBySearched(a,r,i)):(_MTS_JQUERY("<div id='"+r+"_"+_searched.length+"' class='cache'>"+e.tagSelect+"</div>").insertBefore(_MTS_JQUERY("#"+i).find(".finalSelectContainer .buttonContainer")),_MTS_JQUERY(i+" .teamConSel").html(_MTS_JQUERY(i+" .teamConSel .tContainer").sort(function(e,t){e=_MTS_JQUERY(e).find(".tagSelect").html(),t=_MTS_JQUERY(t).find(".tagSelect").html();return e==t?0:e<t?-1:1}))),_searched.push({type:r,sport:s,level:c,league:_,phrase:o,gender:d,page:n,end:t}),CacheSearch(i,!0)),_searchInProgress=!1,_MTS_JQUERY("#searchActive"+l).hide()})}}function FindSearch(e,t,a,n,r,i,l){for(var s=_searched.length-1;0<=s;s--)if(_searched[s].type==e&&_searched[s].sport==t&&_searched[s].level==a&&_searched[s].league==n&&_searched[s].phrase==r&&_searched[s].gender==i&&_searched[s].page==l)return s;return-1}function FindSearchEv(e,t,a,n,r,i,l,s,c,o,d){for(var _=_searchedEv.length-1;0<=_;_--)if(_searchedEv[_].type==e&&_searchedEv[_].sport==t&&_searchedEv[_].level==a&&_searchedEv[_].league==n&&_searchedEv[_].phrase==r&&_searchedEv[_].gender==i&&_searchedEv[_].dtStart==l&&_searchedEv[_].dtEnd==s&&_searchedEv[_].homeTeam==c&&_searchedEv[_].awayTeam==o&&_searchedEv[_].page==d)return _;return-1}function LoadBySearched(e,t,a){_MTS_JQUERY("#cache").find("#"+t+"_"+e).clone().insertBefore(_MTS_JQUERY("#"+a).find(".finalSelectContainer .buttonContainer")),"typeEvent"!=t?_curPage=_searched[e].page:_curEvPage=_searchedEv[e].page}function CacheSearch(e,t){null==t&&(t=!1);var a=_MTS_JQUERY("#cache"),n=(0==a.length&&(_MTS_JQUERY("body").append("<div id='cache' style='display: none'></div>"),a=_MTS_JQUERY("#cache")),_MTS_JQUERY("#"+e).find(".cache")),r=0<n.length?n.attr("id"):-1;if(0<n.length){for(var i=0,l=a.children().length;i<l;i++)if(a.children()[i].id==r)return t||n.remove(),!1;(t?n.clone():n).appendTo(a)}}function performSearch(){var l=Date.now;_currentSeed=l,setTimeout(function(){if(l!=_currentSeed)return!1;var t,e=_MTS_JQUERY("#searchBar").val();if(_MTS_JQUERY(".finalSelectContainer").each(function(){var e=_MTS_JQUERY(this);if("none"!=e.css("display"))return t=e.find(".tagSelect"),!1}),null==t||0==t.length)return!1;var a=_MTS_JQUERY(t[0]).parent().attr("class");if("tContainer"==a||"eventContainer"==a)return!1;var n=t.length-1;t.css("display","none");do{var r=t[n],i=_MTS_JQUERY.trim(r.innerHTML.toLowerCase())}while((""==e||0<=i.indexOf(e.toLowerCase()))&&(r.style.display="block"),n--)},200)}function togglePhoto(){window.parent.tinyMCE.activeEditor.windowManager.open({file:"/mce/imageSel.aspx?id="+_teamId,width:450,height:300,inline:1},{plugin_url:"/"})}function toggleNext(t){for(var e,a=!1,n=("typeRoster"==t.id||"typePlayer"==t.id||"typeVideos"==t.id)&&0<_searchId,r=t.id+"_"+_searchId,i=_loadedCat.length-1;0<=i;i--)if(_loadedCat[i]==t.id&&!n||n&&_loadedCat[i]==r){a=!0;break}a||"typeSch"==t.id||"typeTeam"==t.id||"typeEvent"==t.id||(n||"typeRoster"==t.id||"typePlayer"==t.id||"typeVideos"==t.id)&&!n?n?(TargetByTeam(t),_MTS_JQUERY("#"+r).show()):NextAction(t):(_loadedCat.push(n?r:t.id),(e=[]).push({name:"type",value:t.id}),e.push({name:"isPortal",value:_isPortalTag}),e.push({name:"searchId",value:_searchId}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/getTagSelectCat.aspx",e,function(e){e.ok&&(n&&(e.tagSelect="<div id='"+r+"' class='searched'>"+e.tagSelect+"</div>",TargetByTeam(t)),_MTS_JQUERY(e.tagSelect).insertBefore(_MTS_JQUERY(t).find(".finalSelectContainer .buttonContainer")),n||NextAction(t))}))}function TargetByTeam(e){var t=_MTS_JQUERY("#searchBar");0<t.val().length&&(t.val(""),performSearch("")),_MTS_JQUERY("#sBarTitle").html("Type name of "+("typeRoster"==e.id||"typePlayer"==e.id?"player":"video")+" to narrow results:"),_MTS_JQUERY(e).find(".filterOptions, .tNext, .tPrev, .cache, .searched").hide()}function NextAction(e){var t=_MTS_JQUERY(e).find(".firstSelectContainer"),a=_MTS_JQUERY(e).find(".finalSelectContainer"),n=_MTS_JQUERY(".tTitle"),r=_MTS_JQUERY(".sBar"),i=_MTS_JQUERY("#sBarTitle");switch(_MTS_JQUERY("#selCat").hide(),"typeEvent"!=e.id&&"typeSch"!=e.id&&r.show(),e.id){case"typePortalVideos":case"typePlayer":case"typeRoster":case"typeVideos":case"typeTeam":i.html("Enter team name to narrow search:");break;case"typeSports":i.html("Type name of sport to narrow results:");break;case"typeLeagues":i.html("Type name of league to narrow results:");break;case"typeSchools":i.html("Type name of school to narrow results:");break;case"typeCategories":i.html("Type name of the category/subcategory to narrow results:")}switch("none"!=n.css("display")&&0<t.length?t.show():(t.hide(),a.show(),a.children().show()),ToggleCustomDropdowns(),n.hide(),_MTS_JQUERY(e).find(".buttonContainer")[0].style.display="block",performSearch(_MTS_JQUERY("#searchBar").val()),_MTS_JQUERY(".searched").hide(),e.id){case"typeRoster":case"typeVideos":var l=getTagsByType("Team");if($("#typeTeam_-1").remove(),CacheSearch(e.id),0<l.length){for(var s="<div id='typeTeam_-1' class='cache'>",c=l.length-1;0<=c;c--)s+="<div class='tContainer'><div id='team_"+l[c].id.split("_")[2]+"' class='teamTagSelect'>"+$.trim(_MTS_JQUERY(l[c]).find(".tagTitle").html())+"</div></div>";s+="</div>",$(s).insertBefore(_MTS_JQUERY("#"+e.id).find(".finalSelectContainer .buttonContainer"))}}}function toggleBack(e){_MTS_JQUERY(".sBar").hide(),_MTS_JQUERY(".searched").hide(),_MTS_JQUERY(".tPrev, .tNext").show(),_MTS_JQUERY("#searchBar").val("");var e=_MTS_JQUERY(e).parent().parent(),t=0<e.filter(":visible").length;e.hide(),"firstSelectContainer"!=e.attr("class")&&0!=e.parent().parent().find(".firstSelectContainer").length&&t?(_MTS_JQUERY(".sBar").show(),e.parent().parent().find(".firstSelectContainer").show()):(_MTS_JQUERY(".tTitle").show(),_MTS_JQUERY("#selCat").show()),_MTS_JQUERY(".typeSelect").hide(),_MTS_JQUERY("#"+_selectedMenu).show(),_MTS_JQUERY(".tTitle").each(function(){"none"!==_MTS_JQUERY(this).css("display")&&_MTS_JQUERY(this).parent().show()}),_searchId=-1}function selectSch(e){e.parent().parent().find(".scheduleContainer").each(function(){this.id.split("_")[1]==e.attr("id").split("_")[1]?this.style.display="block":this.style.display="none"}),e.parent().hide(),e.parent().parent().find(".finalSelectContainer").show(),e.parent().parent().find(".buttonContainer")[1].style.display="block"}function findTag(e,t){for(var a=window.parent,n=_MTS_JQUERY(a.document.getElementsByClassName("tagContainer")[0]).find(".tagBlock, .imageTag"),r=0;r<n.length;r++){var i=n[r],l=i.id.split("_")[1];if(null!=i.id&&"tag"==i.id.split("_")[0]&&l==e&&i.id.split("_")[2]==t)return!0;if(l==t&&(i=_MTS_JQUERY(i)).children("input")[0].value==e)return!0}if("undefined"!=typeof _currentImage&&"object"!=typeof _currentImage)for(r=0;r<_currentImage.links.length;r++)if(_currentImage.links[r].linkId==t&&_currentImage.links[r].tagType==e)return!0;return!1}function getTagsByType(e){for(var t=window.parent,a=_MTS_JQUERY(t.document.getElementsByClassName("tagContainer")[0]).find(".tagBlock, .imageTag"),n=[],r=0;r<a.length;r++){var i=a[r],l=i.id.split("_")[1];null!=i.id&&"tag"==i.id.split("_")[0]&&l==e&&n.push(i)}if("undefined"!=typeof _currentImage&&"object"!=typeof _currentImage)for(r=0;r<_currentImage.links.length;r++)_currentImage.links[r].tagType==e&&n.push(_currentImage.links[r]);return n}function selectTag(e,t,a,n){var r,i=window.parent,l=i.document.getElementsByClassName("tagContainer")[0],s='<a href="'+e+'" data-mce-href="'+e+'">'+unescape(t)+"</a>";0<_MTS_JQUERY(l).length?findTag(n,a)||(r=(l.childNodes.length<1?"<div class='portalText'>Current Tags</div>":"")+"<div class='tagBlock' id='tag_"+a+"'><div class='tagTitle'>"+unescape(t)+"</div><div class='tagOptions'><div class='mts_cc_button tagButton' id='tagAdd_"+a+"'>Add Link</div><img class='tagButton' id='tagRem_"+a+"' src='"+_mediaUrl+"images/gratsClose.png' title='remove' /></div><input type='hidden' id='linkType_"+a+"' value='"+n+"' /></div>",_MTS_JQUERY(l).append(r),i.WireUpTag(a,s,n),_MTS_JQUERY(i.document.getElementsByClassName("noTagsYet")).hide(),(_MTS_JQUERY(i.document.getElementById("useAutoTagger")).length<0||!_MTS_JQUERY(i.document.getElementById("useAutoTagger")).prop("checked"))&&("undefined"!=typeof _DoNotSuggestRelated&&_DoNotSuggestRelated||FindRelatedTag(a,n))):"function"==typeof i.AddTagHtml&&i.AddTagHtml(a,t,s,n),null==i.tinymce||"boolean"==typeof i._autoLink&&!i._autoLink||("Image"!=n?i.tinymce.execCommand("mceInsertContent",!1,"PortalVideo"==n?"<iframe src='/api/getPortalVideoPlayer.aspx?videoId="+a+"' frameborder='0' allowFullScreen='true' webkitallowfullscreen='true' mozallowfullscreen='true' width='100%' height='450px' scrolling='no'></iframe>":s):i.insertPhotoCaptionTable(a,'<img src="'+e+'" alt="[Image]" />'))}function FindRelatedTag(id,type){var p=[];p.push({name:"id",value:id}),p.push({name:"type",value:type}),ajax("/api/getRelatedTags.aspx",p,function(ret){var o;eval("o = "+ret),0<o.tags.length&&SuggestTags(o.tags)})}function SuggestTags(e){for(var t,a=e.length-1;0<=a;a--)findTag(e[a].type,e[a].id)||isDeclinedTag(e[a])||(null!=(t=confirm("Would you like to add "+e[a].title+" ("+e[a].type+") as a tag to this story?"))&&t?selectTag(e[a].link,e[a].title,e[a].id,e[a].type):_declinedTags.push(e[a]))}function isDeclinedTag(e){for(var t=_declinedTags.length-1;0<=t;t--)if(e.id==_declinedTags[t].id&&e.type==_declinedTags[t].type)return!0;return!1}function GetMiniCalendar(e,t,a,n){var r=new Date;_cal.clearRecycle(),_cal.mode=e,_cal.wndTitle=t,_cal.setContract(r.getFullYear()-1,0,0),_cal.maxYear=_cal.startContractYear+5,_cal.setCallback(a),_cal.setSelection(r.getMonth()+1,r.getDate(),r.getFullYear()),_cal.show(100,100),_MTS_JQUERY(".listingBg").css({height:_MTS_JQUERY(document).height(),zIndex:113}),_MTS_JQUERY(".listingBg").show()}function GetIdFrom(e,t){if("string"!=typeof e||null==e)return null;if("string"!=typeof t||null==t)return null;if(e.length>=t.length)return null;var a=null;try{a=t.substring(e.length)}catch(e){return null}return a}
﻿var _TIMING_=1e4,_ajax_map=[];function ajax(n,a,t,e,o,r,i){if(null==e&&(e="POST"),!0!==i&&(i=!1),Date.now||(Date.now=function(){return(new Date).valueOf()}),void 0===_ajax_map&&(_ajax_map=[]),!i)for(var p=Date.now(),l=0;l<_ajax_map.length;l++)if(_ajax_map[l].Url==n)if(Date.now()-_ajax_map[l].Time<_TIMING_)return;_ajax_map.push(new ajaxMapEntry(n,p));for(var u=createAjax(),_=(u.onreadystatechange=function(){if(4==u.readyState&&200==u.status){for(var a=-1,e=0;e<_ajax_map.length;e++)if(_ajax_map[e].Url==n){a=e;break}-1<a&&_ajax_map.splice(a,1),"function"==typeof t&&null!=t&&t(u.responseText),null!=o&&"undefined"!=o&&("function"!=typeof o?console.log("An error occurred calling next().\nUrl: "+n+"\ndata: "+data):o())}},("undefined"!=typeof event&&event.which||"boolean"==typeof _MTS_ajaxPending&&_MTS_ajaxPending)&&(u.onloadstart=function(){MTS_startAjax()},u.onloadend=function(){MTS_endAjax(),_MTS_ajaxPending=!1}),"ajax=1"),l=0;l<a.length;l++)_+="&"+a[l].name+"="+encodeURIComponent(a[l].value);return"GET"==e?u.open("GET",n+"?"+_,!0):(u.open("POST",n+(null==r||r?"?"+Date.now()+"=r":""),!0),u.setRequestHeader("Content-type","application/x-www-form-urlencoded")),u.send(_),u}function createAjax(){var a=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest;if(null!=a)return a;alert("Your browser does not support the functionality to complete this request.")}function ajaxMapEntry(a,e){this.Url=a,this.Time=e}
﻿/*! jQuery UI - v1.12.1 - 2021-08-03
* http://jqueryui.com
* Includes: widget.js, data.js, disable-selection.js, keycode.js, scroll-parent.js, widgets/draggable.js, widgets/resizable.js, widgets/sortable.js, widgets/mouse.js, widgets/slider.js
* Copyright jQuery Foundation and other contributors; Licensed MIT */

(function( factory ) {
	if ( typeof define === "function" && define.amd ) {

		// AMD. Register as an anonymous module.
		define([ "jquery" ], factory );
	} else {

		// Browser globals
		factory( jQuery );
	}
}(function( $ ) {

$.ui = $.ui || {};

var version = $.ui.version = "1.12.1";


/*!
 * jQuery UI Widget 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Widget
//>>group: Core
//>>description: Provides a factory for creating stateful widgets with a common API.
//>>docs: http://api.jqueryui.com/jQuery.widget/
//>>demos: http://jqueryui.com/widget/



var widgetUuid = 0;
var widgetSlice = Array.prototype.slice;

$.cleanData = ( function( orig ) {
	return function( elems ) {
		var events, elem, i;
		for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
			try {

				// Only trigger remove when necessary to save time
				events = $._data( elem, "events" );
				if ( events && events.remove ) {
					$( elem ).triggerHandler( "remove" );
				}

			// Http://bugs.jquery.com/ticket/8235
			} catch ( e ) {}
		}
		orig( elems );
	};
} )( $.cleanData );

$.widget = function( name, base, prototype ) {
	var existingConstructor, constructor, basePrototype;

	// ProxiedPrototype allows the provided prototype to remain unmodified
	// so that it can be used as a mixin for multiple widgets (#8876)
	var proxiedPrototype = {};

	var namespace = name.split( "." )[ 0 ];
	name = name.split( "." )[ 1 ];
	var fullName = namespace + "-" + name;

	if ( !prototype ) {
		prototype = base;
		base = $.Widget;
	}

	if ( $.isArray( prototype ) ) {
		prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
	}

	// Create selector for plugin
	$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
		return !!$.data( elem, fullName );
	};

	$[ namespace ] = $[ namespace ] || {};
	existingConstructor = $[ namespace ][ name ];
	constructor = $[ namespace ][ name ] = function( options, element ) {

		// Allow instantiation without "new" keyword
		if ( !this._createWidget ) {
			return new constructor( options, element );
		}

		// Allow instantiation without initializing for simple inheritance
		// must use "new" keyword (the code above always passes args)
		if ( arguments.length ) {
			this._createWidget( options, element );
		}
	};

	// Extend with the existing constructor to carry over any static properties
	$.extend( constructor, existingConstructor, {
		version: prototype.version,

		// Copy the object used to create the prototype in case we need to
		// redefine the widget later
		_proto: $.extend( {}, prototype ),

		// Track widgets that inherit from this widget in case this widget is
		// redefined after a widget inherits from it
		_childConstructors: []
	} );

	basePrototype = new base();

	// We need to make the options hash a property directly on the new instance
	// otherwise we'll modify the options hash on the prototype that we're
	// inheriting from
	basePrototype.options = $.widget.extend( {}, basePrototype.options );
	$.each( prototype, function( prop, value ) {
		if ( !$.isFunction( value ) ) {
			proxiedPrototype[ prop ] = value;
			return;
		}
		proxiedPrototype[ prop ] = ( function() {
			function _super() {
				return base.prototype[ prop ].apply( this, arguments );
			}

			function _superApply( args ) {
				return base.prototype[ prop ].apply( this, args );
			}

			return function() {
				var __super = this._super;
				var __superApply = this._superApply;
				var returnValue;

				this._super = _super;
				this._superApply = _superApply;

				returnValue = value.apply( this, arguments );

				this._super = __super;
				this._superApply = __superApply;

				return returnValue;
			};
		} )();
	} );
	constructor.prototype = $.widget.extend( basePrototype, {

		// TODO: remove support for widgetEventPrefix
		// always use the name + a colon as the prefix, e.g., draggable:start
		// don't prefix for widgets that aren't DOM-based
		widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
	}, proxiedPrototype, {
		constructor: constructor,
		namespace: namespace,
		widgetName: name,
		widgetFullName: fullName
	} );

	// If this widget is being redefined then we need to find all widgets that
	// are inheriting from it and redefine all of them so that they inherit from
	// the new version of this widget. We're essentially trying to replace one
	// level in the prototype chain.
	if ( existingConstructor ) {
		$.each( existingConstructor._childConstructors, function( i, child ) {
			var childPrototype = child.prototype;

			// Redefine the child widget using the same prototype that was
			// originally used, but inherit from the new version of the base
			$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
				child._proto );
		} );

		// Remove the list of existing child constructors from the old constructor
		// so the old child constructors can be garbage collected
		delete existingConstructor._childConstructors;
	} else {
		base._childConstructors.push( constructor );
	}

	$.widget.bridge( name, constructor );

	return constructor;
};

$.widget.extend = function( target ) {
	var input = widgetSlice.call( arguments, 1 );
	var inputIndex = 0;
	var inputLength = input.length;
	var key;
	var value;

	for ( ; inputIndex < inputLength; inputIndex++ ) {
		for ( key in input[ inputIndex ] ) {
			value = input[ inputIndex ][ key ];
			if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {

				// Clone objects
				if ( $.isPlainObject( value ) ) {
					target[ key ] = $.isPlainObject( target[ key ] ) ?
						$.widget.extend( {}, target[ key ], value ) :

						// Don't extend strings, arrays, etc. with objects
						$.widget.extend( {}, value );

				// Copy everything else by reference
				} else {
					target[ key ] = value;
				}
			}
		}
	}
	return target;
};

$.widget.bridge = function( name, object ) {
	var fullName = object.prototype.widgetFullName || name;
	$.fn[ name ] = function( options ) {
		var isMethodCall = typeof options === "string";
		var args = widgetSlice.call( arguments, 1 );
		var returnValue = this;

		if ( isMethodCall ) {

			// If this is an empty collection, we need to have the instance method
			// return undefined instead of the jQuery instance
			if ( !this.length && options === "instance" ) {
				returnValue = undefined;
			} else {
				this.each( function() {
					var methodValue;
					var instance = $.data( this, fullName );

					if ( options === "instance" ) {
						returnValue = instance;
						return false;
					}

					if ( !instance ) {
						return $.error( "cannot call methods on " + name +
							" prior to initialization; " +
							"attempted to call method '" + options + "'" );
					}

					if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
						return $.error( "no such method '" + options + "' for " + name +
							" widget instance" );
					}

					methodValue = instance[ options ].apply( instance, args );

					if ( methodValue !== instance && methodValue !== undefined ) {
						returnValue = methodValue && methodValue.jquery ?
							returnValue.pushStack( methodValue.get() ) :
							methodValue;
						return false;
					}
				} );
			}
		} else {

			// Allow multiple hashes to be passed on init
			if ( args.length ) {
				options = $.widget.extend.apply( null, [ options ].concat( args ) );
			}

			this.each( function() {
				var instance = $.data( this, fullName );
				if ( instance ) {
					instance.option( options || {} );
					if ( instance._init ) {
						instance._init();
					}
				} else {
					$.data( this, fullName, new object( options, this ) );
				}
			} );
		}

		return returnValue;
	};
};

$.Widget = function( /* options, element */ ) {};
$.Widget._childConstructors = [];

$.Widget.prototype = {
	widgetName: "widget",
	widgetEventPrefix: "",
	defaultElement: "<div>",

	options: {
		classes: {},
		disabled: false,

		// Callbacks
		create: null
	},

	_createWidget: function( options, element ) {
		element = $( element || this.defaultElement || this )[ 0 ];
		this.element = $( element );
		this.uuid = widgetUuid++;
		this.eventNamespace = "." + this.widgetName + this.uuid;

		this.bindings = $();
		this.hoverable = $();
		this.focusable = $();
		this.classesElementLookup = {};

		if ( element !== this ) {
			$.data( element, this.widgetFullName, this );
			this._on( true, this.element, {
				remove: function( event ) {
					if ( event.target === element ) {
						this.destroy();
					}
				}
			} );
			this.document = $( element.style ?

				// Element within the document
				element.ownerDocument :

				// Element is window or document
				element.document || element );
			this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
		}

		this.options = $.widget.extend( {},
			this.options,
			this._getCreateOptions(),
			options );

		this._create();

		if ( this.options.disabled ) {
			this._setOptionDisabled( this.options.disabled );
		}

		this._trigger( "create", null, this._getCreateEventData() );
		this._init();
	},

	_getCreateOptions: function() {
		return {};
	},

	_getCreateEventData: $.noop,

	_create: $.noop,

	_init: $.noop,

	destroy: function() {
		var that = this;

		this._destroy();
		$.each( this.classesElementLookup, function( key, value ) {
			that._removeClass( value, key );
		} );

		// We can probably remove the unbind calls in 2.0
		// all event bindings should go through this._on()
		this.element
			.off( this.eventNamespace )
			.removeData( this.widgetFullName );
		this.widget()
			.off( this.eventNamespace )
			.removeAttr( "aria-disabled" );

		// Clean up events and states
		this.bindings.off( this.eventNamespace );
	},

	_destroy: $.noop,

	widget: function() {
		return this.element;
	},

	option: function( key, value ) {
		var options = key;
		var parts;
		var curOption;
		var i;

		if ( arguments.length === 0 ) {

			// Don't return a reference to the internal hash
			return $.widget.extend( {}, this.options );
		}

		if ( typeof key === "string" ) {

			// Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
			options = {};
			parts = key.split( "." );
			key = parts.shift();
			if ( parts.length ) {
				curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
				for ( i = 0; i < parts.length - 1; i++ ) {
					curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
					curOption = curOption[ parts[ i ] ];
				}
				key = parts.pop();
				if ( arguments.length === 1 ) {
					return curOption[ key ] === undefined ? null : curOption[ key ];
				}
				curOption[ key ] = value;
			} else {
				if ( arguments.length === 1 ) {
					return this.options[ key ] === undefined ? null : this.options[ key ];
				}
				options[ key ] = value;
			}
		}

		this._setOptions( options );

		return this;
	},

	_setOptions: function( options ) {
		var key;

		for ( key in options ) {
			this._setOption( key, options[ key ] );
		}

		return this;
	},

	_setOption: function( key, value ) {
		if ( key === "classes" ) {
			this._setOptionClasses( value );
		}

		this.options[ key ] = value;

		if ( key === "disabled" ) {
			this._setOptionDisabled( value );
		}

		return this;
	},

	_setOptionClasses: function( value ) {
		var classKey, elements, currentElements;

		for ( classKey in value ) {
			currentElements = this.classesElementLookup[ classKey ];
			if ( value[ classKey ] === this.options.classes[ classKey ] ||
					!currentElements ||
					!currentElements.length ) {
				continue;
			}

			// We are doing this to create a new jQuery object because the _removeClass() call
			// on the next line is going to destroy the reference to the current elements being
			// tracked. We need to save a copy of this collection so that we can add the new classes
			// below.
			elements = $( currentElements.get() );
			this._removeClass( currentElements, classKey );

			// We don't use _addClass() here, because that uses this.options.classes
			// for generating the string of classes. We want to use the value passed in from
			// _setOption(), this is the new value of the classes option which was passed to
			// _setOption(). We pass this value directly to _classes().
			elements.addClass( this._classes( {
				element: elements,
				keys: classKey,
				classes: value,
				add: true
			} ) );
		}
	},

	_setOptionDisabled: function( value ) {
		this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );

		// If the widget is becoming disabled, then nothing is interactive
		if ( value ) {
			this._removeClass( this.hoverable, null, "ui-state-hover" );
			this._removeClass( this.focusable, null, "ui-state-focus" );
		}
	},

	enable: function() {
		return this._setOptions( { disabled: false } );
	},

	disable: function() {
		return this._setOptions( { disabled: true } );
	},

	_classes: function( options ) {
		var full = [];
		var that = this;

		options = $.extend( {
			element: this.element,
			classes: this.options.classes || {}
		}, options );

		function processClassString( classes, checkOption ) {
			var current, i;
			for ( i = 0; i < classes.length; i++ ) {
				current = that.classesElementLookup[ classes[ i ] ] || $();
				if ( options.add ) {
					current = $( $.unique( current.get().concat( options.element.get() ) ) );
				} else {
					current = $( current.not( options.element ).get() );
				}
				that.classesElementLookup[ classes[ i ] ] = current;
				full.push( classes[ i ] );
				if ( checkOption && options.classes[ classes[ i ] ] ) {
					full.push( options.classes[ classes[ i ] ] );
				}
			}
		}

		this._on( options.element, {
			"remove": "_untrackClassesElement"
		} );

		if ( options.keys ) {
			processClassString( options.keys.match( /\S+/g ) || [], true );
		}
		if ( options.extra ) {
			processClassString( options.extra.match( /\S+/g ) || [] );
		}

		return full.join( " " );
	},

	_untrackClassesElement: function( event ) {
		var that = this;
		$.each( that.classesElementLookup, function( key, value ) {
			if ( $.inArray( event.target, value ) !== -1 ) {
				that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
			}
		} );
	},

	_removeClass: function( element, keys, extra ) {
		return this._toggleClass( element, keys, extra, false );
	},

	_addClass: function( element, keys, extra ) {
		return this._toggleClass( element, keys, extra, true );
	},

	_toggleClass: function( element, keys, extra, add ) {
		add = ( typeof add === "boolean" ) ? add : extra;
		var shift = ( typeof element === "string" || element === null ),
			options = {
				extra: shift ? keys : extra,
				keys: shift ? element : keys,
				element: shift ? this.element : element,
				add: add
			};
		options.element.toggleClass( this._classes( options ), add );
		return this;
	},

	_on: function( suppressDisabledCheck, element, handlers ) {
		var delegateElement;
		var instance = this;

		// No suppressDisabledCheck flag, shuffle arguments
		if ( typeof suppressDisabledCheck !== "boolean" ) {
			handlers = element;
			element = suppressDisabledCheck;
			suppressDisabledCheck = false;
		}

		// No element argument, shuffle and use this.element
		if ( !handlers ) {
			handlers = element;
			element = this.element;
			delegateElement = this.widget();
		} else {
			element = delegateElement = $( element );
			this.bindings = this.bindings.add( element );
		}

		$.each( handlers, function( event, handler ) {
			function handlerProxy() {

				// Allow widgets to customize the disabled handling
				// - disabled as an array instead of boolean
				// - disabled class as method for disabling individual parts
				if ( !suppressDisabledCheck &&
						( instance.options.disabled === true ||
						$( this ).hasClass( "ui-state-disabled" ) ) ) {
					return;
				}
				return ( typeof handler === "string" ? instance[ handler ] : handler )
					.apply( instance, arguments );
			}

			// Copy the guid so direct unbinding works
			if ( typeof handler !== "string" ) {
				handlerProxy.guid = handler.guid =
					handler.guid || handlerProxy.guid || $.guid++;
			}

			var match = event.match( /^([\w:-]*)\s*(.*)$/ );
			var eventName = match[ 1 ] + instance.eventNamespace;
			var selector = match[ 2 ];

			if ( selector ) {
				delegateElement.on( eventName, selector, handlerProxy );
			} else {
				element.on( eventName, handlerProxy );
			}
		} );
	},

	_off: function( element, eventName ) {
		eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
			this.eventNamespace;
		element.off( eventName ).off( eventName );

		// Clear the stack to avoid memory leaks (#10056)
		this.bindings = $( this.bindings.not( element ).get() );
		this.focusable = $( this.focusable.not( element ).get() );
		this.hoverable = $( this.hoverable.not( element ).get() );
	},

	_delay: function( handler, delay ) {
		function handlerProxy() {
			return ( typeof handler === "string" ? instance[ handler ] : handler )
				.apply( instance, arguments );
		}
		var instance = this;
		return setTimeout( handlerProxy, delay || 0 );
	},

	_hoverable: function( element ) {
		this.hoverable = this.hoverable.add( element );
		this._on( element, {
			mouseenter: function( event ) {
				this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
			},
			mouseleave: function( event ) {
				this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
			}
		} );
	},

	_focusable: function( element ) {
		this.focusable = this.focusable.add( element );
		this._on( element, {
			focusin: function( event ) {
				this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
			},
			focusout: function( event ) {
				this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
			}
		} );
	},

	_trigger: function( type, event, data ) {
		var prop, orig;
		var callback = this.options[ type ];

		data = data || {};
		event = $.Event( event );
		event.type = ( type === this.widgetEventPrefix ?
			type :
			this.widgetEventPrefix + type ).toLowerCase();

		// The original event may come from any element
		// so we need to reset the target on the new event
		event.target = this.element[ 0 ];

		// Copy original event properties over to the new event
		orig = event.originalEvent;
		if ( orig ) {
			for ( prop in orig ) {
				if ( !( prop in event ) ) {
					event[ prop ] = orig[ prop ];
				}
			}
		}

		this.element.trigger( event, data );
		return !( $.isFunction( callback ) &&
			callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
			event.isDefaultPrevented() );
	}
};

$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
	$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
		if ( typeof options === "string" ) {
			options = { effect: options };
		}

		var hasOptions;
		var effectName = !options ?
			method :
			options === true || typeof options === "number" ?
				defaultEffect :
				options.effect || defaultEffect;

		options = options || {};
		if ( typeof options === "number" ) {
			options = { duration: options };
		}

		hasOptions = !$.isEmptyObject( options );
		options.complete = callback;

		if ( options.delay ) {
			element.delay( options.delay );
		}

		if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
			element[ method ]( options );
		} else if ( effectName !== method && element[ effectName ] ) {
			element[ effectName ]( options.duration, options.easing, callback );
		} else {
			element.queue( function( next ) {
				$( this )[ method ]();
				if ( callback ) {
					callback.call( element[ 0 ] );
				}
				next();
			} );
		}
	};
} );

var widget = $.widget;


/*!
 * jQuery UI :data 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: :data Selector
//>>group: Core
//>>description: Selects elements which have data stored under the specified key.
//>>docs: http://api.jqueryui.com/data-selector/


var data = $.extend( $.expr[ ":" ], {
	data: $.expr.createPseudo ?
		$.expr.createPseudo( function( dataName ) {
			return function( elem ) {
				return !!$.data( elem, dataName );
			};
		} ) :

		// Support: jQuery <1.8
		function( elem, i, match ) {
			return !!$.data( elem, match[ 3 ] );
		}
} );

/*!
 * jQuery UI Disable Selection 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: disableSelection
//>>group: Core
//>>description: Disable selection of text content within the set of matched elements.
//>>docs: http://api.jqueryui.com/disableSelection/

// This file is deprecated


var disableSelection = $.fn.extend( {
	disableSelection: ( function() {
		var eventType = "onselectstart" in document.createElement( "div" ) ?
			"selectstart" :
			"mousedown";

		return function() {
			return this.on( eventType + ".ui-disableSelection", function( event ) {
				event.preventDefault();
			} );
		};
	} )(),

	enableSelection: function() {
		return this.off( ".ui-disableSelection" );
	}
} );


/*!
 * jQuery UI Keycode 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Keycode
//>>group: Core
//>>description: Provide keycodes as keynames
//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/


var keycode = $.ui.keyCode = {
	BACKSPACE: 8,
	COMMA: 188,
	DELETE: 46,
	DOWN: 40,
	END: 35,
	ENTER: 13,
	ESCAPE: 27,
	HOME: 36,
	LEFT: 37,
	PAGE_DOWN: 34,
	PAGE_UP: 33,
	PERIOD: 190,
	RIGHT: 39,
	SPACE: 32,
	TAB: 9,
	UP: 38
};


/*!
 * jQuery UI Scroll Parent 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: scrollParent
//>>group: Core
//>>description: Get the closest ancestor element that is scrollable.
//>>docs: http://api.jqueryui.com/scrollParent/



var scrollParent = $.fn.scrollParent = function( includeHidden ) {
	var position = this.css( "position" ),
		excludeStaticParent = position === "absolute",
		overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
		scrollParent = this.parents().filter( function() {
			var parent = $( this );
			if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
				return false;
			}
			return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
				parent.css( "overflow-x" ) );
		} ).eq( 0 );

	return position === "fixed" || !scrollParent.length ?
		$( this[ 0 ].ownerDocument || document ) :
		scrollParent;
};




// This file is deprecated
var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );

/*!
 * jQuery UI Mouse 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Mouse
//>>group: Widgets
//>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
//>>docs: http://api.jqueryui.com/mouse/



var mouseHandled = false;
$( document ).on( "mouseup", function() {
	mouseHandled = false;
} );

var widgetsMouse = $.widget( "ui.mouse", {
	version: "1.12.1",
	options: {
		cancel: "input, textarea, button, select, option",
		distance: 1,
		delay: 0
	},
	_mouseInit: function() {
		var that = this;

		this.element
			.on( "mousedown." + this.widgetName, function( event ) {
				return that._mouseDown( event );
			} )
			.on( "click." + this.widgetName, function( event ) {
				if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
					$.removeData( event.target, that.widgetName + ".preventClickEvent" );
					event.stopImmediatePropagation();
					return false;
				}
			} );

		this.started = false;
	},

	// TODO: make sure destroying one instance of mouse doesn't mess with
	// other instances of mouse
	_mouseDestroy: function() {
		this.element.off( "." + this.widgetName );
		if ( this._mouseMoveDelegate ) {
			this.document
				.off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
				.off( "mouseup." + this.widgetName, this._mouseUpDelegate );
		}
	},

	_mouseDown: function( event ) {

		// don't let more than one widget handle mouseStart
		if ( mouseHandled ) {
			return;
		}

		this._mouseMoved = false;

		// We may have missed mouseup (out of window)
		( this._mouseStarted && this._mouseUp( event ) );

		this._mouseDownEvent = event;

		var that = this,
			btnIsLeft = ( event.which === 1 ),

			// event.target.nodeName works around a bug in IE 8 with
			// disabled inputs (#7620)
			elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
				$( event.target ).closest( this.options.cancel ).length : false );
		if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
			return true;
		}

		this.mouseDelayMet = !this.options.delay;
		if ( !this.mouseDelayMet ) {
			this._mouseDelayTimer = setTimeout( function() {
				that.mouseDelayMet = true;
			}, this.options.delay );
		}

		if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
			this._mouseStarted = ( this._mouseStart( event ) !== false );
			if ( !this._mouseStarted ) {
				event.preventDefault();
				return true;
			}
		}

		// Click event may never have fired (Gecko & Opera)
		if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
			$.removeData( event.target, this.widgetName + ".preventClickEvent" );
		}

		// These delegates are required to keep context
		this._mouseMoveDelegate = function( event ) {
			return that._mouseMove( event );
		};
		this._mouseUpDelegate = function( event ) {
			return that._mouseUp( event );
		};

		this.document
			.on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
			.on( "mouseup." + this.widgetName, this._mouseUpDelegate );

		event.preventDefault();

		mouseHandled = true;
		return true;
	},

	_mouseMove: function( event ) {

		// Only check for mouseups outside the document if you've moved inside the document
		// at least once. This prevents the firing of mouseup in the case of IE<9, which will
		// fire a mousemove event if content is placed under the cursor. See #7778
		// Support: IE <9
		if ( this._mouseMoved ) {

			// IE mouseup check - mouseup happened when mouse was out of window
			if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
					!event.button ) {
				return this._mouseUp( event );

			// Iframe mouseup check - mouseup occurred in another document
			} else if ( !event.which ) {

				// Support: Safari <=8 - 9
				// Safari sets which to 0 if you press any of the following keys
				// during a drag (#14461)
				if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
						event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
					this.ignoreMissingWhich = true;
				} else if ( !this.ignoreMissingWhich ) {
					return this._mouseUp( event );
				}
			}
		}

		if ( event.which || event.button ) {
			this._mouseMoved = true;
		}

		if ( this._mouseStarted ) {
			this._mouseDrag( event );
			return event.preventDefault();
		}

		if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
			this._mouseStarted =
				( this._mouseStart( this._mouseDownEvent, event ) !== false );
			( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
		}

		return !this._mouseStarted;
	},

	_mouseUp: function( event ) {
		this.document
			.off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
			.off( "mouseup." + this.widgetName, this._mouseUpDelegate );

		if ( this._mouseStarted ) {
			this._mouseStarted = false;

			if ( event.target === this._mouseDownEvent.target ) {
				$.data( event.target, this.widgetName + ".preventClickEvent", true );
			}

			this._mouseStop( event );
		}

		if ( this._mouseDelayTimer ) {
			clearTimeout( this._mouseDelayTimer );
			delete this._mouseDelayTimer;
		}

		this.ignoreMissingWhich = false;
		mouseHandled = false;
		event.preventDefault();
	},

	_mouseDistanceMet: function( event ) {
		return ( Math.max(
				Math.abs( this._mouseDownEvent.pageX - event.pageX ),
				Math.abs( this._mouseDownEvent.pageY - event.pageY )
			) >= this.options.distance
		);
	},

	_mouseDelayMet: function( /* event */ ) {
		return this.mouseDelayMet;
	},

	// These are placeholder methods, to be overriden by extending plugin
	_mouseStart: function( /* event */ ) {},
	_mouseDrag: function( /* event */ ) {},
	_mouseStop: function( /* event */ ) {},
	_mouseCapture: function( /* event */ ) { return true; }
} );




// $.ui.plugin is deprecated. Use $.widget() extensions instead.
var plugin = $.ui.plugin = {
	add: function( module, option, set ) {
		var i,
			proto = $.ui[ module ].prototype;
		for ( i in set ) {
			proto.plugins[ i ] = proto.plugins[ i ] || [];
			proto.plugins[ i ].push( [ option, set[ i ] ] );
		}
	},
	call: function( instance, name, args, allowDisconnected ) {
		var i,
			set = instance.plugins[ name ];

		if ( !set ) {
			return;
		}

		if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
				instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
			return;
		}

		for ( i = 0; i < set.length; i++ ) {
			if ( instance.options[ set[ i ][ 0 ] ] ) {
				set[ i ][ 1 ].apply( instance.element, args );
			}
		}
	}
};



var safeActiveElement = $.ui.safeActiveElement = function( document ) {
	var activeElement;

	// Support: IE 9 only
	// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
	try {
		activeElement = document.activeElement;
	} catch ( error ) {
		activeElement = document.body;
	}

	// Support: IE 9 - 11 only
	// IE may return null instead of an element
	// Interestingly, this only seems to occur when NOT in an iframe
	if ( !activeElement ) {
		activeElement = document.body;
	}

	// Support: IE 11 only
	// IE11 returns a seemingly empty object in some cases when accessing
	// document.activeElement from an <iframe>
	if ( !activeElement.nodeName ) {
		activeElement = document.body;
	}

	return activeElement;
};



var safeBlur = $.ui.safeBlur = function( element ) {

	// Support: IE9 - 10 only
	// If the <body> is blurred, IE will switch windows, see #9420
	if ( element && element.nodeName.toLowerCase() !== "body" ) {
		$( element ).trigger( "blur" );
	}
};


/*!
 * jQuery UI Draggable 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Draggable
//>>group: Interactions
//>>description: Enables dragging functionality for any element.
//>>docs: http://api.jqueryui.com/draggable/
//>>demos: http://jqueryui.com/draggable/
//>>css.structure: ../../themes/base/draggable.css



$.widget( "ui.draggable", $.ui.mouse, {
	version: "1.12.1",
	widgetEventPrefix: "drag",
	options: {
		addClasses: true,
		appendTo: "parent",
		axis: false,
		connectToSortable: false,
		containment: false,
		cursor: "auto",
		cursorAt: false,
		grid: false,
		handle: false,
		helper: "original",
		iframeFix: false,
		opacity: false,
		refreshPositions: false,
		revert: false,
		revertDuration: 500,
		scope: "default",
		scroll: true,
		scrollSensitivity: 20,
		scrollSpeed: 20,
		snap: false,
		snapMode: "both",
		snapTolerance: 20,
		stack: false,
		zIndex: false,

		// Callbacks
		drag: null,
		start: null,
		stop: null
	},
	_create: function() {

		if ( this.options.helper === "original" ) {
			this._setPositionRelative();
		}
		if ( this.options.addClasses ) {
			this._addClass( "ui-draggable" );
		}
		this._setHandleClassName();

		this._mouseInit();
	},

	_setOption: function( key, value ) {
		this._super( key, value );
		if ( key === "handle" ) {
			this._removeHandleClassName();
			this._setHandleClassName();
		}
	},

	_destroy: function() {
		if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
			this.destroyOnClear = true;
			return;
		}
		this._removeHandleClassName();
		this._mouseDestroy();
	},

	_mouseCapture: function( event ) {
		var o = this.options;

		// Among others, prevent a drag on a resizable-handle
		if ( this.helper || o.disabled ||
				$( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
			return false;
		}

		//Quit if we're not on a valid handle
		this.handle = this._getHandle( event );
		if ( !this.handle ) {
			return false;
		}

		this._blurActiveElement( event );

		this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );

		return true;

	},

	_blockFrames: function( selector ) {
		this.iframeBlocks = this.document.find( selector ).map( function() {
			var iframe = $( this );

			return $( "<div>" )
				.css( "position", "absolute" )
				.appendTo( iframe.parent() )
				.outerWidth( iframe.outerWidth() )
				.outerHeight( iframe.outerHeight() )
				.offset( iframe.offset() )[ 0 ];
		} );
	},

	_unblockFrames: function() {
		if ( this.iframeBlocks ) {
			this.iframeBlocks.remove();
			delete this.iframeBlocks;
		}
	},

	_blurActiveElement: function( event ) {
		var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
			target = $( event.target );

		// Don't blur if the event occurred on an element that is within
		// the currently focused element
		// See #10527, #12472
		if ( target.closest( activeElement ).length ) {
			return;
		}

		// Blur any element that currently has focus, see #4261
		$.ui.safeBlur( activeElement );
	},

	_mouseStart: function( event ) {

		var o = this.options;

		//Create and append the visible helper
		this.helper = this._createHelper( event );

		this._addClass( this.helper, "ui-draggable-dragging" );

		//Cache the helper size
		this._cacheHelperProportions();

		//If ddmanager is used for droppables, set the global draggable
		if ( $.ui.ddmanager ) {
			$.ui.ddmanager.current = this;
		}

		/*
		 * - Position generation -
		 * This block generates everything position related - it's the core of draggables.
		 */

		//Cache the margins of the original element
		this._cacheMargins();

		//Store the helper's css position
		this.cssPosition = this.helper.css( "position" );
		this.scrollParent = this.helper.scrollParent( true );
		this.offsetParent = this.helper.offsetParent();
		this.hasFixedAncestor = this.helper.parents().filter( function() {
				return $( this ).css( "position" ) === "fixed";
			} ).length > 0;

		//The element's absolute position on the page minus margins
		this.positionAbs = this.element.offset();
		this._refreshOffsets( event );

		//Generate the original position
		this.originalPosition = this.position = this._generatePosition( event, false );
		this.originalPageX = event.pageX;
		this.originalPageY = event.pageY;

		//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
		( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );

		//Set a containment if given in the options
		this._setContainment();

		//Trigger event + callbacks
		if ( this._trigger( "start", event ) === false ) {
			this._clear();
			return false;
		}

		//Recache the helper size
		this._cacheHelperProportions();

		//Prepare the droppable offsets
		if ( $.ui.ddmanager && !o.dropBehaviour ) {
			$.ui.ddmanager.prepareOffsets( this, event );
		}

		// Execute the drag once - this causes the helper not to be visible before getting its
		// correct position
		this._mouseDrag( event, true );

		// If the ddmanager is used for droppables, inform the manager that dragging has started
		// (see #5003)
		if ( $.ui.ddmanager ) {
			$.ui.ddmanager.dragStart( this, event );
		}

		return true;
	},

	_refreshOffsets: function( event ) {
		this.offset = {
			top: this.positionAbs.top - this.margins.top,
			left: this.positionAbs.left - this.margins.left,
			scroll: false,
			parent: this._getParentOffset(),
			relative: this._getRelativeOffset()
		};

		this.offset.click = {
			left: event.pageX - this.offset.left,
			top: event.pageY - this.offset.top
		};
	},

	_mouseDrag: function( event, noPropagation ) {

		// reset any necessary cached properties (see #5009)
		if ( this.hasFixedAncestor ) {
			this.offset.parent = this._getParentOffset();
		}

		//Compute the helpers position
		this.position = this._generatePosition( event, true );
		this.positionAbs = this._convertPositionTo( "absolute" );

		//Call plugins and callbacks and use the resulting position if something is returned
		if ( !noPropagation ) {
			var ui = this._uiHash();
			if ( this._trigger( "drag", event, ui ) === false ) {
				this._mouseUp( new $.Event( "mouseup", event ) );
				return false;
			}
			this.position = ui.position;
		}

		this.helper[ 0 ].style.left = this.position.left + "px";
		this.helper[ 0 ].style.top = this.position.top + "px";

		if ( $.ui.ddmanager ) {
			$.ui.ddmanager.drag( this, event );
		}

		return false;
	},

	_mouseStop: function( event ) {

		//If we are using droppables, inform the manager about the drop
		var that = this,
			dropped = false;
		if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
			dropped = $.ui.ddmanager.drop( this, event );
		}

		//if a drop comes from outside (a sortable)
		if ( this.dropped ) {
			dropped = this.dropped;
			this.dropped = false;
		}

		if ( ( this.options.revert === "invalid" && !dropped ) ||
				( this.options.revert === "valid" && dropped ) ||
				this.options.revert === true || ( $.isFunction( this.options.revert ) &&
				this.options.revert.call( this.element, dropped ) )
		) {
			$( this.helper ).animate(
				this.originalPosition,
				parseInt( this.options.revertDuration, 10 ),
				function() {
					if ( that._trigger( "stop", event ) !== false ) {
						that._clear();
					}
				}
			);
		} else {
			if ( this._trigger( "stop", event ) !== false ) {
				this._clear();
			}
		}

		return false;
	},

	_mouseUp: function( event ) {
		this._unblockFrames();

		// If the ddmanager is used for droppables, inform the manager that dragging has stopped
		// (see #5003)
		if ( $.ui.ddmanager ) {
			$.ui.ddmanager.dragStop( this, event );
		}

		// Only need to focus if the event occurred on the draggable itself, see #10527
		if ( this.handleElement.is( event.target ) ) {

			// The interaction is over; whether or not the click resulted in a drag,
			// focus the element
			this.element.trigger( "focus" );
		}

		return $.ui.mouse.prototype._mouseUp.call( this, event );
	},

	cancel: function() {

		if ( this.helper.is( ".ui-draggable-dragging" ) ) {
			this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
		} else {
			this._clear();
		}

		return this;

	},

	_getHandle: function( event ) {
		return this.options.handle ?
			!!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
			true;
	},

	_setHandleClassName: function() {
		this.handleElement = this.options.handle ?
			this.element.find( this.options.handle ) : this.element;
		this._addClass( this.handleElement, "ui-draggable-handle" );
	},

	_removeHandleClassName: function() {
		this._removeClass( this.handleElement, "ui-draggable-handle" );
	},

	_createHelper: function( event ) {

		var o = this.options,
			helperIsFunction = $.isFunction( o.helper ),
			helper = helperIsFunction ?
				$( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
				( o.helper === "clone" ?
					this.element.clone().removeAttr( "id" ) :
					this.element );

		if ( !helper.parents( "body" ).length ) {
			helper.appendTo( ( o.appendTo === "parent" ?
				this.element[ 0 ].parentNode :
				o.appendTo ) );
		}

		// Http://bugs.jqueryui.com/ticket/9446
		// a helper function can return the original element
		// which wouldn't have been set to relative in _create
		if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
			this._setPositionRelative();
		}

		if ( helper[ 0 ] !== this.element[ 0 ] &&
				!( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
			helper.css( "position", "absolute" );
		}

		return helper;

	},

	_setPositionRelative: function() {
		if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
			this.element[ 0 ].style.position = "relative";
		}
	},

	_adjustOffsetFromHelper: function( obj ) {
		if ( typeof obj === "string" ) {
			obj = obj.split( " " );
		}
		if ( $.isArray( obj ) ) {
			obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
		}
		if ( "left" in obj ) {
			this.offset.click.left = obj.left + this.margins.left;
		}
		if ( "right" in obj ) {
			this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
		}
		if ( "top" in obj ) {
			this.offset.click.top = obj.top + this.margins.top;
		}
		if ( "bottom" in obj ) {
			this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
		}
	},

	_isRootNode: function( element ) {
		return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
	},

	_getParentOffset: function() {

		//Get the offsetParent and cache its position
		var po = this.offsetParent.offset(),
			document = this.document[ 0 ];

		// This is a special case where we need to modify a offset calculated on start, since the
		// following happened:
		// 1. The position of the helper is absolute, so it's position is calculated based on the
		// next positioned parent
		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
		// the document, which means that the scroll is included in the initial calculation of the
		// offset of the parent, and never recalculated upon drag
		if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
			po.left += this.scrollParent.scrollLeft();
			po.top += this.scrollParent.scrollTop();
		}

		if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
			po = { top: 0, left: 0 };
		}

		return {
			top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
			left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
		};

	},

	_getRelativeOffset: function() {
		if ( this.cssPosition !== "relative" ) {
			return { top: 0, left: 0 };
		}

		var p = this.element.position(),
			scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );

		return {
			top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
				( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
			left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
				( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 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 isUserScrollable, c, ce,
			o = this.options,
			document = this.document[ 0 ];

		this.relativeContainer = null;

		if ( !o.containment ) {
			this.containment = null;
			return;
		}

		if ( o.containment === "window" ) {
			this.containment = [
				$( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
				$( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
				$( window ).scrollLeft() + $( window ).width() -
					this.helperProportions.width - this.margins.left,
				$( window ).scrollTop() +
					( $( window ).height() || document.body.parentNode.scrollHeight ) -
					this.helperProportions.height - this.margins.top
			];
			return;
		}

		if ( o.containment === "document" ) {
			this.containment = [
				0,
				0,
				$( document ).width() - this.helperProportions.width - this.margins.left,
				( $( document ).height() || document.body.parentNode.scrollHeight ) -
					this.helperProportions.height - this.margins.top
			];
			return;
		}

		if ( o.containment.constructor === Array ) {
			this.containment = o.containment;
			return;
		}

		if ( o.containment === "parent" ) {
			o.containment = this.helper[ 0 ].parentNode;
		}

		c = $( o.containment );
		ce = c[ 0 ];

		if ( !ce ) {
			return;
		}

		isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );

		this.containment = [
			( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
				( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
			( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
				( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
			( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
				( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
				( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
				this.helperProportions.width -
				this.margins.left -
				this.margins.right,
			( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
				( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
				( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
				this.helperProportions.height -
				this.margins.top -
				this.margins.bottom
		];
		this.relativeContainer = c;
	},

	_convertPositionTo: function( d, pos ) {

		if ( !pos ) {
			pos = this.position;
		}

		var mod = d === "absolute" ? 1 : -1,
			scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );

		return {
			top: (

				// The absolute mouse position
				pos.top	+

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.top * mod +

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.top * mod -
				( ( this.cssPosition === "fixed" ?
					-this.offset.scroll.top :
					( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
			),
			left: (

				// The absolute mouse position
				pos.left +

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.left * mod +

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.left * mod	-
				( ( this.cssPosition === "fixed" ?
					-this.offset.scroll.left :
					( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
			)
		};

	},

	_generatePosition: function( event, constrainPosition ) {

		var containment, co, top, left,
			o = this.options,
			scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
			pageX = event.pageX,
			pageY = event.pageY;

		// Cache the scroll
		if ( !scrollIsRootNode || !this.offset.scroll ) {
			this.offset.scroll = {
				top: this.scrollParent.scrollTop(),
				left: this.scrollParent.scrollLeft()
			};
		}

		/*
		 * - Position constraining -
		 * Constrain the position to a mix of grid, containment.
		 */

		// If we are not dragging yet, we won't check for options
		if ( constrainPosition ) {
			if ( this.containment ) {
				if ( this.relativeContainer ) {
					co = this.relativeContainer.offset();
					containment = [
						this.containment[ 0 ] + co.left,
						this.containment[ 1 ] + co.top,
						this.containment[ 2 ] + co.left,
						this.containment[ 3 ] + co.top
					];
				} else {
					containment = this.containment;
				}

				if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
					pageX = containment[ 0 ] + this.offset.click.left;
				}
				if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
					pageY = containment[ 1 ] + this.offset.click.top;
				}
				if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
					pageX = containment[ 2 ] + this.offset.click.left;
				}
				if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
					pageY = containment[ 3 ] + this.offset.click.top;
				}
			}

			if ( o.grid ) {

				//Check for grid elements set to 0 to prevent divide by 0 error causing invalid
				// argument errors in IE (see ticket #6950)
				top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
					this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
				pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
					top - this.offset.click.top > containment[ 3 ] ) ?
						top :
						( ( top - this.offset.click.top >= containment[ 1 ] ) ?
							top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;

				left = o.grid[ 0 ] ? this.originalPageX +
					Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
					this.originalPageX;
				pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
					left - this.offset.click.left > containment[ 2 ] ) ?
						left :
						( ( left - this.offset.click.left >= containment[ 0 ] ) ?
							left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
			}

			if ( o.axis === "y" ) {
				pageX = this.originalPageX;
			}

			if ( o.axis === "x" ) {
				pageY = this.originalPageY;
			}
		}

		return {
			top: (

				// The absolute mouse position
				pageY -

				// Click offset (relative to the element)
				this.offset.click.top -

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.top -

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.top +
				( this.cssPosition === "fixed" ?
					-this.offset.scroll.top :
					( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
			),
			left: (

				// The absolute mouse position
				pageX -

				// Click offset (relative to the element)
				this.offset.click.left -

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.left -

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.left +
				( this.cssPosition === "fixed" ?
					-this.offset.scroll.left :
					( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
			)
		};

	},

	_clear: function() {
		this._removeClass( this.helper, "ui-draggable-dragging" );
		if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
			this.helper.remove();
		}
		this.helper = null;
		this.cancelHelperRemoval = false;
		if ( this.destroyOnClear ) {
			this.destroy();
		}
	},

	// From now on bulk stuff - mainly helpers

	_trigger: function( type, event, ui ) {
		ui = ui || this._uiHash();
		$.ui.plugin.call( this, type, [ event, ui, this ], true );

		// Absolute position and offset (see #6884 ) have to be recalculated after plugins
		if ( /^(drag|start|stop)/.test( type ) ) {
			this.positionAbs = this._convertPositionTo( "absolute" );
			ui.offset = this.positionAbs;
		}
		return $.Widget.prototype._trigger.call( this, type, event, ui );
	},

	plugins: {},

	_uiHash: function() {
		return {
			helper: this.helper,
			position: this.position,
			originalPosition: this.originalPosition,
			offset: this.positionAbs
		};
	}

} );

$.ui.plugin.add( "draggable", "connectToSortable", {
	start: function( event, ui, draggable ) {
		var uiSortable = $.extend( {}, ui, {
			item: draggable.element
		} );

		draggable.sortables = [];
		$( draggable.options.connectToSortable ).each( function() {
			var sortable = $( this ).sortable( "instance" );

			if ( sortable && !sortable.options.disabled ) {
				draggable.sortables.push( sortable );

				// RefreshPositions is called at drag start to refresh the containerCache
				// which is used in drag. This ensures it's initialized and synchronized
				// with any changes that might have happened on the page since initialization.
				sortable.refreshPositions();
				sortable._trigger( "activate", event, uiSortable );
			}
		} );
	},
	stop: function( event, ui, draggable ) {
		var uiSortable = $.extend( {}, ui, {
			item: draggable.element
		} );

		draggable.cancelHelperRemoval = false;

		$.each( draggable.sortables, function() {
			var sortable = this;

			if ( sortable.isOver ) {
				sortable.isOver = 0;

				// Allow this sortable to handle removing the helper
				draggable.cancelHelperRemoval = true;
				sortable.cancelHelperRemoval = false;

				// Use _storedCSS To restore properties in the sortable,
				// as this also handles revert (#9675) since the draggable
				// may have modified them in unexpected ways (#8809)
				sortable._storedCSS = {
					position: sortable.placeholder.css( "position" ),
					top: sortable.placeholder.css( "top" ),
					left: sortable.placeholder.css( "left" )
				};

				sortable._mouseStop( event );

				// Once drag has ended, the sortable should return to using
				// its original helper, not the shared helper from draggable
				sortable.options.helper = sortable.options._helper;
			} else {

				// Prevent this Sortable from removing the helper.
				// However, don't set the draggable to remove the helper
				// either as another connected Sortable may yet handle the removal.
				sortable.cancelHelperRemoval = true;

				sortable._trigger( "deactivate", event, uiSortable );
			}
		} );
	},
	drag: function( event, ui, draggable ) {
		$.each( draggable.sortables, function() {
			var innermostIntersecting = false,
				sortable = this;

			// Copy over variables that sortable's _intersectsWith uses
			sortable.positionAbs = draggable.positionAbs;
			sortable.helperProportions = draggable.helperProportions;
			sortable.offset.click = draggable.offset.click;

			if ( sortable._intersectsWith( sortable.containerCache ) ) {
				innermostIntersecting = true;

				$.each( draggable.sortables, function() {

					// Copy over variables that sortable's _intersectsWith uses
					this.positionAbs = draggable.positionAbs;
					this.helperProportions = draggable.helperProportions;
					this.offset.click = draggable.offset.click;

					if ( this !== sortable &&
							this._intersectsWith( this.containerCache ) &&
							$.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
						innermostIntersecting = false;
					}

					return innermostIntersecting;
				} );
			}

			if ( innermostIntersecting ) {

				// If it intersects, we use a little isOver variable and set it once,
				// so that the move-in stuff gets fired only once.
				if ( !sortable.isOver ) {
					sortable.isOver = 1;

					// Store draggable's parent in case we need to reappend to it later.
					draggable._parent = ui.helper.parent();

					sortable.currentItem = ui.helper
						.appendTo( sortable.element )
						.data( "ui-sortable-item", true );

					// Store helper option to later restore it
					sortable.options._helper = sortable.options.helper;

					sortable.options.helper = function() {
						return ui.helper[ 0 ];
					};

					// Fire the start events of the sortable with our passed browser event,
					// and our own helper (so it doesn't create a new one)
					event.target = sortable.currentItem[ 0 ];
					sortable._mouseCapture( event, true );
					sortable._mouseStart( event, true, true );

					// Because the browser event is way off the new appended portlet,
					// modify necessary variables to reflect the changes
					sortable.offset.click.top = draggable.offset.click.top;
					sortable.offset.click.left = draggable.offset.click.left;
					sortable.offset.parent.left -= draggable.offset.parent.left -
						sortable.offset.parent.left;
					sortable.offset.parent.top -= draggable.offset.parent.top -
						sortable.offset.parent.top;

					draggable._trigger( "toSortable", event );

					// Inform draggable that the helper is in a valid drop zone,
					// used solely in the revert option to handle "valid/invalid".
					draggable.dropped = sortable.element;

					// Need to refreshPositions of all sortables in the case that
					// adding to one sortable changes the location of the other sortables (#9675)
					$.each( draggable.sortables, function() {
						this.refreshPositions();
					} );

					// Hack so receive/update callbacks work (mostly)
					draggable.currentItem = draggable.element;
					sortable.fromOutside = draggable;
				}

				if ( sortable.currentItem ) {
					sortable._mouseDrag( event );

					// Copy the sortable's position because the draggable's can potentially reflect
					// a relative position, while sortable is always absolute, which the dragged
					// element has now become. (#8809)
					ui.position = sortable.position;
				}
			} else {

				// If it doesn't intersect with the sortable, and it intersected before,
				// we fake the drag stop of the sortable, but make sure it doesn't remove
				// the helper by using cancelHelperRemoval.
				if ( sortable.isOver ) {

					sortable.isOver = 0;
					sortable.cancelHelperRemoval = true;

					// Calling sortable's mouseStop would trigger a revert,
					// so revert must be temporarily false until after mouseStop is called.
					sortable.options._revert = sortable.options.revert;
					sortable.options.revert = false;

					sortable._trigger( "out", event, sortable._uiHash( sortable ) );
					sortable._mouseStop( event, true );

					// Restore sortable behaviors that were modfied
					// when the draggable entered the sortable area (#9481)
					sortable.options.revert = sortable.options._revert;
					sortable.options.helper = sortable.options._helper;

					if ( sortable.placeholder ) {
						sortable.placeholder.remove();
					}

					// Restore and recalculate the draggable's offset considering the sortable
					// may have modified them in unexpected ways. (#8809, #10669)
					ui.helper.appendTo( draggable._parent );
					draggable._refreshOffsets( event );
					ui.position = draggable._generatePosition( event, true );

					draggable._trigger( "fromSortable", event );

					// Inform draggable that the helper is no longer in a valid drop zone
					draggable.dropped = false;

					// Need to refreshPositions of all sortables just in case removing
					// from one sortable changes the location of other sortables (#9675)
					$.each( draggable.sortables, function() {
						this.refreshPositions();
					} );
				}
			}
		} );
	}
} );

$.ui.plugin.add( "draggable", "cursor", {
	start: function( event, ui, instance ) {
		var t = $( "body" ),
			o = instance.options;

		if ( t.css( "cursor" ) ) {
			o._cursor = t.css( "cursor" );
		}
		t.css( "cursor", o.cursor );
	},
	stop: function( event, ui, instance ) {
		var o = instance.options;
		if ( o._cursor ) {
			$( "body" ).css( "cursor", o._cursor );
		}
	}
} );

$.ui.plugin.add( "draggable", "opacity", {
	start: function( event, ui, instance ) {
		var t = $( ui.helper ),
			o = instance.options;
		if ( t.css( "opacity" ) ) {
			o._opacity = t.css( "opacity" );
		}
		t.css( "opacity", o.opacity );
	},
	stop: function( event, ui, instance ) {
		var o = instance.options;
		if ( o._opacity ) {
			$( ui.helper ).css( "opacity", o._opacity );
		}
	}
} );

$.ui.plugin.add( "draggable", "scroll", {
	start: function( event, ui, i ) {
		if ( !i.scrollParentNotHidden ) {
			i.scrollParentNotHidden = i.helper.scrollParent( false );
		}

		if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
				i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
			i.overflowOffset = i.scrollParentNotHidden.offset();
		}
	},
	drag: function( event, ui, i  ) {

		var o = i.options,
			scrolled = false,
			scrollParent = i.scrollParentNotHidden[ 0 ],
			document = i.document[ 0 ];

		if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
			if ( !o.axis || o.axis !== "x" ) {
				if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
						o.scrollSensitivity ) {
					scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
				} else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
					scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
				}
			}

			if ( !o.axis || o.axis !== "y" ) {
				if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
						o.scrollSensitivity ) {
					scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
				} else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
					scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
				}
			}

		} else {

			if ( !o.axis || o.axis !== "x" ) {
				if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
					scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
				} else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
						o.scrollSensitivity ) {
					scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
				}
			}

			if ( !o.axis || o.axis !== "y" ) {
				if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
					scrolled = $( document ).scrollLeft(
						$( document ).scrollLeft() - o.scrollSpeed
					);
				} else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
						o.scrollSensitivity ) {
					scrolled = $( document ).scrollLeft(
						$( document ).scrollLeft() + o.scrollSpeed
					);
				}
			}

		}

		if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
			$.ui.ddmanager.prepareOffsets( i, event );
		}

	}
} );

$.ui.plugin.add( "draggable", "snap", {
	start: function( event, ui, i ) {

		var o = i.options;

		i.snapElements = [];

		$( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
			.each( function() {
				var $t = $( this ),
					$o = $t.offset();
				if ( this !== i.element[ 0 ] ) {
					i.snapElements.push( {
						item: this,
						width: $t.outerWidth(), height: $t.outerHeight(),
						top: $o.top, left: $o.left
					} );
				}
			} );

	},
	drag: function( event, ui, inst ) {

		var ts, bs, ls, rs, l, r, t, b, i, first,
			o = inst.options,
			d = o.snapTolerance,
			x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
			y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;

		for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {

			l = inst.snapElements[ i ].left - inst.margins.left;
			r = l + inst.snapElements[ i ].width;
			t = inst.snapElements[ i ].top - inst.margins.top;
			b = t + inst.snapElements[ i ].height;

			if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
					!$.contains( inst.snapElements[ i ].item.ownerDocument,
					inst.snapElements[ i ].item ) ) {
				if ( inst.snapElements[ i ].snapping ) {
					( inst.options.snap.release &&
						inst.options.snap.release.call(
							inst.element,
							event,
							$.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
						) );
				}
				inst.snapElements[ i ].snapping = false;
				continue;
			}

			if ( o.snapMode !== "inner" ) {
				ts = Math.abs( t - y2 ) <= d;
				bs = Math.abs( b - y1 ) <= d;
				ls = Math.abs( l - x2 ) <= d;
				rs = Math.abs( r - x1 ) <= d;
				if ( ts ) {
					ui.position.top = inst._convertPositionTo( "relative", {
						top: t - inst.helperProportions.height,
						left: 0
					} ).top;
				}
				if ( bs ) {
					ui.position.top = inst._convertPositionTo( "relative", {
						top: b,
						left: 0
					} ).top;
				}
				if ( ls ) {
					ui.position.left = inst._convertPositionTo( "relative", {
						top: 0,
						left: l - inst.helperProportions.width
					} ).left;
				}
				if ( rs ) {
					ui.position.left = inst._convertPositionTo( "relative", {
						top: 0,
						left: r
					} ).left;
				}
			}

			first = ( ts || bs || ls || rs );

			if ( o.snapMode !== "outer" ) {
				ts = Math.abs( t - y1 ) <= d;
				bs = Math.abs( b - y2 ) <= d;
				ls = Math.abs( l - x1 ) <= d;
				rs = Math.abs( r - x2 ) <= d;
				if ( ts ) {
					ui.position.top = inst._convertPositionTo( "relative", {
						top: t,
						left: 0
					} ).top;
				}
				if ( bs ) {
					ui.position.top = inst._convertPositionTo( "relative", {
						top: b - inst.helperProportions.height,
						left: 0
					} ).top;
				}
				if ( ls ) {
					ui.position.left = inst._convertPositionTo( "relative", {
						top: 0,
						left: l
					} ).left;
				}
				if ( rs ) {
					ui.position.left = inst._convertPositionTo( "relative", {
						top: 0,
						left: r - inst.helperProportions.width
					} ).left;
				}
			}

			if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
				( inst.options.snap.snap &&
					inst.options.snap.snap.call(
						inst.element,
						event,
						$.extend( inst._uiHash(), {
							snapItem: inst.snapElements[ i ].item
						} ) ) );
			}
			inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );

		}

	}
} );

$.ui.plugin.add( "draggable", "stack", {
	start: function( event, ui, instance ) {
		var min,
			o = instance.options,
			group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
				return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
					( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
			} );

		if ( !group.length ) { return; }

		min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
		$( group ).each( function( i ) {
			$( this ).css( "zIndex", min + i );
		} );
		this.css( "zIndex", ( min + group.length ) );
	}
} );

$.ui.plugin.add( "draggable", "zIndex", {
	start: function( event, ui, instance ) {
		var t = $( ui.helper ),
			o = instance.options;

		if ( t.css( "zIndex" ) ) {
			o._zIndex = t.css( "zIndex" );
		}
		t.css( "zIndex", o.zIndex );
	},
	stop: function( event, ui, instance ) {
		var o = instance.options;

		if ( o._zIndex ) {
			$( ui.helper ).css( "zIndex", o._zIndex );
		}
	}
} );

var widgetsDraggable = $.ui.draggable;


/*!
 * jQuery UI Resizable 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Resizable
//>>group: Interactions
//>>description: Enables resize functionality for any element.
//>>docs: http://api.jqueryui.com/resizable/
//>>demos: http://jqueryui.com/resizable/
//>>css.structure: ../../themes/base/core.css
//>>css.structure: ../../themes/base/resizable.css
//>>css.theme: ../../themes/base/theme.css



$.widget( "ui.resizable", $.ui.mouse, {
	version: "1.12.1",
	widgetEventPrefix: "resize",
	options: {
		alsoResize: false,
		animate: false,
		animateDuration: "slow",
		animateEasing: "swing",
		aspectRatio: false,
		autoHide: false,
		classes: {
			"ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
		},
		containment: false,
		ghost: false,
		grid: false,
		handles: "e,s,se",
		helper: false,
		maxHeight: null,
		maxWidth: null,
		minHeight: 10,
		minWidth: 10,

		// See #7960
		zIndex: 90,

		// Callbacks
		resize: null,
		start: null,
		stop: null
	},

	_num: function( value ) {
		return parseFloat( value ) || 0;
	},

	_isNumber: function( value ) {
		return !isNaN( parseFloat( value ) );
	},

	_hasScroll: function( el, a ) {

		if ( $( el ).css( "overflow" ) === "hidden" ) {
			return false;
		}

		var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
			has = false;

		if ( el[ scroll ] > 0 ) {
			return true;
		}

		// TODO: determine which cases actually cause this to happen
		// if the element doesn't have the scroll set, see if it's possible to
		// set the scroll
		el[ scroll ] = 1;
		has = ( el[ scroll ] > 0 );
		el[ scroll ] = 0;
		return has;
	},

	_create: function() {

		var margins,
			o = this.options,
			that = this;
		this._addClass( "ui-resizable" );

		$.extend( this, {
			_aspectRatio: !!( o.aspectRatio ),
			aspectRatio: o.aspectRatio,
			originalElement: this.element,
			_proportionallyResizeElements: [],
			_helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
		} );

		// Wrap the element if it cannot hold child nodes
		if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {

			this.element.wrap(
				$( "<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.resizable( "instance" )
			);

			this.elementIsWrapper = true;

			margins = {
				marginTop: this.originalElement.css( "marginTop" ),
				marginRight: this.originalElement.css( "marginRight" ),
				marginBottom: this.originalElement.css( "marginBottom" ),
				marginLeft: this.originalElement.css( "marginLeft" )
			};

			this.element.css( margins );
			this.originalElement.css( "margin", 0 );

			// support: Safari
			// Prevent Safari textarea resize
			this.originalResizeStyle = this.originalElement.css( "resize" );
			this.originalElement.css( "resize", "none" );

			this._proportionallyResizeElements.push( this.originalElement.css( {
				position: "static",
				zoom: 1,
				display: "block"
			} ) );

			// Support: IE9
			// avoid IE jump (hard set the margin)
			this.originalElement.css( margins );

			this._proportionallyResize();
		}

		this._setupHandles();

		if ( o.autoHide ) {
			$( this.element )
				.on( "mouseenter", function() {
					if ( o.disabled ) {
						return;
					}
					that._removeClass( "ui-resizable-autohide" );
					that._handles.show();
				} )
				.on( "mouseleave", function() {
					if ( o.disabled ) {
						return;
					}
					if ( !that.resizing ) {
						that._addClass( "ui-resizable-autohide" );
						that._handles.hide();
					}
				} );
		}

		this._mouseInit();
	},

	_destroy: function() {

		this._mouseDestroy();

		var wrapper,
			_destroy = function( exp ) {
				$( exp )
					.removeData( "resizable" )
					.removeData( "ui-resizable" )
					.off( ".resizable" )
					.find( ".ui-resizable-handle" )
						.remove();
			};

		// TODO: Unwrap at same DOM position
		if ( this.elementIsWrapper ) {
			_destroy( this.element );
			wrapper = this.element;
			this.originalElement.css( {
				position: wrapper.css( "position" ),
				width: wrapper.outerWidth(),
				height: wrapper.outerHeight(),
				top: wrapper.css( "top" ),
				left: wrapper.css( "left" )
			} ).insertAfter( wrapper );
			wrapper.remove();
		}

		this.originalElement.css( "resize", this.originalResizeStyle );
		_destroy( this.originalElement );

		return this;
	},

	_setOption: function( key, value ) {
		this._super( key, value );

		switch ( key ) {
		case "handles":
			this._removeHandles();
			this._setupHandles();
			break;
		default:
			break;
		}
	},

	_setupHandles: function() {
		var o = this.options, handle, i, n, hname, axis, that = this;
		this.handles = o.handles ||
			( !$( ".ui-resizable-handle", this.element ).length ?
				"e,s,se" : {
					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"
				} );

		this._handles = $();
		if ( this.handles.constructor === String ) {

			if ( this.handles === "all" ) {
				this.handles = "n,e,s,w,se,sw,ne,nw";
			}

			n = this.handles.split( "," );
			this.handles = {};

			for ( i = 0; i < n.length; i++ ) {

				handle = $.trim( n[ i ] );
				hname = "ui-resizable-" + handle;
				axis = $( "<div>" );
				this._addClass( axis, "ui-resizable-handle " + hname );

				axis.css( { zIndex: o.zIndex } );

				this.handles[ handle ] = ".ui-resizable-" + handle;
				this.element.append( axis );
			}

		}

		this._renderAxis = function( target ) {

			var i, axis, padPos, padWrapper;

			target = target || this.element;

			for ( i in this.handles ) {

				if ( this.handles[ i ].constructor === String ) {
					this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
				} else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
					this.handles[ i ] = $( this.handles[ i ] );
					this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
				}

				if ( this.elementIsWrapper &&
						this.originalElement[ 0 ]
							.nodeName
							.match( /^(textarea|input|select|button)$/i ) ) {
					axis = $( this.handles[ i ], this.element );

					padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
						axis.outerHeight() :
						axis.outerWidth();

					padPos = [ "padding",
						/ne|nw|n/.test( i ) ? "Top" :
						/se|sw|s/.test( i ) ? "Bottom" :
						/^e$/.test( i ) ? "Right" : "Left" ].join( "" );

					target.css( padPos, padWrapper );

					this._proportionallyResize();
				}

				this._handles = this._handles.add( this.handles[ i ] );
			}
		};

		// TODO: make renderAxis a prototype function
		this._renderAxis( this.element );

		this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
		this._handles.disableSelection();

		this._handles.on( "mouseover", function() {
			if ( !that.resizing ) {
				if ( this.className ) {
					axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
				}
				that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
			}
		} );

		if ( o.autoHide ) {
			this._handles.hide();
			this._addClass( "ui-resizable-autohide" );
		}
	},

	_removeHandles: function() {
		this._handles.remove();
	},

	_mouseCapture: function( event ) {
		var i, handle,
			capture = false;

		for ( i in this.handles ) {
			handle = $( this.handles[ i ] )[ 0 ];
			if ( handle === event.target || $.contains( handle, event.target ) ) {
				capture = true;
			}
		}

		return !this.options.disabled && capture;
	},

	_mouseStart: function( event ) {

		var curleft, curtop, cursor,
			o = this.options,
			el = this.element;

		this.resizing = true;

		this._renderProxy();

		curleft = this._num( this.helper.css( "left" ) );
		curtop = this._num( this.helper.css( "top" ) );

		if ( o.containment ) {
			curleft += $( o.containment ).scrollLeft() || 0;
			curtop += $( o.containment ).scrollTop() || 0;
		}

		this.offset = this.helper.offset();
		this.position = { left: curleft, top: curtop };

		this.size = this._helper ? {
				width: this.helper.width(),
				height: this.helper.height()
			} : {
				width: el.width(),
				height: el.height()
			};

		this.originalSize = this._helper ? {
				width: el.outerWidth(),
				height: el.outerHeight()
			} : {
				width: el.width(),
				height: el.height()
			};

		this.sizeDiff = {
			width: el.outerWidth() - el.width(),
			height: el.outerHeight() - el.height()
		};

		this.originalPosition = { left: curleft, top: curtop };
		this.originalMousePosition = { left: event.pageX, top: event.pageY };

		this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
			o.aspectRatio :
			( ( this.originalSize.width / this.originalSize.height ) || 1 );

		cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
		$( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );

		this._addClass( "ui-resizable-resizing" );
		this._propagate( "start", event );
		return true;
	},

	_mouseDrag: function( event ) {

		var data, props,
			smp = this.originalMousePosition,
			a = this.axis,
			dx = ( event.pageX - smp.left ) || 0,
			dy = ( event.pageY - smp.top ) || 0,
			trigger = this._change[ a ];

		this._updatePrevProperties();

		if ( !trigger ) {
			return false;
		}

		data = trigger.apply( this, [ event, dx, dy ] );

		this._updateVirtualBoundaries( event.shiftKey );
		if ( this._aspectRatio || event.shiftKey ) {
			data = this._updateRatio( data, event );
		}

		data = this._respectSize( data, event );

		this._updateCache( data );

		this._propagate( "resize", event );

		props = this._applyChanges();

		if ( !this._helper && this._proportionallyResizeElements.length ) {
			this._proportionallyResize();
		}

		if ( !$.isEmptyObject( props ) ) {
			this._updatePrevProperties();
			this._trigger( "resize", event, this.ui() );
			this._applyChanges();
		}

		return false;
	},

	_mouseStop: function( event ) {

		this.resizing = false;
		var pr, ista, soffseth, soffsetw, s, left, top,
			o = this.options, that = this;

		if ( this._helper ) {

			pr = this._proportionallyResizeElements;
			ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
			soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
			soffsetw = ista ? 0 : that.sizeDiff.width;

			s = {
				width: ( that.helper.width()  - soffsetw ),
				height: ( that.helper.height() - soffseth )
			};
			left = ( parseFloat( that.element.css( "left" ) ) +
				( that.position.left - that.originalPosition.left ) ) || null;
			top = ( parseFloat( that.element.css( "top" ) ) +
				( that.position.top - that.originalPosition.top ) ) || null;

			if ( !o.animate ) {
				this.element.css( $.extend( s, { top: top, left: left } ) );
			}

			that.helper.height( that.size.height );
			that.helper.width( that.size.width );

			if ( this._helper && !o.animate ) {
				this._proportionallyResize();
			}
		}

		$( "body" ).css( "cursor", "auto" );

		this._removeClass( "ui-resizable-resizing" );

		this._propagate( "stop", event );

		if ( this._helper ) {
			this.helper.remove();
		}

		return false;

	},

	_updatePrevProperties: function() {
		this.prevPosition = {
			top: this.position.top,
			left: this.position.left
		};
		this.prevSize = {
			width: this.size.width,
			height: this.size.height
		};
	},

	_applyChanges: function() {
		var props = {};

		if ( this.position.top !== this.prevPosition.top ) {
			props.top = this.position.top + "px";
		}
		if ( this.position.left !== this.prevPosition.left ) {
			props.left = this.position.left + "px";
		}
		if ( this.size.width !== this.prevSize.width ) {
			props.width = this.size.width + "px";
		}
		if ( this.size.height !== this.prevSize.height ) {
			props.height = this.size.height + "px";
		}

		this.helper.css( props );

		return props;
	},

	_updateVirtualBoundaries: function( forceAspectRatio ) {
		var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
			o = this.options;

		b = {
			minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
			maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
			minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
			maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
		};

		if ( this._aspectRatio || forceAspectRatio ) {
			pMinWidth = b.minHeight * this.aspectRatio;
			pMinHeight = b.minWidth / this.aspectRatio;
			pMaxWidth = b.maxHeight * this.aspectRatio;
			pMaxHeight = b.maxWidth / this.aspectRatio;

			if ( pMinWidth > b.minWidth ) {
				b.minWidth = pMinWidth;
			}
			if ( pMinHeight > b.minHeight ) {
				b.minHeight = pMinHeight;
			}
			if ( pMaxWidth < b.maxWidth ) {
				b.maxWidth = pMaxWidth;
			}
			if ( pMaxHeight < b.maxHeight ) {
				b.maxHeight = pMaxHeight;
			}
		}
		this._vBoundaries = b;
	},

	_updateCache: function( data ) {
		this.offset = this.helper.offset();
		if ( this._isNumber( data.left ) ) {
			this.position.left = data.left;
		}
		if ( this._isNumber( data.top ) ) {
			this.position.top = data.top;
		}
		if ( this._isNumber( data.height ) ) {
			this.size.height = data.height;
		}
		if ( this._isNumber( data.width ) ) {
			this.size.width = data.width;
		}
	},

	_updateRatio: function( data ) {

		var cpos = this.position,
			csize = this.size,
			a = this.axis;

		if ( this._isNumber( data.height ) ) {
			data.width = ( data.height * this.aspectRatio );
		} else if ( this._isNumber( data.width ) ) {
			data.height = ( data.width / this.aspectRatio );
		}

		if ( a === "sw" ) {
			data.left = cpos.left + ( csize.width - data.width );
			data.top = null;
		}
		if ( a === "nw" ) {
			data.top = cpos.top + ( csize.height - data.height );
			data.left = cpos.left + ( csize.width - data.width );
		}

		return data;
	},

	_respectSize: function( data ) {

		var o = this._vBoundaries,
			a = this.axis,
			ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
			ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
			isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
			isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
			dw = this.originalPosition.left + this.originalSize.width,
			dh = this.originalPosition.top + this.originalSize.height,
			cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
		if ( isminw ) {
			data.width = o.minWidth;
		}
		if ( isminh ) {
			data.height = o.minHeight;
		}
		if ( ismaxw ) {
			data.width = o.maxWidth;
		}
		if ( ismaxh ) {
			data.height = o.maxHeight;
		}

		if ( isminw && cw ) {
			data.left = dw - o.minWidth;
		}
		if ( ismaxw && cw ) {
			data.left = dw - o.maxWidth;
		}
		if ( isminh && ch ) {
			data.top = dh - o.minHeight;
		}
		if ( ismaxh && ch ) {
			data.top = dh - o.maxHeight;
		}

		// Fixing jump error on top/left - bug #2330
		if ( !data.width && !data.height && !data.left && data.top ) {
			data.top = null;
		} else if ( !data.width && !data.height && !data.top && data.left ) {
			data.left = null;
		}

		return data;
	},

	_getPaddingPlusBorderDimensions: function( element ) {
		var i = 0,
			widths = [],
			borders = [
				element.css( "borderTopWidth" ),
				element.css( "borderRightWidth" ),
				element.css( "borderBottomWidth" ),
				element.css( "borderLeftWidth" )
			],
			paddings = [
				element.css( "paddingTop" ),
				element.css( "paddingRight" ),
				element.css( "paddingBottom" ),
				element.css( "paddingLeft" )
			];

		for ( ; i < 4; i++ ) {
			widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
			widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
		}

		return {
			height: widths[ 0 ] + widths[ 2 ],
			width: widths[ 1 ] + widths[ 3 ]
		};
	},

	_proportionallyResize: function() {

		if ( !this._proportionallyResizeElements.length ) {
			return;
		}

		var prel,
			i = 0,
			element = this.helper || this.element;

		for ( ; i < this._proportionallyResizeElements.length; i++ ) {

			prel = this._proportionallyResizeElements[ i ];

			// TODO: Seems like a bug to cache this.outerDimensions
			// considering that we are in a loop.
			if ( !this.outerDimensions ) {
				this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
			}

			prel.css( {
				height: ( element.height() - this.outerDimensions.height ) || 0,
				width: ( element.width() - this.outerDimensions.width ) || 0
			} );

		}

	},

	_renderProxy: function() {

		var el = this.element, o = this.options;
		this.elementOffset = el.offset();

		if ( this._helper ) {

			this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );

			this._addClass( this.helper, this._helper );
			this.helper.css( {
				width: this.element.outerWidth(),
				height: this.element.outerHeight(),
				position: "absolute",
				left: this.elementOffset.left + "px",
				top: this.elementOffset.top + "px",
				zIndex: ++o.zIndex //TODO: Don't modify option
			} );

			this.helper
				.appendTo( "body" )
				.disableSelection();

		} else {
			this.helper = this.element;
		}

	},

	_change: {
		e: function( event, dx ) {
			return { width: this.originalSize.width + dx };
		},
		w: function( event, dx ) {
			var cs = this.originalSize, sp = this.originalPosition;
			return { left: sp.left + dx, width: cs.width - dx };
		},
		n: function( event, dx, dy ) {
			var cs = this.originalSize, sp = this.originalPosition;
			return { top: sp.top + dy, height: cs.height - dy };
		},
		s: function( event, dx, dy ) {
			return { height: this.originalSize.height + dy };
		},
		se: function( event, dx, dy ) {
			return $.extend( this._change.s.apply( this, arguments ),
				this._change.e.apply( this, [ event, dx, dy ] ) );
		},
		sw: function( event, dx, dy ) {
			return $.extend( this._change.s.apply( this, arguments ),
				this._change.w.apply( this, [ event, dx, dy ] ) );
		},
		ne: function( event, dx, dy ) {
			return $.extend( this._change.n.apply( this, arguments ),
				this._change.e.apply( this, [ event, dx, dy ] ) );
		},
		nw: function( event, dx, dy ) {
			return $.extend( this._change.n.apply( this, arguments ),
				this._change.w.apply( this, [ event, dx, dy ] ) );
		}
	},

	_propagate: function( n, event ) {
		$.ui.plugin.call( this, n, [ event, this.ui() ] );
		( n !== "resize" && this._trigger( n, event, 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
		};
	}

} );

/*
 * Resizable Extensions
 */

$.ui.plugin.add( "resizable", "animate", {

	stop: function( event ) {
		var that = $( this ).resizable( "instance" ),
			o = that.options,
			pr = that._proportionallyResizeElements,
			ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
			soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
			soffsetw = ista ? 0 : that.sizeDiff.width,
			style = {
				width: ( that.size.width - soffsetw ),
				height: ( that.size.height - soffseth )
			},
			left = ( parseFloat( that.element.css( "left" ) ) +
				( that.position.left - that.originalPosition.left ) ) || null,
			top = ( parseFloat( that.element.css( "top" ) ) +
				( that.position.top - that.originalPosition.top ) ) || null;

		that.element.animate(
			$.extend( style, top && left ? { top: top, left: left } : {} ), {
				duration: o.animateDuration,
				easing: o.animateEasing,
				step: function() {

					var data = {
						width: parseFloat( that.element.css( "width" ) ),
						height: parseFloat( that.element.css( "height" ) ),
						top: parseFloat( that.element.css( "top" ) ),
						left: parseFloat( that.element.css( "left" ) )
					};

					if ( pr && pr.length ) {
						$( pr[ 0 ] ).css( { width: data.width, height: data.height } );
					}

					// Propagating resize, and updating values for each animation step
					that._updateCache( data );
					that._propagate( "resize", event );

				}
			}
		);
	}

} );

$.ui.plugin.add( "resizable", "containment", {

	start: function() {
		var element, p, co, ch, cw, width, height,
			that = $( this ).resizable( "instance" ),
			o = that.options,
			el = that.element,
			oc = o.containment,
			ce = ( oc instanceof $ ) ?
				oc.get( 0 ) :
				( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;

		if ( !ce ) {
			return;
		}

		that.containerElement = $( ce );

		if ( /document/.test( oc ) || oc === document ) {
			that.containerOffset = {
				left: 0,
				top: 0
			};
			that.containerPosition = {
				left: 0,
				top: 0
			};

			that.parentData = {
				element: $( document ),
				left: 0,
				top: 0,
				width: $( document ).width(),
				height: $( document ).height() || document.body.parentNode.scrollHeight
			};
		} else {
			element = $( ce );
			p = [];
			$( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
				p[ i ] = that._num( element.css( "padding" + name ) );
			} );

			that.containerOffset = element.offset();
			that.containerPosition = element.position();
			that.containerSize = {
				height: ( element.innerHeight() - p[ 3 ] ),
				width: ( element.innerWidth() - p[ 1 ] )
			};

			co = that.containerOffset;
			ch = that.containerSize.height;
			cw = that.containerSize.width;
			width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
			height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;

			that.parentData = {
				element: ce,
				left: co.left,
				top: co.top,
				width: width,
				height: height
			};
		}
	},

	resize: function( event ) {
		var woset, hoset, isParent, isOffsetRelative,
			that = $( this ).resizable( "instance" ),
			o = that.options,
			co = that.containerOffset,
			cp = that.position,
			pRatio = that._aspectRatio || event.shiftKey,
			cop = {
				top: 0,
				left: 0
			},
			ce = that.containerElement,
			continueResize = true;

		if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
			cop = co;
		}

		if ( cp.left < ( that._helper ? co.left : 0 ) ) {
			that.size.width = that.size.width +
				( that._helper ?
					( that.position.left - co.left ) :
					( that.position.left - cop.left ) );

			if ( pRatio ) {
				that.size.height = that.size.width / that.aspectRatio;
				continueResize = false;
			}
			that.position.left = o.helper ? co.left : 0;
		}

		if ( cp.top < ( that._helper ? co.top : 0 ) ) {
			that.size.height = that.size.height +
				( that._helper ?
					( that.position.top - co.top ) :
					that.position.top );

			if ( pRatio ) {
				that.size.width = that.size.height * that.aspectRatio;
				continueResize = false;
			}
			that.position.top = that._helper ? co.top : 0;
		}

		isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
		isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );

		if ( isParent && isOffsetRelative ) {
			that.offset.left = that.parentData.left + that.position.left;
			that.offset.top = that.parentData.top + that.position.top;
		} else {
			that.offset.left = that.element.offset().left;
			that.offset.top = that.element.offset().top;
		}

		woset = Math.abs( that.sizeDiff.width +
			( that._helper ?
				that.offset.left - cop.left :
				( that.offset.left - co.left ) ) );

		hoset = Math.abs( that.sizeDiff.height +
			( that._helper ?
				that.offset.top - cop.top :
				( that.offset.top - co.top ) ) );

		if ( woset + that.size.width >= that.parentData.width ) {
			that.size.width = that.parentData.width - woset;
			if ( pRatio ) {
				that.size.height = that.size.width / that.aspectRatio;
				continueResize = false;
			}
		}

		if ( hoset + that.size.height >= that.parentData.height ) {
			that.size.height = that.parentData.height - hoset;
			if ( pRatio ) {
				that.size.width = that.size.height * that.aspectRatio;
				continueResize = false;
			}
		}

		if ( !continueResize ) {
			that.position.left = that.prevPosition.left;
			that.position.top = that.prevPosition.top;
			that.size.width = that.prevSize.width;
			that.size.height = that.prevSize.height;
		}
	},

	stop: function() {
		var that = $( this ).resizable( "instance" ),
			o = that.options,
			co = that.containerOffset,
			cop = that.containerPosition,
			ce = that.containerElement,
			helper = $( that.helper ),
			ho = helper.offset(),
			w = helper.outerWidth() - that.sizeDiff.width,
			h = helper.outerHeight() - that.sizeDiff.height;

		if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
			$( this ).css( {
				left: ho.left - cop.left - co.left,
				width: w,
				height: h
			} );
		}

		if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
			$( this ).css( {
				left: ho.left - cop.left - co.left,
				width: w,
				height: h
			} );
		}
	}
} );

$.ui.plugin.add( "resizable", "alsoResize", {

	start: function() {
		var that = $( this ).resizable( "instance" ),
			o = that.options;

		$( o.alsoResize ).each( function() {
			var el = $( this );
			el.data( "ui-resizable-alsoresize", {
				width: parseFloat( el.width() ), height: parseFloat( el.height() ),
				left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
			} );
		} );
	},

	resize: function( event, ui ) {
		var that = $( this ).resizable( "instance" ),
			o = that.options,
			os = that.originalSize,
			op = that.originalPosition,
			delta = {
				height: ( that.size.height - os.height ) || 0,
				width: ( that.size.width - os.width ) || 0,
				top: ( that.position.top - op.top ) || 0,
				left: ( that.position.left - op.left ) || 0
			};

			$( o.alsoResize ).each( function() {
				var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
					css = el.parents( ui.originalElement[ 0 ] ).length ?
							[ "width", "height" ] :
							[ "width", "height", "top", "left" ];

				$.each( css, function( i, prop ) {
					var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
					if ( sum && sum >= 0 ) {
						style[ prop ] = sum || null;
					}
				} );

				el.css( style );
			} );
	},

	stop: function() {
		$( this ).removeData( "ui-resizable-alsoresize" );
	}
} );

$.ui.plugin.add( "resizable", "ghost", {

	start: function() {

		var that = $( this ).resizable( "instance" ), cs = that.size;

		that.ghost = that.originalElement.clone();
		that.ghost.css( {
			opacity: 0.25,
			display: "block",
			position: "relative",
			height: cs.height,
			width: cs.width,
			margin: 0,
			left: 0,
			top: 0
		} );

		that._addClass( that.ghost, "ui-resizable-ghost" );

		// DEPRECATED
		// TODO: remove after 1.12
		if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {

			// Ghost option
			that.ghost.addClass( this.options.ghost );
		}

		that.ghost.appendTo( that.helper );

	},

	resize: function() {
		var that = $( this ).resizable( "instance" );
		if ( that.ghost ) {
			that.ghost.css( {
				position: "relative",
				height: that.size.height,
				width: that.size.width
			} );
		}
	},

	stop: function() {
		var that = $( this ).resizable( "instance" );
		if ( that.ghost && that.helper ) {
			that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
		}
	}

} );

$.ui.plugin.add( "resizable", "grid", {

	resize: function() {
		var outerDimensions,
			that = $( this ).resizable( "instance" ),
			o = that.options,
			cs = that.size,
			os = that.originalSize,
			op = that.originalPosition,
			a = that.axis,
			grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
			gridX = ( grid[ 0 ] || 1 ),
			gridY = ( grid[ 1 ] || 1 ),
			ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
			oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
			newWidth = os.width + ox,
			newHeight = os.height + oy,
			isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
			isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
			isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
			isMinHeight = o.minHeight && ( o.minHeight > newHeight );

		o.grid = grid;

		if ( isMinWidth ) {
			newWidth += gridX;
		}
		if ( isMinHeight ) {
			newHeight += gridY;
		}
		if ( isMaxWidth ) {
			newWidth -= gridX;
		}
		if ( isMaxHeight ) {
			newHeight -= gridY;
		}

		if ( /^(se|s|e)$/.test( a ) ) {
			that.size.width = newWidth;
			that.size.height = newHeight;
		} else if ( /^(ne)$/.test( a ) ) {
			that.size.width = newWidth;
			that.size.height = newHeight;
			that.position.top = op.top - oy;
		} else if ( /^(sw)$/.test( a ) ) {
			that.size.width = newWidth;
			that.size.height = newHeight;
			that.position.left = op.left - ox;
		} else {
			if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
				outerDimensions = that._getPaddingPlusBorderDimensions( this );
			}

			if ( newHeight - gridY > 0 ) {
				that.size.height = newHeight;
				that.position.top = op.top - oy;
			} else {
				newHeight = gridY - outerDimensions.height;
				that.size.height = newHeight;
				that.position.top = op.top + os.height - newHeight;
			}
			if ( newWidth - gridX > 0 ) {
				that.size.width = newWidth;
				that.position.left = op.left - ox;
			} else {
				newWidth = gridX - outerDimensions.width;
				that.size.width = newWidth;
				that.position.left = op.left + os.width - newWidth;
			}
		}
	}

} );

var widgetsResizable = $.ui.resizable;


/*!
 * jQuery UI Sortable 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Sortable
//>>group: Interactions
//>>description: Enables items in a list to be sorted using the mouse.
//>>docs: http://api.jqueryui.com/sortable/
//>>demos: http://jqueryui.com/sortable/
//>>css.structure: ../../themes/base/sortable.css



var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
	version: "1.12.1",
	widgetEventPrefix: "sort",
	ready: false,
	options: {
		appendTo: "parent",
		axis: false,
		connectWith: false,
		containment: false,
		cursor: "auto",
		cursorAt: false,
		dropOnEmpty: true,
		forcePlaceholderSize: false,
		forceHelperSize: false,
		grid: false,
		handle: false,
		helper: "original",
		items: "> *",
		opacity: false,
		placeholder: false,
		revert: false,
		scroll: true,
		scrollSensitivity: 20,
		scrollSpeed: 20,
		scope: "default",
		tolerance: "intersect",
		zIndex: 1000,

		// Callbacks
		activate: null,
		beforeStop: null,
		change: null,
		deactivate: null,
		out: null,
		over: null,
		receive: null,
		remove: null,
		sort: null,
		start: null,
		stop: null,
		update: null
	},

	_isOverAxis: function( x, reference, size ) {
		return ( x >= reference ) && ( x < ( reference + size ) );
	},

	_isFloating: function( item ) {
		return ( /left|right/ ).test( item.css( "float" ) ) ||
			( /inline|table-cell/ ).test( item.css( "display" ) );
	},

	_create: function() {
		this.containerCache = {};
		this._addClass( "ui-sortable" );

		//Get the items
		this.refresh();

		//Let's determine the parent's offset
		this.offset = this.element.offset();

		//Initialize mouse events for interaction
		this._mouseInit();

		this._setHandleClassName();

		//We're ready to go
		this.ready = true;

	},

	_setOption: function( key, value ) {
		this._super( key, value );

		if ( key === "handle" ) {
			this._setHandleClassName();
		}
	},

	_setHandleClassName: function() {
		var that = this;
		this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
		$.each( this.items, function() {
			that._addClass(
				this.instance.options.handle ?
					this.item.find( this.instance.options.handle ) :
					this.item,
				"ui-sortable-handle"
			);
		} );
	},

	_destroy: function() {
		this._mouseDestroy();

		for ( var i = this.items.length - 1; i >= 0; i-- ) {
			this.items[ i ].item.removeData( this.widgetName + "-item" );
		}

		return this;
	},

	_mouseCapture: function( event, overrideHandle ) {
		var currentItem = null,
			validHandle = false,
			that = this;

		if ( this.reverting ) {
			return false;
		}

		if ( this.options.disabled || this.options.type === "static" ) {
			return false;
		}

		//We have to refresh the items data once first
		this._refreshItems( event );

		//Find out if the clicked node (or one of its parents) is a actual item in this.items
		$( event.target ).parents().each( function() {
			if ( $.data( this, that.widgetName + "-item" ) === that ) {
				currentItem = $( this );
				return false;
			}
		} );
		if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
			currentItem = $( event.target );
		}

		if ( !currentItem ) {
			return false;
		}
		if ( this.options.handle && !overrideHandle ) {
			$( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
				if ( this === event.target ) {
					validHandle = true;
				}
			} );
			if ( !validHandle ) {
				return false;
			}
		}

		this.currentItem = currentItem;
		this._removeCurrentsFromItems();
		return true;

	},

	_mouseStart: function( event, overrideHandle, noActivation ) {

		var i, body,
			o = this.options;

		this.currentContainer = this;

		//We only need to call refreshPositions, because the refreshItems call has been moved to
		// mouseCapture
		this.refreshPositions();

		//Create and append the visible helper
		this.helper = this._createHelper( event );

		//Cache the helper size
		this._cacheHelperProportions();

		/*
		 * - Position generation -
		 * This block generates everything position related - it's the core of draggables.
		 */

		//Cache the margins of the original element
		this._cacheMargins();

		//Get the next scrolling parent
		this.scrollParent = this.helper.scrollParent();

		//The element's absolute position on the page minus margins
		this.offset = this.currentItem.offset();
		this.offset = {
			top: this.offset.top - this.margins.top,
			left: this.offset.left - this.margins.left
		};

		$.extend( this.offset, {
			click: { //Where the click happened, relative to the element
				left: event.pageX - this.offset.left,
				top: event.pageY - this.offset.top
			},
			parent: this._getParentOffset(),

			// This is a relative to absolute position minus the actual position calculation -
			// only used for relative positioned helper
			relative: this._getRelativeOffset()
		} );

		// Only after we got the offset, we can change the helper's position to absolute
		// TODO: Still need to figure out a way to make relative sorting possible
		this.helper.css( "position", "absolute" );
		this.cssPosition = this.helper.css( "position" );

		//Generate the original position
		this.originalPosition = this._generatePosition( event );
		this.originalPageX = event.pageX;
		this.originalPageY = event.pageY;

		//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
		( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );

		//Cache the former DOM position
		this.domPosition = {
			prev: this.currentItem.prev()[ 0 ],
			parent: this.currentItem.parent()[ 0 ]
		};

		// If the helper is not the original, hide the original so it's not playing any role during
		// the drag, won't cause anything bad this way
		if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
			this.currentItem.hide();
		}

		//Create the placeholder
		this._createPlaceholder();

		//Set a containment if given in the options
		if ( o.containment ) {
			this._setContainment();
		}

		if ( o.cursor && o.cursor !== "auto" ) { // cursor option
			body = this.document.find( "body" );

			// Support: IE
			this.storedCursor = body.css( "cursor" );
			body.css( "cursor", o.cursor );

			this.storedStylesheet =
				$( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
		}

		if ( o.opacity ) { // opacity option
			if ( this.helper.css( "opacity" ) ) {
				this._storedOpacity = this.helper.css( "opacity" );
			}
			this.helper.css( "opacity", o.opacity );
		}

		if ( o.zIndex ) { // zIndex option
			if ( this.helper.css( "zIndex" ) ) {
				this._storedZIndex = this.helper.css( "zIndex" );
			}
			this.helper.css( "zIndex", o.zIndex );
		}

		//Prepare scrolling
		if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
				this.scrollParent[ 0 ].tagName !== "HTML" ) {
			this.overflowOffset = this.scrollParent.offset();
		}

		//Call callbacks
		this._trigger( "start", event, this._uiHash() );

		//Recache the helper size
		if ( !this._preserveHelperProportions ) {
			this._cacheHelperProportions();
		}

		//Post "activate" events to possible containers
		if ( !noActivation ) {
			for ( i = this.containers.length - 1; i >= 0; i-- ) {
				this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
			}
		}

		//Prepare possible droppables
		if ( $.ui.ddmanager ) {
			$.ui.ddmanager.current = this;
		}

		if ( $.ui.ddmanager && !o.dropBehaviour ) {
			$.ui.ddmanager.prepareOffsets( this, event );
		}

		this.dragging = true;

		this._addClass( this.helper, "ui-sortable-helper" );

		// Execute the drag once - this causes the helper not to be visiblebefore getting its
		// correct position
		this._mouseDrag( event );
		return true;

	},

	_mouseDrag: function( event ) {
		var i, item, itemElement, intersection,
			o = this.options,
			scrolled = false;

		//Compute the helpers position
		this.position = this._generatePosition( event );
		this.positionAbs = this._convertPositionTo( "absolute" );

		if ( !this.lastPositionAbs ) {
			this.lastPositionAbs = this.positionAbs;
		}

		//Do scrolling
		if ( this.options.scroll ) {
			if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
					this.scrollParent[ 0 ].tagName !== "HTML" ) {

				if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
						event.pageY < o.scrollSensitivity ) {
					this.scrollParent[ 0 ].scrollTop =
						scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
				} else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
					this.scrollParent[ 0 ].scrollTop =
						scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
				}

				if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
						event.pageX < o.scrollSensitivity ) {
					this.scrollParent[ 0 ].scrollLeft = scrolled =
						this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
				} else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
					this.scrollParent[ 0 ].scrollLeft = scrolled =
						this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
				}

			} else {

				if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
					scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
				} else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
						o.scrollSensitivity ) {
					scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
				}

				if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
					scrolled = this.document.scrollLeft(
						this.document.scrollLeft() - o.scrollSpeed
					);
				} else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
						o.scrollSensitivity ) {
					scrolled = this.document.scrollLeft(
						this.document.scrollLeft() + o.scrollSpeed
					);
				}

			}

			if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
				$.ui.ddmanager.prepareOffsets( this, event );
			}
		}

		//Regenerate the absolute position used for position checks
		this.positionAbs = this._convertPositionTo( "absolute" );

		//Set the helper 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";
		}

		//Rearrange
		for ( i = this.items.length - 1; i >= 0; i-- ) {

			//Cache variables and intersection, continue if no intersection
			item = this.items[ i ];
			itemElement = item.item[ 0 ];
			intersection = this._intersectsWithPointer( item );
			if ( !intersection ) {
				continue;
			}

			// Only put the placeholder inside the current Container, skip all
			// items from other containers. This works because when moving
			// an item from one container to another the
			// currentContainer is switched before the placeholder is moved.
			//
			// Without this, moving items in "sub-sortables" can cause
			// the placeholder to jitter between the outer and inner container.
			if ( item.instance !== this.currentContainer ) {
				continue;
			}

			// Cannot intersect with itself
			// no useless actions that have been done before
			// no action if the item moved is the parent of the item checked
			if ( itemElement !== this.currentItem[ 0 ] &&
				this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
				!$.contains( this.placeholder[ 0 ], itemElement ) &&
				( this.options.type === "semi-dynamic" ?
					!$.contains( this.element[ 0 ], itemElement ) :
					true
				)
			) {

				this.direction = intersection === 1 ? "down" : "up";

				if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
					this._rearrange( event, item );
				} else {
					break;
				}

				this._trigger( "change", event, this._uiHash() );
				break;
			}
		}

		//Post events to containers
		this._contactContainers( event );

		//Interconnect with droppables
		if ( $.ui.ddmanager ) {
			$.ui.ddmanager.drag( this, event );
		}

		//Call callbacks
		this._trigger( "sort", event, this._uiHash() );

		this.lastPositionAbs = this.positionAbs;
		return false;

	},

	_mouseStop: function( event, noPropagation ) {

		if ( !event ) {
			return;
		}

		//If we are using droppables, inform the manager about the drop
		if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
			$.ui.ddmanager.drop( this, event );
		}

		if ( this.options.revert ) {
			var that = this,
				cur = this.placeholder.offset(),
				axis = this.options.axis,
				animation = {};

			if ( !axis || axis === "x" ) {
				animation.left = cur.left - this.offset.parent.left - this.margins.left +
					( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
						0 :
						this.offsetParent[ 0 ].scrollLeft
					);
			}
			if ( !axis || axis === "y" ) {
				animation.top = cur.top - this.offset.parent.top - this.margins.top +
					( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
						0 :
						this.offsetParent[ 0 ].scrollTop
					);
			}
			this.reverting = true;
			$( this.helper ).animate(
				animation,
				parseInt( this.options.revert, 10 ) || 500,
				function() {
					that._clear( event );
				}
			);
		} else {
			this._clear( event, noPropagation );
		}

		return false;

	},

	cancel: function() {

		if ( this.dragging ) {

			this._mouseUp( new $.Event( "mouseup", { target: null } ) );

			if ( this.options.helper === "original" ) {
				this.currentItem.css( this._storedCSS );
				this._removeClass( this.currentItem, "ui-sortable-helper" );
			} else {
				this.currentItem.show();
			}

			//Post deactivating events to containers
			for ( var i = this.containers.length - 1; i >= 0; i-- ) {
				this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
				if ( this.containers[ i ].containerCache.over ) {
					this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
					this.containers[ i ].containerCache.over = 0;
				}
			}

		}

		if ( this.placeholder ) {

			//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
			// it unbinds ALL events from the original node!
			if ( this.placeholder[ 0 ].parentNode ) {
				this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
			}
			if ( this.options.helper !== "original" && this.helper &&
					this.helper[ 0 ].parentNode ) {
				this.helper.remove();
			}

			$.extend( this, {
				helper: null,
				dragging: false,
				reverting: false,
				_noFinalSort: null
			} );

			if ( this.domPosition.prev ) {
				$( this.domPosition.prev ).after( this.currentItem );
			} else {
				$( this.domPosition.parent ).prepend( this.currentItem );
			}
		}

		return this;

	},

	serialize: function( o ) {

		var items = this._getItemsAsjQuery( o && o.connected ),
			str = [];
		o = o || {};

		$( items ).each( function() {
			var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
				.match( o.expression || ( /(.+)[\-=_](.+)/ ) );
			if ( res ) {
				str.push(
					( o.key || res[ 1 ] + "[]" ) +
					"=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
			}
		} );

		if ( !str.length && o.key ) {
			str.push( o.key + "=" );
		}

		return str.join( "&" );

	},

	toArray: function( o ) {

		var items = this._getItemsAsjQuery( o && o.connected ),
			ret = [];

		o = o || {};

		items.each( function() {
			ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
		} );
		return ret;

	},

	/* Be careful with the following core functions */
	_intersectsWith: function( item ) {

		var x1 = this.positionAbs.left,
			x2 = x1 + this.helperProportions.width,
			y1 = this.positionAbs.top,
			y2 = y1 + this.helperProportions.height,
			l = item.left,
			r = l + item.width,
			t = item.top,
			b = t + item.height,
			dyClick = this.offset.click.top,
			dxClick = this.offset.click.left,
			isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
				( y1 + dyClick ) < b ),
			isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
				( x1 + dxClick ) < r ),
			isOverElement = isOverElementHeight && isOverElementWidth;

		if ( this.options.tolerance === "pointer" ||
			this.options.forcePointerForContainers ||
			( this.options.tolerance !== "pointer" &&
				this.helperProportions[ this.floating ? "width" : "height" ] >
				item[ this.floating ? "width" : "height" ] )
		) {
			return isOverElement;
		} else {

			return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
				x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
				t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
				y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half

		}
	},

	_intersectsWithPointer: function( item ) {
		var verticalDirection, horizontalDirection,
			isOverElementHeight = ( this.options.axis === "x" ) ||
				this._isOverAxis(
					this.positionAbs.top + this.offset.click.top, item.top, item.height ),
			isOverElementWidth = ( this.options.axis === "y" ) ||
				this._isOverAxis(
					this.positionAbs.left + this.offset.click.left, item.left, item.width ),
			isOverElement = isOverElementHeight && isOverElementWidth;

		if ( !isOverElement ) {
			return false;
		}

		verticalDirection = this._getDragVerticalDirection();
		horizontalDirection = this._getDragHorizontalDirection();

		return this.floating ?
			( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
			: ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );

	},

	_intersectsWithSides: function( item ) {

		var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
				this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
			isOverRightHalf = this._isOverAxis( this.positionAbs.left +
				this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
			verticalDirection = this._getDragVerticalDirection(),
			horizontalDirection = this._getDragHorizontalDirection();

		if ( this.floating && horizontalDirection ) {
			return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
				( horizontalDirection === "left" && !isOverRightHalf ) );
		} else {
			return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
				( verticalDirection === "up" && !isOverBottomHalf ) );
		}

	},

	_getDragVerticalDirection: function() {
		var delta = this.positionAbs.top - this.lastPositionAbs.top;
		return delta !== 0 && ( delta > 0 ? "down" : "up" );
	},

	_getDragHorizontalDirection: function() {
		var delta = this.positionAbs.left - this.lastPositionAbs.left;
		return delta !== 0 && ( delta > 0 ? "right" : "left" );
	},

	refresh: function( event ) {
		this._refreshItems( event );
		this._setHandleClassName();
		this.refreshPositions();
		return this;
	},

	_connectWith: function() {
		var options = this.options;
		return options.connectWith.constructor === String ?
			[ options.connectWith ] :
			options.connectWith;
	},

	_getItemsAsjQuery: function( connected ) {

		var i, j, cur, inst,
			items = [],
			queries = [],
			connectWith = this._connectWith();

		if ( connectWith && connected ) {
			for ( i = connectWith.length - 1; i >= 0; i-- ) {
				cur = $( connectWith[ i ], this.document[ 0 ] );
				for ( j = cur.length - 1; j >= 0; j-- ) {
					inst = $.data( cur[ j ], this.widgetFullName );
					if ( inst && inst !== this && !inst.options.disabled ) {
						queries.push( [ $.isFunction( inst.options.items ) ?
							inst.options.items.call( inst.element ) :
							$( inst.options.items, inst.element )
								.not( ".ui-sortable-helper" )
								.not( ".ui-sortable-placeholder" ), inst ] );
					}
				}
			}
		}

		queries.push( [ $.isFunction( this.options.items ) ?
			this.options.items
				.call( this.element, null, { options: this.options, item: this.currentItem } ) :
			$( this.options.items, this.element )
				.not( ".ui-sortable-helper" )
				.not( ".ui-sortable-placeholder" ), this ] );

		function addItems() {
			items.push( this );
		}
		for ( i = queries.length - 1; i >= 0; i-- ) {
			queries[ i ][ 0 ].each( addItems );
		}

		return $( items );

	},

	_removeCurrentsFromItems: function() {

		var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );

		this.items = $.grep( this.items, function( item ) {
			for ( var j = 0; j < list.length; j++ ) {
				if ( list[ j ] === item.item[ 0 ] ) {
					return false;
				}
			}
			return true;
		} );

	},

	_refreshItems: function( event ) {

		this.items = [];
		this.containers = [ this ];

		var i, j, cur, inst, targetData, _queries, item, queriesLength,
			items = this.items,
			queries = [ [ $.isFunction( this.options.items ) ?
				this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
				$( this.options.items, this.element ), this ] ],
			connectWith = this._connectWith();

		//Shouldn't be run the first time through due to massive slow-down
		if ( connectWith && this.ready ) {
			for ( i = connectWith.length - 1; i >= 0; i-- ) {
				cur = $( connectWith[ i ], this.document[ 0 ] );
				for ( j = cur.length - 1; j >= 0; j-- ) {
					inst = $.data( cur[ j ], this.widgetFullName );
					if ( inst && inst !== this && !inst.options.disabled ) {
						queries.push( [ $.isFunction( inst.options.items ) ?
							inst.options.items
								.call( inst.element[ 0 ], event, { item: this.currentItem } ) :
							$( inst.options.items, inst.element ), inst ] );
						this.containers.push( inst );
					}
				}
			}
		}

		for ( i = queries.length - 1; i >= 0; i-- ) {
			targetData = queries[ i ][ 1 ];
			_queries = queries[ i ][ 0 ];

			for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
				item = $( _queries[ j ] );

				// Data for target checking (mouse manager)
				item.data( this.widgetName + "-item", targetData );

				items.push( {
					item: item,
					instance: targetData,
					width: 0, height: 0,
					left: 0, top: 0
				} );
			}
		}

	},

	refreshPositions: function( fast ) {

		// Determine whether items are being displayed horizontally
		this.floating = this.items.length ?
			this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
			false;

		//This has to be redone because due to the item being moved out/into the offsetParent,
		// the offsetParent's position will change
		if ( this.offsetParent && this.helper ) {
			this.offset.parent = this._getParentOffset();
		}

		var i, item, t, p;

		for ( i = this.items.length - 1; i >= 0; i-- ) {
			item = this.items[ i ];

			//We ignore calculating positions of all connected containers when we're not over them
			if ( item.instance !== this.currentContainer && this.currentContainer &&
					item.item[ 0 ] !== this.currentItem[ 0 ] ) {
				continue;
			}

			t = this.options.toleranceElement ?
				$( this.options.toleranceElement, item.item ) :
				item.item;

			if ( !fast ) {
				item.width = t.outerWidth();
				item.height = t.outerHeight();
			}

			p = t.offset();
			item.left = p.left;
			item.top = p.top;
		}

		if ( this.options.custom && this.options.custom.refreshContainers ) {
			this.options.custom.refreshContainers.call( this );
		} else {
			for ( i = this.containers.length - 1; i >= 0; i-- ) {
				p = this.containers[ i ].element.offset();
				this.containers[ i ].containerCache.left = p.left;
				this.containers[ i ].containerCache.top = p.top;
				this.containers[ i ].containerCache.width =
					this.containers[ i ].element.outerWidth();
				this.containers[ i ].containerCache.height =
					this.containers[ i ].element.outerHeight();
			}
		}

		return this;
	},

	_createPlaceholder: function( that ) {
		that = that || this;
		var className,
			o = that.options;

		if ( !o.placeholder || o.placeholder.constructor === String ) {
			className = o.placeholder;
			o.placeholder = {
				element: function() {

					var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
						element = $( "<" + nodeName + ">", that.document[ 0 ] );

						that._addClass( element, "ui-sortable-placeholder",
								className || that.currentItem[ 0 ].className )
							._removeClass( element, "ui-sortable-helper" );

					if ( nodeName === "tbody" ) {
						that._createTrPlaceholder(
							that.currentItem.find( "tr" ).eq( 0 ),
							$( "<tr>", that.document[ 0 ] ).appendTo( element )
						);
					} else if ( nodeName === "tr" ) {
						that._createTrPlaceholder( that.currentItem, element );
					} else if ( nodeName === "img" ) {
						element.attr( "src", that.currentItem.attr( "src" ) );
					}

					if ( !className ) {
						element.css( "visibility", "hidden" );
					}

					return element;
				},
				update: function( container, p ) {

					// 1. If a className is set as 'placeholder option, we don't force sizes -
					// the class is responsible for that
					// 2. The option 'forcePlaceholderSize can be enabled to force it even if a
					// class name is specified
					if ( className && !o.forcePlaceholderSize ) {
						return;
					}

					//If the element doesn't have a actual height by itself (without styles coming
					// from a stylesheet), it receives the inline height from the dragged item
					if ( !p.height() ) {
						p.height(
							that.currentItem.innerHeight() -
							parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
							parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
					}
					if ( !p.width() ) {
						p.width(
							that.currentItem.innerWidth() -
							parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
							parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
					}
				}
			};
		}

		//Create the placeholder
		that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );

		//Append it after the actual current item
		that.currentItem.after( that.placeholder );

		//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
		o.placeholder.update( that, that.placeholder );

	},

	_createTrPlaceholder: function( sourceTr, targetTr ) {
		var that = this;

		sourceTr.children().each( function() {
			$( "<td>&#160;</td>", that.document[ 0 ] )
				.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
				.appendTo( targetTr );
		} );
	},

	_contactContainers: function( event ) {
		var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
			floating, axis,
			innermostContainer = null,
			innermostIndex = null;

		// Get innermost container that intersects with item
		for ( i = this.containers.length - 1; i >= 0; i-- ) {

			// Never consider a container that's located within the item itself
			if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
				continue;
			}

			if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {

				// If we've already found a container and it's more "inner" than this, then continue
				if ( innermostContainer &&
						$.contains(
							this.containers[ i ].element[ 0 ],
							innermostContainer.element[ 0 ] ) ) {
					continue;
				}

				innermostContainer = this.containers[ i ];
				innermostIndex = i;

			} else {

				// container doesn't intersect. trigger "out" event if necessary
				if ( this.containers[ i ].containerCache.over ) {
					this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
					this.containers[ i ].containerCache.over = 0;
				}
			}

		}

		// If no intersecting containers found, return
		if ( !innermostContainer ) {
			return;
		}

		// Move the item into the container if it's not there already
		if ( this.containers.length === 1 ) {
			if ( !this.containers[ innermostIndex ].containerCache.over ) {
				this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
				this.containers[ innermostIndex ].containerCache.over = 1;
			}
		} else {

			// When entering a new container, we will find the item with the least distance and
			// append our item near it
			dist = 10000;
			itemWithLeastDistance = null;
			floating = innermostContainer.floating || this._isFloating( this.currentItem );
			posProperty = floating ? "left" : "top";
			sizeProperty = floating ? "width" : "height";
			axis = floating ? "pageX" : "pageY";

			for ( j = this.items.length - 1; j >= 0; j-- ) {
				if ( !$.contains(
						this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
				) {
					continue;
				}
				if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
					continue;
				}

				cur = this.items[ j ].item.offset()[ posProperty ];
				nearBottom = false;
				if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
					nearBottom = true;
				}

				if ( Math.abs( event[ axis ] - cur ) < dist ) {
					dist = Math.abs( event[ axis ] - cur );
					itemWithLeastDistance = this.items[ j ];
					this.direction = nearBottom ? "up" : "down";
				}
			}

			//Check if dropOnEmpty is enabled
			if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
				return;
			}

			if ( this.currentContainer === this.containers[ innermostIndex ] ) {
				if ( !this.currentContainer.containerCache.over ) {
					this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
					this.currentContainer.containerCache.over = 1;
				}
				return;
			}

			itemWithLeastDistance ?
				this._rearrange( event, itemWithLeastDistance, null, true ) :
				this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
			this._trigger( "change", event, this._uiHash() );
			this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
			this.currentContainer = this.containers[ innermostIndex ];

			//Update the placeholder
			this.options.placeholder.update( this.currentContainer, this.placeholder );

			this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
			this.containers[ innermostIndex ].containerCache.over = 1;
		}

	},

	_createHelper: function( event ) {

		var o = this.options,
			helper = $.isFunction( o.helper ) ?
				$( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
				( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );

		//Add the helper to the DOM if that didn't happen already
		if ( !helper.parents( "body" ).length ) {
			$( o.appendTo !== "parent" ?
				o.appendTo :
				this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
		}

		if ( helper[ 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" )
			};
		}

		if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
			helper.width( this.currentItem.width() );
		}
		if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
			helper.height( this.currentItem.height() );
		}

		return helper;

	},

	_adjustOffsetFromHelper: function( obj ) {
		if ( typeof obj === "string" ) {
			obj = obj.split( " " );
		}
		if ( $.isArray( obj ) ) {
			obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
		}
		if ( "left" in obj ) {
			this.offset.click.left = obj.left + this.margins.left;
		}
		if ( "right" in obj ) {
			this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
		}
		if ( "top" in obj ) {
			this.offset.click.top = obj.top + this.margins.top;
		}
		if ( "bottom" in obj ) {
			this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
		}
	},

	_getParentOffset: function() {

		//Get the offsetParent and cache its position
		this.offsetParent = this.helper.offsetParent();
		var po = this.offsetParent.offset();

		// This is a special case where we need to modify a offset calculated on start, since the
		// following happened:
		// 1. The position of the helper is absolute, so it's position is calculated based on the
		// next positioned parent
		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
		// the document, which means that the scroll is included in the initial calculation of the
		// offset of the parent, and never recalculated upon drag
		if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
			po.left += this.scrollParent.scrollLeft();
			po.top += this.scrollParent.scrollTop();
		}

		// This needs to be actually done for all browsers, since pageX/pageY includes this
		// information with an ugly IE fix
		if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
				( this.offsetParent[ 0 ].tagName &&
				this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
			po = { top: 0, left: 0 };
		}

		return {
			top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
			left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
		};

	},

	_getRelativeOffset: function() {

		if ( this.cssPosition === "relative" ) {
			var p = this.currentItem.position();
			return {
				top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
					this.scrollParent.scrollTop(),
				left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
					this.scrollParent.scrollLeft()
			};
		} else {
			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 ce, co, over,
			o = this.options;
		if ( o.containment === "parent" ) {
			o.containment = this.helper[ 0 ].parentNode;
		}
		if ( o.containment === "document" || o.containment === "window" ) {
			this.containment = [
				0 - this.offset.relative.left - this.offset.parent.left,
				0 - this.offset.relative.top - this.offset.parent.top,
				o.containment === "document" ?
					this.document.width() :
					this.window.width() - this.helperProportions.width - this.margins.left,
				( o.containment === "document" ?
					( this.document.height() || document.body.parentNode.scrollHeight ) :
					this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
				) - this.helperProportions.height - this.margins.top
			];
		}

		if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
			ce = $( o.containment )[ 0 ];
			co = $( o.containment ).offset();
			over = ( $( ce ).css( "overflow" ) !== "hidden" );

			this.containment = [
				co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
					( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
				co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
					( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
				co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
					( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
					( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
					this.helperProportions.width - this.margins.left,
				co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
					( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
					( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
					this.helperProportions.height - this.margins.top
			];
		}

	},

	_convertPositionTo: function( d, pos ) {

		if ( !pos ) {
			pos = this.position;
		}
		var mod = d === "absolute" ? 1 : -1,
			scroll = this.cssPosition === "absolute" &&
				!( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
					this.offsetParent :
					this.scrollParent,
			scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );

		return {
			top: (

				// The absolute mouse position
				pos.top	+

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.top * mod +

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.top * mod -
				( ( this.cssPosition === "fixed" ?
					-this.scrollParent.scrollTop() :
					( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
			),
			left: (

				// The absolute mouse position
				pos.left +

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.left * mod +

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.left * mod	-
				( ( this.cssPosition === "fixed" ?
					-this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
					scroll.scrollLeft() ) * mod )
			)
		};

	},

	_generatePosition: function( event ) {

		var top, left,
			o = this.options,
			pageX = event.pageX,
			pageY = event.pageY,
			scroll = this.cssPosition === "absolute" &&
				!( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
				$.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
					this.offsetParent :
					this.scrollParent,
				scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );

		// This is another very weird special case that only happens for relative elements:
		// 1. If the css position is relative
		// 2. and the scroll parent is the document or similar to the offset parent
		// we have to refresh the relative offset during the scroll so there are no jumps
		if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
				this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
			this.offset.relative = this._getRelativeOffset();
		}

		/*
		 * - Position constraining -
		 * Constrain the position to a mix of grid, containment.
		 */

		if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options

			if ( this.containment ) {
				if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
					pageX = this.containment[ 0 ] + this.offset.click.left;
				}
				if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
					pageY = this.containment[ 1 ] + this.offset.click.top;
				}
				if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
					pageX = this.containment[ 2 ] + this.offset.click.left;
				}
				if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
					pageY = this.containment[ 3 ] + this.offset.click.top;
				}
			}

			if ( o.grid ) {
				top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
					o.grid[ 1 ] ) * o.grid[ 1 ];
				pageY = this.containment ?
					( ( top - this.offset.click.top >= this.containment[ 1 ] &&
						top - this.offset.click.top <= this.containment[ 3 ] ) ?
							top :
							( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
								top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
								top;

				left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
					o.grid[ 0 ] ) * o.grid[ 0 ];
				pageX = this.containment ?
					( ( left - this.offset.click.left >= this.containment[ 0 ] &&
						left - this.offset.click.left <= this.containment[ 2 ] ) ?
							left :
							( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
								left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
								left;
			}

		}

		return {
			top: (

				// The absolute mouse position
				pageY -

				// Click offset (relative to the element)
				this.offset.click.top -

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.top -

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.top +
				( ( this.cssPosition === "fixed" ?
					-this.scrollParent.scrollTop() :
					( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
			),
			left: (

				// The absolute mouse position
				pageX -

				// Click offset (relative to the element)
				this.offset.click.left -

				// Only for relative positioned nodes: Relative offset from element to offset parent
				this.offset.relative.left -

				// The offsetParent's offset without borders (offset + border)
				this.offset.parent.left +
				( ( this.cssPosition === "fixed" ?
					-this.scrollParent.scrollLeft() :
					scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
			)
		};

	},

	_rearrange: function( event, i, a, hardRefresh ) {

		a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
			i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
				( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );

		//Various things done here to improve the performance:
		// 1. we create a setTimeout, that calls refreshPositions
		// 2. on the instance, we have a counter variable, that get's higher after every append
		// 3. on the local scope, we copy the counter variable, and check in the timeout,
		// if it's still the same
		// 4. this lets only the last addition to the timeout stack through
		this.counter = this.counter ? ++this.counter : 1;
		var counter = this.counter;

		this._delay( function() {
			if ( counter === this.counter ) {

				//Precompute after each DOM insertion, NOT on mousemove
				this.refreshPositions( !hardRefresh );
			}
		} );

	},

	_clear: function( event, noPropagation ) {

		this.reverting = false;

		// We delay all events that have to be triggered to after the point where the placeholder
		// has been removed and everything else normalized again
		var i,
			delayedTriggers = [];

		// We first have to update the dom position of the actual currentItem
		// Note: don't do it if the current item is already removed (by a user), or it gets
		// reappended (see #4088)
		if ( !this._noFinalSort && this.currentItem.parent().length ) {
			this.placeholder.before( this.currentItem );
		}
		this._noFinalSort = null;

		if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
			for ( i in this._storedCSS ) {
				if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
					this._storedCSS[ i ] = "";
				}
			}
			this.currentItem.css( this._storedCSS );
			this._removeClass( this.currentItem, "ui-sortable-helper" );
		} else {
			this.currentItem.show();
		}

		if ( this.fromOutside && !noPropagation ) {
			delayedTriggers.push( function( event ) {
				this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
			} );
		}
		if ( ( this.fromOutside ||
				this.domPosition.prev !==
				this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
				this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {

			// Trigger update callback if the DOM position has changed
			delayedTriggers.push( function( event ) {
				this._trigger( "update", event, this._uiHash() );
			} );
		}

		// Check if the items Container has Changed and trigger appropriate
		// events.
		if ( this !== this.currentContainer ) {
			if ( !noPropagation ) {
				delayedTriggers.push( function( event ) {
					this._trigger( "remove", event, this._uiHash() );
				} );
				delayedTriggers.push( ( function( c ) {
					return function( event ) {
						c._trigger( "receive", event, this._uiHash( this ) );
					};
				} ).call( this, this.currentContainer ) );
				delayedTriggers.push( ( function( c ) {
					return function( event ) {
						c._trigger( "update", event, this._uiHash( this ) );
					};
				} ).call( this, this.currentContainer ) );
			}
		}

		//Post events to containers
		function delayEvent( type, instance, container ) {
			return function( event ) {
				container._trigger( type, event, instance._uiHash( instance ) );
			};
		}
		for ( i = this.containers.length - 1; i >= 0; i-- ) {
			if ( !noPropagation ) {
				delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
			}
			if ( this.containers[ i ].containerCache.over ) {
				delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
				this.containers[ i ].containerCache.over = 0;
			}
		}

		//Do what was originally in plugins
		if ( this.storedCursor ) {
			this.document.find( "body" ).css( "cursor", this.storedCursor );
			this.storedStylesheet.remove();
		}
		if ( this._storedOpacity ) {
			this.helper.css( "opacity", this._storedOpacity );
		}
		if ( this._storedZIndex ) {
			this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
		}

		this.dragging = false;

		if ( !noPropagation ) {
			this._trigger( "beforeStop", event, this._uiHash() );
		}

		//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
		// it unbinds ALL events from the original node!
		this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );

		if ( !this.cancelHelperRemoval ) {
			if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
				this.helper.remove();
			}
			this.helper = null;
		}

		if ( !noPropagation ) {
			for ( i = 0; i < delayedTriggers.length; i++ ) {

				// Trigger all delayed events
				delayedTriggers[ i ].call( this, event );
			}
			this._trigger( "stop", event, this._uiHash() );
		}

		this.fromOutside = false;
		return !this.cancelHelperRemoval;

	},

	_trigger: function() {
		if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
			this.cancel();
		}
	},

	_uiHash: function( _inst ) {
		var inst = _inst || this;
		return {
			helper: inst.helper,
			placeholder: inst.placeholder || $( [] ),
			position: inst.position,
			originalPosition: inst.originalPosition,
			offset: inst.positionAbs,
			item: inst.currentItem,
			sender: _inst ? _inst.element : null
		};
	}

} );


/*!
 * jQuery UI Slider 1.12.1
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Slider
//>>group: Widgets
//>>description: Displays a flexible slider with ranges and accessibility via keyboard.
//>>docs: http://api.jqueryui.com/slider/
//>>demos: http://jqueryui.com/slider/
//>>css.structure: ../../themes/base/core.css
//>>css.structure: ../../themes/base/slider.css
//>>css.theme: ../../themes/base/theme.css



var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
	version: "1.12.1",
	widgetEventPrefix: "slide",

	options: {
		animate: false,
		classes: {
			"ui-slider": "ui-corner-all",
			"ui-slider-handle": "ui-corner-all",

			// Note: ui-widget-header isn't the most fittingly semantic framework class for this
			// element, but worked best visually with a variety of themes
			"ui-slider-range": "ui-corner-all ui-widget-header"
		},
		distance: 0,
		max: 100,
		min: 0,
		orientation: "horizontal",
		range: false,
		step: 1,
		value: 0,
		values: null,

		// Callbacks
		change: null,
		slide: null,
		start: null,
		stop: null
	},

	// Number of pages in a slider
	// (how many times can you page up/down to go through the whole range)
	numPages: 5,

	_create: function() {
		this._keySliding = false;
		this._mouseSliding = false;
		this._animateOff = true;
		this._handleIndex = null;
		this._detectOrientation();
		this._mouseInit();
		this._calculateNewMax();

		this._addClass( "ui-slider ui-slider-" + this.orientation,
			"ui-widget ui-widget-content" );

		this._refresh();

		this._animateOff = false;
	},

	_refresh: function() {
		this._createRange();
		this._createHandles();
		this._setupEvents();
		this._refreshValue();
	},

	_createHandles: function() {
		var i, handleCount,
			options = this.options,
			existingHandles = this.element.find( ".ui-slider-handle" ),
			handle = "<span tabindex='0'></span>",
			handles = [];

		handleCount = ( options.values && options.values.length ) || 1;

		if ( existingHandles.length > handleCount ) {
			existingHandles.slice( handleCount ).remove();
			existingHandles = existingHandles.slice( 0, handleCount );
		}

		for ( i = existingHandles.length; i < handleCount; i++ ) {
			handles.push( handle );
		}

		this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );

		this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );

		this.handle = this.handles.eq( 0 );

		this.handles.each( function( i ) {
			$( this )
				.data( "ui-slider-handle-index", i )
				.attr( "tabIndex", 0 );
		} );
	},

	_createRange: function() {
		var options = this.options;

		if ( options.range ) {
			if ( options.range === true ) {
				if ( !options.values ) {
					options.values = [ this._valueMin(), this._valueMin() ];
				} else if ( options.values.length && options.values.length !== 2 ) {
					options.values = [ options.values[ 0 ], options.values[ 0 ] ];
				} else if ( $.isArray( options.values ) ) {
					options.values = options.values.slice( 0 );
				}
			}

			if ( !this.range || !this.range.length ) {
				this.range = $( "<div>" )
					.appendTo( this.element );

				this._addClass( this.range, "ui-slider-range" );
			} else {
				this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );

				// Handle range switching from true to min/max
				this.range.css( {
					"left": "",
					"bottom": ""
				} );
			}
			if ( options.range === "min" || options.range === "max" ) {
				this._addClass( this.range, "ui-slider-range-" + options.range );
			}
		} else {
			if ( this.range ) {
				this.range.remove();
			}
			this.range = null;
		}
	},

	_setupEvents: function() {
		this._off( this.handles );
		this._on( this.handles, this._handleEvents );
		this._hoverable( this.handles );
		this._focusable( this.handles );
	},

	_destroy: function() {
		this.handles.remove();
		if ( this.range ) {
			this.range.remove();
		}

		this._mouseDestroy();
	},

	_mouseCapture: function( event ) {
		var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
			that = this,
			o = this.options;

		if ( o.disabled ) {
			return false;
		}

		this.elementSize = {
			width: this.element.outerWidth(),
			height: this.element.outerHeight()
		};
		this.elementOffset = this.element.offset();

		position = { x: event.pageX, y: event.pageY };
		normValue = this._normValueFromMouse( position );
		distance = this._valueMax() - this._valueMin() + 1;
		this.handles.each( function( i ) {
			var thisDistance = Math.abs( normValue - that.values( i ) );
			if ( ( distance > thisDistance ) ||
				( distance === thisDistance &&
					( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
				distance = thisDistance;
				closestHandle = $( this );
				index = i;
			}
		} );

		allowed = this._start( event, index );
		if ( allowed === false ) {
			return false;
		}
		this._mouseSliding = true;

		this._handleIndex = index;

		this._addClass( closestHandle, null, "ui-state-active" );
		closestHandle.trigger( "focus" );

		offset = closestHandle.offset();
		mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
		this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
			left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
			top: event.pageY - offset.top -
				( closestHandle.height() / 2 ) -
				( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
				( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
				( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
		};

		if ( !this.handles.hasClass( "ui-state-hover" ) ) {
			this._slide( event, index, normValue );
		}
		this._animateOff = true;
		return true;
	},

	_mouseStart: function() {
		return true;
	},

	_mouseDrag: function( event ) {
		var position = { x: event.pageX, y: event.pageY },
			normValue = this._normValueFromMouse( position );

		this._slide( event, this._handleIndex, normValue );

		return false;
	},

	_mouseStop: function( event ) {
		this._removeClass( this.handles, null, "ui-state-active" );
		this._mouseSliding = false;

		this._stop( event, this._handleIndex );
		this._change( event, this._handleIndex );

		this._handleIndex = null;
		this._clickOffset = null;
		this._animateOff = false;

		return false;
	},

	_detectOrientation: function() {
		this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
	},

	_normValueFromMouse: function( position ) {
		var pixelTotal,
			pixelMouse,
			percentMouse,
			valueTotal,
			valueMouse;

		if ( this.orientation === "horizontal" ) {
			pixelTotal = this.elementSize.width;
			pixelMouse = position.x - this.elementOffset.left -
				( this._clickOffset ? this._clickOffset.left : 0 );
		} else {
			pixelTotal = this.elementSize.height;
			pixelMouse = position.y - this.elementOffset.top -
				( this._clickOffset ? this._clickOffset.top : 0 );
		}

		percentMouse = ( pixelMouse / pixelTotal );
		if ( percentMouse > 1 ) {
			percentMouse = 1;
		}
		if ( percentMouse < 0 ) {
			percentMouse = 0;
		}
		if ( this.orientation === "vertical" ) {
			percentMouse = 1 - percentMouse;
		}

		valueTotal = this._valueMax() - this._valueMin();
		valueMouse = this._valueMin() + percentMouse * valueTotal;

		return this._trimAlignValue( valueMouse );
	},

	_uiHash: function( index, value, values ) {
		var uiHash = {
			handle: this.handles[ index ],
			handleIndex: index,
			value: value !== undefined ? value : this.value()
		};

		if ( this._hasMultipleValues() ) {
			uiHash.value = value !== undefined ? value : this.values( index );
			uiHash.values = values || this.values();
		}

		return uiHash;
	},

	_hasMultipleValues: function() {
		return this.options.values && this.options.values.length;
	},

	_start: function( event, index ) {
		return this._trigger( "start", event, this._uiHash( index ) );
	},

	_slide: function( event, index, newVal ) {
		var allowed, otherVal,
			currentValue = this.value(),
			newValues = this.values();

		if ( this._hasMultipleValues() ) {
			otherVal = this.values( index ? 0 : 1 );
			currentValue = this.values( index );

			if ( this.options.values.length === 2 && this.options.range === true ) {
				newVal =  index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
			}

			newValues[ index ] = newVal;
		}

		if ( newVal === currentValue ) {
			return;
		}

		allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );

		// A slide can be canceled by returning false from the slide callback
		if ( allowed === false ) {
			return;
		}

		if ( this._hasMultipleValues() ) {
			this.values( index, newVal );
		} else {
			this.value( newVal );
		}
	},

	_stop: function( event, index ) {
		this._trigger( "stop", event, this._uiHash( index ) );
	},

	_change: function( event, index ) {
		if ( !this._keySliding && !this._mouseSliding ) {

			//store the last changed value index for reference when handles overlap
			this._lastChangedValue = index;
			this._trigger( "change", event, this._uiHash( index ) );
		}
	},

	value: function( newValue ) {
		if ( arguments.length ) {
			this.options.value = this._trimAlignValue( newValue );
			this._refreshValue();
			this._change( null, 0 );
			return;
		}

		return this._value();
	},

	values: function( index, newValue ) {
		var vals,
			newValues,
			i;

		if ( arguments.length > 1 ) {
			this.options.values[ index ] = this._trimAlignValue( newValue );
			this._refreshValue();
			this._change( null, index );
			return;
		}

		if ( arguments.length ) {
			if ( $.isArray( arguments[ 0 ] ) ) {
				vals = this.options.values;
				newValues = arguments[ 0 ];
				for ( i = 0; i < vals.length; i += 1 ) {
					vals[ i ] = this._trimAlignValue( newValues[ i ] );
					this._change( null, i );
				}
				this._refreshValue();
			} else {
				if ( this._hasMultipleValues() ) {
					return this._values( index );
				} else {
					return this.value();
				}
			}
		} else {
			return this._values();
		}
	},

	_setOption: function( key, value ) {
		var i,
			valsLength = 0;

		if ( key === "range" && this.options.range === true ) {
			if ( value === "min" ) {
				this.options.value = this._values( 0 );
				this.options.values = null;
			} else if ( value === "max" ) {
				this.options.value = this._values( this.options.values.length - 1 );
				this.options.values = null;
			}
		}

		if ( $.isArray( this.options.values ) ) {
			valsLength = this.options.values.length;
		}

		this._super( key, value );

		switch ( key ) {
			case "orientation":
				this._detectOrientation();
				this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
					._addClass( "ui-slider-" + this.orientation );
				this._refreshValue();
				if ( this.options.range ) {
					this._refreshRange( value );
				}

				// Reset positioning from previous orientation
				this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
				break;
			case "value":
				this._animateOff = true;
				this._refreshValue();
				this._change( null, 0 );
				this._animateOff = false;
				break;
			case "values":
				this._animateOff = true;
				this._refreshValue();

				// Start from the last handle to prevent unreachable handles (#9046)
				for ( i = valsLength - 1; i >= 0; i-- ) {
					this._change( null, i );
				}
				this._animateOff = false;
				break;
			case "step":
			case "min":
			case "max":
				this._animateOff = true;
				this._calculateNewMax();
				this._refreshValue();
				this._animateOff = false;
				break;
			case "range":
				this._animateOff = true;
				this._refresh();
				this._animateOff = false;
				break;
		}
	},

	_setOptionDisabled: function( value ) {
		this._super( value );

		this._toggleClass( null, "ui-state-disabled", !!value );
	},

	//internal value getter
	// _value() returns value trimmed by min and max, aligned by step
	_value: function() {
		var val = this.options.value;
		val = this._trimAlignValue( val );

		return val;
	},

	//internal values getter
	// _values() returns array of values trimmed by min and max, aligned by step
	// _values( index ) returns single value trimmed by min and max, aligned by step
	_values: function( index ) {
		var val,
			vals,
			i;

		if ( arguments.length ) {
			val = this.options.values[ index ];
			val = this._trimAlignValue( val );

			return val;
		} else if ( this._hasMultipleValues() ) {

			// .slice() creates a copy of the array
			// this copy gets trimmed by min and max and then returned
			vals = this.options.values.slice();
			for ( i = 0; i < vals.length; i += 1 ) {
				vals[ i ] = this._trimAlignValue( vals[ i ] );
			}

			return vals;
		} else {
			return [];
		}
	},

	// Returns the step-aligned value that val is closest to, between (inclusive) min and max
	_trimAlignValue: function( val ) {
		if ( val <= this._valueMin() ) {
			return this._valueMin();
		}
		if ( val >= this._valueMax() ) {
			return this._valueMax();
		}
		var step = ( this.options.step > 0 ) ? this.options.step : 1,
			valModStep = ( val - this._valueMin() ) % step,
			alignValue = val - valModStep;

		if ( Math.abs( valModStep ) * 2 >= step ) {
			alignValue += ( valModStep > 0 ) ? step : ( -step );
		}

		// Since JavaScript has problems with large floats, round
		// the final value to 5 digits after the decimal point (see #4124)
		return parseFloat( alignValue.toFixed( 5 ) );
	},

	_calculateNewMax: function() {
		var max = this.options.max,
			min = this._valueMin(),
			step = this.options.step,
			aboveMin = Math.round( ( max - min ) / step ) * step;
		max = aboveMin + min;
		if ( max > this.options.max ) {

			//If max is not divisible by step, rounding off may increase its value
			max -= step;
		}
		this.max = parseFloat( max.toFixed( this._precision() ) );
	},

	_precision: function() {
		var precision = this._precisionOf( this.options.step );
		if ( this.options.min !== null ) {
			precision = Math.max( precision, this._precisionOf( this.options.min ) );
		}
		return precision;
	},

	_precisionOf: function( num ) {
		var str = num.toString(),
			decimal = str.indexOf( "." );
		return decimal === -1 ? 0 : str.length - decimal - 1;
	},

	_valueMin: function() {
		return this.options.min;
	},

	_valueMax: function() {
		return this.max;
	},

	_refreshRange: function( orientation ) {
		if ( orientation === "vertical" ) {
			this.range.css( { "width": "", "left": "" } );
		}
		if ( orientation === "horizontal" ) {
			this.range.css( { "height": "", "bottom": "" } );
		}
	},

	_refreshValue: function() {
		var lastValPercent, valPercent, value, valueMin, valueMax,
			oRange = this.options.range,
			o = this.options,
			that = this,
			animate = ( !this._animateOff ) ? o.animate : false,
			_set = {};

		if ( this._hasMultipleValues() ) {
			this.handles.each( function( i ) {
				valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
					that._valueMin() ) * 100;
				_set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
				$( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
				if ( that.options.range === true ) {
					if ( that.orientation === "horizontal" ) {
						if ( i === 0 ) {
							that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
								left: valPercent + "%"
							}, o.animate );
						}
						if ( i === 1 ) {
							that.range[ animate ? "animate" : "css" ]( {
								width: ( valPercent - lastValPercent ) + "%"
							}, {
								queue: false,
								duration: o.animate
							} );
						}
					} else {
						if ( i === 0 ) {
							that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
								bottom: ( valPercent ) + "%"
							}, o.animate );
						}
						if ( i === 1 ) {
							that.range[ animate ? "animate" : "css" ]( {
								height: ( valPercent - lastValPercent ) + "%"
							}, {
								queue: false,
								duration: o.animate
							} );
						}
					}
				}
				lastValPercent = valPercent;
			} );
		} else {
			value = this.value();
			valueMin = this._valueMin();
			valueMax = this._valueMax();
			valPercent = ( valueMax !== valueMin ) ?
					( value - valueMin ) / ( valueMax - valueMin ) * 100 :
					0;
			_set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
			this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );

			if ( oRange === "min" && this.orientation === "horizontal" ) {
				this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
					width: valPercent + "%"
				}, o.animate );
			}
			if ( oRange === "max" && this.orientation === "horizontal" ) {
				this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
					width: ( 100 - valPercent ) + "%"
				}, o.animate );
			}
			if ( oRange === "min" && this.orientation === "vertical" ) {
				this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
					height: valPercent + "%"
				}, o.animate );
			}
			if ( oRange === "max" && this.orientation === "vertical" ) {
				this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
					height: ( 100 - valPercent ) + "%"
				}, o.animate );
			}
		}
	},

	_handleEvents: {
		keydown: function( event ) {
			var allowed, curVal, newVal, step,
				index = $( event.target ).data( "ui-slider-handle-index" );

			switch ( event.keyCode ) {
				case $.ui.keyCode.HOME:
				case $.ui.keyCode.END:
				case $.ui.keyCode.PAGE_UP:
				case $.ui.keyCode.PAGE_DOWN:
				case $.ui.keyCode.UP:
				case $.ui.keyCode.RIGHT:
				case $.ui.keyCode.DOWN:
				case $.ui.keyCode.LEFT:
					event.preventDefault();
					if ( !this._keySliding ) {
						this._keySliding = true;
						this._addClass( $( event.target ), null, "ui-state-active" );
						allowed = this._start( event, index );
						if ( allowed === false ) {
							return;
						}
					}
					break;
			}

			step = this.options.step;
			if ( this._hasMultipleValues() ) {
				curVal = newVal = this.values( index );
			} else {
				curVal = newVal = this.value();
			}

			switch ( event.keyCode ) {
				case $.ui.keyCode.HOME:
					newVal = this._valueMin();
					break;
				case $.ui.keyCode.END:
					newVal = this._valueMax();
					break;
				case $.ui.keyCode.PAGE_UP:
					newVal = this._trimAlignValue(
						curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
					);
					break;
				case $.ui.keyCode.PAGE_DOWN:
					newVal = this._trimAlignValue(
						curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
					break;
				case $.ui.keyCode.UP:
				case $.ui.keyCode.RIGHT:
					if ( curVal === this._valueMax() ) {
						return;
					}
					newVal = this._trimAlignValue( curVal + step );
					break;
				case $.ui.keyCode.DOWN:
				case $.ui.keyCode.LEFT:
					if ( curVal === this._valueMin() ) {
						return;
					}
					newVal = this._trimAlignValue( curVal - step );
					break;
			}

			this._slide( event, index, newVal );
		},
		keyup: function( event ) {
			var index = $( event.target ).data( "ui-slider-handle-index" );

			if ( this._keySliding ) {
				this._keySliding = false;
				this._stop( event, index );
				this._change( event, index );
				this._removeClass( $( event.target ), null, "ui-state-active" );
			}
		}
	}
} );




}));
﻿!function(t){function e(o,t){var e,u;1<o.originalEvent.touches.length||(o.preventDefault(),e=o.originalEvent.changedTouches[0],(u=document.createEvent("MouseEvents")).initMouseEvent(t,!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,!1,!1,!1,!1,0,null),o.target.dispatchEvent(u))}var u,o,n,c;t.support.touch="ontouchend"in document,t.support.touch&&(o=t.ui.mouse.prototype,n=o._mouseInit,c=o._mouseDestroy,o._touchStart=function(o){!u&&this._mouseCapture(o.originalEvent.changedTouches[0])&&(u=!0,this._touchMoved=!1,e(o,"mouseover"),e(o,"mousemove"),e(o,"mousedown"))},o._touchMove=function(o){u&&(this._touchMoved=!0,e(o,"mousemove"))},o._touchEnd=function(o){u&&(e(o,"mouseup"),e(o,"mouseout"),this._touchMoved||e(o,"click"),u=!1)},o._mouseInit=function(){var o=this;o.element.bind({touchstart:t.proxy(o,"_touchStart"),touchmove:t.proxy(o,"_touchMove"),touchend:t.proxy(o,"_touchEnd")}),n.call(o)},o._mouseDestroy=function(){var o=this;o.element.unbind({touchstart:t.proxy(o,"_touchStart"),touchmove:t.proxy(o,"_touchMove"),touchend:t.proxy(o,"_touchEnd")}),c.call(o)})}(jQuery);
﻿/*!
 * Lazy Load - jQuery plugin for lazy loading images
 *
 * Copyright (c) 2007-2015 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   http://www.appelsiini.net/projects/lazyload
 *
 * Version:  1.9.7
 *
 */

(function($, window, document, undefined) {
    var $window = $(window);

    $.fn.lazyload = function(options) {
        var elements = this;
        var $container;
        var settings = {
            threshold       : 0,
            failure_limit   : 0,
            event           : "scroll",
            effect          : "show",
            container       : window,
            data_attribute  : "original",
            skip_invisible  : false,
            appear          : null,
            load            : null,
            placeholder     : _MTS_MEDIAURL + "images/busySpinner.gif",
            error           : _MTS_MEDIAURL + "images/noImage.png"
        };

        function update() {
            var counter = 0;

            elements.each(function() {
                var $this = $(this);
                if (settings.skip_invisible && !$this.is(":visible")) {
                    return;
                }
                if ($.abovethetop(this, settings) ||
                    $.leftofbegin(this, settings)) {
                        /* Nothing. */
                } else if (!$.belowthefold(this, settings) &&
                    !$.rightoffold(this, settings)) {
                        $this.trigger("appear");
                        /* if we found an image we'll load, reset the counter */
                        counter = 0;
                } else {
                    if (++counter > settings.failure_limit) {
                        return false;
                    }
                }
            });

        }

        if(options) {
            /* Maintain BC for a couple of versions. */
            if (undefined !== options.failurelimit) {
                options.failure_limit = options.failurelimit;
                delete options.failurelimit;
            }
            if (undefined !== options.effectspeed) {
                options.effect_speed = options.effectspeed;
                delete options.effectspeed;
            }

            $.extend(settings, options);
        }

        /* Cache container as jQuery as object. */
        $container = (settings.container === undefined ||
                      settings.container === window) ? $window : $(settings.container);

        /* Fire one scroll event per scroll. Not one scroll event per image. */
        if (0 === settings.event.indexOf("scroll")) {
            $container.bind(settings.event, function() {
                return update();
            });
        }

        this.each(function() {
            var self = this;
            var $self = $(self);

            self.loaded = false;

            /* If no src attribute given use data:uri. */
            if ($self.attr("src") === undefined || $self.attr("src") === false) {
                if ($self.is("img")) {
                    $self.attr("src", settings.placeholder);
                }
            }

            /* When appear is triggered load original image. */
            $self.one("appear", function() {
                if (!this.loaded) {
                    if (settings.appear) {
                        var elements_left = elements.length;
                        settings.appear.call(self, elements_left, settings);
                    }
                    $("<img />")
                        .bind("load", function() {
                            var original = $self.attr("data-" + settings.data_attribute);
                            $self.hide();
                            if ($self.is("img")) {
                                $self.attr("src", original);
                            } else {
                                $self.css("background-image", "url('" + original + "')");
                            }
                            $self[settings.effect](settings.effect_speed);

                            self.loaded = true;

                            /* Remove image from array so it is not looped next time. */
                            var temp = $.grep(elements, function(element) {
                                return !element.loaded;
                            });
                            elements = $(temp);

                            if (settings.load) {
                                var elements_left = elements.length;
                                settings.load.call(self, elements_left, settings);
                            }
                        })
                     .bind("error", function () { 
                           $self.attr("src", settings.error); 
                        })
                        .attr("src", $self.attr("data-" + settings.data_attribute));
                }
            });

            /* When wanted event is triggered load original image */
            /* by triggering appear.                              */
            if (0 !== settings.event.indexOf("scroll")) {
                $self.bind(settings.event, function() {
                    if (!self.loaded) {
                        $self.trigger("appear");
                    }
                });
            }
        });

        /* Check if something appears when window is resized. */
        $window.bind("resize", function() {
            update();
        });

        /* With IOS5 force loading images when navigating with back button. */
        /* Non optimal workaround. */
        if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
            $window.bind("pageshow", function(event) {
                if (event.originalEvent && event.originalEvent.persisted) {
                    elements.each(function() {
                        $(this).trigger("appear");
                    });
                }
            });
        }

        /* Force initial check if images should appear. */
        $(document).ready(function() {
            update();
        });

        return this;
    };

    /* Convenience methods in jQuery namespace.           */
    /* Use as  $.belowthefold(element, {threshold : 100, container : window}) */

    $.belowthefold = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
        } else {
            fold = $(settings.container).offset().top + $(settings.container).height();
        }

        return fold <= $(element).offset().top - settings.threshold;
    };

    $.rightoffold = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = $window.width() + $window.scrollLeft();
        } else {
            fold = $(settings.container).offset().left + $(settings.container).width();
        }

        return fold <= $(element).offset().left - settings.threshold;
    };

    $.abovethetop = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = $window.scrollTop();
        } else {
            fold = $(settings.container).offset().top;
        }

        return fold >= $(element).offset().top + settings.threshold  + $(element).height();
    };

    $.leftofbegin = function(element, settings) {
        var fold;

        if (settings.container === undefined || settings.container === window) {
            fold = $window.scrollLeft();
        } else {
            fold = $(settings.container).offset().left;
        }

        return fold >= $(element).offset().left + settings.threshold + $(element).width();
    };

    $.inviewport = function(element, settings) {
         return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
                !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
     };

    /* Custom selectors for your convenience.   */
    /* Use as $("img:below-the-fold").something() or */
    /* $("img").filter(":below-the-fold").something() which is faster */

    $.extend($.expr[":"], {
        "below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
        "above-the-top"  : function(a) { return !$.belowthefold(a, {threshold : 0}); },
        "right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
        "left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
        "in-viewport"    : function(a) { return $.inviewport(a, {threshold : 0}); },
        /* Maintain BC for couple of versions. */
        "above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
        "right-of-fold"  : function(a) { return $.rightoffold(a, {threshold : 0}); },
        "left-of-fold"   : function(a) { return !$.rightoffold(a, {threshold : 0}); }
    });

})(jQuery, window, document);

﻿/* Chosen v1.7.0 | (c) 2011-2017 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
(function () { var a, b, c, d, e, f = function (a, b) { return function () { return a.apply(b, arguments) } }, g = {}.hasOwnProperty, h = function (a, b) { function c() { this.constructor = a } for (var d in b) g.call(b, d) && (a[d] = b[d]); return c.prototype = b.prototype, a.prototype = new c, a.__super__ = b.prototype, a }; d = function () { function a() { this.options_index = 0, this.parsed = [] } return a.prototype.add_node = function (a) { return "OPTGROUP" === a.nodeName.toUpperCase() ? this.add_group(a) : this.add_option(a) }, a.prototype.add_group = function (a) { var b, c, d, e, f, g; for (b = this.parsed.length, this.parsed.push({ array_index: b, group: !0, label: this.escapeExpression(a.label), title: a.title ? a.title : void 0, children: 0, disabled: a.disabled, classes: a.className }), f = a.childNodes, g = [], d = 0, e = f.length; e > d; d++)c = f[d], g.push(this.add_option(c, b, a.disabled)); return g }, a.prototype.add_option = function (a, b, c) { return "OPTION" === a.nodeName.toUpperCase() ? ("" !== a.text ? (null != b && (this.parsed[b].children += 1), this.parsed.push({ array_index: this.parsed.length, options_index: this.options_index, value: a.value, text: a.text, html: a.innerHTML, title: a.title ? a.title : void 0, selected: a.selected, disabled: c === !0 ? c : a.disabled, group_array_index: b, group_label: null != b ? this.parsed[b].label : null, classes: a.className, style: a.style.cssText })) : this.parsed.push({ array_index: this.parsed.length, options_index: this.options_index, empty: !0 }), this.options_index += 1) : void 0 }, a.prototype.escapeExpression = function (a) { var b, c; return null == a || a === !1 ? "" : /[\&\<\>\"\'\`]/.test(a) ? (b = { "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#x27;", "`": "&#x60;" }, c = /&(?!\w+;)|[\<\>\"\'\`]/g, a.replace(c, function (a) { return b[a] || "&amp;" })) : a }, a }(), d.select_to_array = function (a) { var b, c, e, f, g; for (c = new d, g = a.childNodes, e = 0, f = g.length; f > e; e++)b = g[e], c.add_node(b); return c.parsed }, b = function () { function a(b, c) { this.form_field = b, this.options = null != c ? c : {}, this.label_click_handler = f(this.label_click_handler, this), a.browser_is_supported() && (this.is_multiple = this.form_field.multiple, this.set_default_text(), this.set_default_values(), this.setup(), this.set_up_html(), this.register_observers(), this.on_ready()) } return a.prototype.set_default_values = function () { var a = this; return this.click_test_action = function (b) { return a.test_active_click(b) }, this.activate_action = function (b) { return a.activate_field(b) }, this.active_field = !1, this.mouse_on_container = !1, this.results_showing = !1, this.result_highlighted = null, this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className), this.allow_single_deselect = null != this.options.allow_single_deselect && null != this.form_field.options[0] && "" === this.form_field.options[0].text ? this.options.allow_single_deselect : !1, this.disable_search_threshold = this.options.disable_search_threshold || 0, this.disable_search = this.options.disable_search || !1, this.enable_split_word_search = null != this.options.enable_split_word_search ? this.options.enable_split_word_search : !0, this.group_search = null != this.options.group_search ? this.options.group_search : !0, this.search_contains = this.options.search_contains || !1, this.single_backstroke_delete = null != this.options.single_backstroke_delete ? this.options.single_backstroke_delete : !0, this.max_selected_options = this.options.max_selected_options || 1 / 0, this.inherit_select_classes = this.options.inherit_select_classes || !1, this.display_selected_options = null != this.options.display_selected_options ? this.options.display_selected_options : !0, this.display_disabled_options = null != this.options.display_disabled_options ? this.options.display_disabled_options : !0, this.include_group_label_in_selected = this.options.include_group_label_in_selected || !1, this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY, this.case_sensitive_search = this.options.case_sensitive_search || !1, this.hide_results_on_select = null != this.options.hide_results_on_select ? this.options.hide_results_on_select : !0 }, a.prototype.set_default_text = function () { return this.form_field.getAttribute("data-placeholder") ? this.default_text = this.form_field.getAttribute("data-placeholder") : this.is_multiple ? this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || a.default_multiple_text : this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || a.default_single_text, this.default_text = this.escape_html(this.default_text), this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || a.default_no_result_text }, a.prototype.choice_label = function (a) { return this.include_group_label_in_selected && null != a.group_label ? "<b class='group-name'>" + a.group_label + "</b>" + a.html : a.html }, a.prototype.mouse_enter = function () { return this.mouse_on_container = !0 }, a.prototype.mouse_leave = function () { return this.mouse_on_container = !1 }, a.prototype.input_focus = function (a) { var b = this; if (this.is_multiple) { if (!this.active_field) return setTimeout(function () { return b.container_mousedown() }, 50) } else if (!this.active_field) return this.activate_field() }, a.prototype.input_blur = function (a) { var b = this; return this.mouse_on_container ? void 0 : (this.active_field = !1, setTimeout(function () { return b.blur_test() }, 100)) }, a.prototype.label_click_handler = function (a) { return this.is_multiple ? this.container_mousedown(a) : this.activate_field() }, a.prototype.results_option_build = function (a) { var b, c, d, e, f, g, h; for (b = "", e = 0, h = this.results_data, f = 0, g = h.length; g > f && (c = h[f], d = "", d = c.group ? this.result_add_group(c) : this.result_add_option(c), "" !== d && (e++ , b += d), (null != a ? a.first : void 0) && (c.selected && this.is_multiple ? this.choice_build(c) : c.selected && !this.is_multiple && this.single_set_selected_text(this.choice_label(c))), !(e >= this.max_shown_results)); f++); return b }, a.prototype.result_add_option = function (a) { var b, c; return a.search_match && this.include_option_in_results(a) ? (b = [], a.disabled || a.selected && this.is_multiple || b.push("active-result"), !a.disabled || a.selected && this.is_multiple || b.push("disabled-result"), a.selected && b.push("result-selected"), null != a.group_array_index && b.push("group-option"), "" !== a.classes && b.push(a.classes), c = document.createElement("li"), c.className = b.join(" "), c.style.cssText = a.style, c.setAttribute("data-option-array-index", a.array_index), c.innerHTML = a.search_text, a.title && (c.title = a.title), this.outerHTML(c)) : "" }, a.prototype.result_add_group = function (a) { var b, c; return (a.search_match || a.group_match) && a.active_options > 0 ? (b = [], b.push("group-result"), a.classes && b.push(a.classes), c = document.createElement("li"), c.className = b.join(" "), c.innerHTML = a.search_text, a.title && (c.title = a.title), this.outerHTML(c)) : "" }, a.prototype.results_update_field = function () { return this.set_default_text(), this.is_multiple || this.results_reset_cleanup(), this.result_clear_highlight(), this.results_build(), this.results_showing ? this.winnow_results() : void 0 }, a.prototype.reset_single_select_options = function () { var a, b, c, d, e; for (d = this.results_data, e = [], b = 0, c = d.length; c > b; b++)a = d[b], a.selected ? e.push(a.selected = !1) : e.push(void 0); return e }, a.prototype.results_toggle = function () { return this.results_showing ? this.results_hide() : this.results_show() }, a.prototype.results_search = function (a) { return this.results_showing ? this.winnow_results() : this.results_show() }, a.prototype.winnow_results = function () { var a, b, c, d, e, f, g, h, i, j, k, l; for (this.no_results_clear(), e = 0, g = this.get_search_text(), a = g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), d = this.get_search_regex(a), b = this.get_highlight_regex(a), l = this.results_data, j = 0, k = l.length; k > j; j++)c = l[j], c.search_match = !1, f = null, this.include_option_in_results(c) && (c.group && (c.group_match = !1, c.active_options = 0), null != c.group_array_index && this.results_data[c.group_array_index] && (f = this.results_data[c.group_array_index], 0 === f.active_options && f.search_match && (e += 1), f.active_options += 1), c.search_text = c.group ? c.label : c.html, (!c.group || this.group_search) && (c.search_match = this.search_string_match(c.search_text, d), c.search_match && !c.group && (e += 1), c.search_match ? (g.length && (h = c.search_text.search(b), i = c.search_text.substr(0, h + g.length) + "</em>" + c.search_text.substr(h + g.length), c.search_text = i.substr(0, h) + "<em>" + i.substr(h)), null != f && (f.group_match = !0)) : null != c.group_array_index && this.results_data[c.group_array_index].search_match && (c.search_match = !0))); return this.result_clear_highlight(), 1 > e && g.length ? (this.update_results_content(""), this.no_results(g)) : (this.update_results_content(this.results_option_build()), this.winnow_results_set_highlight()) }, a.prototype.get_search_regex = function (a) { var b, c; return b = this.search_contains ? "" : "^", c = this.case_sensitive_search ? "" : "i", new RegExp(b + a, c) }, a.prototype.get_highlight_regex = function (a) { var b, c; return b = this.search_contains ? "" : "\\b", c = this.case_sensitive_search ? "" : "i", new RegExp(b + a, c) }, a.prototype.search_string_match = function (a, b) { var c, d, e, f; if (b.test(a)) return !0; if (this.enable_split_word_search && (a.indexOf(" ") >= 0 || 0 === a.indexOf("[")) && (d = a.replace(/\[|\]/g, "").split(" "), d.length)) for (e = 0, f = d.length; f > e; e++)if (c = d[e], b.test(c)) return !0 }, a.prototype.choices_count = function () { var a, b, c, d; if (null != this.selected_option_count) return this.selected_option_count; for (this.selected_option_count = 0, d = this.form_field.options, b = 0, c = d.length; c > b; b++)a = d[b], a.selected && (this.selected_option_count += 1); return this.selected_option_count }, a.prototype.choices_click = function (a) { return a.preventDefault(), this.activate_field(), this.results_showing || this.is_disabled ? void 0 : this.results_show() }, a.prototype.keydown_checker = function (a) { var b, c; switch (b = null != (c = a.which) ? c : a.keyCode, this.search_field_scale(), 8 !== b && this.pending_backstroke && this.clear_backstroke(), b) { case 8: this.backstroke_length = this.get_search_field_value().length; break; case 9: this.results_showing && !this.is_multiple && this.result_select(a), this.mouse_on_container = !1; break; case 13: this.results_showing && a.preventDefault(); break; case 27: this.results_showing && a.preventDefault(); break; case 32: this.disable_search && a.preventDefault(); break; case 38: a.preventDefault(), this.keyup_arrow(); break; case 40: a.preventDefault(), this.keydown_arrow() } }, a.prototype.keyup_checker = function (a) { var b, c; switch (b = null != (c = a.which) ? c : a.keyCode, this.search_field_scale(), b) { case 8: this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0 ? this.keydown_backstroke() : this.pending_backstroke || (this.result_clear_highlight(), this.results_search()); break; case 13: a.preventDefault(), this.results_showing && this.result_select(a); break; case 27: this.results_showing && this.results_hide(); break; case 9: case 16: case 17: case 18: case 38: case 40: case 91: break; default: this.results_search() } }, a.prototype.clipboard_event_checker = function (a) { var b = this; if (!this.is_disabled) return setTimeout(function () { return b.results_search() }, 50) }, a.prototype.container_width = function () { return null != this.options.width ? this.options.width : "" + this.form_field.offsetWidth + "px" }, a.prototype.include_option_in_results = function (a) { return this.is_multiple && !this.display_selected_options && a.selected ? !1 : !this.display_disabled_options && a.disabled ? !1 : a.empty ? !1 : !0 }, a.prototype.search_results_touchstart = function (a) { return this.touch_started = !0, this.search_results_mouseover(a) }, a.prototype.search_results_touchmove = function (a) { return this.touch_started = !1, this.search_results_mouseout(a) }, a.prototype.search_results_touchend = function (a) { return this.touch_started ? this.search_results_mouseup(a) : void 0 }, a.prototype.outerHTML = function (a) { var b; return a.outerHTML ? a.outerHTML : (b = document.createElement("div"), b.appendChild(a), b.innerHTML) }, a.prototype.get_single_html = function () { return '<a class="chosen-single chosen-default">\n  <span>' + this.default_text + '</span>\n  <div><b></b></div>\n</a>\n<div class="chosen-drop">\n  <div class="chosen-search">\n    <input class="chosen-search-input" type="text" autocomplete="off" />\n  </div>\n  <ul class="chosen-results"></ul>\n</div>' }, a.prototype.get_multi_html = function () { return '<ul class="chosen-choices">\n  <li class="search-field">\n    <input class="chosen-search-input" type="text" autocomplete="off" value="' + this.default_text + '" />\n  </li>\n</ul>\n<div class="chosen-drop">\n  <ul class="chosen-results"></ul>\n</div>' }, a.prototype.get_no_results_html = function (a) { return '<li class="no-results">\n  ' + this.results_none_found + " <span>" + a + "</span>\n</li>" }, a.browser_is_supported = function () { return "Microsoft Internet Explorer" === window.navigator.appName ? document.documentMode >= 8 : /iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent) ? !1 : !0 }, a.default_multiple_text = "Select Some Options", a.default_single_text = "Select an Option", a.default_no_result_text = "No results match", a }(), a = _MTS_JQUERY, a.fn.extend({ chosen: function (d) { return b.browser_is_supported() ? this.each(function (b) { var e, f; return e = a(this), f = e.data("chosen"), "destroy" === d ? void (f instanceof c && f.destroy()) : void (f instanceof c || e.data("chosen", new c(this, d))) }) : this } }), c = function (b) { function c() { return e = c.__super__.constructor.apply(this, arguments) } return h(c, b), c.prototype.setup = function () { return this.form_field_jq = a(this.form_field), this.current_selectedIndex = this.form_field.selectedIndex }, c.prototype.set_up_html = function () { var b, c; return b = ["chosen-container"], b.push("chosen-container-" + (this.is_multiple ? "multi" : "single")), this.inherit_select_classes && this.form_field.className && b.push(this.form_field.className), this.is_rtl && b.push("chosen-rtl"), c = { "class": b.join(" "), title: this.form_field.title }, this.form_field.id.length && (c.id = this.form_field.id.replace(/[^\w]/g, "_") + "_chosen"), this.container = a("<div />", c), this.container.width(this.container_width()), this.is_multiple ? this.container.html(this.get_multi_html()) : this.container.html(this.get_single_html()), this.form_field_jq.hide().after(this.container), this.dropdown = this.container.find("div.chosen-drop").first(), this.search_field = this.container.find("input").first(), this.search_results = this.container.find("ul.chosen-results").first(), this.search_field_scale(), this.search_no_results = this.container.find("li.no-results").first(), this.is_multiple ? (this.search_choices = this.container.find("ul.chosen-choices").first(), this.search_container = this.container.find("li.search-field").first()) : (this.search_container = this.container.find("div.chosen-search").first(), this.selected_item = this.container.find(".chosen-single").first()), this.results_build(), this.set_tab_index(), this.set_label_behavior() }, c.prototype.on_ready = function () { return this.form_field_jq.trigger("chosen:ready", { chosen: this }) }, c.prototype.register_observers = function () { var a = this; return this.container.bind("touchstart.chosen", function (b) { a.container_mousedown(b) }), this.container.bind("touchend.chosen", function (b) { a.container_mouseup(b) }), this.container.bind("mousedown.chosen", function (b) { a.container_mousedown(b) }), this.container.bind("mouseup.chosen", function (b) { a.container_mouseup(b) }), this.container.bind("mouseenter.chosen", function (b) { a.mouse_enter(b) }), this.container.bind("mouseleave.chosen", function (b) { a.mouse_leave(b) }), this.search_results.bind("mouseup.chosen", function (b) { a.search_results_mouseup(b) }), this.search_results.bind("mouseover.chosen", function (b) { a.search_results_mouseover(b) }), this.search_results.bind("mouseout.chosen", function (b) { a.search_results_mouseout(b) }), this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen", function (b) { a.search_results_mousewheel(b) }), this.search_results.bind("touchstart.chosen", function (b) { a.search_results_touchstart(b) }), this.search_results.bind("touchmove.chosen", function (b) { a.search_results_touchmove(b) }), this.search_results.bind("touchend.chosen", function (b) { a.search_results_touchend(b) }), this.form_field_jq.bind("chosen:updated.chosen", function (b) { a.results_update_field(b) }), this.form_field_jq.bind("chosen:activate.chosen", function (b) { a.activate_field(b) }), this.form_field_jq.bind("chosen:open.chosen", function (b) { a.container_mousedown(b) }), this.form_field_jq.bind("chosen:close.chosen", function (b) { a.close_field(b) }), this.search_field.bind("blur.chosen", function (b) { a.input_blur(b) }), this.search_field.bind("keyup.chosen", function (b) { a.keyup_checker(b) }), this.search_field.bind("keydown.chosen", function (b) { a.keydown_checker(b) }), this.search_field.bind("focus.chosen", function (b) { a.input_focus(b) }), this.search_field.bind("cut.chosen", function (b) { a.clipboard_event_checker(b) }), this.search_field.bind("paste.chosen", function (b) { a.clipboard_event_checker(b) }), this.is_multiple ? this.search_choices.bind("click.chosen", function (b) { a.choices_click(b) }) : this.container.bind("click.chosen", function (a) { a.preventDefault() }) }, c.prototype.destroy = function () { return a(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action), this.form_field_label.length > 0 && this.form_field_label.unbind("click.chosen"), this.search_field[0].tabIndex && (this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex), this.container.remove(), this.form_field_jq.removeData("chosen"), this.form_field_jq.show() }, c.prototype.search_field_disabled = function () { return this.is_disabled = this.form_field.disabled || this.form_field_jq.parents("fieldset").is(":disabled"), this.container.toggleClass("chosen-disabled", this.is_disabled), this.search_field[0].disabled = this.is_disabled, this.is_multiple || this.selected_item.unbind("focus.chosen", this.activate_field), this.is_disabled ? this.close_field() : this.is_multiple ? void 0 : this.selected_item.bind("focus.chosen", this.activate_field) }, c.prototype.container_mousedown = function (b) { var c; if (!this.is_disabled) return !b || "mousedown" !== (c = b.type) && "touchstart" !== c || this.results_showing || b.preventDefault(), null != b && a(b.target).hasClass("search-choice-close") ? void 0 : (this.active_field ? this.is_multiple || !b || a(b.target)[0] !== this.selected_item[0] && !a(b.target).parents("a.chosen-single").length || (b.preventDefault(), this.results_toggle()) : (this.is_multiple && this.search_field.val(""), a(this.container[0].ownerDocument).bind("click.chosen", this.click_test_action), this.results_show()), this.activate_field()) }, c.prototype.container_mouseup = function (a) { return "ABBR" !== a.target.nodeName || this.is_disabled ? void 0 : this.results_reset(a) }, c.prototype.search_results_mousewheel = function (a) { var b; return a.originalEvent && (b = a.originalEvent.deltaY || -a.originalEvent.wheelDelta || a.originalEvent.detail), null != b ? (a.preventDefault(), "DOMMouseScroll" === a.type && (b = 40 * b), this.search_results.scrollTop(b + this.search_results.scrollTop())) : void 0 }, c.prototype.blur_test = function (a) { return !this.active_field && this.container.hasClass("chosen-container-active") ? this.close_field() : void 0 }, c.prototype.close_field = function () { return a(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action), this.active_field = !1, this.results_hide(), this.container.removeClass("chosen-container-active"), this.clear_backstroke(), this.show_search_field_default(), this.search_field_scale(), this.search_field.blur() }, c.prototype.activate_field = function () { return this.is_disabled ? void 0 : (this.container.addClass("chosen-container-active"), this.active_field = !0, this.search_field.val(this.search_field.val()), this.search_field.focus()) }, c.prototype.test_active_click = function (b) { var c; return c = a(b.target).closest(".chosen-container"), c.length && this.container[0] === c[0] ? this.active_field = !0 : this.close_field() }, c.prototype.results_build = function () { return this.parsing = !0, this.selected_option_count = null, this.results_data = d.select_to_array(this.form_field), this.is_multiple ? this.search_choices.find("li.search-choice").remove() : this.is_multiple || (this.single_set_selected_text(), this.disable_search || this.form_field.options.length <= this.disable_search_threshold ? (this.search_field[0].readOnly = !0, this.container.addClass("chosen-container-single-nosearch")) : (this.search_field[0].readOnly = !1, this.container.removeClass("chosen-container-single-nosearch"))), this.update_results_content(this.results_option_build({ first: !0 })), this.search_field_disabled(), this.show_search_field_default(), this.search_field_scale(), this.parsing = !1 }, c.prototype.result_do_highlight = function (a) { var b, c, d, e, f; if (a.length) { if (this.result_clear_highlight(), this.result_highlight = a, this.result_highlight.addClass("highlighted"), d = parseInt(this.search_results.css("maxHeight"), 10), f = this.search_results.scrollTop(), e = d + f, c = this.result_highlight.position().top + this.search_results.scrollTop(), b = c + this.result_highlight.outerHeight(), b >= e) return this.search_results.scrollTop(b - d > 0 ? b - d : 0); if (f > c) return this.search_results.scrollTop(c) } }, c.prototype.result_clear_highlight = function () { return this.result_highlight && this.result_highlight.removeClass("highlighted"), this.result_highlight = null }, c.prototype.results_show = function () { return this.is_multiple && this.max_selected_options <= this.choices_count() ? (this.form_field_jq.trigger("chosen:maxselected", { chosen: this }), !1) : (this.container.addClass("chosen-with-drop"), this.results_showing = !0, this.search_field.focus(), this.search_field.val(this.get_search_field_value()), this.winnow_results(), this.form_field_jq.trigger("chosen:showing_dropdown", { chosen: this })) }, c.prototype.update_results_content = function (a) { return this.search_results.html(a) }, c.prototype.results_hide = function () { return this.results_showing && (this.result_clear_highlight(), this.container.removeClass("chosen-with-drop"), this.form_field_jq.trigger("chosen:hiding_dropdown", { chosen: this })), this.results_showing = !1 }, c.prototype.set_tab_index = function (a) { var b; return this.form_field.tabIndex ? (b = this.form_field.tabIndex, this.form_field.tabIndex = -1, this.search_field[0].tabIndex = b) : void 0 }, c.prototype.set_label_behavior = function () { return this.form_field_label = this.form_field_jq.parents("label"), !this.form_field_label.length && this.form_field.id.length && (this.form_field_label = a("label[for='" + this.form_field.id + "']")), this.form_field_label.length > 0 ? this.form_field_label.bind("click.chosen", this.label_click_handler) : void 0 }, c.prototype.show_search_field_default = function () { return this.is_multiple && this.choices_count() < 1 && !this.active_field ? (this.search_field.val(this.default_text), this.search_field.addClass("default")) : (this.search_field.val(""), this.search_field.removeClass("default")) }, c.prototype.search_results_mouseup = function (b) { var c; return c = a(b.target).hasClass("active-result") ? a(b.target) : a(b.target).parents(".active-result").first(), c.length ? (this.result_highlight = c, this.result_select(b), this.search_field.focus()) : void 0 }, c.prototype.search_results_mouseover = function (b) { var c; return c = a(b.target).hasClass("active-result") ? a(b.target) : a(b.target).parents(".active-result").first(), c ? this.result_do_highlight(c) : void 0 }, c.prototype.search_results_mouseout = function (b) { return a(b.target).hasClass("active-result") ? this.result_clear_highlight() : void 0 }, c.prototype.choice_build = function (b) { var c, d, e = this; return c = a("<li />", { "class": "search-choice" }).html("<span>" + this.choice_label(b) + "</span>"), b.disabled ? c.addClass("search-choice-disabled") : (d = a("<a />", { "class": "search-choice-close", "data-option-array-index": b.array_index }), d.bind("click.chosen", function (a) { return e.choice_destroy_link_click(a) }), c.append(d)), this.search_container.before(c) }, c.prototype.choice_destroy_link_click = function (b) { return b.preventDefault(), b.stopPropagation(), this.is_disabled ? void 0 : this.choice_destroy(a(b.target)) }, c.prototype.choice_destroy = function (a) { return this.result_deselect(a[0].getAttribute("data-option-array-index")) ? (this.active_field ? this.search_field.focus() : this.show_search_field_default(), this.is_multiple && this.choices_count() > 0 && this.get_search_field_value().length < 1 && this.results_hide(), a.parents("li").first().remove(), this.search_field_scale()) : void 0 }, c.prototype.results_reset = function () { return this.reset_single_select_options(), this.form_field.options[0].selected = !0, this.single_set_selected_text(), this.show_search_field_default(), this.results_reset_cleanup(), this.trigger_form_field_change(), this.active_field ? this.results_hide() : void 0 }, c.prototype.results_reset_cleanup = function () { return this.current_selectedIndex = this.form_field.selectedIndex, this.selected_item.find("abbr").remove() }, c.prototype.result_select = function (a) { var b, c; return this.result_highlight ? (b = this.result_highlight, this.result_clear_highlight(), this.is_multiple && this.max_selected_options <= this.choices_count() ? (this.form_field_jq.trigger("chosen:maxselected", { chosen: this }), !1) : (this.is_multiple ? b.removeClass("active-result") : this.reset_single_select_options(), b.addClass("result-selected"), c = this.results_data[b[0].getAttribute("data-option-array-index")], c.selected = !0, this.form_field.options[c.options_index].selected = !0, this.selected_option_count = null, this.is_multiple ? this.choice_build(c) : this.single_set_selected_text(this.choice_label(c)), (!this.is_multiple || this.hide_results_on_select && !a.metaKey && !a.ctrlKey) && (this.results_hide(), this.show_search_field_default()), (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) && this.trigger_form_field_change({ selected: this.form_field.options[c.options_index].value }), this.current_selectedIndex = this.form_field.selectedIndex, a.preventDefault(), this.search_field_scale())) : void 0 }, c.prototype.single_set_selected_text = function (a) { return null == a && (a = this.default_text), a === this.default_text ? this.selected_item.addClass("chosen-default") : (this.single_deselect_control_build(), this.selected_item.removeClass("chosen-default")), this.selected_item.find("span").html(a) }, c.prototype.result_deselect = function (a) { var b; return b = this.results_data[a], this.form_field.options[b.options_index].disabled ? !1 : (b.selected = !1, this.form_field.options[b.options_index].selected = !1, this.selected_option_count = null, this.result_clear_highlight(), this.results_showing && this.winnow_results(), this.trigger_form_field_change({ deselected: this.form_field.options[b.options_index].value }), this.search_field_scale(), !0) }, c.prototype.single_deselect_control_build = function () { return this.allow_single_deselect ? (this.selected_item.find("abbr").length || this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'), this.selected_item.addClass("chosen-single-with-deselect")) : void 0 }, c.prototype.get_search_field_value = function () { return this.search_field.val() }, c.prototype.get_search_text = function () { return this.escape_html(a.trim(this.get_search_field_value())) }, c.prototype.escape_html = function (b) { return a("<div/>").text(b).html() }, c.prototype.winnow_results_set_highlight = function () { var a, b; return b = this.is_multiple ? [] : this.search_results.find(".result-selected.active-result"), a = b.length ? b.first() : this.search_results.find(".active-result").first(), null != a ? this.result_do_highlight(a) : void 0 }, c.prototype.no_results = function (a) { var b; return b = this.get_no_results_html(a), this.search_results.append(b), this.form_field_jq.trigger("chosen:no_results", { chosen: this }) }, c.prototype.no_results_clear = function () { return this.search_results.find(".no-results").remove() }, c.prototype.keydown_arrow = function () { var a; return this.results_showing && this.result_highlight ? (a = this.result_highlight.nextAll("li.active-result").first()) ? this.result_do_highlight(a) : void 0 : this.results_show() }, c.prototype.keyup_arrow = function () { var a; return this.results_showing || this.is_multiple ? this.result_highlight ? (a = this.result_highlight.prevAll("li.active-result"), a.length ? this.result_do_highlight(a.first()) : (this.choices_count() > 0 && this.results_hide(), this.result_clear_highlight())) : void 0 : this.results_show() }, c.prototype.keydown_backstroke = function () { var a; return this.pending_backstroke ? (this.choice_destroy(this.pending_backstroke.find("a").first()), this.clear_backstroke()) : (a = this.search_container.siblings("li.search-choice").last(), a.length && !a.hasClass("search-choice-disabled") ? (this.pending_backstroke = a, this.single_backstroke_delete ? this.keydown_backstroke() : this.pending_backstroke.addClass("search-choice-focus")) : void 0) }, c.prototype.clear_backstroke = function () { return this.pending_backstroke && this.pending_backstroke.removeClass("search-choice-focus"), this.pending_backstroke = null }, c.prototype.search_field_scale = function () { var b, c, d, e, f, g, h, i; if (this.is_multiple) { for (e = { position: "absolute", left: "-1000px", top: "-1000px", display: "none", whiteSpace: "pre" }, f = ["fontSize", "fontStyle", "fontWeight", "fontFamily", "lineHeight", "textTransform", "letterSpacing"], h = 0, i = f.length; i > h; h++)d = f[h], e[d] = this.search_field.css(d); return c = a("<div />").css(e), c.text(this.get_search_field_value()), a("body").append(c), g = c.width() + 25, c.remove(), b = this.container.outerWidth(), g = Math.min(b - 10, g), this.search_field.width(g) } }, c.prototype.trigger_form_field_change = function (a) { return this.form_field_jq.trigger("input", a), this.form_field_jq.trigger("change", a) }, c }(b) }).call(this);
﻿var mobileTab="news",_autocompIdx=-1,_acTimer=-1,_ajaxSpinTimer=null,_submenu=($(document).on("click","#twitterConnect",function(){window.open("https://twitter.com/"+("undefined"!=typeof _twitterName&&0<_twitterName.length?_twitterName:"myteamscoop"),"_blank")}),$(document).on("click","#facebookConnect, #facebookClick",function(){window.open("https://www.facebook.com/"+("undefined"!=typeof _facebookName&&0<_facebookName.length?_facebookName:"MyTeamScoop"),"_blank")}),[]),_iPad=0<=navigator.userAgent.toLowerCase().search(/ipad/)||0<=navigator.userAgent.toLowerCase().search(/iphone/),_event="click",_event2="mouseenter",_curShareId=-1,_emailFrom="From (Required)",_emailReq="Recipients (Required)",_emailMsg="Check out this story I found at "+("undefined"!=typeof _portalName&&0<_portalName.length?_portalName+"!":"My Team Scoop!"),_emailMsgOpt="Personal Message (Optional)",_reqColor="#BBBBBB",_blkColor="#1D1D1D",_errorTxt="",_focusErr="",_typeCon=null,_showMenu=!1,_menuItem=[],_justSlided=!1,_adClicks=[],_defaultPortalSport=0,_doneLoading=!1,_hitTimer=!1,_filterPages=[],_filterKeys=[["#msNews","#newsInsert, #featuredContent, #news, #features, .fpvHeadHolder, .fPContainer, .videoWrap"],["#msMyTeams",".teamsFollowWrap"],["#msTeams","#teamList"],["#msStats","#filterMenu, #stats, .note1"],["#msScores","#scores, .note1, #scoreGridWidget"],["#msSchedules","#upcoming, #ucEvents, #upEvents, .note1"],["#msStandings","#filterMenu, #standings"],["#msSchools","#schoolList"]],_keyException=[8,37,38,39,40],_sm=0,_jsCachedSequence=[],_jsCacheBusy=!1,_chosenSupported="Microsoft Internet Explorer"===window.navigator.appName?8<=document.documentMode:!/iP(od|hone)/i.test(window.navigator.userAgent)&&(!/Android/i.test(window.navigator.userAgent)||!/Mobile/i.test(window.navigator.userAgent));function debounce(i,o,a){var r;return function(){var e=this,t=arguments,n=a&&!r;clearTimeout(r),r=setTimeout(function(){r=null,a||i.apply(e,t)},o),n&&i.apply(e,t)}}function isMobileMedia(){return window.matchMedia?window.matchMedia("(min-width: 320px)").matches&&window.matchMedia("(max-width: 767px)").matches:320<=window.innerWidth&&window.innerWidth<=767}function isTabletMedia(){return window.matchMedia?window.matchMedia("(min-width: 768px)").matches&&window.matchMedia("(max-width: 1024px)").matches:768<=window.innerWidth&&window.innerWidth<=1024}function isDesktopMedia(){return window.matchMedia?window.matchMedia("(min-width: 1025px)").matches:1025<=window.innerWidth}function GetQueryArrayFromUrl(e){var t=e.indexOf("?");if(""==e||t<0)return{};e=e.substr(t+1).split("&");for(var n={},i=0;i<e.length;++i){var o=e[i].split("=");2==o.length&&(n[o[0]]=decodeURIComponent(o[1].replace(/\+/g," ")))}return n}$.fn.center=function(){this.css("position","absolute");var e=($(window).height()-this.height())/2+$(window).scrollTop(),t=($(window).width()-this.width())/2+$(window).scrollLeft();return this.css("top",(0<e?e:0)+"px"),this.css("left",(0<t?t:0)+"px"),this},jQuery.Query=GetQueryArrayFromUrl(window.location.search),jQuery.urlName=function(e){return e.replace(_MTS_urlRegex,"-").replace(/ /g,"-").replace(/\-+/g,"-")};var _isFileInputSupported=!navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0)|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|Pre\/1.2|Kindle\/(1.0|2.0|2.5|3.0))/),_noFileReaderSupport=void 0===window.FileReader||void 0===window.File||void 0===window.FileList||void 0===window.Blob;function AlertCycle(){this.parent=null,this.frames=0,this.callback=function(){},this.last=new Date,this.index=0,this.delay=0,this.drop=0}AlertCycle.prototype={init:function(e,t){this.index=0,this.frames=$(".alertItem").length,this.delay=5e3,this.drop=7500,this.last=new Date;var n=this;setInterval(function(){n.timer()},this.delay)},timer:function(){var e,t=new Date;t-this.last>this.drop||(this.last=t,e=this.index++,this.index>=this.frames&&(this.index=0),this.index!=e&&(this.anim(),this.last=t))},anim:function(){var e=this;$("#alertsBody").animate({"margin-top":"30px"},100,"swing",function(){$("#alertsBody").html($("#alert_item_"+e.index).html()),$("#alertsBody").animate({"margin-top":"0px"},100,"swing",function(){})})}},"refresh"==window.name&&(window.stop(),window.location.replace(window.location.pathname+window.location.search+window.location.hash),window.name="");var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser",this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version",this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(e){for(var t=0;t<e.length;t++){var n=e[t].string,i=e[t].prop;if(this.versionSearchString=e[t].versionSearch||e[t].identity,n){if(-1!=n.indexOf(e[t].subString))return e[t].identity}else if(i)return e[t].identity}},searchVersion:function(e){var t=e.indexOf(this.versionSearchString);if(-1!=t)return parseFloat(e.substring(t+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera",versionSearch:"Version"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Internet Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.userAgent,subString:"iPad",identity:"iPad"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};function partial(t){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.concat(Array.prototype.slice.call(arguments));return t.apply(this,e)}}function mts_lazyloading(){$("img.mts_lazy").lazyload({failure_limit:$("img.mts_lazy").length-1,event:"mts_lazy"}),$(".mts_lazy:in-viewport").removeClass("mts_lazy")}function set_MTS_SaveHistoryState(e){"undefined"==typeof _MTS_SaveHistoryState&&(_MTS_SaveHistoryState=[]),_MTS_SaveHistoryState.push(e)}function _MTS_commonWidgetInit(){var e=$(".mobileSelectors");if(0<e.length&&"none"!=e.css("display")){switch(mobileTab){case"schedules":$("#msSchedules").click();break;case"scores":$("#msScores").click();break;default:$("#msNews").click()}0<$(".scores_list_widget:visible").length&&$(".scores_grid_widget").hide()}}function resizeNav(){isDesktopMedia()&&($("#mainContainer").show(),$("#content").show())}function resizeOnLoad(){"boolean"==typeof _registrationPop&&_registrationPop&&GetRegistrationPop(),resizeNav();var e=new Image;e.src=$("#logo").attr("src"),e.onload=function(){$("#headContainer"),$("#logo").outerHeight(),$(".navigationContainer"),$(".masterMcWrap"),$(".sportsContainer"),$(".centeredAd"),$(".hpCtr"),$("#page"),$("#logo");var e=$(".searchBar"),e=($(".searchBar .chosen-container, .searchBar select"),$(".hSignLog"),e.position().left,$("#header")),e=(parseInt(e.css("padding-left")),$(".mts_widget:empty").hide(),$(".teamsFollowWrap"));0==e.children().length&&(e.hide(),$(".myTeamsHeader").hide())}}function GetRegistrationPop(){null==readCookie("popupTimeout")&&ajax("/Content/regPromo.aspx",[],function(e){$("body").append(e),$("#regPromoContentCtr, .rpBg").click(function(){HideRegistrationPop(7)}),$("#regPromoContentCtr #signUpNow").click(function(e){e.stopPropagation(),GotoRegistration()}),$("#regPromoContentCtr #signInNow").click(function(e){e.stopPropagation(),GotoLogin()}),$("#regPromoContentCtr #never").click(function(e){e.stopPropagation(),HideRegistrationPop(365)})})}function createCookie(e,t,n){var i;n=n?((i=new Date).setTime(i.getTime()+24*n*60*60*1e3),"; expires="+i.toGMTString()):"",document.cookie=e+"="+t+n+"; path=/"}function readCookie(e){for(var t=e+"=",n=document.cookie.split(";"),i=0;i<n.length;i++){for(var o=n[i];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return null}function HideRegistrationPop(e){createCookie("popupTimeout","",e),$(".rpBg, #regPromoContentCtr").fadeTo(1e3,0,function(){$(this).hide()})}function GotoRegistration(){window.location="/user/register/"}function GotoLogin(){window.location=$("#loginBottom").attr("href")}function HighlightAutoComplete(e,t){for(var n=e-1;0<=n;n--){var i=$(t.children()[n]);n==_autocompIdx?i.addClass("highlight"):i.removeClass("highlight")}}function SubmitSearch(){var e=$("#searchFrm"),t=$("#searchType"),t=0<t.length?t[0].options:"";0<t.length&&e.attr("action",ReplaceQueryParameter(e.attr("action"),"type",t[t.selectedIndex].value)),e.submit()}function StartAutoComplete(me,a,action,attach){if(0<me.value.length){var p=[],filters=(p.push({name:"phrase",value:me.value}),p.push({name:"ac",value:1}),p.push({name:"gz",value:"t"}),p.push({name:"s",value:"0"}),p.push({name:"rt",value:-1}),p.push({name:"n",value:5}),p.push({name:"sport",value:-1}),p.push({name:"incHid",value:"f"}),$("#searchType"));if(0<filters.length){var types=[],options=filters[0].options;if("All"==filters.val())for(var i=options.length-1;1<=i;i--)types.push(options[i].value);else types.push(options[options.selectedIndex].value);0<types.length&&p.push({name:"types",value:types}),ajax("/api/search.aspx",p,function(r){var o;if(eval("o = "+r+";"),0!=o.items.length){a.html("");for(var attachTarget=void 0!==attach?attach:$("#searchTxt"),sbh=attachTarget.height(),sbt=attachTarget.offset().top,sbl=attachTarget.offset().left,e=(a.css({top:sbt+sbh+10+"px"}),a.css({left:sbl+"px"}),a.show(),null),i=0;i<o.items.length;i++)e=document.createElement("a"),e.className="itm",e.innerHTML=o.items[i].title,e.id=o.items[i].id,e.href=o.items[i].link,a.append(e)}else $("#acomp").css({display:"none"})})}}}function GetSportFromId(e){if(null==typeof _sports)return e;for(var t=_sports.length-1;0<=t;t--)if(_sports[t].Id==e)return _sports[t].UrlName;return e}function GetLevelFromId(e){if(null==typeof _levels)return e;for(var t=_levels.length-1;0<=t;t--)if(_levels[t].Id==e)return _levels[t].UrlName;return e}function GetGenderFromId(e){return null==typeof _genders||_genders.length<e?e:_genders[e]}function CreateMenuClick(e,t){var n,i=t.split(",");for(n in i)if(!(i[n].length<=0)){var o,a=!1;for(o in _filterPages)if($.trim(i[n])==_filterPages[o]){a=!0;break}a||_filterPages.push($.trim(i[n]))}$(e).click(function(){FilterContent(t)})}function ToggleMobileMenu(){$(".topTabs").toggleClass("topTabsO")}function FilterContent(e){for(var t=_filterPages.length-1;0<=t;t--)$(_filterPages[t]).hide();$(e).show()}function TrackImpression(e,t){TrackingEvent("impression","DFP Impression",e,1)}function TrackClick(e){TrackingEvent("click","DFP Click",e,1)}function TrackPhoto(e){TrackingEvent("click","Photo Click","IMG "+e,1)}function TrackingEvent(e,t,n,i){"undefined"!=typeof ga&&ga("send","event",n,e,t,i,!0),"undefined"!=typeof _gaq&&_gaq.push(["_trackEvent",t,n])}function HideAd(){var e=$(".fullAdView"),t=$(".fullPageAd");e.fadeTo(600,0,function(){e.hide()}),t.fadeTo(600,0,function(){t.hide()})}function AdHeight(e){var t=e-100;0<t&&setTimeout(function(){AdHeight(e)},t)}function AdjustAdHeight(){var e=$(".fullAdView");0<e.length&&e.css({height:window.innerHeight+window.outerHeight||document.height||$(document).height()})}function PositionDropdown(e,t){var e=$(e),n=(t.offset(),$("#mainContainer").offset());t.css({top:e.offset().top+e.outerHeight()-n.top+"px",left:e.offset().left-n.left+"px"})}function CreateSearchButton(t,e,n){t.focus(function(){var t=$(this);t.select(),window.setTimeout(function(){t.select()},1),t.mouseup(function e(){return t.off("mouseup",e),!1})}),e.click(function(){PerformSearch(t,n)}),t.keyup(function(e){13==e.keyCode&&PerformSearch(t,n)})}function PerformSearch(e,t){e=$.trim(e.val());0<e.length&&(window.location=t+encodeURIComponent(escape(e)))}function CheckAdClick(e){for(var t=_adClicks.length-1;0<=t;t--)if(e==_adClicks[t])return!1;return _adClicks.push(e),!0}function SaveToHistory(){try{if(window.self!==window.top)return}catch(e){return}var e=JSON.parse(sessionStorage.getItem("history")),t=(null==e&&(e=[]),parseInt(sessionStorage.getItem("lastPg"))),n="true"==sessionStorage.getItem("back"),i=parseInt(sessionStorage.getItem("histLength"));if(0==window.performance.navigation.type&&null!=t&&!n){for(var o=-1,a=e.length-1;0<=a;a--)if(e[a].id==t){o=a;break}0<=a&&(e=e.splice(0,a+1))}if(null!=history&&"object"==typeof history&&null!==history.state){var n=$.grep(history.state,function(e){return"historyId"==e.name}),r=$.grep(history.state,function(e){return"histCount"==e.name});0<n.length&&(_MTS_pageId=n[0].value);for(o=-1,a=e.length-1;0<=a;a--)if(e[a].id==_MTS_pageId&&e[a].pg==_MTS_pageVP){o=a;break}0<r.length&&0<=o&&(_MTS_histCount=r[0].value,e[o].count=r[0].value)}else 0==window.performance.navigation.type&&(0<e.length&&e[e.length-1].pg==_MTS_pageVP?(_MTS_pageId=e[e.length-1].id,history.length!==i&&e[e.length-1].count++,_MTS_histCount=e[e.length-1].count):(0<e.length&&(_MTS_pageId=e[e.length-1].id+1),_MTS_histCount=1,e.push({id:_MTS_pageId,pg:_MTS_pageVP,count:_MTS_histCount})));sessionStorage.setItem("history",JSON.stringify(e)),sessionStorage.setItem("lastPg",_MTS_pageId),sessionStorage.setItem("back",!1),sessionStorage.setItem("histLength",history.length)}function BackAndRefresh(){if("undefined"==typeof mts_androidApp){(null==window.history||window.history.length<=1)&&window.close();var e=JSON.parse(sessionStorage.getItem("history")),t=-1;if(null!=e){for(var n=0,i=e.length-1;0<=i&&(e[i].id==_MTS_pageId||e[i].pg==_MTS_pageVP||0<=e[i].pg.indexOf("~/Login.aspx")||0<=e[i].pg.indexOf("~/Register.aspx"));i--)n--;t=n}window.name="refresh",sessionStorage.setItem("back",!0),window.history.go(t)}else mts_androidApp.BackAndRefresh()}function HoverMenu(e,t,n){if($(window).width()<=768)return!1;for(var i=-1,o=_menuItem.length-1;0<=o;o--)if(_menuItem[o].id==e&&_menuItem[o].type==t&&_menuItem[o].gender==n){i=o;break}-1==i&&(_menuItem.push({id:e,type:t,show:!1,loaded:!1,loading:!1,gender:n}),i=_menuItem.length-1),LoadMenu(i,t,n)}function UnhoverMenu(e,t,n){for(var i=_menuItem.length-1;0<=i;i--)if(_menuItem[i].id==e&&_menuItem[i].type==t&&(null==n||_menuItem[i].gender==n))return _menuItem[i].show=!1}function holdMenu(){_justSlided=_showMenu=!0,setTimeout(function(){_justSlided=!1},400)}function slideMenu(e,t){var n;null!=_typeCon&&(n=_typeCon[0].scrollHeight-_typeCon[0].clientHeight,_typeCon.scrollTop(n-n*(t.value/100)))}function LoadMenu(t,n,i){return 1!=_menuItem[t].show&&(_menuItem[t].show=!0,!_menuItem[t].loading&&(_menuItem[t].loading=!0,void setTimeout(function(){var e;1==_menuItem[t].show?((e=$(".menuDrop")).find(".featuredStoryContainer").remove(),e.find(".recentHeadlinesContainer").remove(),e.find(".noHeadlines").remove(),1==_menuItem[t].loaded?(e.append($("#"+n+"_"+_menuItem[t].id+(null!=i?"_"+i:"")).html()),_menuItem[t].loading=!1):((e=[]).push({name:"mode",value:n}),e.push({name:"menuId",value:_menuItem[t].id}),null!=_menuItem[t].gender&&e.push({name:"gender",value:_menuItem[t].gender}))):_menuItem[t].loading=!1},400)))}function HidePopupMenu(e){return!_justSlided&&(_showMenu=!1,e?($(".menuDropBg").removeClass("menuDropBgShow").removeAttr("style"),!1):void setTimeout(function(){_showMenu||($(".menuDropBg").removeClass("menuDropBgShow"),$("#div-gpt-ad-728x90_ad_container").show())},125))}function CheckEmailAddress(e){var t=new RegExp(/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i);return!!e.match(t)}function CheckForm(e,t){if(e==_emailReq)return _errorTxt="You have entered an invalid email address.",_focusErr=$("#emailList"),!1;if(-1==_userId&&t==_emailFrom)return _errorTxt="The from field is required when not logged in.",_focusErr=$("#emailFrom"),!1;for(var n=e.split(";"),i=0;i<n.length;i++)for(var o=n[i].split(","),a=0;a<o.length;a++)if(!CheckEmailAddress(o[a].trim()))return _errorTxt="You have entered an invalid email address.",_focusErr=$("#emailList"),!1;return!0}BrowserDetect.init(),"boolean"==typeof _MTS_fireCommon&&!_MTS_fireCommon||(window.fbAsyncInit=function(){FB.init({appId:_fbClientId,channelUrl:_baseUri+"auth/facebook/channel.htm",status:!0,cookie:!0,xfbml:!0})},function(e){var t="facebook-jssdk",n=e.getElementsByTagName("script")[0];e.getElementById(t)||((e=e.createElement("script")).id=t,e.async=!0,e.src="//connect.facebook.net/en_US/all.js",n.parentNode.insertBefore(e,n))}(document),"boolean"==typeof _loadTwitterSDK&&null!=_loadTwitterSDK&&!1===_loadTwitterSDK&&(void 0===window.FileReader||"Opera"==BrowserDetect.browser||_iPad||"Safari"==BrowserDetect.browser||(_loadTwitterSDK=!0)),"boolean"==typeof _loadTwitterSDK&&null!=_loadTwitterSDK&&!_loadTwitterSDK||function(e,t,n){var i=e.getElementsByTagName(t)[0];e.getElementById(n)||((e=e.createElement(t)).id=n,e.src="https://platform.twitter.com/widgets.js",i.parentNode.insertBefore(e,i))}(document,"script","twitter-wjs")),$(window).bind("load",function(){_doneLoading=!0,_hitTimer&&HideAd(),AdjustAdHeight()}),$(document).on("widgetsloaded",mts_lazyloading),$(window).on("unload",function(){var e;"undefined"!=typeof _MTS_SaveHistoryState&&$(_MTS_SaveHistoryState).each(function(e,t){t()}),null!=history&&"object"==typeof history&&null!=history.replaceState&&"function"==typeof history.replaceState&&(null==(e=history.state)&&(e=[]),0==$.grep(e,function(e){return"historyId"==e.name}).length&&"undefined"!=typeof _MTS_pageId&&e.push({name:"historyId",value:_MTS_pageId}),0==$.grep(e,function(e){return"histCount"==e.name}).length&&"undefined"!=typeof _MTS_histcount&&e.push({name:"histCount",value:_MTS_histCount}),history.replaceState(e,""))}),$(document).one("widgetsloaded",function(){if(SaveToHistory(),leftRight(),$(window).resize(function(){leftRight(),window.matchMedia("(min-width: 1024px)").matches&&($(".hpCtr, .navigationContainer").removeClass("mainNavO"),"boolean"==typeof _MTS_customDropdown&&!_MTS_customDropdown||ToggleCustomDropdowns())}),$(".betaIndicator").click(function(){$(this).hide()}),WireLockingNotice(),"boolean"==typeof _MTS_fireCommon&&!_MTS_fireCommon)return!1;var er,appUrl,fav=("boolean"==typeof _warnAboutRejected&&_warnAboutRejected&&(er=$(".emailRejected"),er.show(),$(".rejectHide").click(function(){er.hide()})),"boolean"==typeof _MTS_customDropdown&&!_MTS_customDropdown||ToggleCustomDropdowns(),"function"==typeof $.smartbanner&&(appUrl=_webUri+"images/custom/"+_portalId+"/AppIcon40.png",$.smartbanner()),$(window).width()<768&&319<$(window).width()&&$(".note1").click(function(){var e=$("#options");"none"==e.css("display")?e.show():e.hide()}),$(".fullAdView")),adLength=5e3,sa,bbr=(AdHeight(adLength),0<fav.length&&(sa=$("#skipAd"),sa.slideToggle(),sa.click(function(){HideAd()}),setTimeout(function(){_hitTimer=!0,_doneLoading&&HideAd()},adLength)),$("#backBtnRef")),search=((null==window.history||window.history.length<=1)&&bbr.html("Close"),bbr.click(function(){BackAndRefresh()}),21!=_portalId&&$(document).on(_event,".grdImgBot",function(){var e=$(".sportsContainer");e.animate({scrollTop:e.scrollTop()+e.height()})}),$(".closeSpinner, .busySpinnerBg").click(function(){$(".busySpinnerBg").hide()}),$(document).on(_event,"#linkToScores",function(){var e,t,n,i=$("#scoreLink"),o=$("#sport"),o=0<o.length?o.val():void 0!==_sm?_sm:-1;0<i.length&&o<=0?window.location=i.attr("href"):(i="object"==typeof _date&&null!=_date?_date:new Date,e="object"==typeof _endDate&&null!=_endDate?_endDate:new Date(i.getFullYear(),i.getMonth(),i.getDate()-6),i=i.getMonth()+1+"-"+i.getDate()+"-"+i.getFullYear(),e=e.getMonth()+1+"-"+e.getDate()+"-"+e.getFullYear(),t=n="","undefined"!=typeof _filterType&&"undefined"!=typeof _filterId&&"school"===_filterType.toLowerCase()&&(t=_filterId),n="undefined"!=typeof _curGender?getDescription(o,0<$("#level option").length?$("#level").val():1,t,_curGender,!1)+"?start="+e+"&end="+i:0<_defaultPortalSport?getDescription(_defaultPortalSport,1,t,0,!1)+"?start="+e+"&end="+i:getDescription(0,1,t,0,!1)+"?start="+i+"&end="+i,window.location=_MTS_SITEURL+"scores"+n)}),$("#fbLogin, #fbCont").click(function(){FB.login(function(t){t.authResponse&&FB.api("/me?fields=first_name,last_name,gender,email",function(e){window.location="/auth/facebook/oauth2.aspx?fbId="+t.authResponse.userID+"&email="+e.email+"&first="+e.first_name+"&last="+e.last_name+"&gender="+e.gender+"&ret="+_fbTarget})},{scope:"email"})}),"#searchTxt"),goSearch=($(document).on("keypress",search,function(e){var t=$("#acomp");return 0!=t.length&&"none"!=t.attr("display")&&0!=t.children(".highlight").length||13!=e.keyCode||SubmitSearch(),!0}),"#goSearch"),dlc=($(document).on("click",goSearch,function(e){var t=$("#acomp");return 0!=t.length&&"none"!=t.attr("display")&&0!=t.children(".highlight").length||SubmitSearch(),!0}),$(document).on("keyup",search,function(e){var t=$("#acomp"),n=(0==t.length&&(t=$("<div id='acomp' />"),$(document.body).append(t)),t.children().length);hasChildren=0<n,altKeyCodes=[38,40,13],isUsingAltCode=!1;for(var i=altKeyCodes.length-1;0<=i;i--)if(altKeyCodes[i]==e.keyCode){isUsingAltCode=!0;break}isUsingAltCode&&hasChildren&&"none"!=t.css("display")?38==e.keyCode?(0==_autocompIdx?_autocompIdx=n-1:_autocompIdx--,HighlightAutoComplete(n,t)):40==e.keyCode?(_autocompIdx==n-1?_autocompIdx=0:_autocompIdx++,HighlightAutoComplete(n,t)):13==e.keyCode&&$(t.children()[_autocompIdx])[0].click():isUsingAltCode||(-1!=_acTimer&&(clearTimeout(_acTimer),_acTimer=-1),n=partial(StartAutoComplete,this,t),MTS_searchHelper(n))}),$(document).click(function(e){var t=$("#acomp");"none"!=t.css("display")&&e.target.id!=t.attr("id")&&t.hide()}),$(document).on(_event,"#searchBarBtn",function(){SubmitSearch()}),$(".subNav").hide(),$("#alertsArrow").click(function(){"0px"!=$("#alertDD").css("height")?$("#alertDD").css("height","0px"):$("#alertDD").css("height","auto")}),(new AlertCycle).init(),$(document).on(_event,".shareIcons",function(){var e=(t=this.id).split("_")[0],t=t.split("_")[1];"eShare"===e&&emailShare(t)}),$(document).on(_event,".shareIconsEmail, .emShare",function(){emailShare(this.id.split("_")[1])}),$(document).on(_event,"#emailCancel",function(){$(".emailBg").remove(),$(".emailTemplate").remove()}),$(document).on(_event,"#emailSend",function(){emailSend($.trim($("#emailList").val()),$.trim($("#emailMsg").val()),0<_userId?"":$.trim($("#emailFrom").val()),$(this).parent().find("#shareMode").val())}),$(document).on("focusin",".emailTxt",function(){this.value!=_emailReq&&this.value!=_emailMsg&&this.value!=_emailMsgOpt&&this.value!=_emailFrom||(this.value="",this.style.color=_blkColor)}),$(document).on("focusout",".emailTxt",function(){""==this.value&&(this.value="emailList"==this.id?_emailReq:"emailFrom"==this.id?_emailFrom:_emailMsgOpt,this.style.color=_reqColor)}),$(document).on("mouseenter",".itemAdd",function(){clearTimeout(timerRemove),$(".moreListCtr").show()}),$(".menuDropBg")),timerRemove=null,showClass="menuDropBgShow";function _MTS_handleMouseNav(e){var t,n,i,o;""!=$.trim(e.innerHTML)&&(e.parentNode.attributes.id&&"navbar"==e.parentNode.attributes.id.value||$(e).parent().hasClass("moreList"))&&($(e).hasClass("categoryItem")||$(e).hasClass("headerItem"))&&(clearTimeout(timerRemove),n=$(".mainNavContainerO"),o=$.trim($(e).find(".navType").html().replace(/<div>|<\/div>/gi,"")),t=e.id.split("_")[1],i=$(".featuredStoryContainer, .recentHeadlinesContainer"),"Sports"==o||"Schools"==o||"Leagues"==o||"District"==o?i.show():i.hide(),$(".mt").hide(),0<(_typeCon=$(".list_"+t)).length&&(_typeCon.show(),n.css({height:"0px"}),_showMenu=!0,-1==(i=$(".menuDropBg")).attr("class").indexOf("menuDropBgShow")&&(i.toggleClass("menuDropBgShow"),i.css({left:$(e).offset().left+"px"})),$("#menuText").html(o.toUpperCase()),t=$(".menuDropBgShow"),window.matchMedia("(min-width: 1024px)").matches?(n=$(e).position().left,0<$(e).parent(".moreList").length&&(n+=$(".moreListCtr").outerWidth()),i=$(".menuDropBgShow"),$(e).parent().hasClass("moreList")?i.css({right:"200px",left:"auto"}):i.css({left:n+"px"})):(t.removeAttr("style"),t.css({height:"100%"}),$(".masterMcwrap").toggleClass("menuDropBgShow")),21!=_portalId&&(o=$(".mt:visible").children(".mdItem").length,(e=$(".grdImgBot")).removeClass("grdImgBotHide"),o<9?e.addClass("grdImgBotHide"):e.removeClass("grdImgBotHide"))))}$(document).on("mouseleave",".mainNavContainer .item, .menuDropBg, .moreListCtr",function(){0<$(this).parent(".moreList").length||(clearTimeout(timerRemove),timerRemove=setTimeout(function(){window.matchMedia("(min-width: 1024px)").matches&&(dlc.removeClass(showClass),$(".moreListCtr").hide())},250))}),$(document).on("mouseenter",".menuDropBg, .moreListCtr",function(){clearTimeout(timerRemove)}),$(document).on(_event,".navCaret",function(e){e.preventDefault()}),$(document).on({click:function(){isDesktopMedia()||_MTS_handleMouseNav(this)},mouseenter:function(){isDesktopMedia()&&_MTS_handleMouseNav(this)}},".item"),$(document).on("mouseleave",".item",function(){HidePopupMenu()}),$(".menuDropBg").hover(function(){_showMenu=!0},function(){HidePopupMenu()}),$(".scrollerContainer").slider({create:slideMenu,orientation:"vertical",slide:slideMenu,stop:holdMenu,min:0,max:100,value:100}),$(document).on({mouseenter:function(){HoverMenu(this.id.split("_")[2],this.id.split("_")[1])},mouseleave:function(){UnhoverMenu(this.id.split("_")[2],this.id.split("_")[1])}},".dropDownElement, .dropDownArr"),$(document).on(_event,"#menuHeader",function(e){e.stopPropagation(),HidePopupMenu(!0),$(".mainNavContainerO").css({height:"auto"})});var myProfile=$(".myProfile"),phl;0<myProfile.length&&(phl=$(".myProfile").position().left,$(".profileHover").css({left:phl}),$(".myProfile").hover(function(){$(".profileHover").fadeTo("fast",1)},function(){$(".profileHover").fadeTo("fast",0)})),$(".shareTopIcon").click(function(){0==$(".sharingIcons").width()?$(".sharingIcons").animate({width:"192px"}):$(".sharingIcons").animate({width:"0px"})}),$(document).on(_event,".iA",function(e){e.stopPropagation();var e=$(this),t=$(e.parent().find("iframe")[0].contentWindow.document.body).find("a").attr("href"),e=e.width()+"x"+e.height();if(CheckAdClick(e))try{TrackClick("DFP-"+e)}catch(e){}setTimeout(function(){0<t.length&&window.open(t)},100)}),$("#OASFlashPeel").mousedown(function(e){if(CheckAdClick("peel"))try{TrackClick("DFP-Peel")}catch(e){}}),0<$("#dfp-pagepeel-oop_ad_container").length&&(($(window).width()<=1024||_iPad)&&$("#dfp-pagepeel-oop_ad_container").hide(),$(window).resize(function(){$(window).width()<=1024?$("#dfp-pagepeel-oop_ad_container").hide():$("#dfp-pagepeel-oop_ad_container").show()})),$(document).on(_event,".mobileMenuBtn",function(){$(".navigationContainer, .hpCtr").toggleClass("mainNavO").removeAttr("style"),$(".navigationContainer").show();var e=$("#mainContainer"),e=("none"!==e.css("display")?e.hide():e.show(),$("#content"));"none"!==e.css("display")?e.hide():e.show()}),$(".msBtn").click(function(){$("#features").hide()});for(var i=_filterKeys.length-1;0<=i;i--)CreateMenuClick(_filterKeys[i][0],_filterKeys[i][1]);$(".mOptBtn").click(function(){$(".optionsContainer").toggleClass("optionsContainerO")});var masterBackBtn=$(".masterBackButton"),lg,hhpc,hc;null!=window.history&&1<window.history.length?masterBackBtn.click(function(){null!=window.history&&2<window.history.length&&(null!=document.referrer&&0<=document.referrer.indexOf("user/login")?window.history.go(-2):window.history.go(-1))}):masterBackBtn.hide(),$("#mctMnuBtn").click(function(){$(".topTabs").toggleClass("tto")}),$("#showMoreScoresMobile").click(function(){_MTS_ajaxPending=!0,$.ajax("/api/getPortalScoresMobile",[],function(e){alert(e)})}),$(document).on(_event,"#portalPost, #mPortalPost",function(){window.location="/news/editor/?mode=portal&sTag="+_sm}),$(document).on(_event,"#portalAdmin, #mPortalAdmin",function(){window.location="/admin/"}),$(document).on("DOMNodeInserted",".pac-container",function(){$(".pac-item, .pac-item span",this).addClass("needsclick")}),$(".layoutPreviewOverlay").click(function(){var p=confirm("Do you want to push this preview live?"),p;p?(p=[],p.param("id",$("#previewVal").val()),ajax("/api/portalAdmin/saveCustomLayout.aspx",p,function(ret){var o;eval("o = "+ret),o.ok?window.close():alert("Error : "+o.error)})):window.close()}),_portalId<1&&1024<$(window).width()&&(lg=$("#logo_image"),hhpc=$(".hpCtr"),hc=$("#headContainer, #headContainerL"),hhpc.css({top:"4px"}),hhpc.css({transform:"none","-webkit-transform":"none","-moz-transform":"none","-ms-transform":"none"})),resizeOnLoad(),$(".sportsContainer").scroll(function(){0<$(this).scrollTop()?$(".grdImgBot").addClass("grdImgBotHide"):$(".grdImgBot").removeClass("grdImgBotHide")}),noPortalVertNav(),setNav(),targetFirefoxHeader(),$(window).resize(setNav)}),_MTS_widgetsReady?_MTS_commonWidgetInit():$(document).bind(_MTS_widgetsReady,_MTS_commonWidgetInit);var _recaptchaLoaded=!1;function requireCaptcha(e,t){if(_recaptchaLoaded)return sendRecaptcha(i,t,e,0),!1;_recaptchaLoaded=!0;var n,i="6LfGm-cUAAAAADpBRiNHbpTrOzZMn9JcB2UPwhW2",o="https://www.google.com/recaptcha/api.js?render="+i,a=function(){sendRecaptcha(i,t,e,0)},r=document.createElement("script");r.setAttribute("src",o),a&&(r.onreadystatechange=r.onload=function(){n||a(),n=!0}),document.getElementsByTagName("head")[0].appendChild(r)}function sendRecaptcha(e,t,n,i){if(void 0===i)i=0;else if(20<i)return;"function"==typeof grecaptcha.execute?grecaptcha.execute(e,{action:t}).then(function(e){n(e)}):(i++,setTimeout(function(){sendRecaptcha(e,t,n,i)},250))}function emailSend(n,i,o,a){var e,r;CheckForm(n,o)?(e="number"==typeof _teamId&&0<_teamId,requireCaptcha(function(e){i==_emailMsgOpt&&(i="");var t=[];t.push({name:"shareId",value:_curShareId}),t.push({name:"emailList",value:n}),t.push({name:"emailMsg",value:i}),t.push({name:"from",value:o}),t.push({name:"recaptcha",value:e}),t.push({name:"action",value:r}),t.push({name:"mode",value:r}),"video"==a&&t.push({name:"playlistId",value:_playlistId}),_MTS_JQUERY.post("/api/sendShareEmail.aspx",t,function(e){e.ok&&($(".emailBg").remove(),$(".emailTemplate").remove())},"json")},r=a||(e?"newsItem":"portalNews"))):(alert(_errorTxt),_focusErr.focus(),_focusErr.select())}function emailShare(e){_curShareId=e;e="<div class='emailBg'><div class='emailTemplate' id='sendEmail'><div class='emailTempHead'>Share This Story</div>"+(0<_userId?"":"<input title='E-mail From' type='text' class='emailTxt' id='emailFrom' value='"+_emailFrom+"' />")+"<input title='E-mail List' type='text' class='emailTxt' id='emailList' value='"+_emailReq+"' /><textarea title='Email Message' class='emailTxtArea' id='emailMsg'>"+_emailMsg+"</textarea><div class='tempButtons'><div class='mts_cc_button tempButton' id='emailSend'>Send</div><div class='mts_cc_button tempButton' id='emailCancel'>Cancel</div></div></div > </div";$("body").append(e),$(".emailBg").show()}function DbToHtml(e){var t=[];return t.push({oldValue:"\n",newValue:"<br />"}),replace(e,t)}function HtmlToDb(e){var t=[];return t.push({oldValue:"<br />",newValue:"\n"}),t.push({oldValue:"<br>",newValue:"\n"}),t.push({oldValue:"<BR />",newValue:"\n"}),t.push({oldValue:"<BR>",newValue:"\n"}),replace(e,t)}function htmlEncode(e){return e?jQuery("<div />").text(e).html():""}function htmlDecode(e){return e?$("<div />").html(e).text():""}function replace(e,t){for(var n,i=0;i<t.length;i++)n=new RegExp(t[i].oldValue,"g"),e=e.replace(n,t[i].newValue);return e}function CenterElement(e){var t,n,i,o,e=$(e);0!==e.length&&(e[0].parentNode!==document.body&&(e[0].parentNode.removeChild(e[0]),document.body.appendChild(e[0])),n=$(window).width(),t=$(window).height(),i=e.outerWidth(),t=t/2-e.outerHeight()/2,n=n/2-i/2,i=$(document).scrollTop(),o=$(document).scrollLeft(),t+=i,e.css({left:(n+=o).toString()+"px",top:t.toString()+"px"}))}function getDescription(e,t,n,i,o){var a="/";if(0!=t?o?a+="Varsity":0<$("#level").length&&0<$("#level option").length?a+=$.trim($("#level option:selected").text()).replace(/ /g,"-"):"1"==t&&(a+="Varsity"):a+="All",0!=i||0!=n)switch(a+="/",i){default:a+="All";break;case 1:a+="Boys";break;case 2:a+="Girls";break;case 3:a+="Coed"}return 0!=e?(t="",a+="/",o?t=_defaultPortalSportName:0<$(".sportBanner").length?t=$(".sportBanner").text():0<$("#sport").length?0<=(t=$("#sport option:selected").text()).indexOf("Boys")||0<=t.indexOf("Coed")?t=t.substring(5):0<=t.indexOf("Girls")&&(t=t.substring(6)):t=_defaultPortalSportName,a+=$.trim(t).replace(/ /g,"-")):a+="/All",0!=n&&(i="",i=0<$(".schoolName").length?$.trim($(".schoolName").text()):(0<$("#school").length?$("#school option:selected"):$("#schoolDrop option:selected")).text(),a+="/"+$.trim(i).replace(/ /g,"-")),(a=""==(a=a.replace(/ /g,"-"))?"undefined":a).toLowerCase()}function mainLogClick(){(new PopupDialog).NewYesNoPrompt("Are you sure you want to log out?","Log Out",null,function(e,t,n){e&&(window.location="/SignOut.aspx")})}Array.prototype.param=function(e,t){this.push({name:e,value:t})},Array.prototype.contains=function(e){for(var t=this.length-1;0<=t;--t)if(this[t]===e)return!0;return!1};var _resizeSelectors=[],_readySpool=[],_spoolTimer=null;function SpoolTimeout(){if(0===_readySpool.length)return clearInterval(_spoolTimer),void(_spoolTimer=null);var e=_readySpool.pop();HeightResizer(e.selector,e.size,e.callback)}function PushToSpool(e,t,n){for(var i=!1,o=0;o<_readySpool.length;o++)if(_readySpool[o].selector===e&&_readySpool[o].size===t){i=!0;break}i||_readySpool.push({selector:e,size:t,callback:n}),null==_spoolTimer&&(_spoolTimer=setInterval(SpoolTimeout,10))}function AddResizeSelector(e,t,n){for(var i=!1,o=0;o<_resizeSelectors.length;o++)if(_resizeSelectors[o].selector===e&&_resizeSelectors[o].size===t){i=!0;break}i||(_resizeSelectors.push({selector:e,size:t,callback:n}),HeightResizer(e,t,n))}function SetThumbnailHeightFromWidth(e,t){AddResizeSelector(e,0,t)}function SetSlideHeightFromWidth(e){AddResizeSelector(e,1)}function SetTeamLogoHeightFromWidth(e){AddResizeSelector(e,3)}function HeightResizer(i,o,a){var r=$(i+":visible");0!==r.length&&("IMG"!=r[0].nodeName||r[0].complete&&void 0!==r[0].naturalWidth&&0!=r[0].naturalWidth)&&("IMG"==r[0].nodeName||0!=r.find("img").length&&r.find("img")[0].complete&&void 0!==r.find("img")[0].naturalWidth&&0!=r.find("img")[0].naturalWidth)?$(i).ready(function(){var e,t;if(0===o)e=_imageSizes.ThumbnailMxW,t=_imageSizes.ThumbnailMxH;else if(1===o)e=_imageSizes.SlideShowMxW,t=_imageSizes.SlideShowMxH;else{if(3!==o)return;e=_imageSizes.TeamLogoMxW,t=_imageSizes.TeamLogoMxH}var n=document.createElement("style"),n=(n.setAttribute("type","text/css"),n.setAttribute("id","customHeightcss"),document.getElementsByTagName("head")[0].appendChild(n),r.contents().filter(function(){return 3===this.nodeType}).remove(),r.children().contents().filter(function(){return 3===this.nodeType}).remove(),r.children().children().contents().filter(function(){return 3===this.nodeType}).remove(),document.createTextNode(i+" { height: "+Math.floor($($(i+":visible")[0]).width()/(e/t))+"px; }"));$("#customHeightcss").append(n),"function"==typeof a&&a()}):PushToSpool(i,o,a)}function AdjustWrap(e,t){var n,i,e=$(e),t=$(t);0<e.length&&0<t.length&&(i=(n=GetElementWithMaxHeight(e)).outerHeight(!0),t.height("auto"),e.outerHeight(n.outerHeight()),e=Math.ceil(t.outerHeight(!0)/i),t.outerHeight(e*i-GrabMarginHeight(t)))}function GetElementWithMaxHeight(e){for(var t=null,n=null,i=e.length-1;0<=i;i--){var o=$(e[i]).outerHeight();(null==n||n<o)&&(t=i,n=o)}return $(e[t])}function GrabMarginHeight(e){var t=parseInt(e.css("margin-top")),e=parseInt(e.css("margin-bottom"));return(isNaN(t)?0:t)+(isNaN(e)?0:e)}function ValidateNumber(e){for(var e=e||window.event,t=e.keyCode||e.which,n=_keyException.length-1;0<=n;n--)if(_keyException[n]==t)return!1;t=String.fromCharCode(t);/[0-9]|\./.test(t)||(e.returnValue=!1,e.preventDefault&&e.preventDefault())}function loadJSCached(e){for(var t=$("script"),n=e.toLowerCase(),i=t.length-1;0<=i;i--)if(0<=t[i].src.toLowerCase().indexOf(n))return!1;_jsCachedSequence.push(e),startJSGrab()}function startJSGrab(){!_jsCacheBusy&&0<_jsCachedSequence.length&&loadJSCachedSequenced(_jsCachedSequence.shift())}function loadJSCachedSequenced(e){_jsCacheBusy=!0;var t=document.createElement("script");t.type="text/javascript",t.src=e,t.async=!1,document.getElementsByTagName("head")[0].appendChild(t),_jsCacheBusy=!1,startJSGrab()}function CreateAlertsCookie(){for(var e=$(".alertItem"),t="",n=0;n<e.length;n++)t+=e[n].id.split("_")[2]+(n!=e.length-1?",":"");var i=new Date,i=(i.setTime(i.getTime()+2592e6),"; expires="+i.toGMTString());document.cookie="alerts="+t+i+"; path=/"}function ToggleCustomDropdowns(e,t,n){$().chosen&&$(null==t?"select:visible":t).chosen({width:"number"==typeof e?e+"px":"240px",disable_search:null==n||n})}function ReplaceQueryParameter(e,t,n){var i=new RegExp("([?&])"+t+"=.*?(&|$)","i"),o=-1!==e.indexOf("?")?"&":"?";return e.match(i)?e.replace(i,"$1"+t+"="+n+"$2"):e+o+t+"="+n}function noPortalVertNav(){}function fireEmailRejected(){ajax("/api/changeEmailRejected.aspx",{},function(){alert("Your notifications have been turned off."),$(".emailRejected").hide()})}function WireLockingNotice(){var e=$("#mts_unlockstory");0<e.length&&e.click(function(){unlockStory()})}function unlockStory(t,e,n){var i=$("#mts_unlockstory"),o=[];o.push({name:"itemId",value:e}),o.push({name:"tagType",value:n}),$.post("/api/portalAdmin/unlockPortalNews.aspx",o,function(e){e.ok&&(i.slideToggle(),"function"==typeof t&&t())},"json")}function setNav(){if(!$("body").hasClass("vertical")&&!$("body").hasClass("mVertical")){var e=$(".navigationContainer"),t=$("#navbar.mainNavContainer"),n=$(".navigation_admin_menu_widget");if(window.matchMedia("(min-width: 1024px)").matches){$(".mobileNavItem, .mobileNavSection").hide(),$(".desktopNavItem").css("display","inline-block"),$(".desktopNavSection").css("display","block");for(var i=getHNavItemWidth(),o=i+(25==_MTS_PORTALID?0:n.outerWidth());o>e.outerWidth()&&1!=t.children(".item:visible:not('.mobileNavItem')").length;){var a=$("#navbar.mainNavContainer").children(".mnuHeading").last(),r=$("#navbar.mainNavContainer a.item:visible:not('.mobileNavItem, .moreList .item')").last(),s=($(r).data("itemWidth",r.outerWidth()),a.prev().hasClass("itemAdd")||a.before("<div class='itemAdd'><span class='navType'>More</span><i class='fas fa-chevron-down moreItems'></i><div class='moreListCtr'><div class='moreList'></div></div></div>"),$(".moreList"));r.detach(),r.prependTo(s),$(".itemAdd").show(),o=i=getHNavItemWidth()}for(r=(s=$(".moreList")).children(".item:not('.mobileNavItem')").first();o+$(r).data("itemWidth")<e.outerWidth();){if(r.detach(),$(".itemAdd").before(r),0==s.children(".item").length){$(".itemAdd").hide();break}o=i=getHNavItemWidth(),r=s.children(".item:not('.mobileNavItem')").first()}}else $(".mobileNavItem, .mobileNavSection").show(),$(".desktopNavItem, .desktopNavSection").hide(),(r=(s=$(".moreList")).children(".item")).detach(),$(".itemAdd").before(r),$(".itemAdd").hide()}}function getHNavItemWidth(){var e=$("#navbar.mainNavContainer a.item:visible:not('.mobileNavItem, .moreList .item')"),t=0;return e.each(function(){t+=$(this).outerWidth()}),0<$(".itemAdd:visible").length&&(t+=$(".itemAdd:visible").outerWidth()),t}function leftRight(){var e,t,n;window.matchMedia("(min-width: 768px)").matches?(t=$(".leftSide, #lcol, #user_container"),n=$(".rightSide, #rcol, #right_container"),e=$(".innerSec").width(),t.css({width:e-360+"px"}),n.removeAttr("style")):(t=$(".leftSide, #lcol, #user_container"),n=$(".rightSide, #rcol, #right_container"),t.removeAttr("style"),t.css({width:"100%"}),n.css({width:"100%"}))}function targetFirefoxHeader(){-1<navigator.userAgent.toLowerCase().indexOf("firefox")&&$(".horizontal .navigationContainer").css({"white-space":"normal"})}function MTS_startAjax(){MTS_clearAjaxTimer(),_ajaxSpinTimer=setTimeout(function(){$(".busySpinnerBg").show()},600)}function MTS_endAjax(){MTS_clearAjaxTimer(),$(".busySpinnerBg").hide()}function MTS_clearAjaxTimer(){null!=_ajaxSpinTimer&&(clearTimeout(_ajaxSpinTimer),_ajaxSpinTimer=null)}function MTS_routeApiCall(e,t,n,i){var o=[];o.push({name:"path",value:t}),o.push({name:"map",value:e+"&portal_id="+_MTS_PORTALID}),i&&$.ajaxSetup({async:!1}),$.getJSON("/api/portalAdmin/sendApiRequest.aspx?",o,n),i&&$.ajaxSetup({async:!0})}function MTS_validateEmail(e){return/^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/gi.test(e)}function getImageLink(e,t){var n=GetCloudUrl(e),i=e.id,o=_MTS_PHOTO_TEMPLATE.replace("%%IMG_ID%%",i).replace("%%SIZE%%",t).replace("%%TEAM_ID%%",e.teamId).replace("%%USER_ID%%",e.uploaderId).replace("%%TYPE%%",0);return e.inCloud&&null!=n&&0<n.length&&(o=n+"/"+getBigInt(e.id)+i+(2<=t?"":"_"+t),1<e.webActiveVersion&&(o=o+"_v"+e.webActiveVersion)),o}function getBigInt(e){for(var t=[0,0,0,0,0,0],n=t.length-1;t[n]=0==n?Math.floor(e):Math.floor(e%1e3),e/=1e3,0<=--n;);var i,o="";for(i in t)isNaN(parseInt(i))||(o+=parseInt(t[i])+"/");return o}function GetCloudUrl(e){var t="";if("undefined"!=typeof _activeContainer)for(var n=_activeContainer.portals.length-1;0<=n;n--)if(_activeContainer.portals[n].id==e.container){t=_activeContainer.portals[n].url;break}return t}$(window).resize(function(){0<$("#customHeightcss").length&&$("#customHeightcss").remove(),$.each(_resizeSelectors,function(e,t){HeightResizer(t.selector,t.size)})}),Date.prototype.formatDate=function(){return this.getMonth()+1+"/"+this.getDate()+"/"+this.getFullYear()},Date.prototype.formatTime=function(){var e=this.getHours(),t=11<e,n=(12<e&&(e-=12),0==e&&(e=12),this.getMinutes());return e+":"+(n<10?"0":"")+n+" "+(t?"PM":"AM")},Array.prototype.removeIf=function(e){for(var t=this.length;t--;)e(this[t],t)&&this.splice(t,1)};
﻿!function(e){function n(t){this.options=e.extend({},e.smartbanner.defaults,t);var t=navigator.standalone,i=navigator.userAgent;this.options.force?this.type=this.options.force:null!=i.match(/iPhone|iPod/i)||i.match(/iPad/)&&this.options.iOSUniversalApp?null!=i.match(/Safari/i)&&(null!=i.match(/CriOS/i)||window.Number(i.substr(i.indexOf("OS ")+3,3).replace("_","."))<6)&&(this.type="ios"):i.match(/\bSilk\/(.*\bMobile Safari\b)?/)||i.match(/\bKF\w/)||i.match("Kindle Fire")?this.type="kindle":null!=i.match(/Android/i)?this.type="android":null!=i.match(/Windows NT 6.2/i)&&null!==i.match(/Touch/i)&&(this.type="windows"),!this.type||t||this.getCookie("sb-closed")||this.getCookie("sb-installed")||(this.scale="auto"==this.options.scale?e(window).width()/window.screen.width:this.options.scale,this.scale<1&&(this.scale=1),0!=(i=e("android"==this.type?'meta[name="google-play-app"]':"ios"==this.type?'meta[name="apple-itunes-app"]':"kindle"==this.type?'meta[name="kindle-fire-app"]':'meta[name="msApplication-ID"]')).length&&("windows"==this.type?(this.pfn=e('meta[name="msApplication-PackageFamilyName"]').attr("content"),this.appId=i.attr("content")[1]):this.appId=/app-id=([^\s,]+)/.exec(i.attr("content"))[1],this.title=this.options.title||i.data("title")||e("title").text().replace(/\s*[|\-·].*$/,""),this.author=this.options.author||i.data("author")||(e('meta[name="author"]').length?e('meta[name="author"]').attr("content"):window.location.hostname),this.iconUrl=i.data("icon-url"),this.price=i.data("price"),this.create(),this.show(),this.listen()))}n.prototype={constructor:n,create:function(){var t,i=this.options.url||("windows"==this.type?"ms-windows-store:PDP?PFN="+this.pfn:"android"==this.type?"market://details?id=":"kindle"==this.type?"amzn://apps/android?asin=":"https://itunes.apple.com/"+this.options.appStoreLanguage+"/app/id")+this.appId,s=this.price||this.options.price,s=s?s+" - "+("android"==this.type?this.options.inGooglePlay:"kindle"==this.type?this.options.inAmazonAppStore:"ios"==this.type?this.options.inAppStore:this.options.inWindowsStore):"",n=null===this.options.iconGloss?"ios"==this.type:this.options.iconGloss,s=(this.options.url?i=this.options.url:"android"==this.type?(i="market://details?id="+this.appId,this.options.GooglePlayParams&&(i=i+"&referrer="+this.options.GooglePlayParams)):i="https://itunes.apple.com/"+this.options.appStoreLanguage+"/app/id"+this.appId,'<div id="smartbanner" class="'+this.type+'"><div class="sb-container"><a title="" href="#" class="sb-close">&times;</a><span class="sb-icon"></span><div class="sb-info"><strong>'+this.title+"</strong><span>"+this.author+"</span><span>"+s+'</span></div><a href="'+i+'" class="sb-button"><span>'+this.options.button+"</span></a></div></div>");this.options.layer?e(this.options.appendToSelector).append(s):e(this.options.appendToSelector).prepend(s),this.options.icon?t=this.options.icon:this.iconUrl?t=this.iconUrl:0<e('link[rel="apple-touch-icon-precomposed"]').length?(t=e('link[rel="apple-touch-icon-precomposed"]').attr("href"),null===this.options.iconGloss&&(n=!1)):0<e('link[rel="apple-touch-icon"]').length?t=e('link[rel="apple-touch-icon"]').attr("href"):0<e('meta[name="msApplication-TileImage"]').length?t=e('meta[name="msApplication-TileImage"]').attr("content"):0<e('meta[name="msapplication-TileImage"]').length&&(t=e('meta[name="msapplication-TileImage"]').attr("content")),t?(e("#smartbanner .sb-icon").css("background-image","url("+t+")"),n&&e("#smartbanner .sb-icon").addClass("gloss")):e("#smartbanner").addClass("no-icon"),this.bannerHeight=e("#smartbanner").outerHeight()+2,1<this.scale&&(e("#smartbanner").css("top",parseFloat(e("#smartbanner").css("top"))*this.scale).css("height",parseFloat(e("#smartbanner").css("height"))*this.scale).hide(),e("#smartbanner .sb-container").css("-webkit-transform","scale("+this.scale+")").css("-msie-transform","scale("+this.scale+")").css("-moz-transform","scale("+this.scale+")").css("width",e(window).width()/this.scale))},listen:function(){e("#smartbanner .sb-close").on("click",e.proxy(this.close,this)),e("#smartbanner .sb-button").on("click",e.proxy(this.install,this))},show:function(t){var i=e("#smartbanner");i.stop(),this.options.layer?(i.animate({top:0,display:"block"},this.options.speedIn).addClass("shown").show(),e("html").animate({marginTop:this.origHtmlMargin+this.bannerHeight*this.scale},this.options.speedIn,"swing",t)):e.support.transition?(i.animate({top:0},this.options.speedIn).addClass("shown"),e("html").addClass("sb-animation").one(e.support.transition.end,function(){e("html").removeClass("sb-animation"),t&&t()}).emulateTransitionEnd(this.options.speedIn).css("margin-top",this.origHtmlMargin+this.bannerHeight*this.scale)):i.slideDown(this.options.speedIn).addClass("shown")},hide:function(t){var i=e("#smartbanner");i.stop(),this.options.layer?(i.animate({top:-1*this.bannerHeight*this.scale,display:"block"},this.options.speedIn).removeClass("shown"),e("html").animate({marginTop:this.origHtmlMargin},this.options.speedIn,"swing",t)):i.slideUp(this.options.speedOut).removeClass("shown")},close:function(t){t.preventDefault(),this.hide(),this.setCookie("sb-closed","true",this.options.daysHidden)},install:function(t){this.options.hideOnInstall&&this.hide(),this.setCookie("sb-installed","true",this.options.daysReminder)},setCookie:function(t,i,s){var n=new Date;n.setDate(n.getDate()+s),i=encodeURI(i)+(null==s?"":"; expires="+n.toUTCString()),document.cookie=t+"="+i+"; path=/;"},getCookie:function(t){for(var i,s,n=document.cookie.split(";"),e=0;e<n.length;e++)if(i=n[e].substr(0,n[e].indexOf("=")),s=n[e].substr(n[e].indexOf("=")+1),(i=i.replace(/^\s+|\s+$/g,""))==t)return decodeURI(s);return null},switchType:function(){var i=this;this.hide(function(){i.type="android"==i.type?"ios":"android";var t=e("android"==i.type?'meta[name="google-play-app"]':'meta[name="apple-itunes-app"]').attr("content");i.appId=/app-id=([^\s,]+)/.exec(t)[1],e("#smartbanner").detach(),i.create(),i.show()})}},e.smartbanner=function(t){var i=e(window),s=i.data("smartbanner");s||i.data("smartbanner",s=new n("object"==typeof t&&t)),"string"==typeof t&&s[t]()},e.smartbanner.defaults={title:null,author:null,price:"FREE",appStoreLanguage:"us",inAppStore:"On the App Store",inGooglePlay:"In Google Play",inAmazonAppStore:"In the Amazon Appstore",inWindowsStore:"In the Windows Store",GooglePlayParams:null,icon:null,iconGloss:null,button:"VIEW",url:null,scale:"auto",speedIn:300,speedOut:400,daysHidden:15,daysReminder:90,force:null,hideOnInstall:!0,layer:!1,iOSUniversalApp:!0,appendToSelector:"body"},e.smartbanner.Constructor=n,void 0===e.support.transition&&(e.fn.emulateTransitionEnd=function(t){var i=!1,s=this;e(this).one(e.support.transition.end,function(){i=!0});return setTimeout(function(){i||e(s).trigger(e.support.transition.end)},t),this},e(function(){e.support.transition=function(){var t,i=document.createElement("smartbanner"),s={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(t in s)if(void 0!==i.style[t])return{end:s[t]};return!1}()}))}(window.jQuery);
﻿/******************************************************************************************************************************************************
   Return value in findXMPinJPEG function was edited that is not present in the version on the site.
   Function now returns { doc: $.parseXML(xmpString), obj: xml2Object(domDocument) }.
   If replacing this file with updated version from site, these changes will need to be added again along with using xmpdata.obj where xmpdata is used.
******************************************************************************************************************************************************/

(function ()
{

   var debug = false;

   var root = this;

   var EXIF = function (obj)
   {
      if (obj instanceof EXIF) return obj;
      if (!(this instanceof EXIF)) return new EXIF(obj);
      this.EXIFwrapped = obj;
   };

   if (typeof exports !== 'undefined')
   {
      if (typeof module !== 'undefined' && module.exports)
      {
         exports = module.exports = EXIF;
      }
      exports.EXIF = EXIF;
   } else
   {
      root.EXIF = EXIF;
   }

   var ExifTags = EXIF.Tags = {

      // version tags
      0x9000: "ExifVersion",             // EXIF version
      0xA000: "FlashpixVersion",         // Flashpix format version

      // colorspace tags
      0xA001: "ColorSpace",              // Color space information tag

      // image configuration
      0xA002: "PixelXDimension",         // Valid width of meaningful image
      0xA003: "PixelYDimension",         // Valid height of meaningful image
      0x9101: "ComponentsConfiguration", // Information about channels
      0x9102: "CompressedBitsPerPixel",  // Compressed bits per pixel

      // user information
      0x927C: "MakerNote",               // Any desired information written by the manufacturer
      0x9286: "UserComment",             // Comments by user

      // related file
      0xA004: "RelatedSoundFile",        // Name of related sound file

      // date and time
      0x9003: "DateTimeOriginal",        // Date and time when the original image was generated
      0x9004: "DateTimeDigitized",       // Date and time when the image was stored digitally
      0x9290: "SubsecTime",              // Fractions of seconds for DateTime
      0x9291: "SubsecTimeOriginal",      // Fractions of seconds for DateTimeOriginal
      0x9292: "SubsecTimeDigitized",     // Fractions of seconds for DateTimeDigitized

      // picture-taking conditions
      0x829A: "ExposureTime",            // Exposure time (in seconds)
      0x829D: "FNumber",                 // F number
      0x8822: "ExposureProgram",         // Exposure program
      0x8824: "SpectralSensitivity",     // Spectral sensitivity
      0x8827: "ISOSpeedRatings",         // ISO speed rating
      0x8828: "OECF",                    // Optoelectric conversion factor
      0x9201: "ShutterSpeedValue",       // Shutter speed
      0x9202: "ApertureValue",           // Lens aperture
      0x9203: "BrightnessValue",         // Value of brightness
      0x9204: "ExposureBias",            // Exposure bias
      0x9205: "MaxApertureValue",        // Smallest F number of lens
      0x9206: "SubjectDistance",         // Distance to subject in meters
      0x9207: "MeteringMode",            // Metering mode
      0x9208: "LightSource",             // Kind of light source
      0x9209: "Flash",                   // Flash status
      0x9214: "SubjectArea",             // Location and area of main subject
      0x920A: "FocalLength",             // Focal length of the lens in mm
      0xA20B: "FlashEnergy",             // Strobe energy in BCPS
      0xA20C: "SpatialFrequencyResponse",    //
      0xA20E: "FocalPlaneXResolution",   // Number of pixels in width direction per FocalPlaneResolutionUnit
      0xA20F: "FocalPlaneYResolution",   // Number of pixels in height direction per FocalPlaneResolutionUnit
      0xA210: "FocalPlaneResolutionUnit",    // Unit for measuring FocalPlaneXResolution and FocalPlaneYResolution
      0xA214: "SubjectLocation",         // Location of subject in image
      0xA215: "ExposureIndex",           // Exposure index selected on camera
      0xA217: "SensingMethod",           // Image sensor type
      0xA300: "FileSource",              // Image source (3 == DSC)
      0xA301: "SceneType",               // Scene type (1 == directly photographed)
      0xA302: "CFAPattern",              // Color filter array geometric pattern
      0xA401: "CustomRendered",          // Special processing
      0xA402: "ExposureMode",            // Exposure mode
      0xA403: "WhiteBalance",            // 1 = auto white balance, 2 = manual
      0xA404: "DigitalZoomRation",       // Digital zoom ratio
      0xA405: "FocalLengthIn35mmFilm",   // Equivalent foacl length assuming 35mm film camera (in mm)
      0xA406: "SceneCaptureType",        // Type of scene
      0xA407: "GainControl",             // Degree of overall image gain adjustment
      0xA408: "Contrast",                // Direction of contrast processing applied by camera
      0xA409: "Saturation",              // Direction of saturation processing applied by camera
      0xA40A: "Sharpness",               // Direction of sharpness processing applied by camera
      0xA40B: "DeviceSettingDescription",    //
      0xA40C: "SubjectDistanceRange",    // Distance to subject

      // other tags
      0xA005: "InteroperabilityIFDPointer",
      0xA420: "ImageUniqueID"            // Identifier assigned uniquely to each image
   };

   var TiffTags = EXIF.TiffTags = {
      0x0100: "ImageWidth",
      0x0101: "ImageHeight",
      0x8769: "ExifIFDPointer",
      0x8825: "GPSInfoIFDPointer",
      0xA005: "InteroperabilityIFDPointer",
      0x0102: "BitsPerSample",
      0x0103: "Compression",
      0x0106: "PhotometricInterpretation",
      0x0112: "Orientation",
      0x0115: "SamplesPerPixel",
      0x011C: "PlanarConfiguration",
      0x0212: "YCbCrSubSampling",
      0x0213: "YCbCrPositioning",
      0x011A: "XResolution",
      0x011B: "YResolution",
      0x0128: "ResolutionUnit",
      0x0111: "StripOffsets",
      0x0116: "RowsPerStrip",
      0x0117: "StripByteCounts",
      0x0201: "JPEGInterchangeFormat",
      0x0202: "JPEGInterchangeFormatLength",
      0x012D: "TransferFunction",
      0x013E: "WhitePoint",
      0x013F: "PrimaryChromaticities",
      0x0211: "YCbCrCoefficients",
      0x0214: "ReferenceBlackWhite",
      0x0132: "DateTime",
      0x010E: "ImageDescription",
      0x010F: "Make",
      0x0110: "Model",
      0x0131: "Software",
      0x013B: "Artist",
      0x8298: "Copyright"
   };

   var GPSTags = EXIF.GPSTags = {
      0x0000: "GPSVersionID",
      0x0001: "GPSLatitudeRef",
      0x0002: "GPSLatitude",
      0x0003: "GPSLongitudeRef",
      0x0004: "GPSLongitude",
      0x0005: "GPSAltitudeRef",
      0x0006: "GPSAltitude",
      0x0007: "GPSTimeStamp",
      0x0008: "GPSSatellites",
      0x0009: "GPSStatus",
      0x000A: "GPSMeasureMode",
      0x000B: "GPSDOP",
      0x000C: "GPSSpeedRef",
      0x000D: "GPSSpeed",
      0x000E: "GPSTrackRef",
      0x000F: "GPSTrack",
      0x0010: "GPSImgDirectionRef",
      0x0011: "GPSImgDirection",
      0x0012: "GPSMapDatum",
      0x0013: "GPSDestLatitudeRef",
      0x0014: "GPSDestLatitude",
      0x0015: "GPSDestLongitudeRef",
      0x0016: "GPSDestLongitude",
      0x0017: "GPSDestBearingRef",
      0x0018: "GPSDestBearing",
      0x0019: "GPSDestDistanceRef",
      0x001A: "GPSDestDistance",
      0x001B: "GPSProcessingMethod",
      0x001C: "GPSAreaInformation",
      0x001D: "GPSDateStamp",
      0x001E: "GPSDifferential"
   };

   // EXIF 2.3 Spec
   var IFD1Tags = EXIF.IFD1Tags = {
      0x0100: "ImageWidth",
      0x0101: "ImageHeight",
      0x0102: "BitsPerSample",
      0x0103: "Compression",
      0x0106: "PhotometricInterpretation",
      0x0111: "StripOffsets",
      0x0112: "Orientation",
      0x0115: "SamplesPerPixel",
      0x0116: "RowsPerStrip",
      0x0117: "StripByteCounts",
      0x011A: "XResolution",
      0x011B: "YResolution",
      0x011C: "PlanarConfiguration",
      0x0128: "ResolutionUnit",
      0x0201: "JpegIFOffset",    // When image format is JPEG, this value show offset to JPEG data stored.(aka "ThumbnailOffset" or "JPEGInterchangeFormat")
      0x0202: "JpegIFByteCount", // When image format is JPEG, this value shows data size of JPEG image (aka "ThumbnailLength" or "JPEGInterchangeFormatLength")
      0x0211: "YCbCrCoefficients",
      0x0212: "YCbCrSubSampling",
      0x0213: "YCbCrPositioning",
      0x0214: "ReferenceBlackWhite"
   };

   var StringValues = EXIF.StringValues = {
      ExposureProgram: {
         0: "Not defined",
         1: "Manual",
         2: "Normal program",
         3: "Aperture priority",
         4: "Shutter priority",
         5: "Creative program",
         6: "Action program",
         7: "Portrait mode",
         8: "Landscape mode"
      },
      MeteringMode: {
         0: "Unknown",
         1: "Average",
         2: "CenterWeightedAverage",
         3: "Spot",
         4: "MultiSpot",
         5: "Pattern",
         6: "Partial",
         255: "Other"
      },
      LightSource: {
         0: "Unknown",
         1: "Daylight",
         2: "Fluorescent",
         3: "Tungsten (incandescent light)",
         4: "Flash",
         9: "Fine weather",
         10: "Cloudy weather",
         11: "Shade",
         12: "Daylight fluorescent (D 5700 - 7100K)",
         13: "Day white fluorescent (N 4600 - 5400K)",
         14: "Cool white fluorescent (W 3900 - 4500K)",
         15: "White fluorescent (WW 3200 - 3700K)",
         17: "Standard light A",
         18: "Standard light B",
         19: "Standard light C",
         20: "D55",
         21: "D65",
         22: "D75",
         23: "D50",
         24: "ISO studio tungsten",
         255: "Other"
      },
      Flash: {
         0x0000: "Flash did not fire",
         0x0001: "Flash fired",
         0x0005: "Strobe return light not detected",
         0x0007: "Strobe return light detected",
         0x0009: "Flash fired, compulsory flash mode",
         0x000D: "Flash fired, compulsory flash mode, return light not detected",
         0x000F: "Flash fired, compulsory flash mode, return light detected",
         0x0010: "Flash did not fire, compulsory flash mode",
         0x0018: "Flash did not fire, auto mode",
         0x0019: "Flash fired, auto mode",
         0x001D: "Flash fired, auto mode, return light not detected",
         0x001F: "Flash fired, auto mode, return light detected",
         0x0020: "No flash function",
         0x0041: "Flash fired, red-eye reduction mode",
         0x0045: "Flash fired, red-eye reduction mode, return light not detected",
         0x0047: "Flash fired, red-eye reduction mode, return light detected",
         0x0049: "Flash fired, compulsory flash mode, red-eye reduction mode",
         0x004D: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",
         0x004F: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",
         0x0059: "Flash fired, auto mode, red-eye reduction mode",
         0x005D: "Flash fired, auto mode, return light not detected, red-eye reduction mode",
         0x005F: "Flash fired, auto mode, return light detected, red-eye reduction mode"
      },
      SensingMethod: {
         1: "Not defined",
         2: "One-chip color area sensor",
         3: "Two-chip color area sensor",
         4: "Three-chip color area sensor",
         5: "Color sequential area sensor",
         7: "Trilinear sensor",
         8: "Color sequential linear sensor"
      },
      SceneCaptureType: {
         0: "Standard",
         1: "Landscape",
         2: "Portrait",
         3: "Night scene"
      },
      SceneType: {
         1: "Directly photographed"
      },
      CustomRendered: {
         0: "Normal process",
         1: "Custom process"
      },
      WhiteBalance: {
         0: "Auto white balance",
         1: "Manual white balance"
      },
      GainControl: {
         0: "None",
         1: "Low gain up",
         2: "High gain up",
         3: "Low gain down",
         4: "High gain down"
      },
      Contrast: {
         0: "Normal",
         1: "Soft",
         2: "Hard"
      },
      Saturation: {
         0: "Normal",
         1: "Low saturation",
         2: "High saturation"
      },
      Sharpness: {
         0: "Normal",
         1: "Soft",
         2: "Hard"
      },
      SubjectDistanceRange: {
         0: "Unknown",
         1: "Macro",
         2: "Close view",
         3: "Distant view"
      },
      FileSource: {
         3: "DSC"
      },

      Components: {
         0: "",
         1: "Y",
         2: "Cb",
         3: "Cr",
         4: "R",
         5: "G",
         6: "B"
      }
   };

   function addEvent(element, event, handler)
   {
      if (element.addEventListener)
      {
         element.addEventListener(event, handler, false);
      } else if (element.attachEvent)
      {
         element.attachEvent("on" + event, handler);
      }
   }

   function imageHasData(img)
   {
      return !!(img.exifdata);
   }


   function base64ToArrayBuffer(base64, contentType)
   {
      contentType = contentType || base64.match(/^data\:([^\;]+)\;base64,/mi)[1] || ''; // e.g. 'data:image/jpeg;base64,...' => 'image/jpeg'
      base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, '');
      var binary = atob(base64);
      var len = binary.length;
      var buffer = new ArrayBuffer(len);
      var view = new Uint8Array(buffer);
      for (var i = 0; i < len; i++)
      {
         view[i] = binary.charCodeAt(i);
      }
      return buffer;
   }

   function objectURLToBlob(url, callback)
   {
      var http = new XMLHttpRequest();
      http.open("GET", url, true);
      http.responseType = "blob";
      http.onload = function (e)
      {
         if (this.status == 200 || this.status === 0)
         {
            callback(this.response);
         }
      };
      http.send();
   }

   function getImageData(img, callback)
   {
      function handleBinaryFile(binFile)
      {
         var data = findEXIFinJPEG(binFile);
         img.exifdata = data || {};
         var iptcdata = findIPTCinJPEG(binFile);
         img.iptcdata = iptcdata || {};
         if (EXIF.isXmpEnabled)
         {
            var xmpdata = {};
            try
            {
               xmpdata = findXMPinJPEG(binFile);
            }
            catch (ex)
            {

            }
            img.xmpdata = xmpdata || {};
         }
         if (callback)
         {
            callback.call(img);
         }
      }

      if (img.src)
      {
         if (/^data\:/i.test(img.src))
         { // Data URI
            var arrayBuffer = base64ToArrayBuffer(img.src);
            handleBinaryFile(arrayBuffer);

         } else if (/^blob\:/i.test(img.src))
         { // Object URL
            var fileReader = new FileReader();
            fileReader.onload = function (e)
            {
               handleBinaryFile(e.target.result);
            };
            objectURLToBlob(img.src, function (blob)
            {
               fileReader.readAsArrayBuffer(blob);
            });
         } else
         {
            var http = new XMLHttpRequest();
            http.onload = function ()
            {
               if (this.status == 200 || this.status === 0)
               {
                  handleBinaryFile(http.response);
               } else
               {
                  throw "Could not load image";
               }
               http = null;
            };
            http.open("GET", img.src, true);
            http.responseType = "arraybuffer";
            http.send(null);
         }
      } else if (self.FileReader && (img instanceof self.Blob || img instanceof self.File))
      {
         var fileReader = new FileReader();
         fileReader.onload = function (e)
         {
            if (debug) console.log("Got file of length " + e.target.result.byteLength);
            handleBinaryFile(e.target.result);
         };

         fileReader.readAsArrayBuffer(img);
      }
   }

   function findEXIFinJPEG(file)
   {
      var dataView = new DataView(file);

      if (debug) console.log("Got file of length " + file.byteLength);
      if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8))
      {
         if (debug) console.log("Not a valid JPEG");
         return false; // not a valid jpeg
      }

      var offset = 2,
          length = file.byteLength,
          marker;

      while (offset < length)
      {
         if (dataView.getUint8(offset) != 0xFF)
         {
            if (debug) console.log("Not a valid marker at offset " + offset + ", found: " + dataView.getUint8(offset));
            return false; // not a valid marker, something is wrong
         }

         marker = dataView.getUint8(offset + 1);
         if (debug) console.log(marker);

         // we could implement handling for other markers here,
         // but we're only looking for 0xFFE1 for EXIF data

         if (marker == 225)
         {
            if (debug) console.log("Found 0xFFE1 marker");

            return readEXIFData(dataView, offset + 4, dataView.getUint16(offset + 2) - 2);

            // offset += 2 + file.getShortAt(offset+2, true);

         } else
         {
            offset += 2 + dataView.getUint16(offset + 2);
         }

      }

   }

   function findIPTCinJPEG(file)
   {
      var dataView = new DataView(file);

      if (debug) console.log("Got file of length " + file.byteLength);
      if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8))
      {
         if (debug) console.log("Not a valid JPEG");
         return false; // not a valid jpeg
      }

      var offset = 2,
          length = file.byteLength;


      var isFieldSegmentStart = function (dataView, offset)
      {
         return (
             dataView.getUint8(offset) === 0x38 &&
             dataView.getUint8(offset + 1) === 0x42 &&
             dataView.getUint8(offset + 2) === 0x49 &&
             dataView.getUint8(offset + 3) === 0x4D &&
             dataView.getUint8(offset + 4) === 0x04 &&
             dataView.getUint8(offset + 5) === 0x04
         );
      };

      while (offset < length)
      {

         if (isFieldSegmentStart(dataView, offset))
         {

            // Get the length of the name header (which is padded to an even number of bytes)
            var nameHeaderLength = dataView.getUint8(offset + 7);
            if (nameHeaderLength % 2 !== 0) nameHeaderLength += 1;
            // Check for pre photoshop 6 format
            if (nameHeaderLength === 0)
            {
               // Always 4
               nameHeaderLength = 4;
            }

            var startOffset = offset + 8 + nameHeaderLength;
            var sectionLength = dataView.getUint16(offset + 6 + nameHeaderLength);

            return readIPTCData(file, startOffset, sectionLength);

            break;

         }


         // Not the marker, continue searching
         offset++;

      }

   }
   var IptcFieldMap = {
      0x78: 'caption',
      0x6E: 'credit',
      0x19: 'keywords',
      0x37: 'dateCreated',
      0x50: 'byline',
      0x55: 'bylineTitle',
      0x7A: 'captionWriter',
      0x69: 'headline',
      0x74: 'copyright',
      0x0F: 'category'
   };
   function readIPTCData(file, startOffset, sectionLength)
   {
      var dataView = new DataView(file);
      var data = {};
      var fieldValue, fieldName, dataSize, segmentType, segmentSize;
      var segmentStartPos = startOffset;
      while (segmentStartPos < startOffset + sectionLength)
      {
         if (dataView.getUint8(segmentStartPos) === 0x1C && dataView.getUint8(segmentStartPos + 1) === 0x02)
         {
            segmentType = dataView.getUint8(segmentStartPos + 2);
            if (segmentType in IptcFieldMap)
            {
               dataSize = dataView.getInt16(segmentStartPos + 3);
               segmentSize = dataSize + 5;
               fieldName = IptcFieldMap[segmentType];
               fieldValue = getStringFromDB(dataView, segmentStartPos + 5, dataSize);
               // Check if we already stored a value with this name
               if (data.hasOwnProperty(fieldName))
               {
                  // Value already stored with this name, create multivalue field
                  if (data[fieldName] instanceof Array)
                  {
                     data[fieldName].push(fieldValue);
                  }
                  else
                  {
                     data[fieldName] = [data[fieldName], fieldValue];
                  }
               }
               else
               {
                  data[fieldName] = fieldValue;
               }
            }

         }
         segmentStartPos++;
      }
      return data;
   }



   function readTags(file, tiffStart, dirStart, strings, bigEnd)
   {
      var entries = file.getUint16(dirStart, !bigEnd),
          tags = {},
          entryOffset, tag,
          i;

      for (i = 0; i < entries; i++)
      {
         entryOffset = dirStart + i * 12 + 2;
         tag = strings[file.getUint16(entryOffset, !bigEnd)];
         if (!tag && debug) console.log("Unknown tag: " + file.getUint16(entryOffset, !bigEnd));
         try
         {
            tags[tag] = readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd);
         }
         catch (ex)
         {

         }
      }
      return tags;
   }


   function readTagValue(file, entryOffset, tiffStart, dirStart, bigEnd)
   {
      var type = file.getUint16(entryOffset + 2, !bigEnd),
          numValues = file.getUint32(entryOffset + 4, !bigEnd),
          valueOffset = file.getUint32(entryOffset + 8, !bigEnd) + tiffStart,
          offset,
          vals, val, n,
          numerator, denominator;

      switch (type)
      {
         case 1: // byte, 8-bit unsigned int
         case 7: // undefined, 8-bit byte, value depending on field
            if (numValues == 1)
            {
               return file.getUint8(entryOffset + 8, !bigEnd);
            } else
            {
               offset = numValues > 4 ? valueOffset : (entryOffset + 8);
               vals = [];
               for (n = 0; n < numValues; n++)
               {
                  vals[n] = file.getUint8(offset + n);
               }
               return vals;
            }

         case 2: // ascii, 8-bit byte
            offset = numValues > 4 ? valueOffset : (entryOffset + 8);
            return getStringFromDB(file, offset, numValues - 1);

         case 3: // short, 16 bit int
            if (numValues == 1)
            {
               return file.getUint16(entryOffset + 8, !bigEnd);
            } else
            {
               offset = numValues > 2 ? valueOffset : (entryOffset + 8);
               vals = [];
               for (n = 0; n < numValues; n++)
               {
                  vals[n] = file.getUint16(offset + 2 * n, !bigEnd);
               }
               return vals;
            }

         case 4: // long, 32 bit int
            if (numValues == 1)
            {
               return file.getUint32(entryOffset + 8, !bigEnd);
            } else
            {
               vals = [];
               for (n = 0; n < numValues; n++)
               {
                  vals[n] = file.getUint32(valueOffset + 4 * n, !bigEnd);
               }
               return vals;
            }

         case 5:    // rational = two long values, first is numerator, second is denominator
            if (numValues == 1)
            {
               numerator = file.getUint32(valueOffset, !bigEnd);
               denominator = file.getUint32(valueOffset + 4, !bigEnd);
               val = new Number(numerator / denominator);
               val.numerator = numerator;
               val.denominator = denominator;
               return val;
            } else
            {
               vals = [];
               for (n = 0; n < numValues; n++)
               {
                  numerator = file.getUint32(valueOffset + 8 * n, !bigEnd);
                  denominator = file.getUint32(valueOffset + 4 + 8 * n, !bigEnd);
                  vals[n] = new Number(numerator / denominator);
                  vals[n].numerator = numerator;
                  vals[n].denominator = denominator;
               }
               return vals;
            }

         case 9: // slong, 32 bit signed int
            if (numValues == 1)
            {
               return file.getInt32(entryOffset + 8, !bigEnd);
            } else
            {
               vals = [];
               for (n = 0; n < numValues; n++)
               {
                  vals[n] = file.getInt32(valueOffset + 4 * n, !bigEnd);
               }
               return vals;
            }

         case 10: // signed rational, two slongs, first is numerator, second is denominator
            if (numValues == 1)
            {
               return file.getInt32(valueOffset, !bigEnd) / file.getInt32(valueOffset + 4, !bigEnd);
            } else
            {
               vals = [];
               for (n = 0; n < numValues; n++)
               {
                  vals[n] = file.getInt32(valueOffset + 8 * n, !bigEnd) / file.getInt32(valueOffset + 4 + 8 * n, !bigEnd);
               }
               return vals;
            }
      }
   }

   /**
   * Given an IFD (Image File Directory) start offset
   * returns an offset to next IFD or 0 if it's the last IFD.
   */
   function getNextIFDOffset(dataView, dirStart, bigEnd)
   {
      //the first 2bytes means the number of directory entries contains in this IFD
      var entries = dataView.getUint16(dirStart, !bigEnd);

      // After last directory entry, there is a 4bytes of data,
      // it means an offset to next IFD.
      // If its value is '0x00000000', it means this is the last IFD and there is no linked IFD.

      return dataView.getUint32(dirStart + 2 + entries * 12, !bigEnd); // each entry is 12 bytes long
   }

   function readThumbnailImage(dataView, tiffStart, firstIFDOffset, bigEnd)
   {
      // get the IFD1 offset
      var IFD1OffsetPointer = getNextIFDOffset(dataView, tiffStart + firstIFDOffset, bigEnd);

      if (!IFD1OffsetPointer)
      {
         // console.log('******** IFD1Offset is empty, image thumb not found ********');
         return {};
      }
      else if (IFD1OffsetPointer > dataView.byteLength)
      { // this should not happen
         // console.log('******** IFD1Offset is outside the bounds of the DataView ********');
         return {};
      }
      // console.log('*******  thumbnail IFD offset (IFD1) is: %s', IFD1OffsetPointer);

      var thumbTags = readTags(dataView, tiffStart, tiffStart + IFD1OffsetPointer, IFD1Tags, bigEnd)

      // EXIF 2.3 specification for JPEG format thumbnail

      // If the value of Compression(0x0103) Tag in IFD1 is '6', thumbnail image format is JPEG.
      // Most of Exif image uses JPEG format for thumbnail. In that case, you can get offset of thumbnail
      // by JpegIFOffset(0x0201) Tag in IFD1, size of thumbnail by JpegIFByteCount(0x0202) Tag.
      // Data format is ordinary JPEG format, starts from 0xFFD8 and ends by 0xFFD9. It seems that
      // JPEG format and 160x120pixels of size are recommended thumbnail format for Exif2.1 or later.

      if (thumbTags['Compression'])
      {
         // console.log('Thumbnail image found!');

         switch (thumbTags['Compression'])
         {
            case 6:
               // console.log('Thumbnail image format is JPEG');
               if (thumbTags.JpegIFOffset && thumbTags.JpegIFByteCount)
               {
                  // extract the thumbnail
                  var tOffset = tiffStart + thumbTags.JpegIFOffset;
                  var tLength = thumbTags.JpegIFByteCount;
                  thumbTags['blob'] = new Blob([new Uint8Array(dataView.buffer, tOffset, tLength)], {
                     type: 'image/jpeg'
                  });
               }
               break;

            case 1:
               console.log("Thumbnail image format is TIFF, which is not implemented.");
               break;
            default:
               console.log("Unknown thumbnail image format '%s'", thumbTags['Compression']);
         }
      }
      else if (thumbTags['PhotometricInterpretation'] == 2)
      {
         console.log("Thumbnail image format is RGB, which is not implemented.");
      }
      return thumbTags;
   }

   function getStringFromDB(buffer, start, length)
   {
      var outstr = "";
      for (var n = start; n < start + length; n++)
      {
         outstr += String.fromCharCode(buffer.getUint8(n));
      }
      return outstr;
   }

   function readEXIFData(file, start)
   {
      if (getStringFromDB(file, start, 4) != "Exif")
      {
         if (debug) console.log("Not valid EXIF data! " + getStringFromDB(file, start, 4));
         return false;
      }

      var bigEnd,
          tags, tag,
          exifData, gpsData,
          tiffOffset = start + 6;

      // test for TIFF validity and endianness
      if (file.getUint16(tiffOffset) == 0x4949)
      {
         bigEnd = false;
      } else if (file.getUint16(tiffOffset) == 0x4D4D)
      {
         bigEnd = true;
      } else
      {
         if (debug) console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)");
         return false;
      }

      if (file.getUint16(tiffOffset + 2, !bigEnd) != 0x002A)
      {
         if (debug) console.log("Not valid TIFF data! (no 0x002A)");
         return false;
      }

      var firstIFDOffset = file.getUint32(tiffOffset + 4, !bigEnd);

      if (firstIFDOffset < 0x00000008)
      {
         if (debug) console.log("Not valid TIFF data! (First offset less than 8)", file.getUint32(tiffOffset + 4, !bigEnd));
         return false;
      }

      tags = readTags(file, tiffOffset, tiffOffset + firstIFDOffset, TiffTags, bigEnd);

      if (tags.ExifIFDPointer)
      {
         exifData = readTags(file, tiffOffset, tiffOffset + tags.ExifIFDPointer, ExifTags, bigEnd);
         for (tag in exifData)
         {
            switch (tag)
            {
               case "LightSource":
               case "Flash":
               case "MeteringMode":
               case "ExposureProgram":
               case "SensingMethod":
               case "SceneCaptureType":
               case "SceneType":
               case "CustomRendered":
               case "WhiteBalance":
               case "GainControl":
               case "Contrast":
               case "Saturation":
               case "Sharpness":
               case "SubjectDistanceRange":
               case "FileSource":
                  exifData[tag] = StringValues[tag][exifData[tag]];
                  break;

               case "ExifVersion":
               case "FlashpixVersion":
                  exifData[tag] = String.fromCharCode(exifData[tag][0], exifData[tag][1], exifData[tag][2], exifData[tag][3]);
                  break;

               case "ComponentsConfiguration":
                  exifData[tag] =
                      StringValues.Components[exifData[tag][0]] +
                      StringValues.Components[exifData[tag][1]] +
                      StringValues.Components[exifData[tag][2]] +
                      StringValues.Components[exifData[tag][3]];
                  break;
            }
            tags[tag] = exifData[tag];
         }
      }

      if (tags.GPSInfoIFDPointer)
      {
         gpsData = readTags(file, tiffOffset, tiffOffset + tags.GPSInfoIFDPointer, GPSTags, bigEnd);
         for (tag in gpsData)
         {
            switch (tag)
            {
               case "GPSVersionID":
                  gpsData[tag] = gpsData[tag][0] +
                      "." + gpsData[tag][1] +
                      "." + gpsData[tag][2] +
                      "." + gpsData[tag][3];
                  break;
            }
            tags[tag] = gpsData[tag];
         }
      }

      // extract thumbnail
      tags['thumbnail'] = readThumbnailImage(file, tiffOffset, firstIFDOffset, bigEnd);

      return tags;
   }

   function findXMPinJPEG(file)
   {

      if (!('DOMParser' in self))
      {
         // console.warn('XML parsing not supported without DOMParser');
         return;
      }
      var dataView = new DataView(file);

      if (debug) console.log("Got file of length " + file.byteLength);
      if ((dataView.getUint8(0) != 0xFF) || (dataView.getUint8(1) != 0xD8))
      {
         if (debug) console.log("Not a valid JPEG");
         return false; // not a valid jpeg
      }

      var offset = 2,
          length = file.byteLength,
          dom = new DOMParser();

      while (offset < (length - 4))
      {
         if (getStringFromDB(dataView, offset, 4) == "http")
         {
            var startOffset = offset - 1;
            var sectionLength = dataView.getUint16(offset - 2) - 1;
            var xmpString = getStringFromDB(dataView, startOffset, sectionLength)
            var xmpEndIndex = xmpString.indexOf('xmpmeta>') + 8;
            xmpString = xmpString.substring(xmpString.indexOf('<x:xmpmeta'), xmpEndIndex);

            var indexOfXmp = xmpString.indexOf('x:xmpmeta') + 10
            //Many custom written programs embed xmp/xml without any namespace. Following are some of them.
            //Without these namespaces, XML is thought to be invalid by parsers
            xmpString = xmpString.slice(0, indexOfXmp)
                        + 'xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" '
                        + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                        + 'xmlns:tiff="http://ns.adobe.com/tiff/1.0/" '
                        + 'xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus" '
                        + 'xmlns:ext="http://www.gettyimages.com/xsltExtension/1.0" '
                        + 'xmlns:exif="http://ns.adobe.com/exif/1.0/" '
                        + 'xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" '
                        + 'xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" '
                        + 'xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/" '
                        + 'xmlns:xapGImg="http://ns.adobe.com/xap/1.0/g/img/" '
                        + 'xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/" '
                        + xmpString.slice(indexOfXmp)

            var domDocument = dom.parseFromString(xmpString, 'text/xml');
            return { doc: $.parseXML(xmpString), obj: xml2Object(domDocument) };
         } else
         {
            offset++;
         }
      }
   }

   function xml2json(xml)
   {
      var json = {};

      if (xml.nodeType == 1)
      { // element node
         if (xml.attributes.length > 0)
         {
            json['@attributes'] = {};
            for (var j = 0; j < xml.attributes.length; j++)
            {
               var attribute = xml.attributes.item(j);
               json['@attributes'][attribute.nodeName] = attribute.nodeValue;
            }
         }
      } else if (xml.nodeType == 3)
      { // text node
         return xml.nodeValue;
      }

      // deal with children
      if (xml.hasChildNodes())
      {
         for (var i = 0; i < xml.childNodes.length; i++)
         {
            var child = xml.childNodes.item(i);
            var nodeName = child.nodeName;
            if (json[nodeName] == null)
            {
               json[nodeName] = xml2json(child);
            } else
            {
               if (json[nodeName].push == null)
               {
                  var old = json[nodeName];
                  json[nodeName] = [];
                  json[nodeName].push(old);
               }
               json[nodeName].push(xml2json(child));
            }
         }
      }

      return json;
   }

   function xml2Object(xml)
   {
      try
      {
         var obj = {};
         if (xml.children.length > 0)
         {
            for (var i = 0; i < xml.children.length; i++)
            {
               var item = xml.children.item(i);
               var attributes = item.attributes;
               for (var idx in attributes)
               {
                  var itemAtt = attributes[idx];
                  var dataKey = itemAtt.nodeName;
                  var dataValue = itemAtt.nodeValue;

                  if (dataKey !== undefined)
                  {
                     obj[dataKey] = dataValue;
                  }
               }
               var nodeName = item.nodeName;

               if (typeof (obj[nodeName]) == "undefined")
               {
                  obj[nodeName] = xml2json(item);
               } else
               {
                  if (typeof (obj[nodeName].push) == "undefined")
                  {
                     var old = obj[nodeName];

                     obj[nodeName] = [];
                     obj[nodeName].push(old);
                  }
                  obj[nodeName].push(xml2json(item));
               }
            }
         } else
         {
            obj = xml.textContent;
         }
         return obj;
      } catch (e)
      {
         console.log(e.message);
      }
   }

   EXIF.enableXmp = function ()
   {
      EXIF.isXmpEnabled = true;
   }

   EXIF.disableXmp = function ()
   {
      EXIF.isXmpEnabled = false;
   }

   EXIF.getData = function (img, callback)
   {
      if (((self.Image && img instanceof self.Image)
          || (self.HTMLImageElement && img instanceof self.HTMLImageElement))
          && !img.complete)
         return false;

      if (!imageHasData(img))
      {
         getImageData(img, callback);
      } else
      {
         if (callback)
         {
            callback.call(img);
         }
      }
      return true;
   }

   EXIF.getTag = function (img, tag)
   {
      if (!imageHasData(img)) return;
      return img.exifdata[tag];
   }

   EXIF.getIptcTag = function (img, tag)
   {
      if (!imageHasData(img)) return;
      return img.iptcdata[tag];
   }

   EXIF.getAllTags = function (img)
   {
      if (!imageHasData(img)) return {};
      var a,
          data = img.exifdata,
          tags = {};
      for (a in data)
      {
         if (data.hasOwnProperty(a))
         {
            tags[a] = data[a];
         }
      }
      return tags;
   }

   EXIF.getAllIptcTags = function (img)
   {
      if (!imageHasData(img)) return {};
      var a,
          data = img.iptcdata,
          tags = {};
      for (a in data)
      {
         if (data.hasOwnProperty(a))
         {
            tags[a] = data[a];
         }
      }
      return tags;
   }

   EXIF.pretty = function (img)
   {
      if (!imageHasData(img)) return "";
      var a,
          data = img.exifdata,
          strPretty = "";
      for (a in data)
      {
         if (data.hasOwnProperty(a))
         {
            if (typeof data[a] == "object")
            {
               if (data[a] instanceof Number)
               {
                  strPretty += a + " : " + data[a] + " [" + data[a].numerator + "/" + data[a].denominator + "]\r\n";
               } else
               {
                  strPretty += a + " : [" + data[a].length + " values]\r\n";
               }
            } else
            {
               strPretty += a + " : " + data[a] + "\r\n";
            }
         }
      }
      return strPretty;
   }

   EXIF.readFromBinaryFile = function (file)
   {
      return findEXIFinJPEG(file);
   }

   if (typeof define === 'function' && define.amd)
   {
      define('exif-js', [], function ()
      {
         return EXIF;
      });
   }
}.call(this));
﻿var _photoList=[],_pubList=[],_tagItemId=-1,_uploading=!1,_badExt=["exe","vbs","bat","com","js","sh","ini","bin","swf","flv"],_imageExtensions=["jpeg","jpg","png","bmp","gif","tif","eps","ai","pdf","psd"],_uploadedCount=0,_defaultTags=[],_uploaderChangesMade=!1,_MTS_previewImg=null,_MTS_previewObj=null,_MTS_selectionScale=1,_MTS_focusImg=null,_MTS_focusObjs=[],_MTS_focusImgs=[],_MTS_focusDims=[],_pendingData=[],_profiles=[],_selectedRunDate=null,_selectedAd=null,_selectedIdx=-1,_imageVersionChange=!1,_changedCount=0,_updateRank=!1,_MTS_published=!1;function WireUpload(){_MTS_stopSearchOnce=!0,_cal.initialize(),_MTS_selectTagOverride=handleTagClick,_MTS_JQUERY(".photo_upload_widget").remove().appendTo("body"),"undefined"==typeof _chosenSupported&&(_chosenSupported="Microsoft Internet Explorer"===window.navigator.appName?8<=document.documentMode:!/iP(od|hone)/i.test(window.navigator.userAgent)&&(!/Android/i.test(window.navigator.userAgent)||!/Mobile/i.test(window.navigator.userAgent))),"function"==typeof _MTS_JQUERY().chosen&&_chosenSupported?_MTS_JQUERY("#albumSelect").chosen({width:"240px",disable_search:!0}):_MTS_JQUERY("#albumSelect").show();var s=_MTS_JQUERY(".photoHolder"),e=_MTS_JQUERY(".photoToolsCtr"),t=_MTS_JQUERY(".interfaceBarCtr"),o=_MTS_JQUERY(".updateButton"),t=(e.css({height:_MTS_JQUERY(window).outerHeight()-o.outerHeight()-t.outerHeight()+"px"}),s.css({height:_MTS_JQUERY(window).outerHeight()-t.outerHeight()+"px"}),_MTS_JQUERY(".mts_cc_text").css("color")),t=(_MTS_JQUERY(".bordered:hover, .indTag:hover, .viewTags:hover").css({"border-bottom-color":t}),_MTS_JQUERY(".phBlock"),_MTS_JQUERY(".phBlockCtr"),_MTS_JQUERY(".phBlockTools"),_MTS_JQUERY(".phImgCtr")),d=_MTS_JQUERY(".closePreview"),l=_MTS_JQUERY(".previewCtr"),r=(_MTS_JQUERY(".dragDrop, .browseUnderlay"),_MTS_JQUERY(".noMedia, .phToolTip"),_MTS_JQUERY(".photoCtr"),_MTS_JQUERY(".prevImg")),_=!1;if("undefined"!=typeof _pubs&&_pubs)for(var i=0;i<_pubs.length;i++)_pubList.push(new publicationInfo(_pubs[i].Id,_pubs[i].Name,_pubs[i].PageRequired));function a(o){var i=!1;_MTS_JQUERY(".photoCtr").children().each(function(e){var t=this.id.split("_")[1];(0<_photoList[t].rank||!i)&&(_photoList[t].rank=e+1,_photoList[t].changesmade=!0),i=i||this.id==o.id}),CheckPhotosForRank()}function n(e){var t=_MTS_JQUERY("#cropGroup"),o=(l.show(),r.outerHeight()>r.outerWidth()&&r.addClass("portrait"),l.css({height:_MTS_JQUERY(window).outerHeight()/2-60+"px"}),(_MTS_focusImg=_MTS_JQUERY(e).parents(".phBlockCtr").find(".phImg")).attr("src")),i=_MTS_JQUERY(".prevImg");i.attr("src",o),l.css({height:s.outerHeight()+"px"}),_MTS_previewImg=i,s.addClass("overflow");for(var a=0,n=_MTS_focusObjs.length-1;a<=n;a++)_MTS_focusObjs[a].setOptions({hide:!0});_?t.show():t.hide(),"Image"==_uploadType&&(o=_MTS_JQUERY(e).parents(".phBlockCtr").find("textarea[name='caption']").val(),i=_MTS_JQUERY(e).parents(".phBlockCtr").find("input[name='credit']").val(),_MTS_JQUERY("#uniCap").val(o),_MTS_JQUERY("#uniCred").val(i)),_MTS_JQUERY(e).parents(".phBlockCtr").find("input[type=checkbox].phCheck").prop("checked",!0).change(),_MTS_JQUERY(".closePreview").data("photoId",_MTS_JQUERY(e).parents(".phBlockCtr").attr("id").split("_")[1])}function p(){l.hide(),e.removeClass("overflow"),s.removeClass("overflow"),_&&(hideImgArea(),_=!1),showThumbnailCrop(),$("#phuDragDrop").removeClass("hideIt")}_MTS_JQUERY("#pageStar").hide(),_MTS_JQUERY(document).on("click",".mts_focus",function(){var e=getAllElementsAt(this);1==e.length&&e[0].find("img").click()}),_MTS_JQUERY(".photoHolder").on("scroll",function(){for(var e=_MTS_focusObjs.length-1;0<=e;e--)_MTS_focusObjs[e].update()}),_MTS_JQUERY(document).on("focus","input[name='link']",function(){""==this.value&&(this.value="http://")}),_MTS_JQUERY(document).on("blur","input[name='link']",function(){"http://"==this.value&&(this.value="")}),_MTS_JQUERY(document).on("click",".closeUpload",function(e){var t=CloseUpload();void 0===t||t||e.preventDefault()}),_MTS_JQUERY(".photo_upload_widget").on("drag dragstart dragend dragover dragenter dragleave",function(e){e.preventDefault()}),0<_MTS_JQUERY(".dragDrop").length&&_MTS_JQUERY(".photoUploadContainer").on("drop",function(e){e.preventDefault(),e.stopPropagation();var t,o=e.target.files;(o=!o||0===o.length||e.dataTransfer?e.dataTransfer?e.dataTransfer.items:e.originalEvent.dataTransfer.files:o)[0]&&"function"==typeof o[0].webkitGetAsEntry&&(t=o[0].webkitGetAsEntry())?traverseFileUploadTree(t.filesystem.root,void 0,void 0,startPhotoUpload):(loopPhotoFiles(o),startPhotoUpload())}),_MTS_JQUERY(document).on("click",".phBrowse, #fPhotoHere",function(){_MTS_JQUERY("#fPhotoBrowse").click()}),_MTS_JQUERY("#fPhotoBrowse").change(function(){loopPhotoFiles(_MTS_JQUERY(this)[0]),startPhotoUpload()}),t.css({height:2.5*t.outerWidth()/4+"px"}),_MTS_JQUERY(".photoHolder").on("click",".phImgCtr",function(){return"Advertisement"!==_uploadType&&(_=!1,n(this),_MTS_JQUERY("#phuDragDrop").addClass("hideIt"),void("Image"==_uploadType&&(_MTS_JQUERY(".tab").removeClass("selected"),_MTS_JQUERY(".tab.tags").addClass("selected"),_MTS_JQUERY(".tool").removeClass("showTool"),_MTS_JQUERY(".phutags").addClass("showTool"))))}),_MTS_JQUERY(".photoHolder").on("click",".phCrop",function(){_=!0,n(this),wireImgArea(),checkForPhotos()}),_MTS_JQUERY(".photoHolder").on("click","#saveCrop",function(){applyImgArea(),p(),checkForPhotos()}),_MTS_JQUERY(".photoHolder").on("click",".phVersion",function(){_MTS_JQUERY(this).parents(".phBlockMain").siblings(".versionCtr").toggleClass("togglePanel")}),_MTS_JQUERY(".photoHolder").on("click",".closeVersionCtr",function(){_MTS_JQUERY(this).parents(".versionCtr").removeClass("togglePanel")}),_MTS_JQUERY(".photoHolder").on("click","input[name='photoStart'], input[name='photoEnd']",function(){var i=_MTS_JQUERY(this),e=new Date($.trim(this.innerHTML));isNaN(e)&&(e=new Date),_cal.GetMiniCalendar("select","Date",e,function(e,t,o){i.val(e.toString()+"/"+t.toString()+"/"+o.toString())})}),"undefined"!=typeof _rankImgs&&_rankImgs&&(1024<_MTS_JQUERY(window).outerWidth()&&_MTS_JQUERY(".photoCtr").sortable({update:function(e,t){a(t.item[0])}}),_MTS_JQUERY(".photoHolder").on("click",".phUp, .phDown",function(){var e=_MTS_JQUERY(this).parents("li"),t=_MTS_JQUERY(this).hasClass("phDown"),o=t?e.next("li"):e.prev("li");0<o.length&&(e.remove(),t?o.after(e):o.before(e),a(e[0]))}),_MTS_JQUERY("#wipeRank").click(function(){var e=!0,t=_MTS_JQUERY.map(_photoList,function(e,t){return t});if(0<_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").length&&(e=!1,t=_MTS_JQUERY.map(_photoList,function(e,t){return 0<_MTS_JQUERY("#block_"+t).find("input[type='checkbox'].phCheck:checked").length?t:null})),confirm("Are you sure you want to reset the display order for all "+(e?"":"selected ")+"items?")){for(var o=0;o<t.length;o++)_photoList[t[o]].rank=0,_photoList[t[o]].changesmade=!0;SortPhotosByRank()}})),_MTS_JQUERY("#prevX1, #prevX2, #prevY1, #prevY2").change(function(){setImgArea()}),d.on("click",function(){p(),_MTS_JQUERY(""),_MTS_JQUERY(".uploadTagWrapper").removeClass("showTagWrapper"),_MTS_JQUERY("#phuDragDrop").removeClass("hideIt"),_MTS_JQUERY("#uniCap, #uniCred").val(""),_MTS_JQUERY("#block_"+_MTS_JQUERY(this).data("photoId")).find(".phCheck").prop("checked",!1).change(),checkForPhotos()});_MTS_JQUERY(".viewTags"),_MTS_JQUERY(".tagViewerCtr");_MTS_JQUERY(".photoHolder").on("click",".viewTags",function(){_tagItemId=_MTS_JQUERY(this).parents(".phBlockCtr").attr("id").split("_")[1];_MTS_JQUERY(".tgImgCtr").css({height:2.5*_MTS_JQUERY(".tagViewerCtr").outerWidth()/4+"px"});var e=_MTS_JQUERY(this).parent(".phBlockInfo").siblings(".phImgCtr").children(".phImg").attr("src");_MTS_JQUERY(".tgImgCtr").children(".phImg").attr("src",e),updateTagList()});var t=_MTS_JQUERY("#cnaBtn, #cancelCna"),h=_MTS_JQUERY(".createNewAlbumCtr"),c=(t.on("click",function(){h.toggleClass("cnaOpen")}),_MTS_JQUERY("#saveCna").click(function(){var e,t=_MTS_JQUERY.trim(_MTS_JQUERY("#albumName").val()),o=_MTS_JQUERY.trim(_MTS_JQUERY("#albumDesc").val()),i=_MTS_JQUERY.trim(_MTS_JQUERY("#albumSlugline").val());0!=t.length?((e=[]).push({name:"albums",value:JSON.stringify([{id:-1,name:t,desc:o,slugline:i,created:!0}])}),_MTS_JQUERY.post("/api/portalAdmin/updateAlbumManager.aspx",e,function(e){e.ok?(_MTS_JQUERY("#albumSelect").append(_MTS_JQUERY("<option></option>").attr("value",e.newAlbumId).text(t).prop("selected",!0)),_MTS_JQUERY("#albumSelect").trigger("chosen:updated"),_uploaderChangesMade=!0,h.toggleClass("cnaOpen")):alert(e.error)},"json")):alert("Album needs a title.")}),o.on("click",function(){_uploading||(0<_pendingData.length?(_MTS_JQUERY(document).off("metadataLoaded"),_MTS_JQUERY(document).on("metadataLoaded",savePhotos)):o.hasClass("updateButtonActive")?(_uploadedCount=0,_MTS_JQUERY(".imgCheck, .imgErr").remove(),savePhotos()):alert("There are no items to save"))}),_MTS_JQUERY("#selAll").change(function(){_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck").prop("checked",_MTS_JQUERY(this).prop("checked")),checkForSelected(),updateTagList()}),_MTS_JQUERY("#remSel").click(function(){_MTS_JQUERY(this).hasClass("noSelect")||removeMultiPhotoUpload(_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").parents(".phBlockCtr").map(function(){return this.id.split("_")[1]}),!0)}),_MTS_JQUERY("#remAll").click(function(){_MTS_JQUERY(this).hasClass("noSelect")||removeMultiPhotoUpload(_MTS_JQUERY(".photoHolder").find(".phBlockCtr").map(function(){return this.id.split("_")[1]}),!1)}),"Advertisement"===_uploadType&&_MTS_JQUERY(".photoHolder").on("click",".phImgCtr",function(){_MTS_JQUERY(this).parents(".phBlockCtr").find("input[type='checkbox'].phCheck").click()}),_MTS_JQUERY(".photoHolder").on("change","input[type='checkbox'].phCheck",function(){var e;"Image"==_uploadType?(checkForSelected(),updateTagList()):"Advertisement"==_uploadType&&(_MTS_JQUERY(".phCheck:checked").not(this).prop("checked",!1),_MTS_JQUERY(this).is(":checked")?(enableAdForm(),e=_MTS_JQUERY(this).parents(".phBlockCtr")[0].id.split("_")[1],_selectedAd=_photoList[e],_selectedIdx=e,_MTS_JQUERY(".adInfoForm").find("input[name='accountNumber']").val(_selectedAd.accountNumber),_MTS_JQUERY(".adInfoForm").find("input[name='title']").val(_selectedAd.title),_MTS_JQUERY(".adInfoForm").find("input[name='adNumber']").val(_selectedAd.adNumber),_MTS_JQUERY(".adInfoForm").find("input[name='width']").val(_selectedAd.width),_MTS_JQUERY(".adInfoForm").find("input[name='height']").val(_selectedAd.height),_MTS_JQUERY(".adInfoForm").find("textarea[name='notes']").val(_selectedAd.notes),_MTS_JQUERY(".adInfoForm").find("input[name='url']").val(_selectedAd.url),_MTS_JQUERY(".adInfoForm").find("input[name='colorSetting'][value='"+_selectedAd.colorSetting+"']").prop("checked",!0),_MTS_JQUERY(".adInfoForm").find("input[name='requestedPageLocation']").val(_selectedAd.requestedPageLocation),_MTS_JQUERY("#dateWrapper").find(".runDate").remove(),_MTS_JQUERY("#insertionWrapper").hide(),_selectedAd.runDates&&_selectedAd.runDates.forEach(function(e,t){var o="<div id='date_"+t+"' class='runDate'>"+_MTS_JQUERY("#dateTemplate").html()+"</div>",o=(_MTS_JQUERY("#dateWrapper").append(o),new Date(e.RunDate));isNaN(o)||(o=o.getMonth()+1+"/"+o.getDate()+"/"+o.getFullYear()),_MTS_JQUERY("#date_"+t).find(".dateContent").html(o)}),_MTS_JQUERY(".result").removeClass("selectedTag")):(_selectedAd=null,disableAdForm()),_MTS_JQUERY(".uploadTagWrapper").removeClass("showTagWrapper"))}),_MTS_JQUERY(".photoHolder").on("click",".phRemove",function(){removePhotoUpload(_MTS_JQUERY(this).parents(".phBlockCtr")[0].id.split("_")[1])}),_MTS_JQUERY(".tagList").on("click",".removeTag",function(){var e=_MTS_JQUERY(this).siblings("input[name='id']").val(),t=_MTS_JQUERY(this).siblings("input[name='type']").val();removeTag([_photoList[_tagItemId]],e,t)}),_MTS_JQUERY("#selectedTags").on("click",".removeTag",function(){var e=_MTS_JQUERY(this).siblings("input[name='id']").val(),t=_MTS_JQUERY(this).siblings("input[name='type']").val();removeTag(_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").parents(".phBlockCtr").map(function(){var e=this.id.split("_")[1];return void 0===_photoList[e]||_photoList[e].removed?null:_photoList[e]}),e,t)}),_MTS_JQUERY("#allTags").on("click",".removeTag",function(){var e=_MTS_JQUERY(this).siblings("input[name='id']").val(),t=_MTS_JQUERY(this).siblings("input[name='type']").val();removeTag(_MTS_JQUERY.map(_photoList,function(e){return e.removed?null:e}),e,t)}),_MTS_JQUERY(".searchResults").on("click",".selectedTag",function(e){e.preventDefault(),e.stopPropagation();var e=this.href.match(/([\w]+)/g),t=e.pop(),o=e.pop();_MTS_JQUERY(this).removeClass("selectedTag"),"Image"==_uploadType?_MTS_JQUERY(".uploadTagContainer:visible .tagAll").each(function(){var e=_MTS_JQUERY(this);e.find("input[name='id']").val()==o&&e.find("input[name='type']").val()==t&&e.find(".removeTag").click()}):removeAdTag(o,t)}),_MTS_JQUERY("#tagSelected").click(function(){_MTS_JQUERY(this).hasClass("noSelect")||(_tagItemId=-1,ToggleNewUploadTag())}),_MTS_JQUERY(".photoHolder").on("click",".tagIcon",function(){_tagItemId=parseInt(_MTS_JQUERY(this).parents(".phBlockCtr").attr("id").split("_")[1]),_MTS_JQUERY("#block_"+_tagItemId).find(".viewTags").click(),ToggleNewUploadTag(),_MTS_JQUERY(".tab").removeClass("selected"),_MTS_JQUERY(".tab.tags").addClass("selected"),_MTS_JQUERY(".tool").removeClass("showTool"),_MTS_JQUERY(".phutags").addClass("showTool"),_MTS_JQUERY("#phuDragDrop").addClass("hideIt"),_MTS_JQUERY(".photoHolder input[type=checkbox].phCheck").prop("checked",!1).change(),_MTS_JQUERY(this).parents(".phBlockCtr").find("input[type=checkbox].phCheck").prop("checked",!0).change()}),_MTS_JQUERY(".photoHolder").on("change","input[type='text']",function(){_uploaderChangesMade=!0}),_MTS_JQUERY("#update_Cap, #update_Cred").click(function(){var e=this.id.split("_")[1],t=_MTS_JQUERY("#uni"+e).val(),o=_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").parents(".phBlockCtr");(o=0==o.length?_MTS_JQUERY(".photoHolder .phBlockCtr"):o).find("[name='"+("Cap"==e?"caption":"credit")+"']").val(t),_uploaderChangesMade=!0}),_MTS_JQUERY("#mts_unlockstory").click(function(){_MTS_JQUERY(".photo_upload_widget").css("height","100%"),_MTS_JQUERY(".updateButtonCtr").css("bottom","0px"),_MTS_JQUERY(".progress").css("bottom","50px")}),_MTS_JQUERY(window).on("orientationchange",function(){var e,t;767<_MTS_JQUERY(window).width()||(_MTS_JQUERY(window).width()>_MTS_JQUERY(window).height()?(e=_MTS_JQUERY(".previewLbl"),setTimeout(function(){e.addClass("hideLbl")},2e3),_MTS_JQUERY(".previewCtr").on("click",function(){e.toggleClass("hideLbl")})):(e=_MTS_JQUERY(".previewLbl")).removeClass("hideLbl"),t=_MTS_JQUERY("#remSel, #remAll").detach(),void 0===window.orientation||0==window.orientation?t.appendTo(".mtType"):t.appendTo(".selOptions"))}),_MTS_JQUERY(window).resize(function(){resizePhotoUpload()}),checkForPhotos(),checkForSelected(),"Image"==_uploadType&&updateTagList(),_MTS_JQUERY(".tab"));c.on("click",function(){var e;_MTS_JQUERY(this).hasClass("selected")||(e=".phu"+_MTS_JQUERY(this).attr("class").substring(4),_MTS_JQUERY(".tool").removeClass("showTool"),c.removeClass("selected"),_MTS_JQUERY(this).addClass("selected"),_MTS_JQUERY(e).addClass("showTool"))}),_MTS_JQUERY(".photo_upload_widget #searchPhrase").on("keydown",function(e){13===e.which&&(e.preventDefault(),MTS_handleEz(0,null,this))}),_MTS_JQUERY(document).on("click","input[name='publication']",function(){ToggleNewUploadTag()}),_MTS_JQUERY(document).on("change","input[name='colorSetting']",function(){_selectedAd.colorSetting=_MTS_JQUERY(this).val(),_uploaderChangesMade=!0}),_MTS_JQUERY("#pickRunDates").on("click",function(){showRunDateCalendar()}),_MTS_JQUERY(document).on("change","input[name='publication'], input[name='edition'], input[name='section'], input[name='page'], input[name='zone'], input[name='horizontalPosition'], input[name='verticalPosition']",function(){var e=(e=this.name)[0].toUpperCase()+e.substr(1);_selectedRunDate[e]=this.value}),_MTS_JQUERY(document).on("click",".dateContent",function(){_MTS_JQUERY(".selectedRunDate").removeClass("selectedRunDate"),_MTS_JQUERY(this).addClass("selectedRunDate"),_MTS_JQUERY("#insertionWrapper").show();var e=_MTS_JQUERY(this).parents(".runDate")[0].id.split("_")[1],e=findPublicationByPubCode((_selectedRunDate=_selectedAd.runDates[e]).Publication,_selectedRunDate.PublicationId);setRunDateValue(null==e?"":e.Name,_selectedRunDate.Edition,_selectedRunDate.Section,_selectedRunDate.Page,_selectedRunDate.Zone,_selectedRunDate.HorizontalPosition,_selectedRunDate.VerticalPosition)}),_MTS_JQUERY(document).on("click",".delete",function(){var e=_MTS_JQUERY(this).parents(".runDate")[0].id.split("_")[1];_MTS_JQUERY(this).parents(".runDate").remove(),_MTS_JQUERY("#insertionWrapper").hide(),_selectedAd.runDates.splice(e,1),_selectedRunDate=null,_MTS_JQUERY(".runDate").each(function(e,t){t.id="date_"+e}),_uploaderChangesMade=!0}),_MTS_JQUERY(document).on("change",".adInfoInput",function(){"title"===this.name&&_MTS_JQUERY("#block_"+_selectedIdx).find(".phInfoName").html(this.value),_selectedAd[this.name]=this.value,_uploaderChangesMade=!0}),_MTS_JQUERY(window).trigger("orientationchange"),disableAdForm()}function findPublicationByPubCode(e,t){for(var o=void 0!==t&&0<t,i=_pubs.length-1;0<=i;i--)if(o?_pubs[i].Id==t:_pubs[i].PubCode===e)return _pubs[i];return null}function setRunDateValue(e,t,o,i,a,n,s){_MTS_JQUERY("input[name='publication']").val(e),_MTS_JQUERY("input[name='edition']").val(t),_MTS_JQUERY("input[name='section']").val(o),_MTS_JQUERY("input[name='page']").val(i),_MTS_JQUERY("input[name='zone']").val(a),_MTS_JQUERY("input[name='horizontalPosition']").val(n),_MTS_JQUERY("input[name='verticalPosition']").val(s)}function resizePhotoUpload(){var e=_MTS_JQUERY(".photoHolder"),t=_MTS_JQUERY(".photoToolsCtr"),o=_MTS_JQUERY(".interfaceBarCtr"),i=_MTS_JQUERY(".updateButton"),a=_MTS_JQUERY(".phImgCtr"),n=(_MTS_JQUERY(".closePreview"),_MTS_JQUERY(".previewCtr"));t.css({height:_MTS_JQUERY(window).outerHeight()-i.outerHeight()-(o.outerHeight()+20)+"px"}),e.css({height:_MTS_JQUERY(window).outerHeight()-o.outerHeight()+"px"}),a.css({height:2.5*a.outerWidth()/4+"px"}),_MTS_JQUERY(".photo_upload_widget").css("height",_MTS_JQUERY(window).height()-_MTS_JQUERY("#mts_unlockstory:visible").height()+"px"),n.css({height:_MTS_JQUERY(window).outerHeight()-40+"px"}),wireImgArea()}function checkForPhotos(){var e=_MTS_JQUERY(".noMediaWrapper"),t=_MTS_JQUERY(".updateButton"),o=_MTS_JQUERY("#remAll, #tagSelected");if(_uploading)e.hide(),t.removeClass("updateButtonActive"),t.html("Sending..."),o.removeClass("noSelect");else if(0<_MTS_JQUERY("#cropGroup #saveCrop:visible").length)e.show(),t.removeClass("updateButtonActive"),t.html("Cropping..."),o.addClass("noSelect");else if(0==_MTS_JQUERY(".photoHolder .phBlockCtr").length){switch(e.show(),t.removeClass("updateButtonActive"),_uploadType){default:case"Image":case"Author":t.html("Waiting for photos");break;case"Advertisement":t.html("Waiting for ads")}o.addClass("noSelect")}else e.hide(),t.addClass("updateButtonActive"),t.html("Save and update"),o.removeClass("noSelect")}function checkForSelected(){0<_MTS_JQUERY(".photoHolder .phBlockCtr").length&&0==_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:not(:checked)").length?_MTS_JQUERY("#selAll").prop("checked",!0):_MTS_JQUERY("#selAll").prop("checked",!1),0<_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").length?(_MTS_JQUERY("#remSel").removeClass("noSelect"),_MTS_JQUERY("#allTags").hide(),_MTS_JQUERY("#selectedTags").show()):(_MTS_JQUERY("#remSel").addClass("noSelect"),_MTS_JQUERY("#allTags").show(),_MTS_JQUERY("#selectedTags").hide()),_MTS_JQUERY(".selectCount").html(_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").length)}function enableAdForm(){_MTS_JQUERY(".adInfoInput, input[name='colorSetting']").prop("disabled",!1),_MTS_JQUERY("#pickRunDates").addClass("pickRunDatesActive").on("click",function(){showRunDateCalendar()})}function disableAdForm(){_MTS_JQUERY(".adInfoInput").prop("disabled",!0).val(""),_MTS_JQUERY(".result").removeClass("selectedTag"),_MTS_JQUERY("input[name='colorSetting']").prop("disabled",!0).first().prop("checked",!0),_MTS_JQUERY("#pickRunDates").removeClass("pickRunDatesActive").off("click"),_MTS_JQUERY(".runDate").remove()}function showRunDateCalendar(){var e=new Date;_cal.GetMiniCalendar("multi","Select Run Dates",e,function(e,t,o){for(var i=0;i<e.length;i++){var a=$(".runDate").length,n="<div id='date_"+a+"' class='runDate'>"+_MTS_JQUERY("#dateTemplate").html()+"</div>",n=($("#dateWrapper").append(n),e[i].toString()+"/"+t[i].toString()+"/"+o[i].toString()),a=$("#date_"+a).find(".dateContent"),s=(a.html(n),{});s.RunDate=n,_selectedAd.runDates.push(s),0==i&&a.click()}0<e.length&&(_uploaderChangesMade=!0)},!1,null)}function getCommonTagHtml(e,t){for(var o="",i=e.length-1;0<=i;i--)if(!e[i].removed){for(var a=!0,n=0;n<t.length;n++){for(var s=!1,l=0;l<t[n].tags.length;l++){var r=t[n].tags[l];if(r.id==e[i].id&&r.type==e[i].type&&!r.removed){s=!0;break}}if(!s){a=!1;break}}a&&(o+=getTagHtml(e[i]))}return o=0==o.length?"No tags selected":o}function getTagHtml(e){return"<div class='tagAll' title=\""+e.title.replace(/"/g,"&quot;")+'">'+e.title+"<img alt='Remove Tag' class='removeTag' src='"+_mediaUrl+"images/gratsClose.png'><input type='hidden' name='id' value='"+e.id+"' /><input type='hidden' name='type' value='"+e.type+"' /></div>"}function removeTag(e,t,o){for(var i=0;i<e.length;i++)for(var a=e[i].tags.length-1;0<=a;a--){var n=e[i].tags[a];n.id==t&&n.type==o&&(n.removed=!0,_uploaderChangesMade=!0,e[i].changesmade=!0)}updateTagList()}function removeAdTag(e,t){for(var o=_selectedAd.tags.length-1;0<=o;o--){var i=_selectedAd.tags[o];i.id==e&&i.type==t&&(i.removed=!0,_uploaderChangesMade=!0)}updateAdTagList()}function loopPhotoFiles(e){for(var t=void 0===e.files?e:e.files,o=0;o<t.length;o++){var i=t[o].size,a=null;if("Image"==_uploadType){if(a=new mtsPhotoInfo(t[o],isImageType(t[o].name),i>_MTS_uploadLimit,!0,!0),"undefined"!=typeof _tagsLinkName&&"undefined"!=typeof _tagsLinkType)for(var n=0;n<_tags.length;n++)a.tags.push(new mtsTag(_tags[n],_tagsLinkType[n],_tagsLinkName[n]))}else a=new adInfo(t[o],isImageType(t[o].name),i>_MTS_uploadLimit,!0,!0);_photoList.push(a),_uploaderChangesMade=!0}}function startPhotoUpload(){drawPhotoUploadList(),loadPhotoThumbnails(),checkForPhotos(),"Image"==_uploadType?updateTagList():"Advertisement"===_uploadType&&setTimeout(function(){_MTS_JQUERY(".phBlockCtr input[type='checkbox'].phCheck:visible:last").click()},0)}function traverseFileUploadTree(o,a,n,s){s.pending||(s.pending=0),s.pending++,a=a||"",o.isFile?o.file(function(e){_photoList.push(new mtsPhotoInfo(e,isImageType(target[i].name),e.size>_MTS_uploadLimit,!0,!0,n)),_uploaderChangesMade=!0,s.pending--,0==s.pending&&s()}):o.isDirectory&&o.createReader().readEntries(function(e){s.pending--;for(var t=0;t<e.length;t++)traverseFileUploadTree(e[t],a+o.name+"/",e[t].isDirectory?e[t].name:n,s)})}function drawPhotoUploadList(){for(var e=0;e<_photoList.length;e++)if(!_photoList[e].drawn&&!_photoList[e].removed){_photoList[e].drawn=!0;var t=_MTS_JQUERY(".photoBlockTemplate").html();if(_photoList[e].isImage||"Advertisement"===_uploadType?_photoList[e].isTooBig?(t="",alert(`File too large: ${_photoList[e].file.name}
Must be smaller than ${_MTS_uploadLimit/1024/1024}MB.`)):t=t.replace(/%%PHOTO_ID%%/g,e):(t="",alert("Invalid File: "+_photoList[e].file.name+"\nFile must be an image.")),_MTS_JQUERY(".photoCtr").append(t),_MTS_JQUERY(".phImgCtr").css({height:2.5*_MTS_JQUERY(".phImgCtr").outerWidth()/4+"px"}),_MTS_JQUERY(".photoCtr .phBlockCtr:last").addClass("fill"),"Image"==_uploadType){var o=_MTS_JQUERY("#block_"+e);if(null!==_photoList[e].file)loadMetadata(e),o.find("input[id='hiddenImage']").prop("checked",_photoList[e].hide);else if(o.find(".phInfoName").html(_photoList[e].filename),o.find(".phInfoName").attr("title",_photoList[e].filename),o.find("textarea[name='caption']").val(_photoList[e].caption),o.find("input[name='fileName']").val(_photoList[e].filename),o.find("input[name='slugline']").val(_photoList[e].slugline),o.find("input[name='credit']").val(_photoList[e].credit),o.find("input[name='link']").val(_photoList[e].link),o.find("textarea[name='desc']").val(_photoList[e].desc),o.find("input[name='photoStart']").val(_photoList[e].start),o.find("input[name='photoEnd']").val(_photoList[e].end),o.find("select[name='toningProfile']").val(_photoList[e].toningId),o.find("select[name='presentation']").val(_photoList[e].presentation),o.find("input[id='hiddenImage']").prop("checked",_photoList[e].hide),null!=_photoList[e].pendingTone&&o.find(".pendingTone").html("Toning Pending: "+_photoList[e].pendingTone.profile).css({color:"#"+_photoList[e].pendingTone.hex}).show(),1<_photoList[e].webActiveVersion){o.find(".versionInfo").html("ver. "+_photoList[e].webActiveVersion),o.find(".phVersion").show();for(var i=_photoList[e].webActiveVersion;1<=i;i--){for(var a="&nbsp;",n=_photoList[e].prevVersions.length-1;0<=n;n--)if(_photoList[e].prevVersions[n].ver==i){a=_photoList[e].prevVersions[n].profile;break}var s="",s=_photoList[e].webActiveVersion==i?'<div class="activeState">Active Web Image</div>':"<a title='Set Active' class=\"setActive mts_cc_text\">Set Active</a>",l=_MTS_JQUERY("#verItemTemplate").html(),s=(l=(l=(l=(l=l.replace(/%%VER_PROF%%/g,a)).replace(/%%VER_NUM%%/g,1<i?"ver. "+i:"original")).replace(/%%VER_ACTION%%/g,s)).replace(/%%IMAGE_ID%%/g,_photoList[e].id),_MTS_JQUERY(l));o.find(".versionCtr").append(s),s.on("click",".setActive",function(e){var t=$(e.target).parent(),e=t.find(".versionNumber").html().split(" "),e=1<e.length?parseInt(e[1]):1,o=t.find("input[name='imageId']").val(),o=parseInt(o),i=[],o=(i.push("image_id="+o),i.push("portal_id="+_portalId),i.push("ver="+e),[]);o.push("path="+encodeURIComponent("/api/v1/cms/images/set/")),o.push("map="+encodeURIComponent(i.join("&"))),_MTS_JQUERY.getJSON("/api/portalAdmin/sendApiRequest.aspx?"+o.join("&"),function(e){e.Success?(t.parents(".versionCtr").find(".activeState").replaceWith("<a title='Set Active' class='setActive mts_cc_text'>Set Active</a>"),t.find(".setActive").replaceWith("<div class='activeState'>Active Web Image</div>"),t.parents(".phBlockCtr").find(".phImg").attr("src",t.siblings(".versionThumb").attr("src"))):alert("Failed to set active: "+e.Error)})})}}else o.find(".phVersion").hide();0==_profiles.length&&o.find("select[name='toningProfile']").hide(),addDefaultTags(e)}else(o=_MTS_JQUERY("#block_"+e)).find("input[name='slugline']").hide(),o.find(".phInfoName").removeClass("hidden"),o.find(".hfgCtr").hide(),o.find("input[name='fileName']").hide(),o.find("select[name='presentation']").hide(),o.find(".phCrop").hide(),o.find(".tagIcon").hide(),o.find("textarea[name='caption']").hide(),o.find("input[name='credit']").hide(),o.find("input[name='link']").hide(),o.find("textarea[name='desc']").hide(),o.find("input[name='photoStart']").hide(),o.find("input[name='photoEnd']").hide(),o.find("select[name='toningProfile']").hide()}}function loadPhotoThumbnails(){for(var e,t=0;t<_photoList.length;t++)if(_photoList[t].isImage&&!_photoList[t].isTooBig&&_photoList[t].isPendingThumb)if(null!==_photoList[t].file)loadPhotoThumb(t,_photoList[t].file);else{_MTS_JQUERY("#block_"+t).find(".phImg").attr("src",_photoList[t].src).removeClass("loading");for(var o=_MTS_JQUERY("#block_"+t).find(".versionItem"),i=o.length-1,a=1;0<=i;i--,a++){var n=_MTS_JQUERY(o[i]).find(".versionNumber").html().split(" ");1<n.length&&parseInt(n[1]);_MTS_JQUERY(o[i]).find(".versionThumb").attr("src",_photoList[t].src.replace(/([0-9]*)_v([0-9]+)/g,"$1")+(1<a?"_v"+a:"")).removeClass("loading")}_photoList[t].isPendingThumb=!1}else"Advertisement"===_uploadType&&_photoList[t].file&&(loadPdfThumb(t,_photoList[t].file),(e=_MTS_JQUERY("#block_"+t)).find(".phInfoName").html(_photoList[t].title),_photoList[t].isPendingThumb=!1,e.find(".loading").attr("src",_MTS_MEDIAURL+"images/blockNoImg.png").removeClass("loading"))}function loadPdfThumb(o,e){var t=new FileReader;t.onload=function(e){var t=_MTS_JQUERY("#block_"+o).find(".phImgCtr");"function"==typeof _MTS_placePdf&&_MTS_placePdf(t,_photoList[o].title,e.target.result),_photoList[o].isPendingThumb=!1},t.readAsDataURL(e)}function loadPhotoThumb(t,e){var o=new FileReader;o.onload=function(e){_MTS_JQUERY("#block_"+t).find(".phImg").removeClass("loading").attr("src",e.target.result),orientPhoto(t),_photoList[t].isPendingThumb=!1},o.readAsDataURL(e)}function getInitCords(){var e=_MTS_previewImg.width(),t=_MTS_previewImg.height(),o=calculateGCD(_imageSizes.SiteWideMxH,_imageSizes.SiteWideMxW),i=!1;return 1<o&&(50<(o=calculateAspectRatioFit(_imageSizes.SiteWideMxW/o,_imageSizes.SiteWideMxH/o,e,t)).width&&50<o.height&&(e=Math.floor(o.width),t=Math.floor(o.height),i=!0)),i||(t=e=50),{x:0,y:0,x2:e,y2:t}}function calculateGCD(e,t){return t?calculateGCD(t,e%t):e}function calculateAspectRatioFit(e,t,o,i){o=Math.min(o/e,i/t);return{width:e*o,height:t*o}}function wireImgArea(){if(null!=_MTS_previewImg){for(var e=getInitCords(),t=e.x,o=e.y,i=e.x2,a=e.y2,n=0,s=_MTS_focusObjs.length-1;n<=s;n++)_MTS_focusObjs[n].setOptions({hide:!0}),_MTS_focusImgs[n][0]==_MTS_focusImg[0]&&(t=_MTS_focusDims[n].x1/_MTS_focusDims[n].previewScale,o=_MTS_focusDims[n].y1/_MTS_focusDims[n].previewScale,i=_MTS_focusDims[n].x2/_MTS_focusDims[n].previewScale,a=_MTS_focusDims[n].y2/_MTS_focusDims[n].previewScale);_MTS_previewImg[0].style.width=_MTS_previewImg.width(),_MTS_previewImg[0].style.height=_MTS_previewImg.height(),null==_MTS_previewObj?_MTS_previewObj=_MTS_previewImg.imgAreaSelect({x1:e.x,y1:e.y,x2:e.x2,y2:e.y2,instance:!0,minWidth:50,minHeight:50,onSelectEnd:handleForm,persistent:!0,handles:!0}):_MTS_previewObj.setOptions({x1:t,y1:o,x2:i,y2:a,hide:!1}),updateCoords(t,i,o,a),_MTS_selectionScale=_MTS_previewImg.width()}}function setImgArea(){var e=parseInt(_MTS_JQUERY("#prevX1").val()),t=parseInt(_MTS_JQUERY("#prevX2").val())+e,o=parseInt(_MTS_JQUERY("#prevY1").val()),i=parseInt(_MTS_JQUERY("#prevY2").val())+o;_MTS_previewObj.setSelection(e,o,t,i),_MTS_previewObj.update()}function hideImgArea(){void 0!==_MTS_previewObj&&null!=_MTS_previewObj&&_MTS_previewObj.setOptions({hide:!0})}function handleForm(e,t){updateCoords(t.x1,t.x2,t.y1,t.y2)}function updateCoords(e,t,o,i){_MTS_JQUERY('input[id="prevX1"]').val(e),_MTS_JQUERY('input[id="prevY1"]').val(o),_MTS_JQUERY('input[id="prevX2"]').val(t),_MTS_JQUERY('input[id="prevY2"]').val(i)}function applyImgArea(){for(var e=parseInt(_MTS_JQUERY("#prevX1").val()),t=parseInt(_MTS_JQUERY("#prevX2").val()),o=parseInt(_MTS_JQUERY("#prevY1").val()),i=parseInt(_MTS_JQUERY("#prevY2").val()),a=_MTS_focusImg.width()/_MTS_selectionScale,n=-1,s=_MTS_focusImgs.length-1;0<=s;s--)if(_MTS_focusImgs[s][0]==_MTS_focusImg[0]){n=s;break}(e*=a)<0&&(e=0),(t*=a)<0&&(t=0),(o*=a)<0&&(o=0),(i*=a)<0&&(i=0),0<=n?(_MTS_focusDims[s]={x1:e,x2:t,y1:o,y2:i,previewScale:a,scale:_MTS_selectionScale/_MTS_previewImg[0].naturalWidth},_MTS_focusObjs[n].setOptions({x1:Math.floor(e),y1:Math.floor(o),x2:Math.floor(t),y2:Math.floor(i)})):(_MTS_focusDims.push({x1:e,x2:t,y1:o,y2:i,previewScale:a,scale:_MTS_selectionScale/_MTS_previewImg[0].naturalWidth}),_MTS_focusObjs.push(_MTS_focusImg.imgAreaSelect({x1:Math.floor(e),y1:Math.floor(o),x2:Math.floor(t),y2:Math.floor(i),persistent:!0,disable:!0,instance:!0})),_MTS_focusImgs.push(_MTS_focusImg))}function showThumbnailCrop(){for(var e=0,t=_MTS_focusObjs.length-1;e<=t;e++)for(var o=_MTS_focusDims[e],i=(_MTS_focusObjs[e].setOptions({x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2,hide:!1,classPrefix:"mts_focus imgareaselect"}),_MTS_JQUERY(".phImgCtr img")),a=i.length-1;0<=a;a--)if(i[a]==_MTS_focusImgs[e][0]){_photoList[a].dims=_MTS_focusDims[e],_photoList[a].changesmade=!0;break}}function disableThumbnailCrop(){for(var e=_MTS_focusObjs.length-1;0<=e;e--){_MTS_focusDims[e];_MTS_focusObjs[e].setOptions({hide:!0});for(var t=_MTS_JQUERY(".phImgCtr img"),o=t.length-1;0<=o;o--)if(t[o]==_MTS_focusImgs[e][0]){_photoList[o].dims=[];break}_MTS_focusImgs.pop(),_MTS_focusDims.pop(),_MTS_focusObjs.pop()}}function getAllElementsAt(e){var t=getElementPosition(e);return null==t?[]:_MTS_JQUERY(".phImgCtr").map(function(){var e=getElementPosition(this);return t.y<=e.y&&t.y>=e.t&&t.x<=e.x&&t.x>=e.l?_MTS_JQUERY(this):null})}function getElementPosition(e){var e=_MTS_JQUERY(e),t=e.offset();if(!t)return null;var o=t.left,t=t.top,i=e.height();return{x:o+e.width(),y:t+i,t:t,l:o}}function addDefaultTags(e){for(var t=0;t<_defaultTags.length;t++)addTag(_photoList[e].tags,_defaultTags[t].id,_defaultTags[t].type,_defaultTags[t].title)}function loadMetadata(o){_pendingData.push(o);var i=_photoList[o],a=_MTS_JQUERY("#block_"+o);EXIF.enableXmp(),EXIF.getData(i.file,function(){var e=EXIF.getTag(this,"Artist")||EXIF.getIptcTag(this,"credit")||$(this.xmpdata.doc).find("dc\\:creator").text().replace(/\s+/g," ").trim(),t=EXIF.getTag(this,"ImageDescription")||EXIF.getIptcTag(this,"caption")||$(this.xmpdata.doc).find("dc\\:description").text().replace(/\s+/g," ").trim();a.find(".phInfoName").html(i.file.name),a.find(".phInfoName").attr("title",i.file.name),a.find("input[name='fileName']").val(i.file.name),a.find("input[name='credit']").val(e),a.find("textarea[name='caption']").val(t),_pendingData.splice(_pendingData.indexOf(o),1),0==_pendingData.length&&(_MTS_JQUERY(document).trigger("metadataLoaded"),_MTS_JQUERY(document).off("metadataLoaded"))})}function orientPhoto(e){_pendingData.push(e);var t=_photoList[e],o=_MTS_JQUERY("#block_"+e).find(".phImg");o.removeClass("flip rotate90 rotate180 rotate270 rotate90flip rotate180flip rotate270flip"),EXIF.getData(t.file,function(){switch(EXIF.getTag(this,"Orientation")){case 8:o.addClass("rotate270");break;case 7:o.addClass("rotate90flip");break;case 6:o.addClass("rotate90");break;case 5:o.addClass("rotate270flip");break;case 4:o.addClass("rotate180flip");break;case 3:o.addClass("rotate180");break;case 2:o.addClass("flip")}_pendingData.splice(_pendingData.indexOf(e),1),_MTS_JQUERY(document).trigger("orientationLoaded"),_MTS_JQUERY(document).off("orientationLoaded")})}function checkFormDataChanges(e,t){var o=e.find("input[name='fileName']"),i=_MTS_JQUERY.trim(0<o.length?o.val():""),a=_MTS_JQUERY.trim(e.find("input[name='slugline']").val()),n=_MTS_JQUERY.trim(e.find("textarea[name='caption']").val()),s=_MTS_JQUERY.trim(e.find("input[name='credit']").val()),l=_MTS_JQUERY.trim(e.find("input[name='link']").val()),r=_MTS_JQUERY.trim(e.find("textarea[name='desc']").val()),_=_MTS_JQUERY.trim(e.find("input[name='photoStart']").val().replace(/\//g,"-")),d=_MTS_JQUERY.trim(e.find("input[name='photoEnd']").val().replace(/\//g,"-")),p=_MTS_JQUERY.trim(e.find("select[name='toningProfile']").val()),h=_MTS_JQUERY.trim(e.find("select[name='presentation']").val()),e=e.find("input[id='hiddenImage']").is(":checked");(_photoList[t].slugline!=a||_photoList[t].caption!=n||_photoList[t].credit!=s||_photoList[t].desc!=r||_photoList[t].start.replace(/\//g,"-")!=_||_photoList[t].end.replace(/\//g,"-")!=d||_photoList[t].toningId!=p||_photoList[t].presentation!=h||_photoList[t].hide!=e||_photoList[t].link!=l||0<o.length&&i!=_photoList[t].filename)&&(_photoList[t].changesmade=!0),_photoList[t].slugline=a,_photoList[t].caption=n,_photoList[t].credit=s,_photoList[t].desc=r,_photoList[t].start=_,_photoList[t].end=d,_photoList[t].toningId=p,_photoList[t].presentation=h,_photoList[t].hide=e,_photoList[t].link=l,_photoList[t].filename=i}function checkImageChanges(){for(var e,t=0;t<_photoList.length;t++)!_photoList[t].removed&&(-1<_photoList[t].id||!_photoList[t].isTooBig&&(!_photoList[t].file||isAllowedType(_photoList[t].file.name))&&_photoList[t].file&&isImageType(_photoList[t].file.name))&&(e=_MTS_JQUERY("#block_"+t),_photoList[t],checkFormDataChanges(e,t),_photoList[t].changesmade&&_changedCount++)}function checkOkSave(e){return!(-1!=e.id&&"Image"==_uploadType&&!e.changesmade)}function savePhotos(e){0==_changedCount&&("Image"===_uploadType?checkImageChanges():_changedCount=_photoList.length);for(var t=0;t<_photoList.length;t++)if(!_photoList[t].removed&&(-1<_photoList[t].id||!_photoList[t].isTooBig&&(!_photoList[t].file||isAllowedType(_photoList[t].file.name))&&_photoList[t].file&&isImageType(_photoList[t].file.name)||"Advertisement"===_uploadType)&&_photoList[t].isPendingUpload&&checkOkSave(_photoList[t]))return void sendPhoto(t);_uploaderChangesMade=_uploading=!1,_photoList=_MTS_JQUERY.map(_photoList,function(e){return e.isPendingUpload=!0,e.alreadyUploaded=!0,e.changesmade=!1,e}),_changedCount=0,checkForPhotos(),disableThumbnailCrop()}function sendPhoto(t){if(null==_photoList[t])return _uploading=!1,checkForPhotos(),!1;var e=_photoList[t],o=-1<e.id?"update":"upload",i=(_MTS_JQUERY("#block_"+t),new FormData),a=(i.append("uploadType",_uploadType),i.append("imgId",e.id),i.append("mode",o),"/api/uploadImage.aspx");switch(_imageVersionChange=!1,_uploadType){case"Image":i.append("dims",JSON.stringify(e.dims)),i.append("cap",htmlEncode(e.caption)),i.append("cre",e.credit),i.append("start",e.start),i.append("end",e.end),i.append("toning",e.toningId),i.append("hide",e.hide),i.append("presentation",e.presentation),i.append("desc",htmlEncode(e.desc)),i.append("link",e.link),i.append("fileName",e.filename),i.append("slugline",e.slugline),"update"==o&&(_imageVersionChange=!0);break;case"Advertisement":var d=JSON.stringify(e.runDates);i.append("accountNumber",e.accountNumber),i.append("title",e.title),i.append("adNumber",e.adNumber),i.append("width",e.width),i.append("height",e.height),i.append("notes",e.notes),i.append("url",e.url),i.append("colorSetting",e.colorSetting),i.append("rpl",e.requestedPageLocation),i.append("runDates",d),i.append("hasPlaceholder",e.HasPlaceholder);break;case"Author":i.append("authorId",_authorId)}var n=_MTS_JQUERY.map(e.tags,function(e){if(!e.removed)return e.id+"_"+e.type}),n=JSON.stringify(n);if(i.append("tags",n),"Advertisement"==_uploadType){n="";if(0==$.trim(e.title).length?n="a title":0==$.trim(e.width.toString()).length?n="a width":0==$.trim(e.height.toString()).length?n="a height":0==e.runDates.length&&(n="at least one run date"),0==n.length){for(var s=!1,p=e.runDates.map(function(e){return null!=e.Publication&&0<e.Publication.length||null!=e.PublicationId&&0<e.PublicationId}),l=p.length-1;0<=l&&0!=(s=p[l]);l--);s||(n="a publication for each run date")}if(0<n.length)return alert("Please provide "+n),void(a="")}e.isPendingUpload=!1,_uploading=!0,checkForPhotos();var r,_=new XMLHttpRequest;_.onreadystatechange=function(e){stateChange_PhotoUpload(_,e,t)},"Image"==_uploadType&&(n=_MTS_JQUERY("#albumSelect").val(),r="",$.each($(".phusites input:checked"),function(e,t){r+=(0===r.length?"":",")+t.id.split("_")[1]}),i.append("aId",n),i.append("sites",r),i.append("alb",void 0!==e.album&&0<e.album.length?e.album:""),_rankImgs&&(i.append("rank",e.rank),i.append("lId",_currentAlbumId),i.append("manager",$("#manager").val()))),_.open("POST",a,!0),"upload"!=o&&!e.file||(_.setRequestHeader("X-FILE-NAME",e.file?encodeURIComponent(e.file.name):""),i.append("image",e.file)),_.send(i)}function stateChange_PhotoUpload(e,t,o){var i,a;4==t.target.readyState&&(_uploadedCount++,i=_MTS_JQUERY("#block_"+o+" .phImgCtr"),200==t.target.status||304==t.target.status?"true"===(e=JSON.parse(e.response)).ok?(i.prepend("<div class='imgCheck'></div>"),_MTS_JQUERY(".imgCheck").addClass("imgCheckShow"),_photoList[o].id=e.imgId,"Advertisement"==_uploadType&&(_photoList[o].runDates=e.runDates,_photoList[o]==_selectedAd&&(_selectedRunDate=null,_MTS_JQUERY("#insertionWrapper").hide(),_MTS_JQUERY("#dateWrapper").empty(),_selectedAd.runDates.forEach(function(e,t){var o="<div id='date_"+t+"' class='runDate'>"+_MTS_JQUERY("#dateTemplate").html()+"</div>",o=(_MTS_JQUERY("#dateWrapper").append(o),new Date(e.RunDate));isNaN(o)||(o=o.getMonth()+1+"/"+o.getDate()+"/"+o.getFullYear()),_MTS_JQUERY("#date_"+t).find(".dateContent").html(o)}))),"function"==typeof _MTS_UPLOAD_CALLBACK&&(_MTS_UPLOAD_CALLBACK(_photoList[o].id,_photoList[o].alreadyUploaded),_photoList[o].alreadyUploaded=!0)):(i.prepend("<div class='imgErr'></div>"),_MTS_JQUERY(".imgErr").addClass("imgCheckShow"),alert((-1<_photoList[o].id?"Update":"Upload")+" Failed!")):(i.prepend("<div class='imgErr'></div>"),_MTS_JQUERY(".imgErr").addClass("imgCheckShow"),alert((-1<_photoList[o].id?"Update":"Upload")+" Failed!\nError "+t.target.status+": "+t.target.statusText)),a=getUploadProgress(),_MTS_JQUERY(".progressBar").animate({width:a+"%"},"linear",function(){if(100==a){for(var e=_MTS_JQUERY(".photoHolder .phImg"),t=(e.removeClass("flip rotate90 rotate180 rotate270 rotate90flip rotate180flip rotate270flip"),e.length-1);0<=t;t--){var o=_MTS_JQUERY(e[t]).parents(".phBlockCtr")[0].id.split("_")[1];"Advertisement"!==_uploadType&&(e[t].src=getImageLink(_photoList[o],2))}alert("Save & Update Complete"+(0<_MTS_JQUERY(".imgErr").length?"d with errors":"")),_MTS_JQUERY(".progressBar").width(0)}_uploading&&savePhotos()}))}function ToggleNewUploadTag(){_beforeUpload=!1,_MTS_JQUERY(".uploadTagWrapper:first").addClass("showTagWrapper"),_MTS_JQUERY(".uploadTagWrapper .search_widget .filterRow").removeClass("filterRowOpen");var e=_MTS_JQUERY(".findTeamFormContainer:visible").height()+_MTS_JQUERY(".formFilterContainer:visible").height()+_MTS_JQUERY(".morePagesContainer:visible").outerHeight();_MTS_JQUERY(".searchResults").css({height:_MTS_JQUERY(".uploadTagWrapper").outerHeight()-e-40+"px"}),"Image"==_uploadType?_MTS_sportsEnabled||_MTS_JQUERY(".filterColumn:not('#CategoryFilter,#SubcategoryFilter')").addClass("filterDisabled"):_MTS_JQUERY(".filterColumn:not('#PublicationFilter')").addClass("filterDisabled"),MTS_handleEz(0,highlightTags,_MTS_JQUERY(".showTagWrapper").find("#searchPhrase"))}function handleTagClick(e,t,o,i){("Image"==_uploadType?0<_MTS_JQUERY(".search_widget:visible").parents(".uploadTagWrapper.showTagWrapper").length?selectUploadTag:selectTag:selectAdTag)(e,t,o,i),_MTS_JQUERY(".result[href$='"+o+",\\'"+i+"\\')']").addClass("selectedTag")}function selectUploadTag(e,t,o,a){if(-1<_tagItemId&&null!=_photoList[_tagItemId])addTag(_photoList[_tagItemId].tags,o,a,t),_photoList[_tagItemId].changesmade=!0;else if(_tagItemId<0){var n=_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").parents(".phBlockCtr");if(0<n.length)for(i=0;i<n.length;i++){var s=n[i].id.split("_")[1];addTag(_photoList[s].tags,o,a,t),_photoList[s].changesmade=!0}else for(i=0;i<_photoList.length;i++)addTag(_photoList[i].tags,o,a,t),_photoList[i].changesmade=!0}updateTagList()}function addTag(e,t,o,i){for(var a=!1,n=0;n<e.length;n++){var s=e[n];if(s.id==t&&s.type==o){s.removed&&(_uploaderChangesMade=!0),s.removed=!(a=!0);break}}a||(e.push(new mtsTag(t,o,i)),_uploaderChangesMade=!0)}function highlightTags(){var e;"Advertisement"===_uploadType?!_selectedRunDate||null!=(e=findPublicationByPubCode(_selectedRunDate.Publication,_selectedRunDate.PublicationId))&&_MTS_JQUERY(".result[href$='"+e.Id+",\\'Publication\\')']").addClass("selectedTag"):_MTS_JQUERY(".uploadTagContainer:visible .tagAll").each(function(){var e=_MTS_JQUERY(this).find("input[name='id']").val(),t=_MTS_JQUERY(this).find("input[name='type']").val();_MTS_JQUERY(".result[href$='"+e+",\\'"+t+"\\')']").addClass("selectedTag")})}function selectAdTag(e,t,o,i){_MTS_JQUERY(".selectedTag").removeClass("selectedTag");for(var a="",n=_pubs.length-1;0<=n;n--)if(_pubs[n].Name==t){a=_pubs[n].PubCode;break}_selectedRunDate.Publication=a,_selectedRunDate.PublicationId=o,_MTS_JQUERY("input[name='publication']").val(t)}function updateTagList(){var e="";if(-1<_tagItemId&&null!=_photoList[_tagItemId]){for(var t=0;t<_photoList[_tagItemId].tags.length;t++)_photoList[_tagItemId].tags[t].removed||(e+=getTagHtml(_photoList[_tagItemId].tags[t]));0==e.length&&(e="No tags selected"),_MTS_JQUERY(".tagList").html(e)}var o=[],i=[];0<(i=_MTS_JQUERY.map(_photoList,function(e){return e.removed?null:e})).length&&(o=i[0].tags),_MTS_JQUERY("#allTags").html(getCommonTagHtml(o,i)),0<(i=_MTS_JQUERY(".photoHolder").find("input[type='checkbox'].phCheck:checked").parents(".phBlockCtr").map(function(){var e=this.id.split("_")[1];return void 0===_photoList[e]||_photoList[e].removed?null:_photoList[e]})).length&&(o=i[0].tags),_MTS_JQUERY("#selectedTags").html(getCommonTagHtml(o,i))}function isAllowedType(e){for(var t=e.substring(e.lastIndexOf(".")+1),o=0;o<_badExt.length;o++)if(_badExt[o]==t.toLowerCase())return!1;return!0}function isImageType(e){return isFileType(e,_imageExtensions)}function isFileType(e,t){for(var o=e.substring(e.lastIndexOf(".")+1),i=0;i<t.length;i++)if(t[i]==o.toLowerCase())return!0;return!1}function getUploadProgress(){_MTS_JQUERY.map(_photoList,function(e){if(!e.removed&&(-1<e.id||!e.isTooBig&&(!e.file||isAllowedType(e.file.name)&&(isImageType(e.file.name)||"Advertisement"===_uploadType))))return e});return _uploadedCount/_changedCount*100}function mtsPhotoInfo(e,t,o,i,a,n){this.file=e,this.isImage=t,this.isTooBig=o,this.isPendingThumb=i,this.isPendingUpload=a,this.album=n;for(var s="",l=_MTS_JQUERY(".phImgCtr img"),r=_MTS_focusImgs.length-1;0<=r;r--)for(var _=l.length-1;0<=_;_--)if(_MTS_focusImgs[r][0]==l[_]){s=_MTS_focusDims[r];break}this.dims=s,this.drawn=!1,this.removed=!1,this.alreadyUploaded=!1,this.id=-1,this.container=-1,this.inCloud=!1,this.src="",this.slugline="",this.caption="",this.credit="",this.filename="",this.link="",this.desc="",this.start="",this.end="",this.rank=0,this.date=new Date,this.uploaderId=_MTS_userId,this.teamId=0,this.portalId=_MTS_PORTALID,this.sites=[],this.toningId=0,this.presentation=0,this.changesmade=!1,this.hide=!_MTS_published,this.tags=[]}function adInfo(e,t,o,i,a){this.file=e,this.isImage=t,this.isTooBig=o,this.isPendingThumb=i,this.isPendingUpload=a,this.drawn=!1,this.removed=!1,this.alreadyUploaded=!1,this.id=-1,this.src="",this.accountNumber="",e?(t=e.name.lastIndexOf("."),this.title=0<t?e.name.substring(0,t):e.name):this.title="",this.title=e?e.name.substring(0,e.name.lastIndexOf(".")):"",this.adNumber="",this.edition="",this.section="",this.page="",this.zone="",this.width="",this.height="",this.horizontalPosition="",this.verticalPosition="",this.notes="",this.url="",this.colorSetting=_MTS_JQUERY("input[name='colorSetting']:checked").val(),this.requestedPageLocation="",this.runDates=[],this.tags=[]}function publicationInfo(e,t,o){this.pubId=e,this.pubName=t,this.pageReq=o}function mtsTag(e,t,o){this.id=e,this.type=t,this.title=o,this.removed=!1}function OpenUpload(e,t,o,i,a,n,s,l,r=!1){if(_MTS_published=r,!isNaN(e)&&"string"==typeof t&&0<t.length?(("PhotoAlbum"===t?_MTS_JQUERY("#albumSelect").find("option[value='"+e+"']"):_MTS_JQUERY("#albumSelect").find("option:first")).prop("selected",!0),o&&getExistingPhotos(e,t,s)):void 0!==l&&o&&getExistingPhotos(null,null,null,l),null!=i&&null!=a&&null!=n)for(var _=0;_<i.length;_++)addTag(_defaultTags,i[_],a[_],n[_]);_uploaderChangesMade=!1,_MTS_JQUERY("#albumSelect").trigger("chosen:updated"),_MTS_JQUERY(".photo_upload_widget").addClass("animateLeft"),_MTS_JQUERY("body").addClass("overflow"),_MTS_JQUERY(".photo_upload_widget").css("height",_MTS_JQUERY(window).height()-_MTS_JQUERY("#mts_unlockstory:visible").height()+"px"),_MTS_JQUERY(".photo_upload_widget .updateButtonCtr").css({bottom:_MTS_JQUERY("#mts_unlockstory:visible").height()+"px"}),resizePhotoUpload()}function CloseUpload(){if(_uploaderChangesMade&&!confirm("You have unsaved changes - would you like to continue anyways?"))return!1;"function"==typeof _MTS_CloseUploadFunc&&_MTS_CloseUploadFunc(),_MTS_JQUERY(".photo_upload_widget").removeClass("animateLeft"),_MTS_JQUERY("body").removeClass("overflow"),_MTS_JQUERY(".imgCheck, .imgErr").remove(),_MTS_JQUERY(".progressBar").width("0"),_MTS_JQUERY(".updateButtonCtr, .progress").css("position","absolute"),_MTS_JQUERY(".previewCtr").hide(),_MTS_JQUERY(".tagViewerCtr").removeClass("tagViewerOpen"),_MTS_JQUERY("#selectedTags").hide(),_MTS_JQUERY("#allTags").show(),_MTS_JQUERY(".showTagWrapper").removeClass("showTagWrapper"),hideImgArea(),disableThumbnailCrop(),_uploderChangesMade=!1,_MTS_previewImg=null;for(var e=_MTS_JQUERY(".photoHolder").find(".phBlockCtr").map(function(){return this.id.split("_")[1]}),t=0;t<e.length;t++)removePhotoUpload(e[t],!1);_photoList.length=0}function removeMultiPhotoUpload(e,t){if("function"!=typeof _MTS_RemoveMultiPhotoPrompt||_MTS_RemoveMultiPhotoPrompt(t))for(var o=0;o<e.length;o++)removePhotoUpload(e[o],!1)}function removePhotoUpload(e,t){var o=_photoList[e].id;(t=void 0===t?!0:t)&&"function"==typeof _MTS_RemovePhotoPrompt&&!_MTS_RemovePhotoPrompt()||("function"!=typeof _MTS_RemovePhotoFunc||o<=0?removePhotoUploadCallback(e):_MTS_RemovePhotoFunc(o+("undefined"!=typeof _currentAlbumId?"_"+_currentAlbumId:""),e,removePhotoUploadCallback))}function removePhotoUploadCallback(e){_photoList[e].removed=!0,_MTS_JQUERY("#block_"+e).remove(),checkForPhotos(),"Image"==_uploadType&&(checkForSelected(),updateTagList())}function decodeURISafe(e,t){var o,i,a,n=new String,s=0;for(void 0===t&&(t=0),i=(o=e.split(/(%(?:d0|d1)%.{2})/)).length;s<i;s++){try{a=decodeURI(o[s])}catch(e){a=t?o[s].replace(/%(?!\d+)/g,"%25"):o[s]}n+=a}return n}function getExistingPhotos(e,t,o,i){var a=[];a.push({name:"id",value:e}),a.push({name:"type",value:t}),a.push({name:"stock",value:o}),a.push({name:"imageIds",value:i}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON("/api/widget/getExistingPhotosForUploader.aspx",a,function(e){e=_MTS_JQUERY.decodeJSONObj(e);for(var t,o=0;o<e.images.length;o++){for(var i=new mtsPhotoInfo(null,!0,!1,!0,!0),a=(i.id=e.images[o].id,i.container=e.images[o].container,i.inCloud=e.images[o].inCloud,i.src=e.images[o].src,i.caption=e.images[o].caption,i.credit=e.images[o].credit,i.filename=e.images[o].filename,i.slugline=e.images[o].slug,i.link=e.images[o].link,i.desc=e.images[o].desc,i.start=e.images[o].start,i.end=e.images[o].end,i.rank=e.images[o].rank,i.date=new Date(e.images[o].date),i.uploaderId=e.images[o].uploaderId,i.teamId=e.images[o].teamId,i.portalId=e.images[o].parentPortalId,i.sites=e.images[o].sites,i.toningId=e.images[o].toningId,i.presentation=e.images[o].presentation,i.pendingTone=e.images[o].pendingTone,i.webActiveVersion=e.images[o].webActiveVersion,i.prevVersions=e.images[o].prevVersions,i.hide=e.images[o].hide,_MTS_JQUERY(".chkCtr input")),n=a.length-1;0<=n;n--){var s=_MTS_JQUERY(a[n]),l=s.attr("id").split("_")[1],r=!1;if(l==i.portalId)r=!0;else for(var _=i.sites.length-1;0<=_;_--)if(l==i.sites[_].id){r=!0;break}r?(s.attr("disabled","disabled"),s.attr("checked","checked")):(s.removeAttr("disabled"),s.removeAttr("checked"))}for(n=0;n<e.images[o].tags.length;n++)i.tags.push(new mtsTag(e.images[o].tags[n].linkId,e.images[o].tags[n].linkType,e.images[o].tags[n].title));_photoList.push(i)}startPhotoUpload(),CheckPhotosForRank(),0<$($(".phImg")[0]).parent().length&&(0<(t=$(".photoCtr > .phBlockCtr")).length&&(t.each(function(e){var t=$("<div class='imageReplace mts_cc_button'>Replace<input title='File Upload' class='replace' type='file' /></div>");_MTS_JQUERY(this).find(".phBlockInfo").prepend(t)}),$(document).on("change",".replace",function(){var e=$(".replace").index(this);_photoList[e].file=this.files[0],_photoList[e].changesmade=!0,_MTS_JQUERY(this).parents(".phBlockCtr").find("input[type=checkbox].phCheck").prop("checked",!0).change()})))})}function CheckPhotosForRank(){0==_MTS_JQUERY.map(_photoList,function(e,t){return 0<e.rank?e:null}).length?_MTS_JQUERY("#wipeRank").addClass("noSelect"):_MTS_JQUERY("#wipeRank").removeClass("noSelect")}function SortPhotosByRank(){var e=_MTS_JQUERY(".photoCtr li").sort(function(e,t){e=e.id.split("_")[1],t=t.id.split("_")[1],e=_photoList[e],t=_photoList[t];return 0<e.rank&&0<t.rank?e.rank>t.rank?1:e.rank<t.rank?-1:0:0==e.rank&&0==t.rank?e.date.getTime()<t.date.getTime()?1:e.date.getTime()>t.date.getTime()?-1:0:0<e.rank&&t.rank<=0?-1:e.rank<=0&&0<t.rank?1:0});_MTS_JQUERY(".photoCtr").append(e),CheckPhotosForRank()}"undefined"==typeof _uploadType&&(_uploadType="image"),_MTS_widgetsReady?WireUpload():_MTS_JQUERY(document).one("widgetsloaded",WireUpload);
﻿eval(function(e,a,t,r){for(r=function(e){return(e<62?"":r(parseInt(e/62)))+(35<(e%=62)?String.fromCharCode(e+29):e.toString(36))};a--;)t[a]&&(e=e.replace(new RegExp("\\b"+r(a)+"\\b","g"),t[a]));return e}('(m($){18 W=2v.4T,D=2v.4S,F=2v.4R,u=2v.4Q;m V(){C $("<4P/>")};$.N=m(T,c){18 O=$(T),1F,A=V(),1k=V(),I=V().r(V()).r(V()).r(V()),B=V().r(V()).r(V()).r(V()),E=$([]),1K,G,l,17={v:0,l:0},Q,M,1l,1g={v:0,l:0},12=0,1J="1H",2k,2j,1t,1s,S,1B,1A,2o,2n,14,1Q,a,b,j,g,f={a:0,b:0,j:0,g:0,H:0,L:0},2u=R.4O,1M=4N.4M,$p,d,i,o,w,h,2p;m 1n(x){C x+17.v-1g.v};m 1m(y){C y+17.l-1g.l};m 1b(x){C x-17.v+1g.v};m 1a(y){C y-17.l+1g.l};m 1z(3J){C 3J.4L-1g.v};m 1y(3I){C 3I.4K-1g.l};m 13(32){18 1i=32||1t,1h=32||1s;C{a:u(f.a*1i),b:u(f.b*1h),j:u(f.j*1i),g:u(f.g*1h),H:u(f.j*1i)-u(f.a*1i),L:u(f.g*1h)-u(f.b*1h)}};m 23(a,b,j,g,31){18 1i=31||1t,1h=31||1s;f={a:u(a/1i||0),b:u(b/1h||0),j:u(j/1i||0),g:u(g/1h||0)};f.H=f.j-f.a;f.L=f.g-f.b};m 1f(){9(!1F||!O.H()){C}17={v:u(O.2t().v),l:u(O.2t().l)};Q=O.2Y();M=O.3H();17.l+=(O.30()-M)>>1;17.v+=(O.2q()-Q)>>1;1B=u(c.4J/1t)||0;1A=u(c.4I/1s)||0;2o=u(F(c.4H/1t||1<<24,Q));2n=u(F(c.4G/1s||1<<24,M));9($().4F=="1.3.2"&&1J=="21"&&!2u["4E"]){17.l+=D(R.1q.2r,2u.2r);17.v+=D(R.1q.2s,2u.2s)}1g=/1H|4D/.1c(1l.q("1p"))?{v:u(1l.2t().v)-1l.2s(),l:u(1l.2t().l)-1l.2r()}:1J=="21"?{v:$(R).2s(),l:$(R).2r()}:{v:0,l:0};G=1n(0);l=1m(0);9(f.j>Q||f.g>M){1U()}};m 1V(3F){9(!1Q){C}A.q({v:1n(f.a),l:1m(f.b)}).r(1k).H(w=f.H).L(h=f.L);1k.r(I).r(E).q({v:0,l:0});I.H(D(w-I.2q()+I.2Y(),0)).L(D(h-I.30()+I.3H(),0));$(B[0]).q({v:G,l:l,H:f.a,L:M});$(B[1]).q({v:G+f.a,l:l,H:w,L:f.b});$(B[2]).q({v:G+f.j,l:l,H:Q-f.j,L:M});$(B[3]).q({v:G+f.a,l:l+f.g,H:w,L:M-f.g});w-=E.2q();h-=E.30();2O(E.3f){15 8:$(E[4]).q({v:w>>1});$(E[5]).q({v:w,l:h>>1});$(E[6]).q({v:w>>1,l:h});$(E[7]).q({l:h>>1});15 4:E.3G(1,3).q({v:w});E.3G(2,4).q({l:h})}9(3F!==Y){9($.N.2Z!=2R){$(R).U($.N.2z,$.N.2Z)}9(c.1T){$(R)[$.N.2z]($.N.2Z=2R)}}9(1j&&I.2q()-I.2Y()==2){I.q("3E",0);3x(m(){I.q("3E","4C")},0)}};m 22(3D){1f();1V(3D);a=1n(f.a);b=1m(f.b);j=1n(f.j);g=1m(f.g)};m 27(2X,2w){c.1P?2X.4B(c.1P,2w):2X.1r()};m 1d(2W){18 x=1b(1z(2W))-f.a,y=1a(1y(2W))-f.b;9(!2p){1f();2p=11;A.1G("4A",m(){2p=Y})}S="";9(c.2D){9(y<=c.1W){S="n"}X{9(y>=f.L-c.1W){S="s"}}9(x<=c.1W){S+="w"}X{9(x>=f.H-c.1W){S+="e"}}}A.q("2V",S?S+"-19":c.26?"4z":"");9(1K){1K.4y()}};m 2S(4x){$("1q").q("2V","");9(c.4w||f.H*f.L==0){27(A.r(B),m(){$(J).1r()})}$(R).U("P",2l);A.P(1d);c.2f(T,13())};m 2C(1X){9(1X.3z!=1){C Y}1f();9(S){$("1q").q("2V",S+"-19");a=1n(f[/w/.1c(S)?"j":"a"]);b=1m(f[/n/.1c(S)?"g":"b"]);$(R).P(2l).1G("1x",2S);A.U("P",1d)}X{9(c.26){2k=G+f.a-1z(1X);2j=l+f.b-1y(1X);A.U("P",1d);$(R).P(2T).1G("1x",m(){c.2f(T,13());$(R).U("P",2T);A.P(1d)})}X{O.1O(1X)}}C Y};m 1w(3C){9(14){9(3C){j=D(G,F(G+Q,a+W(g-b)*14*(j>a||-1)));g=u(D(l,F(l+M,b+W(j-a)/14*(g>b||-1))));j=u(j)}X{g=D(l,F(l+M,b+W(j-a)/14*(g>b||-1)));j=u(D(G,F(G+Q,a+W(g-b)*14*(j>a||-1))));g=u(g)}}};m 1U(){a=F(a,G+Q);b=F(b,l+M);9(W(j-a)<1B){j=a-1B*(j<a||-1);9(j<G){a=G+1B}X{9(j>G+Q){a=G+Q-1B}}}9(W(g-b)<1A){g=b-1A*(g<b||-1);9(g<l){b=l+1A}X{9(g>l+M){b=l+M-1A}}}j=D(G,F(j,G+Q));g=D(l,F(g,l+M));1w(W(j-a)<W(g-b)*14);9(W(j-a)>2o){j=a-2o*(j<a||-1);1w()}9(W(g-b)>2n){g=b-2n*(g<b||-1);1w(11)}f={a:1b(F(a,j)),j:1b(D(a,j)),b:1a(F(b,g)),g:1a(D(b,g)),H:W(j-a),L:W(g-b)};1V();c.2g(T,13())};m 2l(2U){j=/w|e|^$/.1c(S)||14?1z(2U):1n(f.j);g=/n|s|^$/.1c(S)||14?1y(2U):1m(f.g);1U();C Y};m 1v(3B,3A){j=(a=3B)+f.H;g=(b=3A)+f.L;$.2c(f,{a:1b(a),b:1a(b),j:1b(j),g:1a(g)});1V();c.2g(T,13())};m 2T(2m){a=D(G,F(2k+1z(2m),G+Q-f.H));b=D(l,F(2j+1y(2m),l+M-f.L));1v(a,b);2m.4v();C Y};m 2h(){$(R).U("P",2h);1f();j=a;g=b;1U();S="";9(!B.2y(":4u")){A.r(B).1r().2E(c.1P||0)}1Q=11;$(R).U("1x",1N).P(2l).1G("1x",2S);A.U("P",1d);c.3y(T,13())};m 1N(){$(R).U("P",2h).U("1x",1N);27(A.r(B));23(1b(a),1a(b),1b(a),1a(b));9(!(J 4t $.N)){c.2g(T,13());c.2f(T,13())}};m 2A(2i){9(2i.3z!=1||B.2y(":4s")){C Y}1f();2k=a=1z(2i);2j=b=1y(2i);$(R).P(2h).1x(1N);C Y};m 2B(){22(Y)};m 2x(){1F=11;25(c=$.2c({1S:"4r",26:11,20:"1q",2D:11,1W:10,3w:m(){},3y:m(){},2g:m(){},2f:m(){}},c));A.r(B).q({3b:""});9(c.2F){1Q=11;1f();1V();A.r(B).1r().2E(c.1P||0)}3x(m(){c.3w(T,13())},0)};18 2R=m(16){18 k=c.1T,d,t,2N=16.4q;d=!1L(k.2P)&&(16.2e||16.3t.2e)?k.2P:!1L(k.2a)&&16.3u?k.2a:!1L(k.2b)&&16.3v?k.2b:!1L(k.2Q)?k.2Q:10;9(k.2Q=="19"||(k.2b=="19"&&16.3v)||(k.2a=="19"&&16.3u)||(k.2P=="19"&&(16.2e||16.3t.2e))){2O(2N){15 37:d=-d;15 39:t=D(a,j);a=F(a,j);j=D(t+d,a);1w();1u;15 38:d=-d;15 40:t=D(b,g);b=F(b,g);g=D(t+d,b);1w(11);1u;3s:C}1U()}X{a=F(a,j);b=F(b,g);2O(2N){15 37:1v(D(a-d,G),b);1u;15 38:1v(a,D(b-d,l));1u;15 39:1v(a+F(d,Q-1b(j)),b);1u;15 40:1v(a,b+F(d,M-1a(g)));1u;3s:C}}C Y};m 1R(3r,2M){3p(18 2d 4p 2M){9(c[2d]!==1Y){3r.q(2M[2d],c[2d])}}};m 25(K){9(K.20){(1l=$(K.20)).2G(A.r(B))}$.2c(c,K);1f();9(K.2L!=3q){E.1o();E=$([]);i=K.2L?K.2L=="4o"?4:8:0;3g(i--){E=E.r(V())}E.29(c.1S+"-4n").q({1p:"1H",36:0,1I:12+1||1});9(!4m(E.q("H"))>=0){E.H(5).L(5)}9(o=c.2K){E.q({2K:o,2H:"3m"})}1R(E,{3n:"2J-28",3l:"2I-28",3o:"1e"})}1t=c.4l/Q||1;1s=c.4k/M||1;9(K.a!=3q){23(K.a,K.b,K.j,K.g);K.2F=!K.1r}9(K.1T){c.1T=$.2c({2b:1,2a:"19"},K.1T)}B.29(c.1S+"-4j");1k.29(c.1S+"-4i");3p(i=0;i++<4;){$(I[i-1]).29(c.1S+"-2J"+i)}1R(1k,{4h:"2I-28",4g:"1e"});1R(I,{3o:"1e",2K:"2J-H"});1R(B,{4f:"2I-28",4e:"1e"});9(o=c.3n){$(I[0]).q({2H:"3m",3k:o})}9(o=c.3l){$(I[1]).q({2H:"4d",3k:o})}A.2G(1k.r(I).r(1K)).2G(E);9(1j){9(o=(B.q("3j")||"").3i(/1e=(\\d+)/)){B.q("1e",o[1]/1Z)}9(o=(I.q("3j")||"").3i(/1e=(\\d+)/)){I.q("1e",o[1]/1Z)}}9(K.1r){27(A.r(B))}X{9(K.2F&&1F){1Q=11;A.r(B).2E(c.1P||0);22()}}14=(d=(c.4c||"").4b(/:/))[0]/d[1];O.r(B).U("1O",2A);9(c.1E||c.1D===Y){A.U("P",1d).U("1O",2C);$(3h).U("19",2B)}X{9(c.1D||c.1E===Y){9(c.2D||c.26){A.P(1d).1O(2C)}$(3h).19(2B)}9(!c.4a){O.r(B).1O(2A)}}c.1D=c.1E=1Y};J.1o=m(){25({1E:11});A.r(B).1o()};J.49=m(){C c};J.33=25;J.48=13;J.47=23;J.46=1N;J.45=22;18 1j=(/44 ([\\w.]+)/i.43(1M)||[])[1],3c=/42/i.1c(1M),3d=/41/i.1c(1M)&&!/3Z/i.1c(1M);$p=O;3g($p.3f){12=D(12,!1L($p.q("z-3e"))?$p.q("z-3e"):12);9($p.q("1p")=="21"){1J="21"}$p=$p.20(":3Y(1q)")}12=c.1I||12;9(1j){O.3X("3W","3V")}$.N.2z=1j||3d?"3U":"3T";9(3c){1K=V().q({H:"1Z%",L:"1Z%",1p:"1H",1I:12+2||2})}A.r(B).q({3b:"3a",1p:1J,3S:"3a",1I:12||"0"});A.q({1I:12+2||2});1k.r(I).q({1p:"1H",36:0});T.35||T.3R=="35"||!O.2y("3Q")?2x():O.1G("3P",2x);9(!1F&&1j&&1j>=7){T.34=T.34}};$.2w.N=m(Z){Z=Z||{};J.3O(m(){9($(J).1C("N")){9(Z.1o){$(J).1C("N").1o();$(J).3N("N")}X{$(J).1C("N").33(Z)}}X{9(!Z.1o){9(Z.1D===1Y&&Z.1E===1Y){Z.1D=11}$(J).1C("N",3M $.N(J,Z))}}});9(Z.3L){C $(J).1C("N")}C J}})(3K);',304,"|||||||||if|x1|y1|_7|||_23|y2|||x2||top|function||||css|add|||_4|left|||||_a|_d|return|_2|_e|_3|_10|width|_c|this|_55|height|_13|imgAreaSelect|_8|mousemove|_12|document|_1c|_6|unbind|_5|_1|else|false|_58||true|_16|_2c|_21|case|_50|_11|var|resize|_29|_28|test|_3a|opacity|_30|_15|sy|sx|_35|_b|_14|_27|_26|remove|position|body|hide|_1b|_1a|break|_45|_42|mouseup|evY|evX|_1e|_1d|data|enable|disable|_9|one|absolute|zIndex|_17|_f|isNaN|ua|_4a|mousedown|fadeSpeed|_22|_51|classPrefix|keys|_31|_32|resizeMargin|_40|undefined|100|parent|fixed|_36|_2e||_4f|movable|_38|color|addClass|ctrl|shift|extend|_54|altKey|onSelectEnd|onSelectChange|_49|_4c|_19|_18|_3e|_48|_20|_1f|_25|outerWidth|scrollTop|scrollLeft|offset|_24|Math|fn|_4e|is|keyPress|_4b|_4d|_3f|resizable|fadeIn|show|append|borderStyle|background|border|borderWidth|handles|_53|key|switch|alt|arrows|_34|_3c|_41|_44|cursor|_3b|_39|innerWidth|onKeyPress|outerHeight|_2f|_2d|setOptions|src|complete|fontSize||||hidden|visibility|_56|_57|index|length|while|window|match|filter|borderColor|borderColor2|solid|borderColor1|borderOpacity|for|null|_52|default|originalEvent|ctrlKey|shiftKey|onInit|setTimeout|onSelectStart|which|_47|_46|_43|_37|margin|_33|slice|innerHeight|_2b|_2a|jQuery|instance|new|removeData|each|load|img|readyState|overflow|keypress|keydown|on|unselectable|attr|not|chrome||webkit|opera|exec|msie|update|cancelSelection|setSelection|getSelection|getOptions|persistent|split|aspectRatio|dashed|outerOpacity|outerColor|selectionOpacity|selectionColor|selection|outer|imageHeight|imageWidth|parseInt|handle|corners|in|keyCode|imgareaselect|animated|instanceof|visible|preventDefault|autoHide|_3d|toggle|move|mouseout|fadeOut|auto|relative|getBoundingClientRect|jquery|maxHeight|maxWidth|minHeight|minWidth|pageY|pageX|userAgent|navigator|documentElement|div|round|min|max|abs".split("|")));
﻿function _MTS_miniCalenderWidgetInit(){"undefined"!=typeof MTS_CAL_INIT&&MTS_CAL_INIT()}_cal={obj:null,bg:null,monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],doom_codes:[0,6,2,2,5,0,3,5,1,4,6,2,4],monthCount:[0,31,28,31,30,31,30,31,31,30,31,30,31],startContractYear:2008,startContractMonth:1,startContractDay:1,viewMonth:1,viewYear:2010,month:1,day:1,year:2010,wndTitle:"",monthRecycle:[],dayRecycle:[],yearRecycle:[],minYear:2008,maxYear:2011,posTop:0,posLeft:0,mode:"select",rangeStartDate:null,rangeEndDate:null,rangeStartDateSet:!1,rangeEndDateSet:!1,callbackFunc:function(){},closeCallbackFunc:function(){},initialize:function(){if(_cal.obj=document.getElementById("calBox"),null==_cal.obj){var a=document.createElement("div");if(a.id="calBox",a.className="mini_calendar_widget mts_widget",document.body.appendChild(a),_cal.obj=document.getElementById("calBox"),null==_cal.obj)return}_MTS_JQUERY(window).resize(function(){_cal.centerMiniCal()}),_MTS_widgetsReady?_MTS_miniCalenderWidgetInit():_MTS_JQUERY(document).one("widgetsloaded",_MTS_miniCalenderWidgetInit)},clearRecycle:function(){_cal.monthRecycle=[],_cal.dayRecycle=[],_cal.yearRecycle=[]},setContract:function(a,e,t){var c=(new Date).getFullYear();c<a?(_cal.startContractYear=c,_cal.startContractDay=0,_cal.startContractMonth=0):(_cal.startContractDay=t,_cal.startContractMonth=e,_cal.startContractYear=a)},setSelection:function(a,e,t){_cal.month=parseInt(a,10),_cal.day=parseInt(e,10),_cal.year=parseInt(t,10),_cal.viewMonth=parseInt(a,10),_cal.viewYear=parseInt(t,10)},setRange:function(a,e){_cal.rangeStartDate=a,_cal.rangeEndDate=e,_cal.rangeStartDateSet=!0,_cal.rangeEndDateSet=!0;for(var t=new Date(_cal.rangeStartDate);t<=_cal.rangeEndDate;t.setDate(t.getDate()+1))_cal.addDate(t)},setCallback:function(a){_cal.callbackFunc=a},setCloseCallback:function(a){_cal.closeCallbackFunc=a},isLeap:function(a){return a%4==0&&(a%100!=0||a%400==0)},fireCallback:function(){_cal.callbackFunc(_cal.month,_cal.day,_cal.year)},fireCallbackRecycle:function(){_cal.callbackFunc(_cal.monthRecycle,_cal.dayRecycle,_cal.yearRecycle),_cal.hide(),_cal.clearRecycle()},fireCallbackRange:function(){_cal.rangeStartDateSet||_cal.rangeEndDateSet?(_cal.callbackFunc(_cal.rangeStartDate,_cal.rangeEndDate),_cal.hide()):_MTS_JQUERY(".noSelection").html("Select a date or range first")},fireCloseCallback:function(){"function"==typeof _cal.closeCallbackFunc&&_cal.closeCallbackFunc()},selDay:function(a){_cal.month=_cal.viewMonth,_cal.day=parseInt(a,10),_cal.year=_cal.viewYear,_cal.fireCallback(),_cal.hide()},selWeek:function(a,e){_cal.clearRecycle();for(var e=new Date(_cal.viewYear,_cal.viewMonth-1,e),t=(_cal.addDay(e.getDate()),new Date(e.getFullYear(),e.getMonth(),e.getDate())),c=new Date(e.getFullYear(),e.getMonth(),e.getDate());0!=t.getDay();)t.setDate(t.getDate()-1),_cal.viewMonth!=t.getMonth()+1&&(_cal.viewMonth=t.getMonth()+1),_cal.viewYear!=t.getFullYear()&&(_cal.viewYear=t.getFullYear()),_cal.addDay(t.getDate());for(_cal.viewMonth=e.getMonth()+1,_cal.viewYear=e.getFullYear();6!=c.getDay();)c.setDate(c.getDate()+1),_cal.viewMonth!=c.getMonth()+1&&(_cal.viewMonth=c.getMonth()+1),_cal.viewYear!=c.getFullYear()&&(_cal.viewYear=c.getFullYear()),_cal.addDay(c.getDate());_cal.viewMonth=e.getMonth()+1,_cal.viewYear=e.getFullYear(),a||(_cal.fireCallbackRecycle(),_cal.hide())},selRange:function(a){for(var e=_cal.dayRecycle.length;e--;)_cal.addDate(new Date(_cal.yearRecycle[e],_cal.monthRecycle[e]-1,_cal.dayRecycle[e]));a=new Date(_cal.viewYear,_cal.viewMonth-1,a);if(!_cal.rangeStartDateSet&&!_cal.rangeEndDateSet||_cal.rangeStartDateSet&&_cal.rangeEndDateSet||a<_cal.rangeStartDate?(_cal.rangeStartDate=a,_cal.rangeEndDate=a,_cal.rangeStartDateSet=!0,_cal.rangeEndDateSet=!1):_cal.rangeStartDateSet&&!_cal.rangeEndDateSet&&(_cal.rangeEndDate=a,_cal.rangeEndDateSet=!0),null!=_cal.rangeStartDate&&null!=_cal.rangeEndDate)for(var t=new Date(_cal.rangeStartDate);t<=_cal.rangeEndDate;t.setDate(t.getDate()+1))_cal.addDate(t)},selRangeEnd:function(a){for(var e=_cal.dayRecycle.length;e--;)_cal.addDate(new Date(_cal.yearRecycle[e],_cal.monthRecycle[e]-1,_cal.dayRecycle[e]));a=new Date(_cal.viewYear,_cal.viewMonth-1,a);if(_cal.rangeEndDate=a,_cal.rangeEndDateSet=!0,null!=_cal.rangeStartDate&&null!=_cal.rangeEndDate)for(var t=new Date(_cal.rangeStartDate);t<=_cal.rangeEndDate;t.setDate(t.getDate()+1))_cal.addDate(t)},addDay:function(a){var a=parseInt(a,10),e=_cal.inDayArray(a.toString());e<0?(_cal.monthRecycle.push(_cal.viewMonth.toString()),_cal.dayRecycle.push(a.toString()),_cal.yearRecycle.push(_cal.viewYear.toString()),_MTS_JQUERY("#"+_cal.viewMonth+"_"+_cal.viewYear+"_"+a).parent().removeClass("off").addClass("on")):(_cal.monthRecycle.splice(e,1),_cal.yearRecycle.splice(e,1),_cal.dayRecycle.splice(e,1),_MTS_JQUERY("#"+_cal.viewMonth+"_"+_cal.viewYear+"_"+a).parent().removeClass("on").addClass("off"))},addDate:function(a){var e=_cal.dateInArrays(a);e<0?(_cal.monthRecycle.push((a.getMonth()+1).toString()),_cal.dayRecycle.push(a.getDate().toString()),_cal.yearRecycle.push(a.getFullYear().toString()),_MTS_JQUERY("#"+(a.getMonth()+1)+"_"+a.getFullYear()+"_"+a.getDate()).parent().removeClass("off").addClass("on")):(_cal.monthRecycle.splice(e,1),_cal.yearRecycle.splice(e,1),_cal.dayRecycle.splice(e,1),_MTS_JQUERY("#"+(a.getMonth()+1)+"_"+a.getFullYear()+"_"+a.getDate()).parent().removeClass("on").addClass("off"))},fillDays:function(a){if(""!=a)for(var e=0;e<a.split(",").length;e++)_cal.dayRecycle.push(_MTS_JQUERY.trim(a.split(",")[e].split("/")[1])),_cal.monthRecycle.push(_MTS_JQUERY.trim(a.split(",")[e].split("/")[0])),_cal.yearRecycle.push(_MTS_JQUERY.trim(a.split(",")[e].split("/")[2]))},inDayArray:function(a){for(var e=0;e<_cal.dayRecycle.length;e++)if(_cal.dayRecycle[e]==a&&_cal.monthRecycle[e]==_cal.viewMonth&&_cal.yearRecycle[e]==_cal.viewYear)return e;return-1},dateInArrays:function(a){for(var e=0;e<_cal.dayRecycle.length;e++)if(_cal.dayRecycle[e]==a.getDate()&&_cal.monthRecycle[e]==a.getMonth()+1&&_cal.yearRecycle[e]==a.getFullYear())return e;return-1},adjYear:function(a){_cal.viewYear+=parseInt(a,10),_cal.viewYear<_cal.startContractYear?_cal.viewYear=_cal.startContractYear:_cal.viewYear>_cal.maxYear&&(_cal.viewYear=_cal.maxYear),_cal.render()},setYear:function(a){_cal.viewYear=parseInt(a.value,10),_cal.viewYear<_cal.startContractYear?_cal.viewYear=_cal.startContractYear:_cal.viewYear>_cal.maxYear&&(_cal.viewYear=_cal.maxYear),_cal.render()},adjMonth:function(a){var a=_cal.viewMonth+parseInt(a,10),e=_cal.viewYear;12<a?(a=1,e++):a<1&&(a=12,e--),_cal.viewMonth=a,_cal.viewYear=e,_cal.render()},setMonth:function(a){_cal.viewMonth=parseInt(a.value,10),_cal.render()},getMonthName:function(a){return this.monthNames[a]},getDayOfWeekName:function(a){var e="";switch(a){case 0:e="Sunday";break;case 1:e="Monday";break;case 2:e="Tuesday";break;case 3:e="Wednesday";break;case 4:e="Thursday";break;case 5:e="Friday";break;case 6:e="Saturday"}return e},calculateDayOfWeek:function(a,e,t){var c=Math.floor(t/100),l=0;switch((c-15)%4){case 0:l=3;break;case 1:l=2;break;case 2:l=0;break;case 3:l=5}c=(t-2e3)%12,c=(Math.floor((t-2e3)/12)+c+Math.floor(c/4)+l)%7;return _cal.isLeap(t)?_cal.doom_codes=new Array(0,4,1,0,4,9,6,11,8,5,10,7,12):_cal.doom_codes=new Array(0,3,0,0,4,9,6,11,8,5,10,7,12),(e-_cal.doom_codes[a]+c+14)%7},render:function(){_cal.viewYear<_cal.startContractYear?_cal.viewYear=_cal.startContractYear:_cal.viewYear>_cal.maxYear&&(_cal.viewYear=_cal.maxYear),_cal.viewYear==_cal.startContractYear&&_cal.viewMonth<_cal.startContractMonth&&(_cal.viewMonth=_cal.startContractMonth);for(var a=1,e=_cal.monthCount[_cal.viewMonth],t=(_cal.isLeap(_cal.viewYear)&&2==_cal.viewMonth&&(e=29),0),c=0,l=_cal.startContractYear,n=_cal.maxYear,r=_cal.calculateDayOfWeek(_cal.viewMonth,1,_cal.viewYear),i="<div class='listing group rounded'>",i=(i+="<div class='miniCalHeading'><a title='Close Mini-Cal' class='closeMiniCal' class='closeMiniCal' href='javascript:_cal.close();'></a>"+_cal.wndTitle+"</div>")+"<a title='Previous' class='prevArrows' href='javascript:_cal.adjYear(-1);'></a>"+"<div class='selectDate'><select id='calyear' onchange='_cal.setYear(this);'>",o=l;o<=n;o++)i+="<option value='"+o+"'",o==_cal.viewYear&&(i+=" selected"),i+=">"+o+"</option>";i+="</select></div></td><td colspan='1'><a title='Next' class='NxtArrows' href='javascript:_cal.adjYear(1);'></a></td></tr><a title='Previous' class='prevArrows' href='javascript:_cal.adjMonth(-1);'></a><div class='selectMonth'><select id='calmonth' onchange='_cal.setMonth(this);'>";for(o=1;o<13;o++)i+="<option value='"+o+"'",o==_cal.viewMonth&&(i+=" selected"),i+=">"+_cal.monthNames[o]+"</option>";i+="</select></div><a title='Next' class='NxtArrows' href='javascript:_cal.adjMonth(1);'></a><div class='calDays'><div class='dayTxt'>S</div><div class='dayTxt'>M</div><div class='dayTxt'>T</div><div class='dayTxt'>W</div><div class='dayTxt'>T</div><div class='dayTxt'>F</div><div class='dayTxt'>S</div>";do{if(1==a)for(i+="<div class='cent'>";t<r;)i+="<div class='off'><div class='dateLink'>&nbsp;</div></div>",t++}while(this.startContractMonth==_cal.viewMonth&&this.startContractYear==_cal.viewYear&&a<=this.startContractDay?i+="<div class='"+(a==_cal.day&&"select"==this.mode?"on":"off")+"'>"+a+"</div>":"select"==this.mode?i+="<a title='Date Link' href='javascript:_cal.selDay("+a+");' class='"+(_cal.viewMonth==this.month&&_cal.viewYear==this.year&&a==_cal.day||-1<_cal.inDayArray(a)?"on":"off")+"'><div class='dateLink'>"+a+"</div></a>":"range"==this.mode?i+="<a title='Cal Date Range Start' href='javascript:_cal.selRange("+a+");' class='"+(-1<_cal.inDayArray(a)?"on":"off")+"'><div class='dateLink' id='"+_cal.viewMonth+"_"+_cal.viewYear+"_"+a+"'>"+a+"</div></a>":"rangeEnd"==this.mode?i+="<a title='Cal Date Range End' href='javascript:_cal.selRangeEnd("+a+");' class='"+(-1<_cal.inDayArray(a)?"on":"off")+"'><div class='dateLink' id='"+_cal.viewMonth+"_"+_cal.viewYear+"_"+a+"'>"+a+"</div></a>":i+="<a title='Date Link' href='"+("week"==_cal.mode?"javascript:_cal.selWeek(false, ":"javascript:_cal.addDay(")+a+");' class='"+(-1<_cal.inDayArray(a)?"on":"off")+"'><div class='dateLink' id='"+_cal.viewMonth+"_"+_cal.viewYear+"_"+a+"'>"+a+"</div></a>",6<++t&&(i+="</div><div class='cent'>",t=0,c++),++a<=e);for(;t<7&&c<=5;)i+="<div class='off'><div class='dateLink'>&nbsp;</div></div>",7==++t&&c<5&&(t=0,c++,i+="</div><div class='cent'>");i=(i+="select"==_cal.mode||"week"==_cal.mode?"":"<div class='miniCalBtnRow'><div onclick='javascript:"+("range"==_cal.mode||"rangeEnd"==_cal.mode?"_cal.fireCallbackRange();":"_cal.fireCallbackRecycle();")+"' class='buttonMiniCal'>"+("range"==_cal.mode||"rangeEnd"==_cal.mode?"Select":"Create")+"</div>")+("range"==_cal.mode?"<div class='noSelection'></div>":"")+"</div></div>",_cal.obj.innerHTML=i,"function"==typeof ToggleCustomDropDowns&&(ToggleCustomDropdowns(),$("#calBox select").chosen({disable_search:!0}),$("#calBox .chosen-container").css({width:"100%"})),$("#calBox .dateLink").css({height:$(".dateLink").outerWidth()+"px"}),$("#calBox .dateLink").css({"line-height":$("#calBox .dateLink").outerHeight()+"px"}),_cal.centerMiniCal(),_cal.setDateCookie(_cal.viewMonth+"/1/"+_cal.viewYear)},setDateCookie:function(a){"function"==typeof createCookie&&createCookie("MTS_caldate",a)},show:function(a,e){this.posTop=0,this.posLeft=0;var t="function"==typeof readCookie?readCookie("MTS_caldate"):null,t=(null!=t&&(t=new Date(t),isNaN(t)||_cal.setSelection(t.getMonth()+1,t.getDate(),t.getFullYear())),_MTS_JQUERY("#calBox").fadeTo(0,0),_MTS_JQUERY("#calBox").show(),_cal.render(),_MTS_JQUERY("#calBox").fadeTo(0,1),"function"==typeof ToggleCustomDropDowns&&(ToggleCustomDropdowns(),$("#calBox select").chosen({disable_search:!0}),$("#calBox .chosen-container").css({width:"100%"})),$(".on"));$("#calBox .dateLink").css({height:$(".dateLink").outerWidth()+"px"}),$("#calBox .dateLink").css({"line-height":$("#calBox .dateLink").outerHeight()+"px"}),$(".off").css({height:$(".off").outerWidth()+"px"}),t.css({height:t.outerWidth()+"px"}),$("#calBox .dateLink").css({"line-height":$("#calBox .dateLink").outerHeight()+"px"}),$("body").addClass("overflow")},hide:function(){"range"==_cal.mode&&(_cal.rangeStartDate=null,_cal.rangeEndDate=null,_cal.rangeStartDateSet=!1,_cal.rangeEndDateSet=!1,_cal.clearRecycle()),_cal.obj.style.display="none",_MTS_JQUERY("#calBox").hide(),$("body").removeClass("overflow")},close:function(){_cal.hide(),_cal.fireCloseCallback()},centerMiniCal:function(){var a=_MTS_JQUERY(window),e=_MTS_JQUERY(".listing");a.height()>e.height()?(e.removeAttr("style"),e.css({top:(a.height()-e.height())/2+"px",left:(a.width()-e.outerWidth())/2+"px"})):(e.removeAttr("style"),e.css({left:(a.width()-e.outerWidth())/2+"px"}))},GetMiniCalendar:function(a,e,t,c,l,n){var r=new Date,a=(isNaN(t)&&(t=r),_cal.clearRecycle(),_cal.mode=a,_cal.wndTitle=e,_cal.setContract(r.getFullYear()-50,r.getMonth()+1,r.getDate()-1),_cal.maxYear=_cal.startContractYear+100,_cal.setCallback(c),_cal.setCloseCallback(n),_cal.setSelection(t.getMonth()+1,t.getDate(),t.getFullYear()),_cal.show(100,100),_MTS_JQUERY(_cal.bg));a.css({height:_MTS_JQUERY(document).height(),zIndex:113}),a.show()}};
﻿var _MTS_restrictSport=!1,_MTS_adv=!1,_MTS_stopSearchOnce=!1,_MTS_currentSearch=[],_MTS_lastSearchType=null,_searchContainers=[];function MTS_handleEz(start,callback,target){if(!_searchContainers.index||target&&0<target.length&&!_MTS_JQUERY(target).is(":visible"))return!1;var reqTeam="undefined"!=typeof _restrictTeam&&_restrictTeam&&"undefined"!=typeof _teamId,reqSport=_MTS_restrictSport&&"undefined"!=typeof _sportId,showDel="undefined"!=typeof _showDel&&_showDel,showFut="undefined"!=typeof _showFut&&_showFut,phr=_MTS_JQUERY(target||"input[id='searchPhrase']:visible").val()+("undefined"!=typeof _defSearchParam?" "+_defSearchParam:"");if("undefined"!==phr&&(0!==phr.length||"/"!==window.location.pathname)){var p=[],search=(p.push({name:"phrase",value:phr}),p.push({name:"ac",value:0}),p.push({name:"gz",value:"t"}),p.push({name:"s",value:""+start}),p.push({name:"rt",value:reqTeam?_teamId:-1}),p.push({name:"sport",value:reqSport?_sportId:-1}),p.push({name:"incHid",value:showDel?"t":"f"}),p.push({name:"incFut",value:showFut?"t":"f"}),p.push({name:"responseType",value:"undefined"!=typeof _responseType?_responseType:"default"}),"string"==typeof _portalId&&p.push({name:"portalId",value:_portalId}),_MTS_JQUERY(".itemLoader:visible")),par=(0<search.length&&search.show(),target?_MTS_JQUERY(target).parents(".findTeamFormContainer, .search_widget"):_MTS_JQUERY(".search_widget")),parIdx=_searchContainers.index(par[0]),filters=par?par.find(".filterColumn"):_MTS_JQUERY(".filterColumn:visible");if(0<filters.length){for(var types=[],i=filters.length-1,type;0<=i;i--){-1==_MTS_JQUERY(filters[i]).attr("class").indexOf("filterDisabled")&&"none"!==_MTS_JQUERY(filters[i]).css("display")&&(type=filters[i].id.split("Filter")[0],"recentData"==type?p.push({name:"recentData",value:!0}):"frequent"==type?p.push({name:"frequent",value:!0}):types.push(type))}0<types.length&&p.push({name:"types",value:types})}p.push({name:"parIdx",value:parIdx});var direction=_MTS_JQUERY(".direction"),dirSet=(_MTS_adv&&(p.push({name:"adv",value:"1"}),p.push({name:"zip",value:_MTS_JQUERY("#zip").val()}),p.push({name:"dst",value:_MTS_JQUERY("#selRange").val()}),p.push({name:"start",value:_MTS_JQUERY("#start").val()}),p.push({name:"end",value:_MTS_JQUERY("#end").val()}),p.push({name:"sort",value:_MTS_JQUERY("#sort").val()}),p.push({name:"dir",value:_MTS_JQUERY(".direction").hasClass("rotateDir")})),"undefined"!=typeof _MTS_SORT_TYPE&&p.push({name:"sort",value:_MTS_SORT_TYPE}),"undefined"!=typeof _MTS_SORT_DIR);if(_MTS_adv||(dirSet?p.push({name:"dir",value:dirSet?_MTS_SORT_DIR:"false"}):0<direction.length&&(p.push({name:"sort",value:_MTS_JQUERY("#sort").val()}),p.push({name:"dir",value:_MTS_JQUERY(".direction").hasClass("rotateDir")}))),_MTS_stopSearchOnce)return _MTS_stopSearchOnce=!1,!1;"undefined"!=typeof _selectedTeamId&&(_selectedTeamId=-1),_searching=!0,_MTS_ajaxPending=!0,_MTS_currentSearch[parIdx]&&_MTS_currentSearch[parIdx].abort();for(var parent=null,i=0;i<p.length;i++)"parIdx"==p[i].name&&(parent=_searchContainers.eq(p[i].value));var results=parent&&0<parent.length?parent.find("div[id='results']"):_MTS_JQUERY("div[id='results']:visible");0===results.length&&(results=_MTS_JQUERY("div[id='results']:visible")),results.children().remove(),_MTS_currentSearch[parIdx]=_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/search.aspx",p,function(o){if(o.ok){var pStr="div[id='paging_top']:visible, div[id='paging_btm']:visible",pg=parent&&0<parent.length?parent.find(pStr):_MTS_JQUERY(pStr),hasSearchTags=(pg.children().remove(),0<o.searchTagResults.length),a=hasSearchTags?o.searchTagResults:o.results,l=a.length,t={},logo="";if(0==l)results.append(_MTS_JQUERY("<div class='noMatch'>No matching results were found."+(reqTeam?" Click <span id='addTeam' class='link mts_cc_text'>here</span> to add it.":"")+"</div>"));else{for(var exactMatchFound=!1,searching=_MTS_JQUERY.trim(_MTS_JQUERY(target||"input[id='searchPhrase']:visible").val()),i=0;i<l;i++){if(t=a[i],hasSearchTags)switch(t.type){default:case"Roster":case"PortalVideo":case"PortalEvent":case"Image":case"User":case"NewsItem":case"Audio":results.append(_MTS_JQUERY(MTS_composeSearchTagItem(t,o,results,parent)));break;case"Team":for(var j=o.results.length-1;0<=j;j--)if(o.results[j].id==t.id){results.append(_MTS_JQUERY(MTS_composeTeamItem(o.results[j],o,parent)));break}}else{var x=_MTS_JQUERY(MTS_composeTeamItem(t,o,parent)),leagueVal=x.find(".leagueValue"),schoolVal=x.find(".schoolValue"),genderVal=x.find(".genderValue"),league=0<leagueVal.length?leagueVal.find("option[value="+t.leagueId+"]"):"",school=0<schoolVal.length?schoolVal.find("option[value="+t.schoolId+"]"):"",gender=0<genderVal.length?genderVal.find("input[value="+t.gender.replace("'","\\'")+"]"):"",deleted=x.find(".delete"),hidden=x.find(".deactivate");0<league.length&&league.prop("selected",!0),0<school.length&&school.prop("selected",!0),0<gender.length&&gender.prop("checked",!0),0<deleted.length&&deleted.html("True"==t.deleted?"Undelete":"Delete"),0<hidden.length&&hidden.html("True"==t.hidden?"Activate":"Deactivate"),results.append(x)}var searchType=parent&&0<parent.length&&0<parent.find("input[name='searchType']").length?parent.find("input[name='searchType']").val():_MTS_SEARCH_TYPE;0!=searching.length&&decodeURIComponent(t.name).toLowerCase()!=searching.toLowerCase()&&void 0===searchType||(exactMatchFound=!0)}exactMatchFound||results.append(_MTS_JQUERY("<div class='noMatch'>No exact match found."+(reqTeam?" Click <span id='addTeam' class='link mts_cc_text'>here</span> to add it.":"")+"</div>"));var sp=o.start/o.count|0,ep=o.total/o.count|0,si=(0<ep&&o.total%25==0&&ep--,Math.max(sp-2,0)),ei=Math.min(sp+(5-(sp-si)),ep);pg.append(new MTS_pageItem("First",0<sp,0,!1,parent)),pg.append(new MTS_pageItem("Prev",0<sp,sp-1,!1,parent));for(var i=si;i<=ei;i++){var _MTS_JQUERY1=i;pg.append(new MTS_pageItem(""+(i+1),!0,_MTS_JQUERY1,_MTS_JQUERY1==start,parent))}pg.append(new MTS_pageItem("Next",sp<ep,sp+1,!1,parent)),pg.append(new MTS_pageItem("Last",sp<ep,ep,!1,parent))}"function"==typeof _searchEventFired&&_searchEventFired(),"function"==typeof callback&&callback(),"function"==typeof _MTS_JQUERY().dotdotdot&&_MTS_JQUERY(".name:visible").dotdotdot()}(parent?parent.find("#elaps"):_MTS_JQUERY("#elaps")).html(o.elapsed),"function"==typeof SetTeamLogoHeightFromWidth&&SetTeamLogoHeightFromWidth("div[id='results']:visible .logoContainer"),_searching=!1,0<search.length&&search.hide();var searchCallback=parent&&0<parent.length&&0<parent.find("input[name='searchCallback']").length?parent.find("input[name='searchCallback']").val():"";void 0!==eval(searchCallback)?eval(searchCallback)():"function"==typeof _MTS_searchCallback&&_MTS_searchCallback()})}}function MTS_composeTeamItem(e,a,t){var n=(n=MTS_getTemplate(t)).replace(/%%TEAM_NAME%%/g,decodeURIComponent(e.name)),r=(logo=e.logo?(r=(l=a.mediaUrl.replace("%%TEAM_ID%%",e.id)).lastIndexOf("/"),"<img alt='Team Logo' class='logo' src='"+(l=l.substring(0,r)+"/fTeam"+l.substring(r))+"' />"):"<img alt='Team Logo' class='logo' src='"+_MTS_MEDIAURL+"images/sports/"+e.sportThumb+"L.jpg' />","team/"+a.teamDefaultTab+"/"+e.id+"/"+e.urlName+"/"),l=t&&0<t.length&&0<t.find("input[name='searchType']").length?t.find("input[name='searchType']").val():_MTS_SEARCH_TYPE;return n=MTS_getFormatByType(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/%%TEAM_LOGO%%/g,logo)).replace(/%%TEAM_LOCALE%%/g,0<e.city.length?e.city:"")).replace(/%%TEAM_GENDER%%/g,e.gender+" "+e.level+" "+e.sport)).replace(/%%TEAM_LINK%%/g,MTS_getLinkFromSearchType(r,e.name+" "+e.gender+" "+e.sport,e.id,"Team"))).replace(/%%TEAM_ID%%/g,e.id)).replace(/%%FAN_BTN%%/g,void 0===l||"tag"===l.toLowerCase()?"":"true"==e.isFan?"<img class='iamFan' src='"+_MTS_MEDIAURL+"images/iAmFan.png' alt='Fan Of Team' />":"<div id='fan_"+e.id+"' class='mts_cc_button becomeFanBox'> Be A Fan </div>")).replace(/%%TEAM_URLNAME%%/g,e.urlName)).replace(/%%SEARCH_TYPE%%/g,"TeamIcon")).replace(/%%SEARCH_DATE%%/g,"")).replace(/%%TEAM_CODE%%/g,e.scoreKeeperCode),"Team",!0)}function MTS_composeSearchTagItem(e,a,t,n){var n=MTS_getTemplate(n),r=0<e.logo.length,l=e.link,s=("undefined"!=typeof _MTS_ReplaceImgLink&&_MTS_ReplaceImgLink&&"Image"==e.type&&(l=e.logo),e.title);return""!=e.parenttitle&&(s="("+e.parenttitle+") "+e.title),n=MTS_getFormatByType(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n.replace(/%%TEAM_NAME%%/g,s.replace(/"/g,"&quot;"))).replace(/%%TEAM_LOGO%%/g,r?"<img alt='Team Logo' class='logo' src='"+e.logo+"' />":"")).replace(/%%TEAM_LOCALE%%/g,"")).replace(/%%TEAM_GENDER%%/g,"")).replace(/%%TEAM_LINK%%/g,MTS_getLinkFromSearchType(l,""!=e.parenttitle&&"Image"==e.type?e.parenttitle:s,e.id,e.type,t))).replace(/%%TEAM_ID%%/g,e.id)).replace(/%%FAN_BTN%%/g,"")).replace(/%%TEAM_URLNAME%%/g,"")).replace(/%%SEARCH_TYPE%%/g,e.type+"Icon")).replace(/%%SEARCH_DATE%%/g,e.date),e.type,r)}function MTS_getTemplate(e){return e&&0<e.length&&0<e.find(".rTemplate").length?e.find(".rTemplate").html():0<_MTS_JQUERY("#rTemplate").length?_MTS_JQUERY("#rTemplate").html():""}function MTS_getLinkFromSearchType(link,title,id,type,r){var parent=void 0!==r&&0<r.parents(".search_widget").length?r.parents(".search_widget"):null,searchType=parent&&0<parent.length&&0<parent.find("input[name='searchType']").length?parent.find("input[name='searchType']").val():_MTS_SEARCH_TYPE;if(void 0===searchType)return _MTS_SITEURL+link;var selTagFnc=null,selCallStr=parent&&0<parent.length&&0<parent.find("input[name='selectCallback']").length?parent.find("input[name='selectCallback']").val():"",selTagFncName=(void 0!==eval(selCallStr)?selTagFnc=eval(selCallStr):"function"==typeof _MTS_selectTagOverride?selTagFnc=_MTS_selectTagOverride:"function"==typeof selectTag&&(selTagFnc=selectTag),null==selTagFnc?"void":void 0!==selTagFnc.name?selTagFnc.name:selTagFnc.toString().replace(/(\/\*.*?\*\/)/g,"").match(/^function\s*([^\s(]+)/)[1]),newTitle;switch(searchType.toLowerCase()){default:case"search":return _MTS_SITEURL+link;case"layout":switch(type.toLowerCase()){default:newTitle=id;break;case"sport":case"video":case"user":newTitle=id}return"javascript:"+selTagFncName+"('"+escape(newTitle.replace(/'/g,"\\'"))+"')";case"tag":return"javascript:"+selTagFncName+"('"+(link.indexOf("://")<0?"/":"")+link+"','"+escape(title.replace(/'/g,"\\'").replace(/(?!^<(\/|)(\w+)>)(?:\r\n|\r|\n)(?!<(\/|)(\w+)>)/g,""))+"',"+id+",'"+type+"')"}}function MTS_getFormatByType(e,a,t){switch(a){default:case"Team":e=(e=(e=e.replace(/%%LINK_CLASS%%/g,"fullLink")).replace(/%%LOGO_CLASS%%/g,"logoContainer")).replace(/%%INFO_CLASS%%/g,"info");break;case"Roster":case"Audio":case"Image":case"PortalVideo":case"User":case"NewsItem":case"PortalEvent":e=(e=t?(e=e.replace(/%%INFO_CLASS%%/g,"info")).replace(/%%LOGO_CLASS%%/g,"logoContainer"):(e=e.replace(/%%INFO_CLASS%%/g,"fullInfo info")).replace(/%%LOGO_CLASS%%/g,"noLogo logoContainer")).replace(/%%LINK_CLASS%%/g,"fullLink")}return e}function MTS_pageItem(e,a,t,n,r){e=_MTS_JQUERY("<div>"+e+"</div>");return e.attr("class","page"+(n?"Active":a?"Click":"Disabled")).click(function(){a&&MTS_handleEz(t,null,0<r.length?r.find(".mts_search_form, #searchPhrase"):_MTS_JQUERY("#searchPhrase:visible"))}),e}"undefined"==typeof _MTS_SEARCH_TYPE&&(_MTS_SEARCH_TYPE="tag"),_MTS_JQUERY(document).one("widgetsloaded",function(){_searchContainers=_MTS_JQUERY(".findTeamFormContainer, .search_widget, #searchPhrase")}),function(){function e(){_MTS_adv=!_MTS_adv,_MTS_JQUERY(".advCol").toggleClass("advOpen"),"function"==typeof _MTS_toggleMobileFilters&&_MTS_toggleMobileFilters(),_MTS_JQUERY(".toggleOptions").toggleClass("toggleOptionsRotate")}function a(){for(var e=["input[class='mts_search_form']:visible","input[id='searchPhrase']:visible","#zip",".filterColumn:visible","#start","#end"],a=0;a<e.length;a++)for(var t,n,r=_MTS_JQUERY(e[a]),l=0;l<r.length;l++)!function(e){var a=_MTS_JQUERY.trim(e.val());if(e.hasClass("filterColumn")){var t=e.parents(".filterRow");if(t.data("prev-val")!=t.find(".filterDisabled:visible").length)return t.data("prev-val",t.find(".filterDisabled:visible").length),!0}else if(null==e.data("prev-val")&&e.data("prev-val","no search provided"),e.data("prev-val")!=a)return e.data("prev-val",a),!0;return!1}(_MTS_JQUERY(r[l]))||(t=_MTS_JQUERY(r[l]).parents(".findTeamFormContainer, .search_widget"),n=r[l],1<a&&(n=t.find(e[1])),MTS_searchHelper(function(){MTS_handleEz(0,null,n)}))}_MTS_JQUERY(document).ready(function(){_searchContainers=_MTS_JQUERY(".findTeamFormContainer, .search_widget, #searchPhrase"),_MTS_JQUERY(document).on("click","#ezAdv",e),_MTS_JQUERY("#ezGo").click(a),_MTS_JQUERY("#selRange").change(function(){MTS_handleEz(0)}),_MTS_JQUERY("#zip").focus(function(){"Zip Code"===_MTS_JQUERY(this).val()&&_MTS_JQUERY(this).val("")}).blur(function(){""===_MTS_JQUERY(this).val()&&_MTS_JQUERY(this).val("Zip Code")}),setInterval(a,1e3)})}();
﻿/*
 *	jQuery dotdotdot 1.7.4
 *
 *	Copyright (c) Fred Heusschen
 *	www.frebsite.nl
 *
 *	Plugin website:
 *	dotdotdot.frebsite.nl
 *
 *	Licensed under the MIT license.
 *	http://en.wikipedia.org/wiki/MIT_License
 */
!function (t, e) { function n(t, e, n) { var r = t.children(), o = !1; t.empty(); for (var i = 0, d = r.length; d > i; i++) { var l = r.eq(i); if (t.append(l), n && t.append(n), a(t, e)) { l.remove(), o = !0; break } n && n.detach() } return o } function r(e, n, i, d, l) { var s = !1, c = "a, table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, blockquote, select, optgroup, option, textarea, script, style", u = "script, .dotdotdot-keep"; return e.contents().detach().each(function () { var h = this, f = t(h); if ("undefined" == typeof h) return !0; if (f.is(u)) e.append(f); else { if (s) return !0; e.append(f), !l || f.is(d.after) || f.find(d.after).length || e[e.is(c) ? "after" : "append"](l), a(i, d) && (s = 3 == h.nodeType ? o(f, n, i, d, l) : r(f, n, i, d, l), s || (f.detach(), s = !0)), s || l && l.detach() } }), n.addClass("is-truncated"), s } function o(e, n, r, o, d) { var c = e[0]; if (!c) return !1; var h = s(c), f = -1 !== h.indexOf(" ") ? " " : "　", p = "letter" == o.wrap ? "" : f, g = h.split(p), v = -1, w = -1, b = 0, y = g.length - 1; for (o.fallbackToLetter && 0 == b && 0 == y && (p = "", g = h.split(p), y = g.length - 1) ; y >= b && (0 != b || 0 != y) ;) { var m = Math.floor((b + y) / 2); if (m == w) break; w = m, l(c, g.slice(0, w + 1).join(p) + o.ellipsis), r.children().each(function () { t(this).toggle().toggle() }), a(r, o) ? (y = w, o.fallbackToLetter && 0 == b && 0 == y && (p = "", g = g[0].split(p), v = -1, w = -1, b = 0, y = g.length - 1)) : (v = w, b = w) } if (-1 == v || 1 == g.length && 0 == g[0].length) { var x = e.parent(); e.detach(); var T = d && d.closest(x).length ? d.length : 0; x.contents().length > T ? c = u(x.contents().eq(-1 - T), n) : (c = u(x, n, !0), T || x.detach()), c && (h = i(s(c), o), l(c, h), T && d && t(c).parent().append(d)) } else h = i(g.slice(0, v + 1).join(p), o), l(c, h); return !0 } function a(t, e) { return t.innerHeight() > e.maxHeight } function i(e, n) { for (; t.inArray(e.slice(-1), n.lastCharacter.remove) > -1;) e = e.slice(0, -1); return t.inArray(e.slice(-1), n.lastCharacter.noEllipsis) < 0 && (e += n.ellipsis), e } function d(t) { return { width: t.innerWidth(), height: t.innerHeight() } } function l(t, e) { t.innerText ? t.innerText = e : t.nodeValue ? t.nodeValue = e : t.textContent && (t.textContent = e) } function s(t) { return t.innerText ? t.innerText : t.nodeValue ? t.nodeValue : t.textContent ? t.textContent : "" } function c(t) { do t = t.previousSibling; while (t && 1 !== t.nodeType && 3 !== t.nodeType); return t } function u(e, n, r) { var o, a = e && e[0]; if (a) { if (!r) { if (3 === a.nodeType) return a; if (t.trim(e.text())) return u(e.contents().last(), n) } for (o = c(a) ; !o;) { if (e = e.parent(), e.is(n) || !e.length) return !1; o = c(e[0]) } if (o) return u(t(o), n) } return !1 } function h(e, n) { return e ? "string" == typeof e ? (e = t(e, n), e.length ? e : !1) : e.jquery ? e : !1 : !1 } function f(t) { for (var e = t.innerHeight(), n = ["paddingTop", "paddingBottom"], r = 0, o = n.length; o > r; r++) { var a = parseInt(t.css(n[r]), 10); isNaN(a) && (a = 0), e -= a } return e } if (!t.fn.dotdotdot) { t.fn.dotdotdot = function (e) { if (0 == this.length) return t.fn.dotdotdot.debug('No element found for "' + this.selector + '".'), this; if (this.length > 1) return this.each(function () { t(this).dotdotdot(e) }); var o = this; o.data("dotdotdot") && o.trigger("destroy.dot"), o.data("dotdotdot-style", o.attr("style") || ""), o.css("word-wrap", "break-word"), "nowrap" === o.css("white-space") && o.css("white-space", "normal"), o.bind_events = function () { return o.bind("update.dot", function (e, d) { switch (o.removeClass("is-truncated"), e.preventDefault(), e.stopPropagation(), typeof l.height) { case "number": l.maxHeight = l.height; break; case "function": l.maxHeight = l.height.call(o[0]); break; default: l.maxHeight = f(o) } l.maxHeight += l.tolerance, "undefined" != typeof d && (("string" == typeof d || "nodeType" in d && 1 === d.nodeType) && (d = t("<div />").append(d).contents()), d instanceof t && (i = d)), g = o.wrapInner('<div class="dotdotdot" />').children(), g.contents().detach().end().append(i.clone(!0)).find("br").replaceWith("  <br />  ").end().css({ height: "auto", width: "auto", border: "none", padding: 0, margin: 0 }); var c = !1, u = !1; return s.afterElement && (c = s.afterElement.clone(!0), c.show(), s.afterElement.detach()), a(g, l) && (u = "children" == l.wrap ? n(g, l, c) : r(g, o, g, l, c)), g.replaceWith(g.contents()), g = null, t.isFunction(l.callback) && l.callback.call(o[0], u, i), s.isTruncated = u, u }).bind("isTruncated.dot", function (t, e) { return t.preventDefault(), t.stopPropagation(), "function" == typeof e && e.call(o[0], s.isTruncated), s.isTruncated }).bind("originalContent.dot", function (t, e) { return t.preventDefault(), t.stopPropagation(), "function" == typeof e && e.call(o[0], i), i }).bind("destroy.dot", function (t) { t.preventDefault(), t.stopPropagation(), o.unwatch().unbind_events().contents().detach().end().append(i).attr("style", o.data("dotdotdot-style") || "").data("dotdotdot", !1) }), o }, o.unbind_events = function () { return o.unbind(".dot"), o }, o.watch = function () { if (o.unwatch(), "window" == l.watch) { var e = t(window), n = e.width(), r = e.height(); e.bind("resize.dot" + s.dotId, function () { n == e.width() && r == e.height() && l.windowResizeFix || (n = e.width(), r = e.height(), u && clearInterval(u), u = setTimeout(function () { o.trigger("update.dot") }, 100)) }) } else c = d(o), u = setInterval(function () { if (o.is(":visible")) { var t = d(o); (c.width != t.width || c.height != t.height) && (o.trigger("update.dot"), c = t) } }, 500); return o }, o.unwatch = function () { return t(window).unbind("resize.dot" + s.dotId), u && clearInterval(u), o }; var i = o.contents(), l = t.extend(!0, {}, t.fn.dotdotdot.defaults, e), s = {}, c = {}, u = null, g = null; return l.lastCharacter.remove instanceof Array || (l.lastCharacter.remove = t.fn.dotdotdot.defaultArrays.lastCharacter.remove), l.lastCharacter.noEllipsis instanceof Array || (l.lastCharacter.noEllipsis = t.fn.dotdotdot.defaultArrays.lastCharacter.noEllipsis), s.afterElement = h(l.after, o), s.isTruncated = !1, s.dotId = p++, o.data("dotdotdot", !0).bind_events().trigger("update.dot"), l.watch && o.watch(), o }, t.fn.dotdotdot.defaults = { ellipsis: "... ", wrap: "word", fallbackToLetter: !0, lastCharacter: {}, tolerance: 0, callback: null, after: null, height: null, watch: !1, windowResizeFix: !0 }, t.fn.dotdotdot.defaultArrays = { lastCharacter: { remove: [" ", "　", ",", ";", ".", "!", "?"], noEllipsis: [] } }, t.fn.dotdotdot.debug = function () { }; var p = 1, g = t.fn.html; t.fn.html = function (n) { return n != e && !t.isFunction(n) && this.data("dotdotdot") ? this.trigger("update", [n]) : g.apply(this, arguments) }; var v = t.fn.text; t.fn.text = function (n) { return n != e && !t.isFunction(n) && this.data("dotdotdot") ? (n = t("<div />").text(n).html(), this.trigger("update", [n])) : v.apply(this, arguments) } } }(typeof _MTS_JQUERY === "function" ? _MTS_JQUERY : $);
﻿var _searchWidgets={};function TagResults(e){this.obj=e,this.Init=function(){var e=this,i=this.obj;if(0!=i.length){if(0<i.find(".ranOnce").length)return!1;i.append("<input type='hidden' class='ranOnce' />"),this.resizeTagList(),i.on("click",".clearFilters",function(){_MTS_JQUERY(this).parents().find(".filterDisabled").removeClass("filterDisabled"),i.find("#start, #end, #sort").val(""),_MTS_adv=!1,MTS_handleEz(0,null,this)}),i.on("click",".searchClose",function(){i.parents(".uploadTagWrapper").removeClass("showTagWrapper"),i.parents(".hiddenContainer").removeClass("showHidden"),i.parents(".photoUploadContainer").find("#phuDragDrop").removeClass("hideIt"),i.parents("body").removeClass("overflow")}),i.on("keydown","#searchPhrase",function(e){13===e.which&&(e.preventDefault(),MTS_handleEz(0,null,this))}),i.on("click",".showFilterBtn",function(){_MTS_toggleMobileFilters()}),i.on("click","#ezAdv",function(e){e.stopPropagation(),i.find(".filterRow").toggleClass("filterRowOpen"),_MTS_JQUERY(".searchScroll").scrollTop(0)}),i.on("click",".direction",function(){_MTS_adv=!0,$(this).toggleClass("rotateDir"),MTS_handleEz(0,null,this)}),i.on("click",".dateWrap input",function(){var e=new Date(_MTS_JQUERY.trim(this.value)),n=_MTS_JQUERY(this);isNaN(e)&&(e=new Date),_cal.GetMiniCalendar("select","Select Date",e,function(e,t,i){n.val(e.toString()+"/"+t.toString()+"/"+i.toString())},!0),_MTS_adv=!0,MTS_handleEz(0,null,this)}),i.on("click",".chosen-drop",function(){_MTS_adv=!0,MTS_handleEz(0,null,this)}),i.on("click",".filterColumn",function(){var e="filterDisabled",t=i.find(".filterColumn:visible");"recentDataFilter"!=this.id&&"frequentFilter"!=this.id&&0==t.filter("."+e).length&&t.toggleClass(e),_MTS_JQUERY(this).toggleClass(e),i.find(".uploadTagWrapper .result").each(function(){var e=_MTS_JQUERY(this).children(".topRow").outerWidth(),t=_MTS_JQUERY(this).children(".logoContainer").width(),e=_MTS_JQUERY(this).width()-(e+t);_MTS_JQUERY(this).children(".botRow").css({width:e-10+"px",height:_MTS_JQUERY(this).height()+"px"})})}),i.find("#cancelButton").click(function(){i.find("input.text").val(""),i.find("select").val(-1),i.find("input[name=gender]")[0].checked=!0}),i.on("click",".result",function(){_MTS_JQUERY(this).addClass("selectedTag")}),_MTS_JQUERY(window).resize(function(){e.resizeTagList()})}},this.sizeTagItems=function(){var e=this.obj.find(".findTeamFormContainer").outerHeight(),t=this.obj.find(".formFilterContainer").outerHeight(),i=this.obj.find(".morePagesContainer").outerHeight(),e=window.innerHeight-(e+t+i);window.matchMedia("(min-width: 768px)").matches?e-=0<this.obj.find(".searchScroll").parents(".uploadTagWrapper, .hiddenContainer").length?40:0:console.log("Hi"),this.obj.find(".searchScroll").css({height:e+"px"}),this.obj.find(".morePagesContainer").removeAttr("style"),this.obj.find(".searchResultsAdjust").removeAttr("style"),this.obj.find(".info").each(function(){var e=_MTS_JQUERY(this).parents(".result"),e=e.width()-(e.find(".logoContainer").width()+e.find(".leftIcon").width()+100);_MTS_JQUERY(this).css({width:e+"px"})}),this.obj.parents(".uploadTagWrapper").css({height:_MTS_JQUERY(window).height()-40+"px"})},this.overallTags=function(){var e=this.obj.find(".findTeamFormContainer:visible").outerHeight()+this.obj.find(".formFilterContainer:visible").outerHeight()+40;this.obj.find(".searchResults").css({"min-height":_MTS_JQUERY(window).height()-e+"px"}),_MTS_JQUERY(window.parent.document.body).addClass("overflow"),_MTS_JQUERY(window.parent.document).find(".mce-close").click(function(){0==_MTS_JQUERY(window.parent.document).find(".mce-close").length&&_MTS_JQUERY(this).parents("body").removeClass("overflow")})},this.resizeTagList=function(){this.sizeTagItems(),0<this.obj.parents(".overallTags").length&&this.overallTags()}}function SearchResults(obj){this.obj=obj,this.Init=function(){var that=this,parent=this.obj;if(0!=parent.length){if(0<parent.find(".ranOnce").length)return!1;parent.append("<input type='hidden' class='ranOnce' />"),this.sizeItems(),parent.on("click",".clearFilters",function(){_MTS_JQUERY(this).parents().find(".filterDisabled").removeClass("filterDisabled"),parent.find("#start, #end, #sort").val(""),_MTS_adv=!1,MTS_handleEz(0,null,this)}),parent.on("click",".showFilterBtn",function(){_MTS_toggleMobileFilters(),_MTS_adv=!1}),parent.on("click",".searchClose",function(){parent.find(".searchWrapper, .tagWrapper, .background, .uploadTagWrapper, .uploadBackground").hide()}),parent.on("click",".direction",function(){_MTS_adv=!0,$(this).toggleClass("rotateDir"),MTS_handleEz(0,null,this)}),parent.on("click",".dateWrap input",function(){var e=new Date(_MTS_JQUERY.trim(this.value)),n=_MTS_JQUERY(this);isNaN(e)&&(e=new Date),_cal.GetMiniCalendar("select","Select Date",e,function(e,t,i){n.val(e.toString()+"/"+t.toString()+"/"+i.toString())},!0),_MTS_adv=!0,MTS_handleEz(0,null,this)}),parent.on("click",".chosen-drop",function(){_MTS_adv=!0,MTS_handleEz(0,null,this)}),parent.on("keydown","#searchPhrase",function(e){13===e.which&&(e.preventDefault(),MTS_handleEz(0,null,this))}),parent.on("click","#doSearch",function(){var e=parent.find("input[name='searchTxt']").last().val(),t=parent.find("#sport").val();if(""==e&&""==t)return parent.find(".errorNoTeams").html("Please specify at least a search phrase or sport"),!1;parent.find("#findform").submit()}),parent.on("click",".becomeFanBox",function(e){e.stopPropagation(),e.preventDefault();var id=this.id.split("_")[1],button=this,p;0<_userId?(p=[],p.push({name:"id",value:id}),p.push({name:"mode",value:"addFan"}),ajax("/api/updateUserTeamLinks.aspx",p,function(ret){var o;eval("o = "+ret+";"),o.ok&&_MTS_JQUERY(button).replaceWith("<img class='iamFan' src='"+_mediaUrl+"images/iAmFan.png' alt='Fan Of Team'>")})):window.location="/user/register/?teamId="+id+"&mode=fan&target=/team/news/"+id+"/team/"}),parent.on("click",".filterColumn",function(){var e="filterDisabled",t=parent.find(".filterColumn:visible");"recentDataFilter"!=this.id&&0==t.filter("."+e).length&&t.toggleClass(e),_MTS_JQUERY(this).toggleClass(e),parent.find(".uploadTagWrapper .result").each(function(){var e=_MTS_JQUERY(this).children(".topRow").outerWidth(),t=_MTS_JQUERY(this).children(".logoContainer").width(),e=_MTS_JQUERY(this).width()-(e+t);_MTS_JQUERY(this).children(".botRow").css({width:e-10+"px",height:_MTS_JQUERY(this).height()+"px"})})}),parent.find("#cancelButton").click(function(){parent.find("input.text").val(""),parent.find("select").val(-1),parent.find("input[name=gender]")[0].checked=!0}),_MTS_JQUERY(window).resize(function(){that.sizeItems()})}},this.sizeItems=function(){767<this.obj.width()?(this.obj.find(".filterRow").addClass("filterRowOpen"),this.obj.find(".filterRowOpen").height(),this.obj.find(".morePagesContainer").outerHeight(),this.obj.find(".searchResults").css({"overflow-y":"auto","overflow-x":"hidden"})):(this.obj.find(".searchResults").removeAttr("style"),this.obj.find(".morePagesContainer").removeAttr("style")),this.obj.find(".info");this.obj.parents(".uploadTagWrapper").css({height:_MTS_JQUERY(window).height()-40+"px"})}}function _MTS_toggleMobileFilters(){_MTS_JQUERY(".filterRow").toggleClass("filterRowOpen")}_searchWidgets.search=[],_searchWidgets.tag=[],function(){function e(){if(_MTS_JQUERY(".search_widget").each(function(e){var t=null,i=_MTS_JQUERY(this).find("input[name='searchType']").val();_MTS_JQUERY(this).addClass(i).attr("id","searchWidget_"+e),"Search"==i?(t=new SearchResults(_MTS_JQUERY(this)),_searchWidgets.search[e]=t):(t=new TagResults(_MTS_JQUERY(this)),_searchWidgets.tag[e]=t),t.Init()}),"/"!==window.location.pathname)try{if(null!=history.state){var e=[],t=_MTS_JQUERY(history.state,function(e){return"objArray"==e.name});0<t.length&&(e=t[0].value);for(var i=0;i<e.length;i++){var n=_MTS_JQUERY("#searchWidget_"+i),a=e[i];0!=n.length&&null!=a&&(null!=a.search&&(n.find("#searchPhrase").val(a.search),n.find("#searchPhrase").data("prev-val",a.search)),null!=a.disabled&&(n.find(".filterDisabled").removeClass("filterDisabled"),n.find(a.disabled).addClass("filterDisabled"),n.find(".filterRow").data("prev-val",n.find(".filterDisabled:visible").length)),null!=a.page&&MTS_handleEz(a.page,null,n.find("#searchPhrase")))}}}catch(e){console.log(e)}"undefined"!=typeof _cal&&_cal.initialize(),set_MTS_SaveHistoryState(function(){var e=[];objArray=[],_MTS_JQUERY(".search_widget").each(function(){var e={},t=_MTS_JQUERY(this);e.search=t.find("#searchPhrase").val(),e.page=parseInt(t.find(".pageActive:first").html())-1,e.disabled="",t.find(".filterDisabled").each(function(){e.disabled+=(0<e.disabled.length?", #":"#")+this.id}),objArray.push(e)}),e.push({name:"objArray",value:objArray}),history.replaceState(e,"")})}_MTS_widgetsReady?e():_MTS_JQUERY(document).one("widgetsloaded",e)}();
﻿var _currentImage=null,_noCaptionCaptionText="Click here to add a caption.",_noCreditText="Click here to add credits.",_slideShowTimer=null,_changingImage=!1,_beforeUpload=!1,_blockTag=!1,_tags=[],_tagsLinkType=[],_tagsLinkName=[],_wiredTags=[],_archivedAlbum=[],_reloadThumbnails=!1,_lightBoxEmailFrom="From (Required)",_lightBoxEmailReq="Recipients (Required)",_lightBoxEmailMsg="Check out this photo I found at "+("undefined"!=typeof _portalName&&0<_portalName.length?_portalName+"!":"My Team Scoop!"),_albumEmailMsg="Check out this photo album I found at "+("undefined"!=typeof _portalName&&0<_portalName.length?_portalName+"!":"My Team Scoop!"),_MTS_lightBoxRequired=!0,_MTS_countSinceLastAd=(_MTS_JQUERY="undefined"==typeof _MTS_JQUERY?$:_MTS_JQUERY,1),_MTS_adCount=1,_isAlbum=!1;function WireUpLightbox(){if(0==_MTS_JQUERY("#whiteBox").length)return _MTS_lightBoxRequired&&(_MTS_lightBoxRequired=!1,MTS_reloadWidget("","/api/photoLightBox.aspx",null,null,null,WireUpLightbox)),!1;var e=_MTS_JQUERY(".whiteBox");function t(){MTS_PHOTO_AD_CHECK()&&(ChangeWhiteBoxImage(GetPreviousImage(_currentImage)),ResetSlideShow())}function i(){MTS_PHOTO_AD_CHECK()&&(ChangeWhiteBoxImage(GetNextImage(_currentImage)),ResetSlideShow())}e&&1<e.length&&_MTS_JQUERY(e[0]).remove(),_MTS_JQUERY(".uploadTagWrapper").find("script").remove(),_MTS_JQUERY("body").append(_MTS_JQUERY("#whiteBox")),_MTS_JQUERY("body").append(_MTS_JQUERY(".uploadTagWrapper")),_MTS_JQUERY("body").append(_MTS_JQUERY(".background")),_MTS_JQUERY("body").append(_MTS_JQUERY(".listingBg")),_MTS_JQUERY(document).on("#whiteBox").delegate(".whiteBackground, #whiteCloseButton, .imageBackBtn","click",function(){_MTS_JQUERY("#whiteBox").data("stayOpen")||(CloseWiteBox(),_MTS_JQUERY(".filterIcon").removeClass("imageCloseButton"),_MTS_JQUERY("body").removeClass("noScrolling"),_MTS_JQUERY(".rightSideCtr").removeClass("rsOpen"),_MTS_JQUERY(".mtpShow").toggleClass("mtpShow"),_MTS_JQUERY(".adminOptActive").toggleClass("adminOptActive"),_MTS_JQUERY(".searchClose").click())}),_MTS_JQUERY(document).on("#whiteBox").delegate(".toggleCaption","click",function(){var e=$(".titleBuy"),t=e.outerHeight(),i=$(".asCtr"),a=$("#whiteImage.withAlbum");e.toggleClass("hideCaption"),e.hasClass("hideCaption")?(e.css({bottom:"-"+t+"px"}),i.css({bottom:"-100px"}),a.css({height:"calc(100%)"})):(e.removeAttr("style"),i.removeAttr("style"),a.removeAttr("style"))}),_MTS_JQUERY(document).on("#whiteBox").delegate(".mtGear","click",function(){_currentImage&&OpenUpload(void 0,void 0,!0,void 0,void 0,void 0,void 0,_currentImage.id)}),_MTS_JQUERY(document).on("#whiteBox").delegate("#fbPhotoShare","click",function(e){e.preventDefault();var e=screen.width/2-275,t=screen.height/2-225,i=_MTS_SITEURL+(_isAlbum&&void 0!==_selectedAlbum.url?_selectedAlbum.url:"photo-single/"+_currentImage.id+"/?mode=team");window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURI(i)+"&amp;src=sdkpreparse","facebook-share-dialog","width=626,height=436","facebookShare","width=550, height=420, top="+t+", left="+e)}),_MTS_JQUERY(document).on("#whiteBox").delegate("#mailPhotoShare","click",function(){lightBoxEmailShare(_isAlbum&&void 0!==_selectedAlbum.id?_selectedAlbum.id:0)}),_MTS_JQUERY(window).resize(function(){_MTS_JQUERY(".mediaToolPop"),_MTS_JQUERY(".mtGear");sizePhoto()}),_MTS_JQUERY("#whiteBox").on("click",".whiteLeftArrow, .mediaControlLeft",function(e){t()}),_MTS_JQUERY("#whiteBox").on("click",".whiteRightArrow, .mediaControlRight",function(e){i()}),"function"==typeof _MTS_JQUERY().swipe&&_MTS_JQUERY("#whiteImage").swipe(function(e){("right"==e.directionX?t:i)()}),_MTS_JQUERY("#whiteBox").on("click",".albumImageCtr",function(e){return!!MTS_PHOTO_AD_CHECK()&&(ChangeWhiteBoxImage(GetImageById(this.id.split("_")[1],!0)),void ResetSlideShow())}),_MTS_JQUERY("#whiteBox").on("click",".mediaControlStop",function(e){StopSlideShow()}),_MTS_JQUERY("#whiteBox").on("click",".mediaControlPlay",function(e){StartSlideShow(),this.setAttribute("class","mediaControlPause")}),_MTS_JQUERY("#whiteBox").on("click",".mediaControlPause",function(e){PauseSlideShow(),this.setAttribute("class","mediaControlPlay")}),_MTS_JQUERY("#whiteBox").delegate("#whiteCheerButton","click",function(){var e=[];e.push({name:"i",value:_currentImage.id}),e.push({name:"t",value:3}),e.push({name:"c",value:_currentImage.cheers}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"ext/UpdateCheer.aspx",e,function(){_currentImage.cheered?_currentImage.cheers--:_currentImage.cheers++,_currentImage.cheered=!_currentImage.cheered,MTS_reloadWidget("i="+_currentImage.id.toString()+"&t=3","/ext/FancyCheer.aspx",null,"#whiteCheerButton")})}),_MTS_JQUERY("#whiteBox").delegate("#whiteImageDelete","mouseenter mouseleave",function(e){"mouseenter"===e.type?_MTS_JQUERY("#whiteImageDeleteImage").css("background-image","url(/images/deletePhotoH.png)"):_MTS_JQUERY("#whiteImageDeleteImage").css("background-image","url(/images/deletePhoto.png)")}),_MTS_JQUERY("#whiteBox").delegate("#editImgShowBtn","click",function(){var e=_MTS_JQUERY("#whiteTitleNewValue"),e=(0<e.length&&e.val(_MTS_JQUERY("#whiteTitle").text()),_MTS_JQUERY("#whiteSummaryNewValue")),e=(0<e.length&&e.val(_MTS_JQUERY("#whiteSummary").text()),_MTS_JQUERY("#whiteCreditEditText"));0<e.length&&e.val(_MTS_JQUERY("#whiteCredit").text().replace("Credit: ","")),ToggleEdit(!0),_MTS_JQUERY(".editImgInfo").addClass("editImgInfoHide")}),_MTS_JQUERY("#whiteBox").delegate("#editImgCancel","click",function(){ToggleEdit(!1),_MTS_JQUERY(".editImgInfo").removeClass("editImgInfoHide")}),_MTS_JQUERY("#whiteBox").delegate("#editImgSave","click",function(){var e=_MTS_JQUERY("#whiteCreditEditText").val(),t=_MTS_JQUERY("#whiteTitleNewValue").val(),i=_MTS_JQUERY("#whiteSummaryNewValue").val();UpdateImageText(_currentImage,e,t,i),ToggleEdit(!1)}),_MTS_JQUERY("#sharePhoto").on("click",function(){_MTS_JQUERY(".shareCtr").toggleClass("tpsLeft")}),_MTS_JQUERY("#whiteBox").delegate("#whiteImageDelete","click",function(){var t=new PopupDialog;t.NewYesNoPrompt("Would you like to permanently delete this image?","Are you sure?",null,function(e){!1!==e&&DeleteImage(_currentImage,function(e){e?(_MTS_JQUERY("#photo_"+_currentImage.id).hide(),CloseWiteBox()):(t.Hide(),t.NewOkayAlert("An unknown error prevented us from deleting this image at this time.","Error!"))})})}),_MTS_JQUERY("#whiteBox").delegate("#whiteTagButton","click",function(){ToggleTagBox(!0)}),_MTS_JQUERY("#whiteBox").delegate("#whiteTagEditButtonSave","click",function(){var e=0<_MTS_JQUERY("#scheduleResultSelectBox").val()?_MTS_JQUERY("#scheduleEntryResultsSelectBox").val():"-1",t=_MTS_JQUERY("#rosterTag").val(),i=_MTS_JQUERY("#newsTag").val(),a="tagDropContainer",o=_MTS_JQUERY(".albumSelect");"none"==_MTS_JQUERY(".albumSelect").parent().css("display")&&(findSelectId("scheduleResultSelectBox",o,a),e=findSelectId("scheduleEntryResultsSelectBox",_MTS_JQUERY(".scheduleEntrySelect"),a),t=findSelectId("rosterTag",o,a),i=findSelectId("newsTag",o,a)),UpdateImageTag(_currentImage,e,t,i),ToggleTagBox(!1)}),_MTS_JQUERY("#whiteBox").delegate("#whiteTagEditButtonCancel","click",function(){ToggleTagBox(!1)}),_MTS_JQUERY("#whiteBox").delegate("#buyPhoto","click",function(){if(TrackPhoto(_currentImage.id),_currentImage.container&&0<_currentImage.container.length){for(var t="",e="",i=_activeContainer.portals.length-1;0<=i;i--)if(_activeContainer.portals[i].id==_currentImage.container){t=_activeContainer.portals[i].url,e=_activeContainer.portals[i].domain;break}if(""==t||""==e)return!1;window.location.origin||(window.location.origin=window.location.protocol+"//"+window.location.host);var a=_MTS_PHOTO_TEMPLATE.replace("%%IMG_ID%%",_currentImage.id).replace("%%SIZE%%",2).replace("%%TEAM_ID%%",_currentImage.teamId).replace("%%USER_ID%%",_currentImage.uploaderId).replace("%%TYPE%%",0);if("undefined"!=typeof FOTOMOTO)FOTOMOTO.API.showWindow(10,a);else{var o=t+"/"+_currentImage.id,n=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");try{n.open("GET",o,!1),n.send(),404===n.status&&(o=t+"/"+getBigInt(_currentImage.id)+_currentImage.id+"_original")}catch(e){o=t+"/"+getBigInt(_currentImage.id)+_currentImage.id+"_original"}window.open("http://"+e+".mycapture.com/mycapture/remoteimage.asp?caption="+escape(_currentImage.title)+"&image="+a+"&notes="+o+"&backtext=Back")}}}),_MTS_JQUERY("#whiteBox").delegate("#tagButton","click",function(){ToggleNewTag()}),_MTS_JQUERY("#whiteBox").delegate("#cropButton","click",function(){StartImgCrop();var e=_MTS_JQUERY(".mediaToolPop"),t=_MTS_JQUERY(".mtGear");e.toggleClass("mtpShow"),t.toggleClass("adminOptActive"),_MTS_JQUERY(".rightSideCtr").toggleClass("rsOpen")}),_MTS_JQUERY("#whiteBox").delegate("#imageDelete","click",function(){DeleteImagePopup()}),_MTS_JQUERY("#whiteBox").delegate("#whiteSubmitButton","click",function(){var e=_MTS_JQUERY("#whiteTitle").html();null!=e&&"undefined"!=e||(e=""),submitHtml="<div class='submitContainer' id='submitToPortal'><div class='textTitle'> Title </div><input type='text' id='submitTitle' value='' maxlength='256' class='titleTxt' /><div class='textTitle'> Summary </div><textarea id='submitSummary' maxlength='1024' class='summaryTxt' /><div class='submitBtnCon'><div class='submitBtn' id='cancelToPortal'> Cancel </div><div class='submitBtn' id='submitFinal'> Submit </div></div><div class='textTitle' id='erMsg'></div></div>",_MTS_JQUERY("body").append(submitHtml),_MTS_JQUERY("#submitTitle").val(e),_MTS_JQUERY(".submitContainer").css("z-index",160),_MTS_JQUERY(".background").show()}),_MTS_JQUERY(".mainTPContainer").delegate(".startSlideButton","click",function(){OpenWhiteBox(GetImageByPosition(0),!0),StartSlideShow()}),_MTS_JQUERY("#whiteBox").on("click","#cancelFeatLink",function(){_MTS_JQUERY("#photoEditFeatLink").html("Not Featured"),_MTS_JQUERY(this).hide(),_MTS_JQUERY("#featApply, #whiteSubmitButton").show();var e=[];e.push({name:"mode",value:"photo"}),e.push({name:"id",value:_currentImage.imageId}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/editfeatured.aspx",e,function(){_MTS_JQUERY("#featApply, #featureDate").hide(),_MTS_JQUERY("#whiteSummary").html("")})}),_MTS_JQUERY("#featureDate .editFeatLink").click(function(){var a=this;GetMiniCalendarCustom("select","Date Range",function(e,t,i){e=e.toString()+"/"+t.toString()+"/"+i.toString();FeaturePhoto(a.innerHTML=e,_currentImage.imageId)},_MTS_JQUERY.trim(a.innerHTML))}),_MTS_JQUERY("body").delegate("#cancelToPortal","click",function(){CloseSubmitBox()}),_MTS_JQUERY("body").delegate("#submitFinal","click",function(){var e=_MTS_JQUERY("#erMsg"),a=_MTS_JQUERY.trim(_MTS_JQUERY("#submitTitle").val()),o=_MTS_JQUERY.trim(_MTS_JQUERY("#submitSummary").val()),n=_MTS_JQUERY.trim(_MTS_JQUERY("#whiteCredit").text().replace("Credit: ",""));""!=a&&""!=o?_featurePhotos?GetMiniCalendarCustom("select","Featured Until",function(e,t,i){e=e.toString()+"/"+t.toString()+"/"+i.toString();SubmitPhoto(a,o,n,e)}):SubmitPhoto(a,o,n):e.html("Title and summary are required fields!")}),"function"==typeof MTS_lightBoxCallback&&MTS_lightBoxCallback()}function MTS_PHOTO_AD_CHECK(){if("undefined"!=typeof _MTS_ITEM_ADS&&0<_MTS_ITEM_ADS.length&&"undefined"!=typeof _MTS_PHOTO_PER_AD&&0<_MTS_PHOTO_PER_AD.length&&0<_MTS_PHOTO_PER_AD){var e=$(".whiteImgSrc, .titleBuy");if(_MTS_countSinceLastAd>=_MTS_PHOTO_PER_AD){try{var t="mts_ad_"+_MTS_adCount,i=_MTS_JQUERY("<div id='"+t+"' class='_mts_floatingAd borderedAd'></div>");_MTS_adCount++,$("#whiteImage").append(i),ad=_MTS_ITEM_ADS[0],0<=ad.location.indexOf("widget_")?(i.append("<div class='custom_widget'><input name='widgetName' type='hidden' value='"+ad.location.split("_")[1]+"' /></div></div>"),"function"==typeof MTS_loadWidgets&&MTS_loadWidgets(),_MTS_JQUERY(document).one("widgetsloaded",function(){"object"==typeof __gh__webApp&&__gh__webApp.ads.dfp.createLazySlot(".ad-lazy:visible:last")})):(googletag.defineSlot(ad.location,[ad.width||300,ad.height||250],t).setTargeting(ad.target,ad.target2).setCollapseEmptyDiv(!0).addService(googletag.pubads()),googletag.display(t))}catch(e){}return e.hide(),_MTS_countSinceLastAd=0,!1}_MTS_countSinceLastAd++,e.show(),_MTS_JQUERY("._mts_floatingAd").remove()}return!0}function GetMiniCalendarCustom(e,t,i,a){var o=new Date,a=new Date(a);"Invalid Date"==a&&(a=new Date),_cal.clearRecycle(),_cal.mode=e,_cal.wndTitle=t,_cal.setContract(o.getFullYear(),0,0),_cal.maxYear=_cal.startContractYear+5,_cal.setCallback(i),_cal.setSelection(a.getMonth()+1,a.getDate(),a.getFullYear()),_cal.show(100,100),_MTS_JQUERY(".listingBg").css({height:_MTS_JQUERY(document).height(),zIndex:113}),_MTS_JQUERY(".listingBg").show()}function FeaturePhoto(t,e){var i=[];i.push({name:"mode",value:"photo"}),i.push({name:"id",value:e}),i.push({name:"til",value:t}),i.push({name:"title",value:_MTS_JQUERY.trim(_MTS_JQUERY("#whiteTitle").html())}),i.push({name:"desc",value:_MTS_JQUERY.trim(_MTS_JQUERY("#whiteSummary").html())}),_MTS_JQUERY("#featApply").show(),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/editfeatured.aspx",i,function(e){e.error?(_MTS_JQUERY("#fdError").html("You must fill out the title and description."),_MTS_JQUERY("#fdError").show()):(_MTS_JQUERY("#cancelFeatLink").show(),_currentImage.featuredUntil=t),_MTS_JQUERY("#featApply").hide()})}function SubmitPhoto(t,i,e,a){var o=_MTS_JQUERY("#erMsg"),n=[];n.push({name:"mode",value:"requestAuth"}),n.push({name:"title",value:t}),n.push({name:"summary",value:i}),n.push({name:"credit",value:e}),n.push({name:"pid",value:_currentImage.id}),n.push({name:"email",value:"true"}),null!=a&&""!=a&&n.push({name:"date",value:a}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/updatePortalPhoto.aspx",n,function(e){o.html(""),"true"==e.ok?(_currentImage.title=t,_currentImage.summ=i,_currentImage.id=e.imageId,null!=a&&""!=a&&(_currentImage.featuredUntil=a),CloseSubmitBox(),FillWhiteBox(_currentImage)):o.html(e.error)})}function CloseSubmitBox(){_MTS_JQUERY(".submitContainer").remove(),_MTS_JQUERY(".background").hide()}function CloseWiteBox(){ToggleEdit(!1),_MTS_JQUERY("#whiteBox, .mediaTools").removeClass("animateLeft"),setTimeout(function(){_MTS_JQUERY(".whiteBox").hide()},500);_MTS_JQUERY(".mediaInterfaceWrapper").removeClass("snapMiw, fixmia");var e=_MTS_JQUERY(".masterMcWrap"),t=_MTS_JQUERY("body, html");e.removeClass("noScrolling"),t.removeClass("noScrolling"),null!=history&&null!=history.state&&void 0!==history.state.linkBack&&0<history.state.linkBack&&history.go(-1*history.state.linkBack)}function ChangeWhiteBoxImage(e){ToggleEdit(!1),_changingImage||null==e||(_changingImage=!0,_currentImage=e,_MTS_JQUERY(".whiteImgSrc").fadeTo(100,0,function(){DisplayWhiteBox(e,!0,function(){_changingImage=!1,sizePhoto()})}))}function OpenWhiteBox(e,t,i,a,o){null!=_slideShowTimer&&clearTimeout(_slideShowTimer),ToggleTagBox(!1),setTimeout(function(){_MTS_JQUERY(".whiteBackground").css("height",_MTS_JQUERY(document).height().toString()),_MTS_JQUERY(".whiteBackground").fadeTo(0,.8)},500),_MTS_JQUERY("#whiteBox").show(function(){_MTS_JQUERY("#whiteBox, .mediaTools").addClass("animateLeft"),_MTS_JQUERY(".mediaInterfaceWrapper").addClass("fixmia"),_MTS_JQUERY("body").addClass("noScrolling"),_MTS_JQUERY(window).width()<1024&&(_MTS_JQUERY("#whiteImage").outerHeight(),_MTS_JQUERY(".mediaTools").outerHeight(),_MTS_JQUERY(".filterIcon").addClass("imageCloseButton")),setTimeout(function(){sizePhoto()},0)},0),a&&_MTS_JQUERY("#whiteBox").data("stayOpen",!0),_isAlbum=!!i,DisplayWhiteBox(e,!0,sizePhoto,o)}function DisplayWhiteBox(o,e,n,t){null!=o&&(OverwriteUrl("photo-single/"+(0<(_currentImage=o).imageId?o.imageId:o.id)+"/"+(0<o.imageId?"":"?mode=team")),ShowWhiteLoader(),"true"===_MTS_JQUERY("input[name='mts_ilvDisableImages']").val()&&o.container<=0&&(t=!0),FillWhiteBox(o,function(){var e=_MTS_JQUERY(".whiteLeftArrow, .whiteRightArrow, .albumScroller, .asCtr");if(_selectedAlbum.images.length<=1)e.hide();else{e.show();e=_MTS_JQUERY(".albumScroller");if(0<e.length&&0==e.children().length||_reloadThumbnails){for(var t="",i=0,a=_selectedAlbum.images.length-1;i<=a;i++)t+="<div id='aic_"+_selectedAlbum.images[i].id+"' class='albumImageCtr "+(_selectedAlbum.images[i].id==o.id?"glow":"")+"'><img class='albumImage' src='"+(_selectedAlbum.images[i].container<=0?_MTS_MEDIAURL+"images/eventIcon.png":getImageLink(_selectedAlbum.images[i],0))+"' alt='' /></div>";e.html(t),AdjustSlider(1e3),_reloadThumbnails=!1}else _MTS_JQUERY(".albumImageCtr.glow").toggleClass("glow"),_MTS_JQUERY("#aic_"+o.id+".albumImageCtr").toggleClass("glow"),AdjustSlider(1e3)}_MTS_JQUERY.Query.notrack||"function"!=typeof trackItem||trackItem(0<o.imageId?o.imageId:o.id,"Image"),_MTS_JQUERY(".whiteLeftArrow, .whiteRightArrow").css("height","100%"),HideWhiteLoader(),_MTS_JQUERY(".white").fadeTo(100,1,function(){"function"==typeof n&&null!=n&&n()})},t))}function AdjustSlider(e){setTimeout(function(){var e=_MTS_JQUERY(".asCtr"),t=_MTS_JQUERY(".albumScroller"),i=_MTS_JQUERY(".albumImageCtr"),a=(_MTS_JQUERY(".albumImage"),_MTS_JQUERY(".white"),_MTS_JQUERY(".rightSideCtr"));i.css({height:e.outerHeight()+"px"}),t.css({height:e.outerHeight()+"px"}),i.css({width:i.outerHeight()}),t.css({width:i.outerWidth()*i.length+"px"}),_MTS_JQUERY(window).width()<768&&a.css({"padding-bottom":e.outerHeight()+"px"}),t.width()<_MTS_JQUERY(window).width()?t.addClass("mts_transform_left"):(t.removeClass("mts_transform_left"),_MTS_JQUERY(".asCtr").animate({scrollLeft:i.outerHeight()*_MTS_JQUERY(".albumImageCtr.glow").prevAll().length-e.outerWidth()/2+i.outerHeight()/2}))},e)}function ShowWhiteLoader(){_MTS_JQUERY("#whiteLoader").show()}function HideWhiteLoader(){_MTS_JQUERY("#whiteLoader").hide()}function InsertNewTag(e,t,i,a,o,n,u,l,s){if(""==l||""==o)return"";_MTS_JQUERY(".tagContainer").children("div[id!='currentTag']").remove();var r="",l=(n||null!==_MTS_JQUERY("#currentTag").html()||(r+='<div class="currentTag" id="currentTag"><div class="currentTagLbl">Current Tags:</div> '),r+='<div id="tag_'+i+"_"+e+'" class="imageTag"><a title=\''+o+"' href=\""+l+'">'+o+"</a>",""),o=("ScheduleEvent"===i?l=_MTS_JQUERY('#scheduleEntryResultsSelectBox option[value="'+e+'"]'):"Roster"==i?l=_MTS_JQUERY('#rosterTag option[value="'+e+'"]'):"NewsItem"==i&&(l=_MTS_JQUERY('#newsTag option[value="'+e+'"]')),""!=l&&l.attr("disabled","disabled"),0<_MTS_JQUERY("#tagButton").length),_=(s||n&&!o&&("number"!=typeof _userId||isNaN(_userId)||!(_userId===u||"boolean"==typeof _canUpdate&&_canUpdate))||(r+='<div id="tagDelete_'+t+'" title="Delete Tag" class="imageTagRem">x</div>'),r+="</div> ",n||null!==_MTS_JQUERY("#currentTag").html()||(r+="</div>"),0<_MTS_JQUERY("#whiteBox").length?_MTS_JQUERY._data(_MTS_JQUERY("#whiteBox")[0],"events"):void 0);if(null!=_)for(var c=(_=_.click).length,d=0;d<c;d++)if(_[d].selector==="#tagDelete_"+t)return r;return WireImageTag(t,e,a,i),r}function WireImageTag(e,t,i,a){_MTS_JQUERY("#whiteBox").delegate("#tagDelete_"+e,"click",function(){tagPrompt(e,t,i,a)})}function tagPrompt(o,n,e,l){var r=new PopupDialog;r.NewYesNoPrompt("Would you like to permanently delete this tag?","Are you sure?",null,function(e){!1!==e&&DeleteTag(_currentImage,o,function(e){if(e){_MTS_JQUERY("#tag_"+l+"_"+n).remove();for(var e="",t=("ScheduleEvent"==l?e="#scheduleEntryResultsSelectBox":"Roster"==l?e="#rosterTag":"NewsItem"==l&&(e="#newsTag",_forceRefresh=!0),_MTS_JQUERY(e+' option[value="'+n+'"]').removeAttr("disabled"),_currentImage.links.length),i=-1,a=0;a<t;a++)if(_currentImage.links[a].tagId==o){i=a;break}0<=i&&(null!=_MTS_JQUERY("#rP_"+n)&&_MTS_JQUERY("#rP_"+n).find("#photo_"+o).parent().remove(),_currentImage.links.splice(i,1))}else r.Hide(),r.NewOkayAlert("An unknown error prevented us from deleting this tag at this time.","Error!")})})}function lightBoxEmailShare(e){var t=void 0!==e&&0<e,i="<div class='emailBg'><div class='emailTemplate' id='sendEmail'><div class='emailTempHead'>Share This "+(t?"Album":"Photo")+"</div>"+(0<_MTS_userId?"":"<input title='"+_lightBoxEmailFrom+"' type='text' class='emailTxt' id='emailFrom' value='"+_lightBoxEmailFrom+"' />")+"<input title='"+_lightBoxEmailReq+"' type='text' class='emailTxt' id='emailList' value='"+_lightBoxEmailReq+"' /><textarea class='emailTxtArea' id='emailMsg'>"+(t?_albumEmailMsg:_lightBoxEmailMsg)+"</textarea><div class='tempButtons'><div class='mts_cc_button tempButton' id='emailSend'>Send</div><input id='shareMode' type='hidden' value='"+(t?"photoAlbum":"photo")+"' /><div class='mts_cc_button tempButton' id='emailCancel'>Cancel</div></div></div></div>";_MTS_JQUERY("body").append(i),_MTS_JQUERY(".emailTempExit, .emailBg").click(function(){_MTS_JQUERY(".emailBg, .emailTemplate").remove()}),_MTS_JQUERY(".emailBg").show(),t&&(_curShareId=e)}function FillWhiteBox(e,u,s){var t="",i=e.links.length,a=getImageLink(e,2),o=_MTS_SITEURL+(_isAlbum&&void 0!==_selectedAlbum.url?_selectedAlbum.url:"photo-single/"+e.id+"/?mode=team"),n=(_MTS_JQUERY("#tagContainer").html(""),_MTS_JQUERY(".scheduleEntrySelect").removeAttr("disabled"),_MTS_JQUERY(".albumSelect").children().removeAttr("disabled"),"");if(0<i){for(var t='<div class="currentTag" id="currentTag"><div class="currentTagLbl">Current Tags:</div> ',l=0;l<i;l++){var r=e.links[l];""==n&&"PhotoAlbum"==r.tagType&&(n=r.tagName),t+=InsertNewTag(r.linkId,r.tagId,r.tagType,r.scheduleId,r.tagName,!0,r.writerId,r.href,"boolean"==typeof e.isTagged)}t+="</div>",_MTS_JQUERY("#tagContainer").html(t)}_MTS_JQUERY(".whiteAlbumTitle").html(0<n.length?"<span style='font-weight: bold;'>Album: </span>"+n:""),_MTS_JQUERY("#whiteTitleNewValue").html(""),_MTS_JQUERY("#whiteTitle").html(e.title+(e.description&&0<e.description.length?"<br><br>"+e.description:"")),_MTS_JQUERY("#whiteBox #fbTitle").val(_isAlbum&&void 0!==_selectedAlbum.urlName?_selectedAlbum.urlName:e.title),_MTS_JQUERY("#whiteBox #fbImgDefault").val(a),_MTS_JQUERY("#whiteBox #fbLink").val(o),_MTS_JQUERY("#twitterPhotoShare").attr("href","https://twitter.com/intent/tweet?hashtags=mts&original_referer="+encodeURI(o)+"&text="+encodeURI(_isAlbum&&void 0!==_selectedAlbum.urlName?_selectedAlbum.urlName:e.title)+"&tw_p=tweetbutton&url="+encodeURI(o)),_curShareId=(_isAlbum&&void 0!==_selectedAlbum.Id?_selectedAlbum:e).id,_MTS_JQUERY("#whiteSummaryNewValue").html(""),void 0!==e.summ&&""!=e.summ?_MTS_JQUERY("#whiteSummary").html(e.summ):_MTS_JQUERY("#whiteSummary").html(""),_MTS_JQUERY("#whiteCreditEditText").html("");var o=_MTS_JQUERY("#whiteCredit"),o=(""!=e.credit?(o.html(" Credit: "+e.credit),o.show()):o.hide(),_MTS_JQUERY("#photoEditFeatLink").html(""),void 0!==e.featuredUntil&&""!=e.featuredUntil?(o=new Date(e.featuredUntil),_MTS_JQUERY("#photoEditFeatLink").html(o.getMonth()+1+"/"+o.getDate()+"/"+o.getFullYear()),_MTS_JQUERY("#featureDate, #cancelFeatLink").show(),_MTS_JQUERY("#whiteSubmitButton").hide()):(_MTS_JQUERY("#photoEditFeatLink").html(""),_MTS_JQUERY("#featureDate, #cancelFeatLink").hide(),_MTS_JQUERY("#whiteSubmitButton").show()),_MTS_JQUERY("#buyPhoto, .buyTxt"));if(e.container&&""!=e.container&&-1<parseInt(e.container)&&"undefined"!=typeof _activeContainer){for(var _="",d="",l=_activeContainer.portals.length-1;0<=l;l--)if(_activeContainer.portals[l].id==_currentImage.container){_=_activeContainer.portals[l].url,d=_activeContainer.portals[l].domain;break}""==_||""==d?o.hide():o.show()}else o.hide();ToggleTagBox(!1),void 0!==e.isTagged||"number"!=typeof _userId||isNaN(_userId)?(_MTS_JQUERY("#whiteCaptionEdit").hide(),_MTS_JQUERY("#whiteCreditEdit").hide()):(_userId===e.uploaderId||"boolean"==typeof _canUpdate&&_canUpdate?_MTS_JQUERY("#editImgShowBtn").show():_MTS_JQUERY("#editImgShowBtn").hide(),_userId===e.uploaderId||"boolean"==typeof _canDelete&&_canDelete?_MTS_JQUERY("#whiteImageDelete").show():_MTS_JQUERY("#whiteImageDelete").hide()),MTS_reloadWidget("i="+e.id.toString()+"&t=3","/ext/FancyFlag.aspx",null,"#whiteFlagButton"),MTS_reloadWidget("i="+e.id.toString()+"&t=3","/ext/FancyCheer.aspx",null,"#whiteCheerButton"),_MTS_JQUERY("#whiteImage").html("<i class='far fa-chevron-left whiteLeftArrow'></i><div class='cropMarks'><div class='cmTopLeft'></div><div class='cmTopRight'></div><div class='cmBotRight'></div><div class='cmBotLeft'></div></div><img class='whiteImgSrc' src='"+a+"' alt='[Image]'"+(s?" style='display: none;' ":"")+"/><i class='far fa-chevron-right whiteRightArrow'></i></div>"),_MTS_JQUERY("#downloadOriginal").bind("click",function(){window.open("/api/downloadOriginalImage.aspx?id="+_currentImage.id,"_blank")}),_MTS_JQUERY(".whiteImgSrc").on("load",u),_MTS_JQUERY(".whiteImgSrc").on("error",function(){_MTS_JQUERY(this).attr("src",_MTS_MEDIAURL+"images/blockNoImg.png")})}function PositionWhite(e){var t=_MTS_JQUERY(window).height(),i=_MTS_JQUERY(window).scrollTop(),a=_MTS_JQUERY(".white").outerHeight(),o=_MTS_JQUERY(window).width()/2-_MTS_JQUERY(".white").outerWidth()/2,t=a<t?(t-a)/2+i:i;t<150&&(t=150),_MTS_JQUERY(".white").css({left:o+"px",top:t+"px"})}function GetNextImage(e){if(null==e)return null;e=GetImageByPosition(e.position+1);return e=null==e?_selectedAlbum.images[0]:e}function GetPreviousImage(e){if(null==e)return null;e=GetImageByPosition(e.position-1);return e=null==e?_selectedAlbum.images[_selectedAlbum.images.length-1]:e}function GetImageByPosition(e,t,i){var a=-1;if("string"==typeof e&&null!=e)a=parseInt(e,10);else{if("number"!=typeof e||null==e)return null;a=e}if(void 0!==t&&void 0!==i&&"undefined"!=typeof _MTS_album)for(var o=_MTS_album.length-1;0<=o;o--)if(_MTS_album[o].id==t&&_MTS_album[o].mode==i){0==_archivedAlbum.length&&"undefined"!=typeof _selectedAlbum&&(_archivedAlbum=_selectedAlbum),_selectedAlbum=_MTS_album[o],_reloadThumbnails=!0;break}for(o=0;o<_selectedAlbum.images.length;o++)if(_selectedAlbum.images[o].position===a)return _selectedAlbum.images[o];return null}function DeleteTag(e,t,i){var a=[];"object"==typeof e&&null!=e?(a.push({name:"itemId",value:e.id}),"undefined"!=typeof _teamId&&a.push({name:"teamId",value:_teamId}),a.push({name:"tagId",value:t}),a.push({name:"mode",value:"boolean"==typeof _isPortal&&null!=_isPortal&&_isPortal?"portalImage":"image"}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/deleteTags.aspx",a,function(e){"object"==typeof e&&null!=e||i(!1),"boolean"==typeof e.ok&&null!=e.ok||i(!1),"function"==typeof i&&null!=i&&i(e.ok)})):"function"==typeof i&&null!=i&&i(!1)}function DeleteImage(o,n){var e=[],l=[];"object"==typeof o&&null!=o?(e.push({name:"imageId",value:o.id}),"undefined"!=typeof _teamId&&e.push({name:"teamId",value:_teamId}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/deleteImage.aspx",e,function(e){if("object"==typeof e&&null!=e||n(!1),"boolean"==typeof e.ok&&null!=e.ok||n(!1),e.ok){for(var t=_selectedAlbum.images.length,i=0,a=0;a<t&&(a===o.position&&(i++,t--),!(t<i));a++)i>o.position&&_selectedAlbum.images[i].position--,l[a]=_selectedAlbum.images[i],i++;_selectedAlbum.images=null,_selectedAlbum.images=l}"function"==typeof n&&null!=n&&n(e.ok)})):"function"==typeof n&&null!=n&&n(!1)}function UpdateImageText(t,e,i,a,o){var n=null!=e&&0<e.length,l=null!=i&&0<i.length,r=null!=a&&0<a.length,_=[];l&&_.param("title",i),r&&_.param("summary",a),n&&_.param("credit",e),_.param("teamId","undefined"!=typeof _teamId?_teamId:-1),_.param("imageId",t.id),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/updateImage.aspx",_,function(e){e.ok&&(n&&(t.credit=e.credit,_MTS_JQUERY("#whiteCredit").text(0<t.credit.length?"Credit: "+t.credit:"")),l&&(t.title=e.title,_MTS_JQUERY("#whiteTitle").text(t.title)),r&&(t.summ=e.summary,_MTS_JQUERY("#whiteSummary").text(t.summ))),"function"==typeof o&&null!=o&&o(json.ok)})}function ToggleEdit(e){e?_MTS_JQUERY(".editImgCtr").show():(_MTS_JQUERY(".editImgCtr").hide(),_MTS_JQUERY(".imageInfoWrapper").show()),_MTS_JQUERY("#editCaptionWrap").css("display",$("#featureDate").css("display"))}function ToggleTagBox(e){e?((e=_MTS_JQUERY("#whiteTagButton").parent().parent()).find(".chosen-container").show(),e.find("#albumTag_chosen").hide(),_MTS_JQUERY(".albumSelect").val(-1),_MTS_JQUERY(".scheduleEntrySelect").val(-1),_MTS_JQUERY("#scheduleEntryResultsSelectBox_chosen").hide(),_MTS_JQUERY("#whiteTagButton").fadeTo(300,0,function(){_MTS_JQUERY("#whiteTagEditContainer").fadeTo(0,0),_MTS_JQUERY("#whiteTagEditContainer").show(),_MTS_JQUERY("#whiteTagEditContainer").fadeTo(300,1)})):_MTS_JQUERY("#whiteTagEditContainer").fadeTo(300,0,function(){_MTS_JQUERY("#whiteTagEditContainer").hide(),_MTS_JQUERY("#whiteTagButton").show(),_MTS_JQUERY("#whiteTagButton").fadeTo(300,1)})}function UpdateImageTag(c,m,g,h,T){var e=[];"object"!=typeof c||null==c||"string"!=typeof m&&"string"!=typeof g&&"string"!==h||null==m&&null==g&&null==h?"function"==typeof T&&null!=T&&T(!1):(e.push({name:"itemId",value:c.id}),e.push({name:"teamId",value:_teamId}),e.push({name:"seId",value:m}),e.push({name:"rId",value:g}),e.push({name:"nId",value:h}),e.push({name:"mode",value:"image"}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/updateTags.aspx",e,function(e){"object"==typeof e&&null!=e||T(!1),"boolean"==typeof e.ok&&null!=e.ok||T(!1);var t=e.tags;if(e.ok&&0<t.length)for(var i=-1,a=-1,o="",n="",l=0;l<t.length;l++){if("ScheduleEvent"==(d=t[l]).linkType){_MTS_JQUERY("#sE_"+m);for(var a=_MTS_JQUERY("#scheduleResult").val(),o=_MTS_JQUERY("#scheduleEntryResultsSelectBox option[value="+m+"]").html(),n="",i=m.toString(),r=0;r<o.split(" ").length-1;r++)n+=o.split(" ")[r],l<o.split(" ").length-2&&(n+=" ")}else"Roster"==d.linkType?(i=g.toString(),a=-1,n=_MTS_JQUERY("#rE_"+g).html(),null!=_MTS_JQUERY("#rP_"+g).val()&&rCPhotoInsert(g,e.tags[l].id,_currentImage.id)):"NewsItem"==d.linkType&&(i=h.toString(),a=-1,n=_MTS_JQUERY("#nI_"+h).html(),_forceRefresh=!0);var _=d.id,u=d.linkType,s=d.writerId,d=d.href,s=(c.links.push({linkId:i,scheduleId:a,tagId:_,tagName:n,tagType:u,writerId:s,href:d}),InsertNewTag(i,_,u,a,n,!1,0,d));(null===_MTS_JQUERY("#currentTag").html()?_MTS_JQUERY("#tagContainer"):_MTS_JQUERY("#currentTag")).append(s)}"function"==typeof T&&null!=T&&T(e.ok)}))}function StartImgCrop(){$("#cropImgOpts").show(),_MTS_previewImg=$(".whiteImgSrc");var e=getInitCords();_MTS_previewImg.imgAreaSelect({x1:e.x,y1:e.y,x2:e.x2,y2:e.y2,instance:!0,minWidth:50,minHeight:50,onSelectEnd:handleForm,persistent:!0,handles:!0}),adjustMarks()}function getInitCords(){var e=_MTS_previewImg.width(),t=_MTS_previewImg.height(),i=calculateGCD(_imageSizes.SiteWideMxH,_imageSizes.SiteWideMxW),a=!1;return 1<i&&(50<(i=calculateAspectRatioFit(_imageSizes.SiteWideMxW/i,_imageSizes.SiteWideMxH/i,e,t)).width&&50<i.height&&(e=Math.floor(i.width),t=Math.floor(i.height),a=!0)),a||(t=e=50),{x:0,y:0,x2:e,y2:t}}function calculateGCD(e,t){return t?calculateGCD(t,e%t):e}function calculateAspectRatioFit(e,t,i,a){i=Math.min(i/e,a/t);return{width:e*i,height:t*i}}function adjustMarks(){var e=_MTS_JQUERY(".cropMarks"),t=_MTS_JQUERY(".whiteImgSrc");e.css({width:t.outerWidth()+"px",height:t.outerHeight(),left:t.position().left+"px",top:t.position().top+"px",display:"block"})}function handleForm(e,t){updateCoords(t.x1,t.x2,t.y1,t.y2)}function updateCoords(e,t,i,a){_MTS_JQUERY('input[id="prevX1"]').val(e),_MTS_JQUERY('input[id="prevY1"]').val(i),_MTS_JQUERY('input[id="prevX2"]').val(t),_MTS_JQUERY('input[id="prevY2"]').val(a)}function ToggleNewTag(){_beforeUpload=!1,_MTS_JQUERY(".tagBtn").click(),_MTS_JQUERY(".uploadTagWrapper").addClass("showTagWrapper"),_MTS_sportsEnabled||_MTS_JQUERY(".filterColumn:not('#CategoryFilter,#SubcategoryFilter')").addClass("filterDisabled")}function CenterElement(e){var t,i,a,o,e=_MTS_JQUERY(e);0!==e.length&&(e[0].parentNode!==document.body&&(e[0].parentNode.removeChild(e[0]),document.body.appendChild(e[0])),i=_MTS_JQUERY(window).width(),t=_MTS_JQUERY(window).height(),a=e.outerWidth(),t=t/2-e.outerHeight()/2,i=i/2-a/2,a=_MTS_JQUERY(document).scrollTop(),o=_MTS_JQUERY(document).scrollLeft(),(t+=a)<150&&(t=150),e.css({left:(i+=o).toString()+"px",top:t.toString()+"px"}))}function WireUpTag(n,e,l){if(_beforeUpload){_tags.push(n),_tagsLinkType.push(l);for(var t=0;t<_wiredTags.length;t++)if(_wiredTags[t]==n)return;_wiredTags.push(n),_MTS_JQUERY("#tagAdd_"+n).hide()}else{setTimeout(function(){(0<_tags.length?_MTS_JQUERY(".uploadContent .tagContainer").children().last():_MTS_JQUERY(".uploadContent .tagContainer").children()).remove()},500);for(var i=_currentImage.links,t=i.length-1;0<=t;t--)if(i[t].linkId==n&&i[t].tagType==l)return!1;var a=[];a.push({name:"itemId",value:_currentImage.id}),a.push({name:"linkType",value:l}),a.push({name:"linkId",value:n}),a.push({name:"mode",value:"portalImage"}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"api/updateTags.aspx",a,function(e){if(e.ok){_MTS_JQUERY(".tagBlock").remove(),_MTS_JQUERY(".portalText").remove();var t=e.tags[0].id,i=e.tags[0].writerId,a=e.tags[0].href,o=e.tags[0].title,t=(newTag={linkId:n,scheduleId:-1,tagId:t,tagName:o,tagType:l,writerId:i,href:a},_currentImage.links.push(newTag),InsertNewTag(n,e.tags[0].id,l,-1,o,!1,i,a)),e=_MTS_JQUERY("#currentTag");if(0<e.length)return e.append(t),!1;_MTS_JQUERY("#tagContainer").html(t)}})}}function DeleteImagePopup(){var t=new PopupDialog;t.NewYesNoPrompt("Would you like to permanently delete this image?","Are you sure?",null,function(e){!1!==e&&DeleteImage(_currentImage,function(e){e?(_MTS_JQUERY("#photo_"+_currentImage.id).hide(),CloseWiteBox()):(t.Hide(),t.NewOkayAlert("An unknown error prevented us from deleting this image at this time.","Error!"))})})}function StartSlideShow(){_slideShowTimer=setTimeout(function(){var e;null==_currentImage||"none"===_MTS_JQUERY("#whiteBox").css("display")||null!=(e=GetNextImage(_currentImage))&&(ChangeWhiteBoxImage(e),StartSlideShow())},1e4)}function PauseSlideShow(){clearTimeout(_slideShowTimer)}function ResumeSlideShow(){clearTimeout(_slideShowTimer)}function StopSlideShow(){clearTimeout(_slideShowTimer)}function ResetSlideShow(){null!=_slideShowTimer&&(clearTimeout(_slideShowTimer),StartSlideShow())}function RewindSlideShow(){var e=GetImageByPosition(0);null!=e&&ChangeWhiteBoxImage(e)}function findSelectId(e,t,i){var a=-1;return t.each(function(){this.id!=e||"none"==this.parentNode.style.display||this.parentNode.id!=i&&this.parentNode.className!=i||(a=this.value)}),a}function GetIdFromThis(e,t){var i,a="";return"object"!=typeof e||null==e||"string"!=typeof t||null==t||"string"!=typeof(a=e.getAttribute("id"))||null==a||"string"!=typeof(i=a.substring(t.length))||null==i?"":i}function GetImageById(e,t){var i=-1;if("string"==typeof e&&null!=e)i=parseInt(e,10);else{if("number"!=typeof e||null==e)return null;i=e}for(var a=0;a<_selectedAlbum.images.length;a++)if(_selectedAlbum.images[a].id===i)return _selectedAlbum.images[a];return null}function OverwriteUrl(e,t){var i;void 0===t&&(t=!1),"undefined"==typeof _MTS_allowUrlOverwrite||!_MTS_allowUrlOverwrite||null!=history.state&&history.state.haltUpdate||(i=1,null==history.state||void 0===history.state.linkBack||isNaN(history.state.linkBack)||(i=history.state.linkBack+1),history.pushState({linkBack:i,haltUpdate:t},"",_MTS_SITEURL+e))}function ReplacePhotosAndContainer(e,t){void 0!==e&&(_selectedAlbum=e),void 0!==t&&(_activeContainer=t),_reloadThumbnails=!0}function highlightLightboxTags(){_MTS_JQUERY(".whiteTagContainer:visible .imageTag").each(function(){var e=_MTS_JQUERY(this).attr("id").split("_")[2],t=_MTS_JQUERY(this).attr("id").split("_")[1];_MTS_JQUERY(".result[href$='"+e+",\\'"+t+"\\')']").addClass("selectedTag")})}function sizePhoto(){0<_MTS_JQUERY(".albumImageCtr").length&&_MTS_JQUERY("#whiteImage").addClass("withAlbum"),"function"==typeof sizeWhiteBox&&sizeWhiteBox()}function _MTS_CloseUploadFunc(){_MTS_JQUERY.getJSON("/api/v1/portal/images/single?image_id="+_currentImage.id,function(e){_currentImage.credit=e.Credit,_currentImage.description=e.Description,_currentImage.title=e.Title,_currentImage.webActiveVersion=e.WebActiveVersion,_MTS_JQUERY(".whiteImgSrc").attr("src",getImageLink(_currentImage,2)),_MTS_JQUERY("#whiteTitle").html(e.Title+(e.Description&&0<e.Description.length?"<br><br>"+e.Description:""));var t=_MTS_JQUERY("#whiteCredit");""!=e.Credit?(t.html(" Credit: "+e.Credit),t.show()):t.hide()})}_MTS_widgetsReady?WireUpLightbox():_MTS_JQUERY(document).one("widgetsloaded",WireUpLightbox);
﻿function Slider(){this.parent=null,this.frames=[],this.callback=function(){},this.last=new Date,this.index=0,this.delay=0,this.drop=0,this.interval=-1}_MTS_JQUERY="undefined"==typeof _MTS_JQUERY?$:_MTS_JQUERY,Slider.prototype={addImage:function(i){this.imageList.push(i)},init:function(s,i,t,_,c,f,p){this.index=0,this.parent=s,this.callback=t,this.delay=1e3*i,this.drop=1.5*this.delay;for(var m,e,n,v,u,a="object"==typeof s,l=a?s:_MTS_JQUERY("#"+s),h=(l.children().filter(function(){return this.id.match(/sli_frame_/)}).remove(),l.children()),t=0===_MTS_JQUERY("#featFoto").length?"#bigSlide":"#featFoto",i=(a||_MTS_JQUERY("#"+_),a?s:_MTS_JQUERY(t)),t=i.width()/("undefined"!=typeof _imageSizes?_imageSizes.SlideShowMxW/_imageSizes.SlideShowMxH:16/9),d=0;d<h.length;d++)_MTS_JQUERY(h[d]).css({display:"none"}),m="sli_frame_"+d,e=_MTS_JQUERY("<div id='"+m+"'></div>"),n=_MTS_JQUERY("<div class='whiteBoxTrigger'></div>"),!c&&"bigSlide"!==s||(u=d+"",n.on("click touchend",function(){OpenWhiteBox(GetImageByPosition(u,f,p))})),v=_MTS_JQUERY("<span style='display: inline-block; height: 100%; vertical-align: middle;'></span>"),h[d].src||null!=!_MTS_JQUERY(h[d]).attr("data-original")||(h[d].src=_MTS_JQUERY(h[d]).find(".ytImg").attr("src"),n="portalVideo"==h[d].className?_MTS_JQUERY("<a class='ytCon' href='"+h[d].href+"'><img class='ytPB' src='"+_MTS_MEDIAURL+"images/playBtn.png' /></a>"):_MTS_JQUERY("<div id='yt_"+_MTS_JQUERY(h[d]).find(".ytId").val()+"' class='ytThumb ytCon'><img class='ytPB' src='"+_MTS_MEDIAURL+"images/playBtn.png' /></div>")),r=_MTS_JQUERY("<img class='mts_lazy' data-original='"+(h[d].src||_MTS_JQUERY(h[d]).attr("data-original"))+"' alt='' />"),n.append(v),n.append(r),r.css({"max-width":"none","min-width":"100%","min-height":"100%","vertical-align":"middle",transform:"translateX(-50%)",position:"absolute",top:"0px",left:"50%"}),r.addClass("portraitCenter"),e.css({position:"absolute",top:"0px",left:0==d?"0px":"100%",width:"100%",height:"100%",display:"inline-block",overflow:"hidden"}),n.css({display:"block",width:"100%",height:"100%","text-align":"center"}),e.append(n),l.append(e),this.frames.push(m);i.height(t),_MTS_JQUERY(window).resize(function(){l.children();var i=0===_MTS_JQUERY("#featFoto").length?"#bigSlide":"#featFoto",i=(a||_MTS_JQUERY("#"+_),a?s:_MTS_JQUERY(i)),t=i.width(),e="undefined"!=typeof _imageSizes?_imageSizes.SlideShowMxW/_imageSizes.SlideShowMxH:16/9;i.height(t/e)});var o=this;_MTS_JQUERY(window).on("blur focus",function(i){if(_MTS_JQUERY(this).data("prevType")!=i.type)switch(i.type){case"blur":o.interval&&(clearInterval(o.interval),o.interval=null);break;case"focus":o.interval||(o.last=new Date,o.interval=setInterval(function(){o.timer()},o.delay))}_MTS_JQUERY(this).data("prevType",i.type)}),this.interval=setInterval(function(){o.timer()},this.delay)},kill:function(){clearInterval(this.interval)},timer:function(){var i,t=new Date;t-this.last>this.drop||(i=this.index++,this.index>=this.frames.length&&(this.index=0),this.index!=i&&(this.anim(i,this.index),this.last=t))},rev_timer:function(){var i,t=new Date;t-this.last>this.drop||(i=this.index--,this.index<0&&(this.index=this.frames.length-1),this.index!=i&&(this.rev_anim(i,this.index),this.last=t))},jump_to:function(i,t){var e;i!=t&&(e=new Date,(this.index=t)<i?this.rev_anim(i,t):this.anim(i,t),this.last=e)},anim:function(i,t){this.stop(i),this.stop(t),this.slide(i,0,-100,!1),this.slide(t,100,0,!0)},rev_anim:function(i,t){this.stop(i),this.stop(t),this.slide(i,0,100,!1),this.slide(t,-100,0,!0)},next:function(){clearInterval(this.interval),this.timer();var i=this;this.interval=setInterval(function(){i.timer()},this.delay)},previous:function(){clearInterval(this.interval),this.rev_timer();var i=this;this.interval=setInterval(function(){i.timer()},this.delay)},stop:function(i){null==this.frames[i]||i<0||_MTS_JQUERY(this.frames[i]).stop(!0,!0)},slide:function(i,t,e,s){var n,a;null==this.frames[i]||i<0||(a=(n=this).parent.parents(".photo_slider_widget,.featured_news_panel_widget"),_MTS_JQUERY(this.parent).find("#"+this.frames[i]).css("left",t+"%").animate({left:e+"%"},400,"swing",function(){n.last=new Date,s&&n.callback(i,a),setTimeout(function(){var i=$("img.mts_lazy");i.lazyload({failure_limit:i.length-1}),i.lazyload({event:"mts_lazy"})},0)}))}};
﻿!function(){var n=[];function t(){for(var e=_MTS_JQUERY(".mts_widget #featuredContent"),t=e.length-1;0<=t;t--){var i=_MTS_JQUERY(e[t]);0<i.find(".mts_slide_created").length||(i.append("<input type='hidden' class='mts_slide_created' />"),slide=new Slider,slide.init(i.find("#featFoto"),10,d,"features","True"==i.parent().find(".usePhotoBox").val(),i.parent().find(".photoModeId").val(),i.parent().find(".photoMode").val()),n.push(slide),function(e,i){_MTS_JQUERY(e).find("#bsLeft").off("click").click(function(){i.previous()}),_MTS_JQUERY(e).find("#bsRight").off("click").click(function(){i.next()}),"function"==typeof _MTS_JQUERY().swipe&&_MTS_JQUERY(e).find("#featFoto").off("swipe").swipe(!1,!1,function(e){"right"==e.directionX?i.previous():i.next()});_MTS_JQUERY(e).find(".featBox").off("click").click(function(){var e=this.id.split("_")[1],t=_MTS_JQUERY(".selected")[0].id.split("_")[1];i.jump_to(t,e)})}(e[t],slide),d(0,i.parents(".photo_slider_widget, .featured_news_panel_widget")),_MTS_JQUERY("#featLink, .featSmall").dotdotdot())}$("img.mts_lazy").lazyload({failure_limit:$("img.mts_lazy").length-1})}function d(e,t){var i=t.find("#f"+e),n=i.children(".t").html(),d=i.children(".tUrl").val(),l=i.children(".forceUrl").val(),f=t.find("#featLink"),d=_MTS_SITEURL+d,o=t.find("#sli_frame_"+e+" a"),l=("javascript:void(0);"!=o.attr("href")&&"True"!=l||(o.attr("href",d),f.attr("href",d)),t.find("#featPrev").html(i.children(".b").html()),f.html(n),t.find("#featSty"));null==n||0==n.length?l.hide():l.show(),t.find(".selected").removeClass("selected"),t.find("#featBox_"+e).addClass("selected")}"none"!=_MTS_JQUERY(".featured_news_panel_widget #featuredContent").css("display")?_MTS_JQUERY(document).on("widgetsloaded",function(){setTimeout(t,0)}):_MTS_JQUERY("#msNews").click(function(){t()}),_MTS_JQUERY(document).on("resetSlider",function(){for(var e=n.length-1;0<=e;e--)n[e].kill();t()})}();
﻿!function(a){function u(t){var n={},e=null;return"object"!=typeof t.originalEvent||"object"!=typeof t.originalEvent.touches||"object"!=typeof t.originalEvent.changedTouches?null:(0<t.originalEvent.touches.length&&(e=t.originalEvent.touches[0]),"object"!=typeof(e=0<t.originalEvent.changedTouches.length?t.originalEvent.changedTouches[0]:e)||"number"!=typeof e.pageX||null==e.pageX||"number"!=typeof e.pageY||null==e.pageY?null:(n.X=e.pageX,n.Y=e.pageY,n))}function r(t,n,e){try{var o=t-a(e).offset().left,i=n-a(e).offset().top;if(o<a(e).width()&&0<o&&i<a(e).height()&&0<i)return}catch(t){}return 1}a.fn.extend({swipe:function(n,e,o){var i=!1,a={},c="boolean"!=typeof n||n,s="boolean"!=typeof e||e;this.bind("touchstart",function(t){i=!0,a={};t=u(t);null!=t&&(i=!1,a.startX=t.X,a.startY=t.Y)}),this.bind("touchmove",function(t){t.preventDefault();t=u(t);null==t||i||!c&&r(t.X,t.Y,this)&&(i=!0)}),this.bind("touchend",function(t){t.preventDefault();t=u(t);null==t||i||(a.stopX=t.X,a.stopY=t.Y,a.distanceX=Math.abs(a.startX-a.stopX),a.distanceY=Math.abs(a.startY-a.stopY),!s&&r(a.stopX,a.stopY,this)||a.distanceX<40&&a.distanceY<40||(a.directionX=a.startX-a.stopX<0?"right":"left",a.directionY=a.startY-a.stopY<0?"down":"up",a.distanceX<40&&(a.directionX="n/a"),a.distanceY<40&&(a.directionY="n/a"),"function"==typeof n&&n(a),"function"==typeof e&&e(a),"function"==typeof o&&o(a)))})}})}(jQuery);
﻿!function(){var _hoverState=-1,_interval,_slideVal=100,_rated=!1,_rating=0,_newRate=0,_commentType="user",_teamId=-1,_featChange=!1,_articleId=-1,_mts_adCount=1;function runAd(){if("undefined"!=typeof _MTS_PARA_AD&&"undefined"!=typeof googletag){var e=parseInt(_MTS_PARA_AD);if(!isNaN(e)&&0<=e&&(0<_MTS_ITEM_ADS.length||0<_MTS_ITEM_ADS_MOBILE.length)){var t=_MTS_JQUERY(".news_content_widget .body p"),a=-1,o=-1;if(!(0<t.parents("table").length)){for(var n,i,_,l=0,d=t.length-1;l<d;l++){var r=_MTS_JQUERY.trim(t[l].innerHTML);if(20<_MTS_JQUERY("<p/>").append(r).text().length||100<r.length){if(a++,e<=++o)break}else a++}e<=o&&t.length>a&&(n="mts_ad_"+(new Date).getTime(),_=_MTS_JQUERY("<div id='"+n+"' class='borderedAd'></div>"),!(0<(i=_MTS_JQUERY(t[a])).length)||i.next()&&i.next().attr("id")&&i.next().attr("id").startsWith("mts_ad")||(i.after(_),ad=_MTS_ITEM_ADS[0]||{width:0,height:0},mobileAd=_MTS_ITEM_ADS_MOBILE[0]||{width:0,height:0},0<=ad.location.indexOf("widget_")?_.append("<div class='custom_widget'><input name='widgetName' type='hidden' value='"+ad.location.split("_")[1]+"' /></div></div>"):(i=googletag.sizeMapping().addSize([0,0],[mobileAd.width,mobileAd.height]).addSize([1024,768],[ad.width,ad.height]).build(),(_=googletag.defineSlot(ad.location,[ad.width||300,ad.height||250],n))&&(_.defineSizeMapping(i).setTargeting(ad.target,ad.target2).setCollapseEmptyDiv(!0).addService(googletag.pubads()),googletag.display(n))),_mts_adCount++))}}}}function vidMenu(e,t){var a=_MTS_JQUERY(".videos"),o=a[0].scrollHeight-a[0].clientHeight;a.scrollTop(o-o*(t.value/100)),_slideVal=t.value}function getMiniCalendar(e,t,a,o){new Date;sDate=new Date(o),"Invalid Date"==sDate&&(sDate=new Date),_cal.clearRecycle(),_cal.mode=e,_cal.wndTitle=t,_cal.setContract(sDate.getFullYear(),0,0),_cal.maxYear=_cal.startContractYear+5,_cal.setCallback(a),_cal.setSelection(sDate.getMonth()+1,sDate.getDate(),sDate.getFullYear()),_cal.show(100,100),_MTS_JQUERY(".listingBg").css({height:_MTS_JQUERY(document).height(),zIndex:113}),_MTS_JQUERY(".listingBg").show()}function getComments(){var e;"function"!=typeof loadComments?setTimeout(getComments,250):((void 0===_articleId||_articleId<1)&&(_articleId=_MTS_JQUERY("#MTS_STORY_ID").val()),(e=[]).push({name:"newsId",value:_articleId}),e.push({name:"currIdx",value:0}),e.push({name:"commentType",value:_commentType}),e.push({name:"type",value:1}),loadComments(e,_articleId,0))}function sirsz(){var e=_MTS_JQUERY("#story .body img");_MTS_JQUERY(".storyWrapper").width()<=e.width()&&e.css({width:"100%"})}function fireWidgetsLoaded(){_articleId=_MTS_JQUERY("#MTS_STORY_ID").val(),_rated?_MTS_JQUERY(".user_rat").show():_MTS_JQUERY(".user_rat").hide(),sirsz(),MTS_updateRegionCss(),MTS_updateColumnCss(),runAd()}function getStory(a){var e,o=0,n=0,t=_MTS_JQUERY("#delPN_"+a),t=(0<t.length&&(0<(e=_MTS_JQUERY(t.parent().parent().prevAll(".item")[0])).length&&(o=e.find(".delPNBtn").attr("id").split("_")[1],0==t.parent().parent().next(".item").prevAll(".item").length&&e.parents(".news_panel_widget").find(".showMore").click()),0<(e=_MTS_JQUERY(t.parent().parent().nextAll(".item")[0])).length&&(n=e.find(".delPNBtn").attr("id").split("_")[1])),[]);t.push({name:"id",value:a}),t.push({name:"nextId",value:o}),t.push({name:"prevId",value:n}),ajax("/api/getPortalNewsContent.aspx",t,function(e){_MTS_JQUERY(window).off("scroll");var t=_MTS_JQUERY("#newsItem");t.empty(),t.html(e),_MTS_waitingOnLoad=[],_MTS_widgetsReady=!1,_archivedAlbum=[],MTS_loadWidgets(),"undefined"!=typeof googletag&&googletag.pubads().refresh(),"undefined"!=typeof adjustNoUserPrompt&&adjustNoUserPrompt(),o<=0&&n<=0&&window.scrollTo(0,0),trackItem(a,"PortalNews"),_MTS_JQUERY(document).one("scroll",getComments),_MTS_JQUERY(document).one("widgetsloaded",function(){_MTS_JQUERY(document).trigger("resetSlider"),addInfoBox()})})}function addInfoBox(){var e,t,a,o;"undefined"!=typeof _info_box&&null!=_info_box&&"undefined"!=_info_box.DataValue&&0<_info_box.DataValue.length&&(e=_MTS_JQUERY(".storyWrapper p"),t=_info_box.WebParagraphLocation,(a=_MTS_JQUERY("<div>")).attr("class","mts_infoBox"),o=_info_box.DataValue,o=anchorme({input:o,options:{attributes:function(e){return{target:"_blank"}}}}),a.html(o),null!=_info_box.WebBackgroundColor&&0<_info_box.WebBackgroundColor.length&&a.css("backgroundColor","#"+_info_box.WebBackgroundColor),null!=_info_box.WebFontColor&&0<_info_box.WebFontColor.length&&a.css("color","#"+_info_box.WebFontColor),null!=_info_box.WebFont&&0<_info_box.WebFont.length&&a.css("fontFamily",_info_box.WebFont),a.css("float",0<_info_box.WebLocation?_webLocation[_info_box.WebLocation]:"left"),(t<=1?_MTS_JQUERY(e[0]):t-1<e.length?_MTS_JQUERY(e[t-1]):_MTS_JQUERY(e[e.length-1])).prepend(a))}function displayFeatureImageSelectBox(e){var a=[],o=(a.push({name:"newsId",value:_articleId}),new PopupDialog);o.NewCustomDialog("","Select an image to feature",function(){var t=o.GetPopupId();o.AddElement("divWithClass","",null,null,"featureImageCtr"),o.AddButton("Save",saveFeatureImage,e),o.AddButton("Cancel",hidePopup),o.Show(),ajax("/api/getFeatureImageSelectBox.aspx",a,function(e){_MTS_JQUERY(".featureImageCtr").html(e),_isFeatured&&_MTS_JQUERY("#popUpDialog_"+t+" #image_"+_featureImageId).addClass("photoBlockSelected"),_MTS_JQUERY("#popUpDialog_"+t+" .photoBlock").click(function(){_MTS_JQUERY(".photoBlock").removeClass("photoBlockSelected"),_MTS_JQUERY(this).addClass("photoBlockSelected")});e=_MTS_JQUERY("#popUpDialog_"+t+" .photoBlock");e.css({height:e.outerWidth()+"px"})})},hidePopup,null)}function saveFeatureImage(e,t,a){var o=_MTS_JQUERY(".photoBlockSelected");0<o.length&&(_featureImageId=parseInt(o.attr("id").split("_")[1]),hidePopup(e),featureNews(a),_isFeatured=!0,_MTS_JQUERY("#selectFeatureImage").show())}function featureNews(e){var t=[];_MTS_JQUERY("#editFeatLink").html(e),t.push({name:"id",value:_articleId}),t.push({name:"til",value:e}),t.push({name:"featureImageId",value:_featureImageId}),_MTS_JQUERY("#featApply").show(),ajax("/api/editfeatured.aspx",t,function(e){_MTS_JQUERY("#featApply").hide();var t=_MTS_JQUERY("#cancelFeatLink");0==t.length?_MTS_JQUERY("#editFeatLink").parent().append("<a title='Cancel' id='cancelFeatLink' href='javascript:void(0);'>Cancel</a>"):t.show()})}function hidePopup(e){e.Hide()}_MTS_JQUERY(document).ready(function(){$("#previousStoryTitle");$(window).scroll(function(){var e=$("#newsItem");0<e.length&&(e=e.offset().bottom,$(window).scrollTop()>e&&$("#previousStoryTitle").css({top:e+"px"}))}),_MTS_JQUERY(document).on("click","#previousStoryTitle, .storyArrowRight, .storyArrowLeft, #nextStoryTitle",function(){var e=_MTS_JQUERY(this).attr("class").split("_")[1];history.pushState({},"",_MTS_SITEURL+_MTS_JQUERY("#nsUrl_"+e).val()),getStory(e)}),_MTS_JQUERY(document).on("click",".ytThumb",function(){for(var e=_MTS_JQUERY("#vidPlayer"),t=("none"==e.css("display")&&((n=_MTS_JQUERY(".bg")).height(_MTS_JQUERY(document).height()),n.show(),e.center(),e.fadeTo(600,1,function(){e.show(),_MTS_JQUERY(".videoPlayer").show()})),""),a=1,o=this.id.split("_").length;a<o;a++)t+=(1<a?"_":"")+this.id.split("_")[a];var n=_MTS_JQUERY.trim(_MTS_JQUERY("#vidTitle_"+t).html()),i=_MTS_JQUERY.trim(_MTS_JQUERY("#vidDesc_"+t).html()),_=_MTS_JQUERY.trim(_MTS_JQUERY("#vidAuth_"+t).val());"function"==typeof chkPlayer&&null!=chkPlayer&&chkPlayer(),playVideo(t),_MTS_JQUERY("#vidTitle").html(n),_MTS_JQUERY("#vidDesc").html(i),_MTS_JQUERY("#vidAuth").html(0<_.length?_:"Unknown")}),_MTS_JQUERY(document).on("click","#closePlayer",function(){stopVideo();var e=_MTS_JQUERY("#vidPlayer");e.fadeTo(600,0,function(){e.hide(),_MTS_JQUERY(".bg").hide()})}),_MTS_JQUERY(document).on("click","#editFeatLink",function(){getMiniCalendar("select","Date Range",function(e,t,a){displayFeatureImageSelectBox(e.toString()+"/"+t.toString()+"/"+a.toString()+" 12:00 AM")},_MTS_JQUERY.trim(this.innerHTML))}),_MTS_JQUERY(document).on("click","#cancelFeatLink",function(){_MTS_JQUERY("#editFeatLink").html("Not Featured"),_MTS_JQUERY(this).hide(),_MTS_JQUERY("#featApply").show(),ajax("/api/editfeatured.aspx",[{name:"id",value:_articleId}],function(e){_MTS_JQUERY("#featApply").hide()})}),_MTS_JQUERY(document).on("click",".photoThumb",function(){var e=GetImageById(GetIdFromThis(this,"photo_"));OpenWhiteBox(e)}),_MTS_JQUERY(document).on("click","#tweetBtn",function(){var e=[];e.push({name:"mode",value:"twittershare"}),e.push({name:"id",value:_articleId}),ajax("/api/updateNewsTracking.aspx",e,function(e){})}),_MTS_JQUERY(document).on("click","#fbShare",function(){var e=[];e.push({name:"mode",value:"facebookshare"}),e.push({name:"id",value:_articleId}),ajax("/api/updateNewsTracking.aspx",e,function(e){})}),_MTS_JQUERY(document).on("click","#followBtn",function(){var e=[];e.push({name:"id",value:_articleId}),e.push({name:"type",value:"newsitem"}),"Unfollow"==_MTS_JQUERY(".followIcon").attr("title")?e.push({name:"mode",value:"deltag"}):e.push({name:"mode",value:"addtag"}),ajax("/api/updateNotificationSettings.aspx",e,function(e){"Unfollow"==_MTS_JQUERY(".followIcon").attr("title")?_MTS_JQUERY(".followIcon").attr("title","Follow").attr("class","far fa-user-check followIcon unfollowed"):_MTS_JQUERY(".followIcon").attr("title","Unfollow").attr("class","fas fa-user-check followIcon followed")})})}),_MTS_JQUERY(document).on("widgetsloaded",fireWidgetsLoaded),_MTS_JQUERY(document).one("widgetsloaded",function(){var fb_embed_post_template,embedPost;addInfoBox(),trackItem(_articleId,"PortalNews"),getComments(),"object"==typeof FB&&(fb_embed_post_template='<div class="fb-post" data-href="{embed_post_url}" data-width="{embed_post_width}"></div>',embedPost=!1,_MTS_JQUERY.each(_MTS_JQUERY(".FacebookEmbedPost"),function(e,t){embedPost=fb_embed_post_template.replace("{embed_post_url}",_MTS_JQUERY(t).data("post")).replace("{embed_post_width}",_MTS_JQUERY(t).data("width")),_MTS_JQUERY(this).replaceWith(embedPost)}),FB.XFBML.parse()),_cal.initialize(),_cal.centerMiniCal(),_MTS_JQUERY("#back").click(function(){1<window.history.length?BackAndRefresh():window.close()}),_MTS_JQUERY("#rater").mousemove(function(e){5<(_newRate=Math.ceil((e.pageX-(_MTS_JQUERY("#mainContent").offset().left+this.offsetLeft))/20))?_newRate=5:_newRate<1&&(_newRate=1),_MTS_JQUERY(".gold_stars").css("width",20*_newRate+"px")}).hover(function(){},function(){_MTS_JQUERY(".gold_stars").css("width",_rating+"px")}).click(function(){_rating=20*_newRate;var params=[];params.push({name:"id",value:_articleId}),params.push({name:"r",value:_newRate}),ajax("/api/rateArticle.aspx",params,function(ret){var o;eval("o = "+ret),0<o.rCount&&(_MTS_JQUERY("#user_score").html((o.rTotal/o.rCount).toFixed(2)),_MTS_JQUERY(".count").html("("+o.rCount+" ratings)")),_MTS_JQUERY(".user_rat").show()})}),_rated&&_MTS_JQUERY(".gold_stars").css("width",_rating+"px"),_MTS_JQUERY("#vidPlayer, .bg").appendTo("body"),_MTS_JQUERY("#thisButtonWillActivateVideoPlayer").click(function(){var e,t=_MTS_JQUERY("#vidPlayer");"none"==t.css("display")&&((e=_MTS_JQUERY(".bg")).height(_MTS_JQUERY(document).height()),e.show(),t.center(),t.fadeTo(600,1,function(){t.show(),_MTS_JQUERY(".videoPlayer").show()}))}),_MTS_JQUERY.slider&&_MTS_JQUERY("#vidScroller").slider({create:vidMenu,orientation:"vertical",slide:vidMenu,min:0,max:100,value:100}),_MTS_JQUERY(".vidHover").hover(function(){var e=this.id,t=_MTS_JQUERY("#vidScroller").slider("option","value");0<_interval&&clearInterval(_interval),_interval="vidDown"==e?(_hoverState=0,setInterval(function(){0==_hoverState&&0<t?(t-=1,VidHoverMenu(t)):clearInterval(_interval)},10)):(_hoverState=1,setInterval(function(){1==_hoverState&&t<100?(t+=1,VidHoverMenu(t)):clearInterval(_interval)},10))}),_MTS_JQUERY(".vidHover").mouseout(function(){_hoverState=-1,clearInterval(_interval)}),_MTS_JQUERY(window).onresize=function(){sirsz()},"function"!=typeof emailShare&&_MTS_JQUERY(".mts_widget .shareBtn, .mts_widget .shareTitle").hide()})}();
﻿!function (A, u) { "object" == typeof exports && "undefined" != typeof module ? module.exports = u() : "function" == typeof define && define.amd ? define(u) : (A = A || self).anchorme = u() }(this, function () { "use strict"; var t = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}; function A(A) { return A && A.__esModule && Object.prototype.hasOwnProperty.call(A, "default") ? A.default : A } function u(A, u) { return A(u = { exports: {} }, u.exports), u.exports } var N = u(function (A, u) { Object.defineProperty(u, "__esModule", { value: !0 }), u.TLDs = "(AAA|AARP|ABARTH|ABB|ABBOTT|ABBVIE|ABC|ABLE|ABOGADO|ABUDHABI|AC|ACADEMY|ACCENTURE|ACCOUNTANT|ACCOUNTANTS|ACO|ACTOR|AD|ADAC|ADS|ADULT|AE|AEG|AERO|AETNA|AF|AFAMILYCOMPANY|AFL|AFRICA|AG|AGAKHAN|AGENCY|AI|AIG|AIGO|AIRBUS|AIRFORCE|AIRTEL|AKDN|AL|ALFAROMEO|ALIBABA|ALIPAY|ALLFINANZ|ALLSTATE|ALLY|ALSACE|ALSTOM|AM|AMERICANEXPRESS|AMERICANFAMILY|AMEX|AMFAM|AMICA|AMSTERDAM|ANALYTICS|ANDROID|ANQUAN|ANZ|AO|AOL|APARTMENTS|APP|APPLE|AQ|AQUARELLE|AR|ARAB|ARAMCO|ARCHI|ARMY|ARPA|ART|ARTE|AS|ASDA|ASIA|ASSOCIATES|AT|ATHLETA|ATTORNEY|AU|AUCTION|AUDI|AUDIBLE|AUDIO|AUSPOST|AUTHOR|AUTO|AUTOS|AVIANCA|AW|AWS|AX|AXA|AZ|AZURE|BA|BABY|BAIDU|BANAMEX|BANANAREPUBLIC|BAND|BANK|BAR|BARCELONA|BARCLAYCARD|BARCLAYS|BAREFOOT|BARGAINS|BASEBALL|BASKETBALL|BAUHAUS|BAYERN|BB|BBC|BBT|BBVA|BCG|BCN|BD|BE|BEATS|BEAUTY|BEER|BENTLEY|BERLIN|BEST|BESTBUY|BET|BF|BG|BH|BHARTI|BI|BIBLE|BID|BIKE|BING|BINGO|BIO|BIZ|BJ|BLACK|BLACKFRIDAY|BLOCKBUSTER|BLOG|BLOOMBERG|BLUE|BM|BMS|BMW|BN|BNPPARIBAS|BO|BOATS|BOEHRINGER|BOFA|BOM|BOND|BOO|BOOK|BOOKING|BOSCH|BOSTIK|BOSTON|BOT|BOUTIQUE|BOX|BR|BRADESCO|BRIDGESTONE|BROADWAY|BROKER|BROTHER|BRUSSELS|BS|BT|BUDAPEST|BUGATTI|BUILD|BUILDERS|BUSINESS|BUY|BUZZ|BV|BW|BY|BZ|BZH|CA|CAB|CAFE|CAL|CALL|CALVINKLEIN|CAM|CAMERA|CAMP|CANCERRESEARCH|CANON|CAPETOWN|CAPITAL|CAPITALONE|CAR|CARAVAN|CARDS|CARE|CAREER|CAREERS|CARS|CASA|CASE|CASEIH|CASH|CASINO|CAT|CATERING|CATHOLIC|CBA|CBN|CBRE|CBS|CC|CD|CEB|CENTER|CEO|CERN|CF|CFA|CFD|CG|CH|CHANEL|CHANNEL|CHARITY|CHASE|CHAT|CHEAP|CHINTAI|CHRISTMAS|CHROME|CHURCH|CI|CIPRIANI|CIRCLE|CISCO|CITADEL|CITI|CITIC|CITY|CITYEATS|CK|CL|CLAIMS|CLEANING|CLICK|CLINIC|CLINIQUE|CLOTHING|CLOUD|CLUB|CLUBMED|CM|CN|CO|COACH|CODES|COFFEE|COLLEGE|COLOGNE|COM|COMCAST|COMMBANK|COMMUNITY|COMPANY|COMPARE|COMPUTER|COMSEC|CONDOS|CONSTRUCTION|CONSULTING|CONTACT|CONTRACTORS|COOKING|COOKINGCHANNEL|COOL|COOP|CORSICA|COUNTRY|COUPON|COUPONS|COURSES|CPA|CR|CREDIT|CREDITCARD|CREDITUNION|CRICKET|CROWN|CRS|CRUISE|CRUISES|CSC|CU|CUISINELLA|CV|CW|CX|CY|CYMRU|CYOU|CZ|DABUR|DAD|DANCE|DATA|DATE|DATING|DATSUN|DAY|DCLK|DDS|DE|DEAL|DEALER|DEALS|DEGREE|DELIVERY|DELL|DELOITTE|DELTA|DEMOCRAT|DENTAL|DENTIST|DESI|DESIGN|DEV|DHL|DIAMONDS|DIET|DIGITAL|DIRECT|DIRECTORY|DISCOUNT|DISCOVER|DISH|DIY|DJ|DK|DM|DNP|DO|DOCS|DOCTOR|DOG|DOMAINS|DOT|DOWNLOAD|DRIVE|DTV|DUBAI|DUCK|DUNLOP|DUPONT|DURBAN|DVAG|DVR|DZ|EARTH|EAT|EC|ECO|EDEKA|EDU|EDUCATION|EE|EG|EMAIL|EMERCK|ENERGY|ENGINEER|ENGINEERING|ENTERPRISES|EPSON|EQUIPMENT|ER|ERICSSON|ERNI|ES|ESQ|ESTATE|ESURANCE|ET|ETISALAT|EU|EUROVISION|EUS|EVENTS|EXCHANGE|EXPERT|EXPOSED|EXPRESS|EXTRASPACE|FAGE|FAIL|FAIRWINDS|FAITH|FAMILY|FAN|FANS|FARM|FARMERS|FASHION|FAST|FEDEX|FEEDBACK|FERRARI|FERRERO|FI|FIAT|FIDELITY|FIDO|FILM|FINAL|FINANCE|FINANCIAL|FIRE|FIRESTONE|FIRMDALE|FISH|FISHING|FIT|FITNESS|FJ|FK|FLICKR|FLIGHTS|FLIR|FLORIST|FLOWERS|FLY|FM|FO|FOO|FOOD|FOODNETWORK|FOOTBALL|FORD|FOREX|FORSALE|FORUM|FOUNDATION|FOX|FR|FREE|FRESENIUS|FRL|FROGANS|FRONTDOOR|FRONTIER|FTR|FUJITSU|FUJIXEROX|FUN|FUND|FURNITURE|FUTBOL|FYI|GA|GAL|GALLERY|GALLO|GALLUP|GAME|GAMES|GAP|GARDEN|GAY|GB|GBIZ|GD|GDN|GE|GEA|GENT|GENTING|GEORGE|GF|GG|GGEE|GH|GI|GIFT|GIFTS|GIVES|GIVING|GL|GLADE|GLASS|GLE|GLOBAL|GLOBO|GM|GMAIL|GMBH|GMO|GMX|GN|GODADDY|GOLD|GOLDPOINT|GOLF|GOO|GOODYEAR|GOOG|GOOGLE|GOP|GOT|GOV|GP|GQ|GR|GRAINGER|GRAPHICS|GRATIS|GREEN|GRIPE|GROCERY|GROUP|GS|GT|GU|GUARDIAN|GUCCI|GUGE|GUIDE|GUITARS|GURU|GW|GY|HAIR|HAMBURG|HANGOUT|HAUS|HBO|HDFC|HDFCBANK|HEALTH|HEALTHCARE|HELP|HELSINKI|HERE|HERMES|HGTV|HIPHOP|HISAMITSU|HITACHI|HIV|HK|HKT|HM|HN|HOCKEY|HOLDINGS|HOLIDAY|HOMEDEPOT|HOMEGOODS|HOMES|HOMESENSE|HONDA|HORSE|HOSPITAL|HOST|HOSTING|HOT|HOTELES|HOTELS|HOTMAIL|HOUSE|HOW|HR|HSBC|HT|HU|HUGHES|HYATT|HYUNDAI|IBM|ICBC|ICE|ICU|ID|IE|IEEE|IFM|IKANO|IL|IM|IMAMAT|IMDB|IMMO|IMMOBILIEN|IN|INC|INDUSTRIES|INFINITI|INFO|ING|INK|INSTITUTE|INSURANCE|INSURE|INT|INTEL|INTERNATIONAL|INTUIT|INVESTMENTS|IO|IPIRANGA|IQ|IR|IRISH|IS|ISMAILI|IST|ISTANBUL|IT|ITAU|ITV|IVECO|JAGUAR|JAVA|JCB|JCP|JE|JEEP|JETZT|JEWELRY|JIO|JLL|JM|JMP|JNJ|JO|JOBS|JOBURG|JOT|JOY|JP|JPMORGAN|JPRS|JUEGOS|JUNIPER|KAUFEN|KDDI|KE|KERRYHOTELS|KERRYLOGISTICS|KERRYPROPERTIES|KFH|KG|KH|KI|KIA|KIM|KINDER|KINDLE|KITCHEN|KIWI|KM|KN|KOELN|KOMATSU|KOSHER|KP|KPMG|KPN|KR|KRD|KRED|KUOKGROUP|KW|KY|KYOTO|KZ|LA|LACAIXA|LAMBORGHINI|LAMER|LANCASTER|LANCIA|LAND|LANDROVER|LANXESS|LASALLE|LAT|LATINO|LATROBE|LAW|LAWYER|LB|LC|LDS|LEASE|LECLERC|LEFRAK|LEGAL|LEGO|LEXUS|LGBT|LI|LIDL|LIFE|LIFEINSURANCE|LIFESTYLE|LIGHTING|LIKE|LILLY|LIMITED|LIMO|LINCOLN|LINDE|LINK|LIPSY|LIVE|LIVING|LIXIL|LK|LLC|LLP|LOAN|LOANS|LOCKER|LOCUS|LOFT|LOL|LONDON|LOTTE|LOTTO|LOVE|LPL|LPLFINANCIAL|LR|LS|LT|LTD|LTDA|LU|LUNDBECK|LUPIN|LUXE|LUXURY|LV|LY|MA|MACYS|MADRID|MAIF|MAISON|MAKEUP|MAN|MANAGEMENT|MANGO|MAP|MARKET|MARKETING|MARKETS|MARRIOTT|MARSHALLS|MASERATI|MATTEL|MBA|MC|MCKINSEY|MD|ME|MED|MEDIA|MEET|MELBOURNE|MEME|MEMORIAL|MEN|MENU|MERCKMSD|METLIFE|MG|MH|MIAMI|MICROSOFT|MIL|MINI|MINT|MIT|MITSUBISHI|MK|ML|MLB|MLS|MM|MMA|MN|MO|MOBI|MOBILE|MODA|MOE|MOI|MOM|MONASH|MONEY|MONSTER|MORMON|MORTGAGE|MOSCOW|MOTO|MOTORCYCLES|MOV|MOVIE|MP|MQ|MR|MS|MSD|MT|MTN|MTR|MU|MUSEUM|MUTUAL|MV|MW|MX|MY|MZ|NA|NAB|NAGOYA|NAME|NATIONWIDE|NATURA|NAVY|NBA|NC|NE|NEC|NET|NETBANK|NETFLIX|NETWORK|NEUSTAR|NEW|NEWHOLLAND|NEWS|NEXT|NEXTDIRECT|NEXUS|NF|NFL|NG|NGO|NHK|NI|NICO|NIKE|NIKON|NINJA|NISSAN|NISSAY|NL|NO|NOKIA|NORTHWESTERNMUTUAL|NORTON|NOW|NOWRUZ|NOWTV|NP|NR|NRA|NRW|NTT|NU|NYC|NZ|OBI|OBSERVER|OFF|OFFICE|OKINAWA|OLAYAN|OLAYANGROUP|OLDNAVY|OLLO|OM|OMEGA|ONE|ONG|ONL|ONLINE|ONYOURSIDE|OOO|OPEN|ORACLE|ORANGE|ORG|ORGANIC|ORIGINS|OSAKA|OTSUKA|OTT|OVH|PA|PAGE|PANASONIC|PARIS|PARS|PARTNERS|PARTS|PARTY|PASSAGENS|PAY|PCCW|PE|PET|PF|PFIZER|PG|PH|PHARMACY|PHD|PHILIPS|PHONE|PHOTO|PHOTOGRAPHY|PHOTOS|PHYSIO|PICS|PICTET|PICTURES|PID|PIN|PING|PINK|PIONEER|PIZZA|PK|PL|PLACE|PLAY|PLAYSTATION|PLUMBING|PLUS|PM|PN|PNC|POHL|POKER|POLITIE|PORN|POST|PR|PRAMERICA|PRAXI|PRESS|PRIME|PRO|PROD|PRODUCTIONS|PROF|PROGRESSIVE|PROMO|PROPERTIES|PROPERTY|PROTECTION|PRU|PRUDENTIAL|PS|PT|PUB|PW|PWC|PY|QA|QPON|QUEBEC|QUEST|QVC|RACING|RADIO|RAID|RE|READ|REALESTATE|REALTOR|REALTY|RECIPES|RED|REDSTONE|REDUMBRELLA|REHAB|REISE|REISEN|REIT|RELIANCE|REN|RENT|RENTALS|REPAIR|REPORT|REPUBLICAN|REST|RESTAURANT|REVIEW|REVIEWS|REXROTH|RICH|RICHARDLI|RICOH|RIGHTATHOME|RIL|RIO|RIP|RMIT|RO|ROCHER|ROCKS|RODEO|ROGERS|ROOM|RS|RSVP|RU|RUGBY|RUHR|RUN|RW|RWE|RYUKYU|SA|SAARLAND|SAFE|SAFETY|SAKURA|SALE|SALON|SAMSCLUB|SAMSUNG|SANDVIK|SANDVIKCOROMANT|SANOFI|SAP|SARL|SAS|SAVE|SAXO|SB|SBI|SBS|SC|SCA|SCB|SCHAEFFLER|SCHMIDT|SCHOLARSHIPS|SCHOOL|SCHULE|SCHWARZ|SCIENCE|SCJOHNSON|SCOR|SCOT|SD|SE|SEARCH|SEAT|SECURE|SECURITY|SEEK|SELECT|SENER|SERVICES|SES|SEVEN|SEW|SEX|SEXY|SFR|SG|SH|SHANGRILA|SHARP|SHAW|SHELL|SHIA|SHIKSHA|SHOES|SHOP|SHOPPING|SHOUJI|SHOW|SHOWTIME|SHRIRAM|SI|SILK|SINA|SINGLES|SITE|SJ|SK|SKI|SKIN|SKY|SKYPE|SL|SLING|SM|SMART|SMILE|SN|SNCF|SO|SOCCER|SOCIAL|SOFTBANK|SOFTWARE|SOHU|SOLAR|SOLUTIONS|SONG|SONY|SOY|SPACE|SPORT|SPOT|SPREADBETTING|SR|SRL|SS|ST|STADA|STAPLES|STAR|STATEBANK|STATEFARM|STC|STCGROUP|STOCKHOLM|STORAGE|STORE|STREAM|STUDIO|STUDY|STYLE|SU|SUCKS|SUPPLIES|SUPPLY|SUPPORT|SURF|SURGERY|SUZUKI|SV|SWATCH|SWIFTCOVER|SWISS|SX|SY|SYDNEY|SYMANTEC|SYSTEMS|SZ|TAB|TAIPEI|TALK|TAOBAO|TARGET|TATAMOTORS|TATAR|TATTOO|TAX|TAXI|TC|TCI|TD|TDK|TEAM|TECH|TECHNOLOGY|TEL|TEMASEK|TENNIS|TEVA|TF|TG|TH|THD|THEATER|THEATRE|TIAA|TICKETS|TIENDA|TIFFANY|TIPS|TIRES|TIROL|TJ|TJMAXX|TJX|TK|TKMAXX|TL|TM|TMALL|TN|TO|TODAY|TOKYO|TOOLS|TOP|TORAY|TOSHIBA|TOTAL|TOURS|TOWN|TOYOTA|TOYS|TR|TRADE|TRADING|TRAINING|TRAVEL|TRAVELCHANNEL|TRAVELERS|TRAVELERSINSURANCE|TRUST|TRV|TT|TUBE|TUI|TUNES|TUSHU|TV|TVS|TW|TZ|UA|UBANK|UBS|UG|UK|UNICOM|UNIVERSITY|UNO|UOL|UPS|US|UY|UZ|VA|VACATIONS|VANA|VANGUARD|VC|VE|VEGAS|VENTURES|VERISIGN|VERSICHERUNG|VET|VG|VI|VIAJES|VIDEO|VIG|VIKING|VILLAS|VIN|VIP|VIRGIN|VISA|VISION|VIVA|VIVO|VLAANDEREN|VN|VODKA|VOLKSWAGEN|VOLVO|VOTE|VOTING|VOTO|VOYAGE|VU|VUELOS|WALES|WALMART|WALTER|WANG|WANGGOU|WATCH|WATCHES|WEATHER|WEATHERCHANNEL|WEBCAM|WEBER|WEBSITE|WED|WEDDING|WEIBO|WEIR|WF|WHOSWHO|WIEN|WIKI|WILLIAMHILL|WIN|WINDOWS|WINE|WINNERS|WME|WOLTERSKLUWER|WOODSIDE|WORK|WORKS|WORLD|WOW|WS|WTC|WTF|XBOX|XEROX|XFINITY|XIHUAN|XIN|XN--11B4C3D|XN--1CK2E1B|XN--1QQW23A|XN--2SCRJ9C|XN--30RR7Y|XN--3BST00M|XN--3DS443G|XN--3E0B707E|XN--3HCRJ9C|XN--3OQ18VL8PN36A|XN--3PXU8K|XN--42C2D9A|XN--45BR5CYL|XN--45BRJ9C|XN--45Q11C|XN--4GBRIM|XN--54B7FTA0CC|XN--55QW42G|XN--55QX5D|XN--5SU34J936BGSG|XN--5TZM5G|XN--6FRZ82G|XN--6QQ986B3XL|XN--80ADXHKS|XN--80AO21A|XN--80AQECDR1A|XN--80ASEHDB|XN--80ASWG|XN--8Y0A063A|XN--90A3AC|XN--90AE|XN--90AIS|XN--9DBQ2A|XN--9ET52U|XN--9KRT00A|XN--B4W605FERD|XN--BCK1B9A5DRE4C|XN--C1AVG|XN--C2BR7G|XN--CCK2B3B|XN--CG4BKI|XN--CLCHC0EA0B2G2A9GCD|XN--CZR694B|XN--CZRS0T|XN--CZRU2D|XN--D1ACJ3B|XN--D1ALF|XN--E1A4C|XN--ECKVDTC9D|XN--EFVY88H|XN--FCT429K|XN--FHBEI|XN--FIQ228C5HS|XN--FIQ64B|XN--FIQS8S|XN--FIQZ9S|XN--FJQ720A|XN--FLW351E|XN--FPCRJ9C3D|XN--FZC2C9E2C|XN--FZYS8D69UVGM|XN--G2XX48C|XN--GCKR3F0F|XN--GECRJ9C|XN--GK3AT1E|XN--H2BREG3EVE|XN--H2BRJ9C|XN--H2BRJ9C8C|XN--HXT814E|XN--I1B6B1A6A2E|XN--IMR513N|XN--IO0A7I|XN--J1AEF|XN--J1AMH|XN--J6W193G|XN--JLQ61U9W7B|XN--JVR189M|XN--KCRX77D1X4A|XN--KPRW13D|XN--KPRY57D|XN--KPU716F|XN--KPUT3I|XN--L1ACC|XN--LGBBAT1AD8J|XN--MGB9AWBF|XN--MGBA3A3EJT|XN--MGBA3A4F16A|XN--MGBA7C0BBN0A|XN--MGBAAKC7DVF|XN--MGBAAM7A8H|XN--MGBAB2BD|XN--MGBAH1A3HJKRD|XN--MGBAI9AZGQP6J|XN--MGBAYH7GPA|XN--MGBBH1A|XN--MGBBH1A71E|XN--MGBC0A9AZCG|XN--MGBCA7DZDO|XN--MGBCPQ6GPA1A|XN--MGBERP4A5D4AR|XN--MGBGU82A|XN--MGBI4ECEXP|XN--MGBPL2FH|XN--MGBT3DHD|XN--MGBTX2B|XN--MGBX4CD0AB|XN--MIX891F|XN--MK1BU44C|XN--MXTQ1M|XN--NGBC5AZD|XN--NGBE9E0A|XN--NGBRX|XN--NODE|XN--NQV7F|XN--NQV7FS00EMA|XN--NYQY26A|XN--O3CW4H|XN--OGBPF8FL|XN--OTU796D|XN--P1ACF|XN--P1AI|XN--PBT977C|XN--PGBS0DH|XN--PSSY2U|XN--Q7CE6A|XN--Q9JYB4C|XN--QCKA1PMC|XN--QXA6A|XN--QXAM|XN--RHQV96G|XN--ROVU88B|XN--RVC1E0AM3E|XN--S9BRJ9C|XN--SES554G|XN--T60B56A|XN--TCKWE|XN--TIQ49XQYJ|XN--UNUP4Y|XN--VERMGENSBERATER-CTB|XN--VERMGENSBERATUNG-PWB|XN--VHQUV|XN--VUQ861B|XN--W4R85EL8FHU5DNRA|XN--W4RS40L|XN--WGBH1C|XN--WGBL6A|XN--XHQ521B|XN--XKC2AL3HYE2A|XN--XKC2DL3A5EE0H|XN--Y9A3AQ|XN--YFRO4I67O|XN--YGBI2AMMX|XN--ZFR164B|XXX|XYZ|YACHTS|YAHOO|YAMAXUN|YANDEX|YE|YODOBASHI|YOGA|YOKOHAMA|YOU|YOUTUBE|YT|YUN|ZA|ZAPPOS|ZARA|ZERO|ZIP|ZM|ZONE|ZUERICH|ZW|TEST)" }); A(N); N.TLDs; var L = u(function (A, E) { Object.defineProperty(E, "__esModule", { value: !0 }), E.openingParenthesis = "([\"'{", E.closingParenthesis = ")]\"'}", E.parenthesis = E.openingParenthesis.split("").map(function (A, u) { return "" + A + E.closingParenthesis.charAt(u) }), E.htmlAttributes = ["src", "data", "href", "cite", "formaction", "icon", "manifest", "poster", "codebase", "background", "profile", "usemap", "itemtype", "action", "longdesc", "classid", "archive"], E.nonLatinAlphabetRanges = "\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA697\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA793\\uA7A0-\\uA7AA\\uA7F8-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC", E.TLDs = N.TLDs }); A(L); L.openingParenthesis, L.closingParenthesis, L.parenthesis, L.htmlAttributes, L.nonLatinAlphabetRanges, L.TLDs; var B = u(function (A, u) { function S(A, u, E) { return "function" == typeof E ? E(A, u) : E } Object.defineProperty(u, "__esModule", { value: !0 }), u.transform = function (A, u) { var E = "", N = 1 / 0, C = {}, O = !1; if (u && u.specialTransform) for (var I = 0; I < u.specialTransform.length; I++) { var R = u.specialTransform[I]; if (R.test.test(A.string)) return R.transform(A.string, A) } return u && u.exclude && S(A.string, A, u.exclude) ? A.string : (u && u.protocol && (E = S(A.string, A, u.protocol)), E = A.protocol ? "" : E || (A.isEmail ? "mailto:" : A.isFile ? "file:///" : "http://"), u && u.truncate && (N = S(A.string, A, u.truncate)), u && u.middleTruncation && (O = S(A.string, A, u.middleTruncation)), u && u.attributes && (C = S(A.string, A, u.attributes)), "<a " + Object.keys(C).map(function (A) { return !0 === C[A] ? A : A + '="' + C[A] + '" ' }).join(" ") + 'href="' + E + A.string + '">' + (A.string.length > N ? O ? A.string.substring(0, Math.floor(N / 2)) + "�" + A.string.substring(A.string.length - Math.ceil(N / 2), A.string.length) : A.string.substring(0, N) + "�" : A.string) + "</a>") } }); A(B); B.transform; var e = u(function (A, u) { Object.defineProperty(u, "__esModule", { value: !0 }); var E = "([a-z0-9]+(-+[a-z0-9]+)*\\.)+(" + L.TLDs + ")", N = "a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()", C = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", O = "\\[(([a-f0-9:]+:+)+[a-f0-9]+)\\]", I = "(https?:|ftps?:)\\/\\/", R = "(((" + I + ")?(" + E + "|" + C + "|(" + I + ")(" + O + "|" + ("([a-z0-9]+(-+[a-z0-9]+)*\\.)+([a-z0-9][a-z0-9-]{0," + (Math.max.apply(t, L.TLDs.split("|").map(function (A) { return A.length })) - 2) + "}[a-z0-9])") + "))(?!@\\w)(:(\\d{1,5}))?)|(((https?:|ftps?:)\\/\\/)\\S+))", S = R + "((((\\/(([" + N + "]+(\\/[" + N + L.nonLatinAlphabetRanges + "]*)*))?)?)((\\?([" + N + "\\/?]*))?)((\\#([" + N + "\\/?]*))?))?\\b((([" + N + "\\/" + L.nonLatinAlphabetRanges + "][a-zA-Z\\d\\-_~+=\\/" + L.nonLatinAlphabetRanges + "]+)?))+)"; u.email = "\\b(mailto:)?([a-z0-9!#$%&'*+=?^_`{|}~-]+(\\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*)@(" + E + "|" + C + ")\\b", u.url = "(" + S + ")|(\\b" + R + "(((\\/(([a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()]+(\\/[a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()]*)*))?)?)((\\?([a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()\\/?]*))?)((\\#([a-zA-Z\\d\\-._~\\!$&*+,;=:@%'\"\\[\\]()\\/?]*))?))?\\b(([\\/]?))+)", u.file = "(file:\\/\\/\\/)([a-z]+:(\\/|\\\\)+)?([\\w.]+([\\/\\\\]?)+)+", u.final = "(" + u.url + ")|(" + u.email + ")|(" + u.file + ")", u.finalRegex = new RegExp(u.final, "gi"), u.ipRegex = new RegExp("^(" + C + "|" + O + ")$", "i"), u.emailRegex = new RegExp("^(" + u.email + ")$", "i"), u.fileRegex = new RegExp("^(" + u.file + ")$", "i"), u.urlRegex = new RegExp("^(" + u.url + ")$", "i"); var T = { isURL: 0, isEmail: 0, isFile: 0, file: { fileName: 0, protocol: 0 }, email: { protocol: 0, local: 0, host: 0 }, url: { ipv4: 0, ipv6: 0, ipv4Confirmation: 0, byProtocol: 0, port: 0, protocol1: 0, protocol2: 0, protocol3: 0, protocolWithDomain: 0, path: 0, secondPartOfPath: 0, query: 0, fragment: 0 } }; u.iidxes = T; for (var B = ["file:///some/file/path/filename.pdf", "mailto:e+_mail.me@sub.domain.com", "http://sub.domain.co.uk:3000/p/a/t/h_(asd)/h?q=abc123#dfdf", "http://www.????.com", "http://127.0.0.1:3000/p/a/t_(asd)/h?q=abc123#dfdf", "http://[2a00:1450:4025:401::67]/k/something", "a.org/abc/?_??"].join(" "), e = null, D = 0; null !== (e = u.finalRegex.exec(B));)0 === D && (T.isFile = e.lastIndexOf(e[0]), T.file.fileName = e.indexOf("filename.pdf"), T.file.protocol = e.indexOf("file:///")), 1 === D && (T.isEmail = e.lastIndexOf(e[0]), T.email.protocol = e.indexOf("mailto:"), T.email.local = e.indexOf("e+_mail.me"), T.email.host = e.indexOf("sub.domain.com")), 2 === D && (T.isURL = e.lastIndexOf(e[0]), T.url.protocol1 = e.indexOf("http://"), T.url.protocolWithDomain = e.indexOf("http://sub.domain.co.uk:3000"), T.url.port = e.indexOf("3000"), T.url.path = e.indexOf("/p/a/t/h_(asd)/h"), T.url.query = e.indexOf("q=abc123"), T.url.fragment = e.indexOf("dfdf")), 3 === D && (T.url.byProtocol = e.lastIndexOf("http://www.????.com"), T.url.protocol2 = e.lastIndexOf("http://")), 4 === D && (T.url.ipv4 = e.indexOf("127.0.0.1"), T.url.ipv4Confirmation = e.indexOf("0.")), 5 === D && (T.url.ipv6 = e.indexOf("2a00:1450:4025:401::67"), T.url.protocol3 = e.lastIndexOf("http://")), 6 === D && (T.url.secondPartOfPath = e.indexOf("??")), D++ }); A(e); e.email, e.url, e.file, e.finalRegex, e.ipRegex, e.emailRegex, e.fileRegex, e.urlRegex, e.iidxes; var D = u(function (A, u) { Object.defineProperty(u, "__esModule", { value: !0 }), u.checkParenthesis = function (A, u, E, N) { return N === u && (E.split(A).length - E.split(u).length == 1 || A === u && E.split(A).length % 2 == 0 || void 0) }, u.maximumAttrLength = L.htmlAttributes.sort(function (A, u) { return u.length - A.length })[0].length, u.isInsideAttribute = function (A) { return /\s[a-z0-9-]+=('|")$/i.test(A) || /: ?url\(('|")?$/i.test(A) }, u.isInsideAnchorTag = function (A, u, E) { for (var N = A.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), C = new RegExp("(?=(<a))(?!([\\s\\S]*)(<\\/a>)(" + N + "))[\\s\\S]*?(" + N + ")(?!\"|')", "gi"), O = null; null !== (O = C.exec(u));) { if (O.index + O[0].length === E) return !0 } return !1 } }); A(D); D.checkParenthesis, D.maximumAttrLength, D.isInsideAttribute, D.isInsideAnchorTag; return A(u(function (A, u) { Object.defineProperty(u, "__esModule", { value: !0 }); function T(I) { for (var R = [], S = null, A = function () { var A = S.index, N = A + S[0].length, C = S[0]; if ("/" === I.charAt(N) && (C += I.charAt(N), N++), -1 < L.closingParenthesis.indexOf(I.charAt(N)) && L.parenthesis.forEach(function (A) { var u = A.charAt(0), E = A.charAt(1); D.checkParenthesis(u, E, C, I.charAt(N)) && (C += I.charAt(N), N++) }), -1 !== ['""', "''", "()"].indexOf(I.charAt(A - 1) + I.charAt(N)) && D.isInsideAttribute(I.substring(A - D.maximumAttrLength - 15, A))) return "continue"; if (-1 < I.substring(N, I.length).indexOf("</a>") && -1 < I.substring(0, A).indexOf("<a") && D.isInsideAnchorTag(C, I, N)) return "continue"; if (S[e.iidxes.isURL]) { var u = (S[e.iidxes.url.path] || "") + (S[e.iidxes.url.secondPartOfPath] || "") || void 0, E = S[e.iidxes.url.protocol1] || S[e.iidxes.url.protocol2] || S[e.iidxes.url.protocol3]; R.push({ start: A, end: N, string: C, isURL: !0, protocol: E, port: S[e.iidxes.url.port], ipv4: S[e.iidxes.url.ipv4Confirmation] ? S[e.iidxes.url.ipv4] : void 0, ipv6: S[e.iidxes.url.ipv6], host: S[e.iidxes.url.byProtocol] ? void 0 : (S[e.iidxes.url.protocolWithDomain] || "").substr((E || "").length), confirmedByProtocol: !!S[e.iidxes.url.byProtocol], path: S[e.iidxes.url.byProtocol] ? void 0 : u, query: S[e.iidxes.url.query] || void 0, fragment: S[e.iidxes.url.fragment] || void 0 }) } else if (S[e.iidxes.isFile]) { var O = C.substr(8); R.push({ start: A, end: N, string: C, isFile: !0, protocol: S[e.iidxes.file.protocol], filename: S[e.iidxes.file.fileName], filePath: O, fileDirectory: O.substr(0, O.length - S[e.iidxes.file.fileName].length) }) } else S[e.iidxes.isEmail] ? R.push({ start: A, end: N, string: C, isEmail: !0, local: S[e.iidxes.email.local], protocol: S[e.iidxes.email.protocol], host: S[e.iidxes.email.host] }) : R.push({ start: A, end: N, string: C }) }; null !== (S = e.finalRegex.exec(I));)A(); return R } function E(A) { var u = "string" == typeof A ? { input: A, options: void 0, extensions: void 0 } : A, E = u.input, N = u.options, C = u.extensions; if (C) for (var O = 0; O < C.length; O++) { var I = C[O]; E = E.replace(I.test, I.transform) } var R = T(E), S = ""; for (O = 0; O < R.length; O++)S = (S || (0 === O ? E.substring(0, R[O].start) : "")) + B.transform(R[O], N) + (R[O + 1] ? E.substring(R[O].end, R[O + 1].start) : E.substring(R[O].end)); return S || E } E.list = function (A) { return T(A) }, E.validate = { ip: function (A) { return e.ipRegex.test(A) }, email: function (A) { return e.emailRegex.test(A) }, file: function (A) { return e.fileRegex.test(A) }, url: function (A) { return e.urlRegex.test(A) || e.ipRegex.test(A) } }, u.default = E })) });
﻿_MTS_JQUERY(document).one("widgetsloaded",function(){var e,o,t;0<_MTS_JQUERY("#loginBottom").length&&(e="",0<(o=_MTS_JQUERY("#loginBottom").attr("href")).length&&("string"==typeof _encodedPathAndQuery&&null!=_encodedPathAndQuery&&0<_encodedPathAndQuery.length&&(e=_encodedPathAndQuery),t="%2fPortal.aspx",_MTS_JQUERY(".lgBot").attr("href",o.replace(0<=o.indexOf(t)?t:"%2f",e)))),"function"==typeof ToggleCustomDropdowns&&ToggleCustomDropdowns(80,"#searchType:visible")});
﻿_MTS_JQUERY(document).delegate(".inlineCheerCopy","click",function(){var t=_MTS_JQUERY(this).attr("id"),e=-1,i=-1,a="",r=_MTS_JQUERY(this).children(".inlineCheerCount"),n=_MTS_JQUERY(this).find(".activeCheer");parseInt(_MTS_JQUERY("#CommentType").val()),_MTS_JQUERY(this).children("img");try{a=t.substr(12,1),e=t.substr(14),i=parseInt(r.html(),10)}catch(t){return}t=[];t.push({name:"i",value:e}),t.push({name:"t",value:a}),t.push({name:"c",value:i.toString()}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"ext/UpdateCheer.aspx",t,function(){"Unlike"===_MTS_JQUERY.trim(n.attr("title"))?(i--,r.html(i.toString()),n.attr("title","Like").attr("class","far fa-thumbs-up activeCheer unliked")):"Like"===_MTS_JQUERY.trim(n.attr("title"))&&(i++,r.html(i.toString()),n.attr("title","Unlike").attr("class","fas fa-thumbs-up activeCheer liked"))})});
﻿var _fancyFlagId="",_fancyFlagType="",_fancyFlagFlagged=!1,_fancyFlagGuid="",_fancyFlagClicked=!1;_MTS_JQUERY(document).delegate(".fancyFlag","mouseleave",function(){_fancyFlagClicked&&(_fancyFlagClicked=!1,_MTS_JQUERY("#flag_"+_fancyFlagGuid).attr("class","fas fa-flag-alt fancyUnflag"))}),_MTS_JQUERY(document).delegate(".fancyUnflag","mouseleave",function(){_fancyFlagClicked&&(_fancyFlagClicked=!1,_MTS_JQUERY("#flag_"+_fancyFlagGuid).attr("class","fas fa-flag-alt fancyFlag"))}),_MTS_JQUERY(document).delegate(".fancyFlagContainer","click",function(){var a=new Array;a.push({name:"i",value:_fancyFlagId}),a.push({name:"t",value:_fancyFlagType}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"ext/updateFlag.aspx",a,function(){_fancyFlagClicked=!0,1==(_fancyFlagFlagged=!_fancyFlagFlagged)?_MTS_JQUERY("#flag_"+_fancyFlagGuid).attr("title","Undo Report"):_MTS_JQUERY("#flag_"+_fancyFlagGuid).attr("title","Report")})});
﻿function InlineFlagLoad(){_MTS_JQUERY(".fancyFlag").each(function(a,l){"boolean"!=typeof _MTS_JQUERY(l)[0].wired&&!0!==_MTS_JQUERY(l)[0].wired&&(_MTS_JQUERY(l)[0].wired=!0,_MTS_JQUERY(l).click(InlineFlagClick))}),_MTS_JQUERY(".fancyUnflag").each(function(a,l){"boolean"!=typeof _MTS_JQUERY(l)[0].wired&&!0!==_MTS_JQUERY(l)[0].wired&&(_MTS_JQUERY(l)[0].wired=!0,_MTS_JQUERY(l).click(InlineUnflagClick))})}function InlineFlagClick(){UpdateFlag(_MTS_JQUERY(this),!1),_MTS_JQUERY(this).unbind("click"),_MTS_JQUERY(this).click(InlineUnflagClick)}function InlineUnflagClick(){UpdateFlag(_MTS_JQUERY(this),!0),_MTS_JQUERY(this).unbind("click"),_MTS_JQUERY(this).click(InlineFlagClick)}function UpdateFlag(a,l){var n=a.attr("id"),t=0,i=-1;if("boolean"==typeof l&&null!=l){try{t=n.substr(11,1),i=n.substr(13)}catch(a){return}!0===l?(_MTS_JQUERY(a).attr("class","fas fa-flag-alt fancyFlag"),a.attr("title","Undo Report")):(_MTS_JQUERY(a).attr("class","fas fa-flag-alt fancyUnflag"),a.attr("title","Flag As Inappropriate")),_MTS_JQUERY(a).siblings(".flagCommentTxt").html("Report");n=[];n.push({name:"i",value:i}),n.push({name:"t",value:t}),_MTS_ajaxPending=!0,_MTS_JQUERY.getJSON(_MTS_SITEURL+"ext/UpdateFlag.aspx",n)}}
﻿!function(){function d(){var e=_MTS_JQUERY(window),t=e.height()+1,i=_MTS_JQUERY(".navigation_logo_widget"),o=_MTS_JQUERY(".custom_header_widget"),o=i.length<1?o:i,n=_MTS_JQUERY(".navigation_admin_menu_widget"),a=_MTS_JQUERY(".navigationContainer"),_=_MTS_JQUERY(".showSecNav"),s=Math.ceil(a.height()),o=Math.ceil(o.outerHeight()+n.height()+s),n=s+n.height(),i=0<i.length?o:n,o=t-s,n=t-(0<a.next("div").length?i:s);a.hasClass("secNavFixed")?_.css({height:o+"px"}):_.css({height:n+e.scrollTop()+"px"})}function v(){0<_MTS_JQUERY(".mobileMenuBtn:visible").length?$(".dropNavBtn").hide():$(".dropNavBtn").show()}_MTS_JQUERY(document).one("widgetsloaded",function(){var i=_MTS_JQUERY(window),e=i.height()+1,t=_MTS_JQUERY(".navigation_logo_widget"),o=_MTS_JQUERY(".custom_header_widget"),o=t.length<1?o:t,n=_MTS_JQUERY(".navigation_admin_menu_widget"),a=_MTS_JQUERY(".section_navigation_widget"),_=_MTS_JQUERY(".navigationContainer"),s=_MTS_JQUERY(".masterMcWrap"),h=Math.ceil(_.outerHeight()),o=Math.ceil(o.outerHeight()+n.outerHeight()+h),g=h+n.outerHeight(),t=0<t.length?o:g,r=e-h,c=e-(0<_.next("div").length?t:h),l=(_MTS_JQUERY(".mainNavContainer").prepend("<i class='far fa-bars dropNavBtn'></i>"),v(),_.offset().top);i.scroll(function(){var e=i.scrollTop(),t=_MTS_JQUERY(".showSecNav");l<e?(_.addClass("secNavFixed"),t.css({height:r+"px"}),s.css({margin:n.height()+"px auto 0px auto"})):(_.removeClass("secNavFixed"),_.removeAttr("style"),t.css({height:c+e+"px"}),s.css({margin:"0px auto"}))}),_MTS_JQUERY(document).on("click",".dropNavBtn, .mobileMenuBtn",function(){a.toggleClass("showSecNav"),a.hasClass("showSecNav")?(d(),_MTS_JQUERY(".bigBlock").show()):(a.removeAttr("style"),_MTS_JQUERY(".bigBlock").hide())}),_MTS_JQUERY(".bigBlock").on("click",function(){a.removeClass("showSecNav"),a.removeAttr("style"),_MTS_JQUERY(".bigBlock").hide()}),_MTS_JQUERY(".dropLink").on("click",function(e){e.preventDefault(),e.stopPropagation();var e=_MTS_JQUERY(this).next(".sectionDrop"),t=0;e.find(".sectionDropItem").each(function(){t+=_MTS_JQUERY(this).outerHeight()}),e.height()<1?e.outerHeight(t):e.removeAttr("style"),_MTS_JQUERY(this).find(".snDropArrow").toggleClass("rotateArrow")}),i.resize(function(){d(),v()})})}();
