(function($){$.fn.ajaxSubmit=function(options){if(!this.length){log("ajaxSubmit: skipping submit process - no element selected");
return this;
}if(typeof options=="function"){options={success:options};
}var url=$.trim(this.attr("action"));
if(url){url=(url.match(/^([^#]+)/)||[])[1];
}url=url||window.location.href||"";
options=$.extend({url:url,type:this.attr("method")||"GET"},options||{});
var veto={};
this.trigger("form-pre-serialize",[this,options,veto]);
if(veto.veto){log("ajaxSubmit: submit vetoed via form-pre-serialize trigger");
return this;
}if(options.beforeSerialize&&options.beforeSerialize(this,options)===false){log("ajaxSubmit: submit aborted via beforeSerialize callback");
return this;
}var a=this.formToArray(options.semantic);
if(options.data){options.extraData=options.data;
for(var n in options.data){if(options.data[n] instanceof Array){for(var k in options.data[n]){a.push({name:n,value:options.data[n][k]});
}}else{a.push({name:n,value:options.data[n]});
}}}if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){log("ajaxSubmit: submit aborted via beforeSubmit callback");
return this;
}this.trigger("form-submit-validate",[a,this,options,veto]);
if(veto.veto){log("ajaxSubmit: submit vetoed via form-submit-validate trigger");
return this;
}var q=$.param(a);
if(options.type.toUpperCase()=="GET"){options.url+=(options.url.indexOf("?")>=0?"&":"?")+q;
options.data=null;
}else{options.data=q;
}var $form=this,callbacks=[];
if(options.resetForm){callbacks.push(function(){$form.resetForm();
});
}if(options.clearForm){callbacks.push(function(){$form.clearForm();
});
}if(!options.dataType&&options.target){var oldSuccess=options.success||function(){};
callbacks.push(function(data){$(options.target).html(data).each(oldSuccess,arguments);
});
}else{if(options.success){callbacks.push(options.success);
}}options.success=function(data,status){for(var i=0,max=callbacks.length;
i<max;
i++){callbacks[i].apply(options,[data,status,$form]);
}};
var files=$("input:file",this).fieldValue();
var found=false;
for(var j=0;
j<files.length;
j++){if(files[j]){found=true;
}}var multipart=false;
if(options.iframe||found||multipart){if(options.closeKeepAlive){$.get(options.closeKeepAlive,fileUpload);
}else{fileUpload();
}}else{$.ajax(options);
}this.trigger("form-submit-notify",[this,options]);
return this;
function fileUpload(){var form=$form[0];
if($(":input[name=submit]",form).length){alert('Error: Form elements must not be named "submit".');
return;
}var opts=$.extend({},$.ajaxSettings,options);
var s=$.extend(true,{},$.extend(true,{},$.ajaxSettings),opts);
var id="jqFormIO"+(new Date().getTime());
var $io=$('<iframe id="'+id+'" name="'+id+'" src="about:blank" />');
var io=$io[0];
$io.css({position:"absolute",top:"-1000px",left:"-1000px"});
var xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;
$io.attr("src","about:blank");
}};
var g=opts.global;
if(g&&!$.active++){$.event.trigger("ajaxStart");
}if(g){$.event.trigger("ajaxSend",[xhr,opts]);
}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&$.active--;
return;
}if(xhr.aborted){return;
}var cbInvoked=0;
var timedOut=0;
var sub=form.clk;
if(sub){var n=sub.name;
if(n&&!sub.disabled){options.extraData=options.extraData||{};
options.extraData[n]=sub.value;
if(sub.type=="image"){options.extraData[name+".x"]=form.clk_x;
options.extraData[name+".y"]=form.clk_y;
}}}setTimeout(function(){var t=$form.attr("target"),a=$form.attr("action");
form.setAttribute("target",id);
if(form.getAttribute("method")!="POST"){form.setAttribute("method","POST");
}if(form.getAttribute("action")!=opts.url){form.setAttribute("action",opts.url);
}if(!options.skipEncodingOverride){$form.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});
}if(opts.timeout){setTimeout(function(){timedOut=true;
cb();
},opts.timeout);
}var extraInputs=[];
try{if(options.extraData){for(var n in options.extraData){extraInputs.push($('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />').appendTo(form)[0]);
}}$io.appendTo("body");
io.attachEvent?io.attachEvent("onload",cb):io.addEventListener("load",cb,false);
form.submit();
}finally{form.setAttribute("action",a);
t?form.setAttribute("target",t):$form.removeAttr("target");
$(extraInputs).remove();
}},10);
var nullCheckFlag=0;
function cb(){if(cbInvoked++){return;
}io.detachEvent?io.detachEvent("onload",cb):io.removeEventListener("load",cb,false);
var ok=true;
try{if(timedOut){throw"timeout";
}var data,doc;
doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;
if((doc.body==null||doc.body.innerHTML=="")&&!nullCheckFlag){nullCheckFlag=1;
cbInvoked--;
setTimeout(cb,100);
return;
}xhr.responseText=doc.body?doc.body.innerHTML:null;
xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;
xhr.getResponseHeader=function(header){var headers={"content-type":opts.dataType};
return headers[header];
};
if(opts.dataType=="json"||opts.dataType=="script"){var ta=doc.getElementsByTagName("textarea")[0];
xhr.responseText=ta?ta.value:xhr.responseText;
}else{if(opts.dataType=="xml"&&!xhr.responseXML&&xhr.responseText!=null){xhr.responseXML=toXml(xhr.responseText);
}}data=$.httpData(xhr,opts.dataType);
}catch(e){ok=false;
$.handleError(opts,xhr,"error",e);
}if(ok){opts.success(data,"success");
if(g){$.event.trigger("ajaxSuccess",[xhr,opts]);
}}if(g){$.event.trigger("ajaxComplete",[xhr,opts]);
}if(g&&!--$.active){$.event.trigger("ajaxStop");
}if(opts.complete){opts.complete(xhr,ok?"success":"error");
}setTimeout(function(){$io.remove();
xhr.responseXML=null;
},100);
}function toXml(s,doc){if(window.ActiveXObject){doc=new ActiveXObject("Microsoft.XMLDOM");
doc.async="false";
doc.loadXML(s);
}else{doc=(new DOMParser()).parseFromString(s,"text/xml");
}return(doc&&doc.documentElement&&doc.documentElement.tagName!="parsererror")?doc:null;
}}};
$.fn.ajaxForm=function(options){return this.ajaxFormUnbind().bind("submit.form-plugin",function(){$(this).ajaxSubmit(options);
return false;
}).each(function(){$(":submit,input:image",this).bind("click.form-plugin",function(e){var form=this.form;
form.clk=this;
if(this.type=="image"){if(e.offsetX!=undefined){form.clk_x=e.offsetX;
form.clk_y=e.offsetY;
}else{if(typeof $.fn.offset=="function"){var offset=$(this).offset();
form.clk_x=e.pageX-offset.left;
form.clk_y=e.pageY-offset.top;
}else{form.clk_x=e.pageX-this.offsetLeft;
form.clk_y=e.pageY-this.offsetTop;
}}}setTimeout(function(){form.clk=form.clk_x=form.clk_y=null;
},10);
});
});
};
$.fn.ajaxFormUnbind=function(){this.unbind("submit.form-plugin");
return this.each(function(){$(":submit,input:image",this).unbind("click.form-plugin");
});
};
$.fn.formToArray=function(semantic){var a=[];
if(this.length==0){return a;
}var form=this[0];
var els=semantic?form.getElementsByTagName("*"):form.elements;
if(!els){return a;
}for(var i=0,max=els.length;
i<max;
i++){var el=els[i];
var n=el.name;
if(!n){continue;
}if(semantic&&form.clk&&el.type=="image"){if(!el.disabled&&form.clk==el){a.push({name:n,value:$(el).val()});
a.push({name:n+".x",value:form.clk_x},{name:n+".y",value:form.clk_y});
}continue;
}var v=$.fieldValue(el,true);
if(v&&v.constructor==Array){for(var j=0,jmax=v.length;
j<jmax;
j++){a.push({name:n,value:v[j]});
}}else{if(v!==null&&typeof v!="undefined"){a.push({name:n,value:v});
}}}if(!semantic&&form.clk){var $input=$(form.clk),input=$input[0],n=input.name;
if(n&&!input.disabled&&input.type=="image"){a.push({name:n,value:$input.val()});
a.push({name:n+".x",value:form.clk_x},{name:n+".y",value:form.clk_y});
}}return a;
};
$.fn.formSerialize=function(semantic){return $.param(this.formToArray(semantic));
};
$.fn.fieldSerialize=function(successful){var a=[];
this.each(function(){var n=this.name;
if(!n){return;
}var v=$.fieldValue(this,successful);
if(v&&v.constructor==Array){for(var i=0,max=v.length;
i<max;
i++){a.push({name:n,value:v[i]});
}}else{if(v!==null&&typeof v!="undefined"){a.push({name:this.name,value:v});
}}});
return $.param(a);
};
$.fn.fieldValue=function(successful){for(var val=[],i=0,max=this.length;
i<max;
i++){var el=this[i];
var v=$.fieldValue(el,successful);
if(v===null||typeof v=="undefined"||(v.constructor==Array&&!v.length)){continue;
}v.constructor==Array?$.merge(val,v):val.push(v);
}return val;
};
$.fieldValue=function(el,successful){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();
if(typeof successful=="undefined"){successful=true;
}if(successful&&(!n||el.disabled||t=="reset"||t=="button"||(t=="checkbox"||t=="radio")&&!el.checked||(t=="submit"||t=="image")&&el.form&&el.form.clk!=el||tag=="select"&&el.selectedIndex==-1)){return null;
}if(tag=="select"){var index=el.selectedIndex;
if(index<0){return null;
}var a=[],ops=el.options;
var one=(t=="select-one");
var max=(one?index+1:ops.length);
for(var i=(one?index:0);
i<max;
i++){var op=ops[i];
if(op.selected){var v=op.value;
if(!v){v=(op.attributes&&op.attributes["value"]&&!(op.attributes["value"].specified))?op.text:op.value;
}if(one){return v;
}a.push(v);
}}return a;
}return el.value;
};
$.fn.clearForm=function(){return this.each(function(){$("input,select,textarea",this).clearFields();
});
};
$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();
if(t=="text"||t=="password"||tag=="textarea"){this.value="";
}else{if(t=="checkbox"||t=="radio"){this.checked=false;
}else{if(tag=="select"){this.selectedIndex=-1;
}}}});
};
$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset();
}});
};
$.fn.enable=function(b){if(b==undefined){b=true;
}return this.each(function(){this.disabled=!b;
});
};
$.fn.selected=function(select){if(select==undefined){select=true;
}return this.each(function(){var t=this.type;
if(t=="checkbox"||t=="radio"){this.checked=select;
}else{if(this.tagName.toLowerCase()=="option"){var $sel=$(this).parent("select");
if(select&&$sel[0]&&$sel[0].type=="select-one"){$sel.find("option").selected(false);
}this.selected=select;
}}});
};
function log(){if($.fn.ajaxSubmit.debug&&window.console&&window.console.log){window.console.log("[jquery.form] "+Array.prototype.join.call(arguments,""));
}}})(jQuery);
$(function(){if(!$.Kanban){$.Kanban={};
}$.Kanban.DeleteRecord=function(msgFor,sender){if(confirm("Are you sure you want to delete this "+msgFor+" ?")){$.post(sender.href,{},function(data,status){if(!data.isError&&(status==="success")){window.location.reload();
}else{alert(data.replyText);
}},"json");
}};
$.Kanban.DeleteRecord=function(msgFor,secondaryText,sender){if(confirm("Are you sure you want to delete this "+msgFor+" ?\n\n"+secondaryText)){$.post(sender.href,{},function(data,status){if(!data.isError&&(status==="success")){window.location.reload();
}else{alert(data.replyText);
}},"json");
}};
$.Kanban.UpdateUserRole=function(userId,boardId){var userRole=new Object();
userRole.BoardId=boardId;
userRole.UserId=userId;
userRole.RoleId=$("#Roles_Role_"+userId).val();
userRole.WIP=$("#Roles_Wip_"+userId).val();
if(KANBAN.UserList){$.each($(KANBAN.UserList),function(){if(this.Id==userId){this.WIP=userRole.WIP;
this.Role=parseInt(userRole.RoleId);
}});
}var archiveAjaxUrl=KANBAN.ApiUrl()+"Boards/AddBoardRole";
$.ajax({type:"POST",url:archiveAjaxUrl,data:JSON.stringify(userRole),dataType:"json",contentType:"application/json",async:false,success:function(result){var wipString=result[0].WIP===0?"no WIP limit":"a WIP Limit of "+result[0].WIP;
var msg="User has been assigned "+result[0].RoleName+" role and "+wipString;
$(".kb-view-message-success").text(msg).fadeIn();
setTimeout("$('.kb-view-message-success').fadeOut('slow');",3000);
},error:function(request,errorType){alert("An error occurred while updating the user information.");
}});
};
KANBAN.SiteUrl=function(){var regex=/^(http|https):\/\/.+?\//;
return window.location.toString().match(regex)[0];
};
$.Kanban.CheckRegistrationExists=function(){var email=$("#Registration_ConfirmEmailAddress").val();
var eml={Email:email};
var actionURL=KANBAN.SiteUrl()+"Account/Registrations/CheckEmail?emailAddress="+email;
$.ajax({type:"GET",url:actionURL,dataType:"json",contentType:"application/json",async:false,success:function(result){if(result.ReplyCode===902){if(confirm("We already have a registration on record for this email address.\nWould you like us to resend the confirmation email so that you can activate your account?")){$("#resending").val(true);
}else{return false;
}}},error:function(request,errorType){alert("An error occurred while updating the user information.");
return false;
}});
return true;
};
});
$(document).ready(function(){ManagementInitializeDimensions();
$(window).bind("resize",ManagementInitializeDimensions);
});
ManagementInitializeDimensions=function(){$("#kb-content-area").css("min-height",$("body").height()-210);
};
var dateFormat=function(){var token=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,timezone=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,timezoneClip=/[^-+\dA-Z]/g,pad=function(val,len){val=String(val);
len=len||2;
while(val.length<len){val="0"+val;
}return val;
};
return function(date,mask,utc){var dF=dateFormat;
if(arguments.length==1&&Object.prototype.toString.call(date)=="[object String]"&&!/\d/.test(date)){mask=date;
date=undefined;
}date=date?new Date(date):new Date;
if(isNaN(date)){throw SyntaxError("invalid date");
}mask=String(dF.masks[mask]||mask||dF.masks["default"]);
if(mask.slice(0,4)=="UTC:"){mask=mask.slice(4);
utc=true;
}var _=utc?"getUTC":"get",d=date[_+"Date"](),D=date[_+"Day"](),m=date[_+"Month"](),y=date[_+"FullYear"](),H=date[_+"Hours"](),M=date[_+"Minutes"](),s=date[_+"Seconds"](),L=date[_+"Milliseconds"](),o=utc?0:date.getTimezoneOffset(),flags={d:d,dd:pad(d),ddd:dF.i18n.dayNames[D],dddd:dF.i18n.dayNames[D+7],m:m+1,mm:pad(m+1),mmm:dF.i18n.monthNames[m],mmmm:dF.i18n.monthNames[m+12],yy:String(y).slice(2),yyyy:y,h:H%12||12,hh:pad(H%12||12),H:H,HH:pad(H),M:M,MM:pad(M),s:s,ss:pad(s),l:pad(L,3),L:pad(L>99?Math.round(L/10):L),t:H<12?"a":"p",tt:H<12?"am":"pm",T:H<12?"A":"P",TT:H<12?"AM":"PM",Z:utc?"UTC":(String(date).match(timezone)||[""]).pop().replace(timezoneClip,""),o:(o>0?"-":"+")+pad(Math.floor(Math.abs(o)/60)*100+Math.abs(o)%60,4),S:["th","st","nd","rd"][d%10>3?0:(d%100-d%10!=10)*d%10]};
return mask.replace(token,function($0){return $0 in flags?flags[$0]:$0.slice(1,$0.length-1);
});
};
}();
dateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};
dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};
Date.prototype.format=function(mask,utc){return dateFormat(this,mask,utc);
};
var allUIMenus=[];
$.fn.menu=function(options){var caller=this;
var options=options;
var m=new Menu(caller,options);
allUIMenus.push(m);
$(this).mousedown(function(){if(!m.menuOpen){m.showLoading();
}}).click(function(){if(m.menuOpen==false){m.showMenu();
}else{m.kill();
}return false;
});
};
function Menu(caller,options){var menu=this;
var caller=$(caller);
var container=$('<div class="fg-menu-container ui-widget ui-widget-content ui-corner-all">'+options.content+"</div>");
this.menuOpen=false;
this.menuExists=false;
var options=jQuery.extend({content:null,width:180,maxHeight:180,positionOpts:{posX:"left",posY:"bottom",offsetX:0,offsetY:0,directionH:"right",directionV:"down",detectH:true,detectV:true,linkToFront:false},showSpeed:200,callerOnState:"ui-state-active",loadingState:"ui-state-loading",linkHover:"ui-state-hover",linkHoverSecondary:"li-hover",crossSpeed:200,crumbDefaultText:"Choose an option:",backLink:true,backLinkText:"Back",flyOut:false,flyOutOnState:"ui-state-default",nextMenuLink:"ui-icon-triangle-1-e",topLinkText:"All",nextCrumbLink:"ui-icon-carat-1-e"},options);
var killAllMenus=function(){$.each(allUIMenus,function(i){if(allUIMenus[i].menuOpen){allUIMenus[i].kill();
}});
};
this.kill=function(){caller.removeClass(options.loadingState).removeClass("fg-menu-open").removeClass(options.callerOnState);
container.find("li").removeClass(options.linkHoverSecondary).find("a").removeClass(options.linkHover);
if(options.flyOutOnState){container.find("li a").removeClass(options.flyOutOnState);
}if(options.callerOnState){caller.removeClass(options.callerOnState);
}if(container.is(".fg-menu-ipod")){menu.resetDrilldownMenu();
}if(container.is(".fg-menu-flyout")){menu.resetFlyoutMenu();
}container.parent().hide();
menu.menuOpen=false;
$(document).unbind("click",killAllMenus);
$(document).unbind("keydown");
};
this.showLoading=function(){caller.addClass(options.loadingState);
};
this.showMenu=function(){killAllMenus();
if(!menu.menuExists){menu.create();
}caller.addClass("fg-menu-open").addClass(options.callerOnState);
container.parent().show().click(function(){menu.kill();
return false;
});
container.hide().slideDown(options.showSpeed).find(".fg-menu:eq(0)");
menu.menuOpen=true;
caller.removeClass(options.loadingState);
$(document).click(killAllMenus);
$(document).keydown(function(event){var e;
if(event.which!=""){e=event.which;
}else{if(event.charCode!=""){e=event.charCode;
}else{if(event.keyCode!=""){e=event.keyCode;
}}}var menuType=($(event.target).parents("div").is(".fg-menu-flyout"))?"flyout":"ipod";
switch(e){case 37:if(menuType=="flyout"){$(event.target).trigger("mouseout");
if($("."+options.flyOutOnState).size()>0){$("."+options.flyOutOnState).trigger("mouseover");
}}if(menuType=="ipod"){$(event.target).trigger("mouseout");
if($(".fg-menu-footer").find("a").size()>0){$(".fg-menu-footer").find("a").trigger("click");
}if($(".fg-menu-header").find("a").size()>0){$(".fg-menu-current-crumb").prev().find("a").trigger("click");
}if($(".fg-menu-current").prev().is(".fg-menu-indicator")){$(".fg-menu-current").prev().trigger("mouseover");
}}return false;
break;
case 38:if($(event.target).is("."+options.linkHover)){var prevLink=$(event.target).parent().prev().find("a:eq(0)");
if(prevLink.size()>0){$(event.target).trigger("mouseout");
prevLink.trigger("mouseover");
}}else{container.find("a:eq(0)").trigger("mouseover");
}return false;
break;
case 39:if($(event.target).is(".fg-menu-indicator")){if(menuType=="flyout"){$(event.target).next().find("a:eq(0)").trigger("mouseover");
}else{if(menuType=="ipod"){$(event.target).trigger("click");
setTimeout(function(){$(event.target).next().find("a:eq(0)").trigger("mouseover");
},options.crossSpeed);
}}}return false;
break;
case 40:if($(event.target).is("."+options.linkHover)){var nextLink=$(event.target).parent().next().find("a:eq(0)");
if(nextLink.size()>0){$(event.target).trigger("mouseout");
nextLink.trigger("mouseover");
}}else{container.find("a:eq(0)").trigger("mouseover");
}return false;
break;
case 27:killAllMenus();
break;
case 13:if($(event.target).is(".fg-menu-indicator")&&menuType=="ipod"){$(event.target).trigger("click");
setTimeout(function(){$(event.target).next().find("a:eq(0)").trigger("mouseover");
},options.crossSpeed);
}break;
}});
};
this.create=function(){container.css({width:options.width}).appendTo("body").find("ul:first").not(".fg-menu-breadcrumb").addClass("fg-menu");
container.find("ul, li a").addClass("ui-corner-all");
container.find("ul").attr("role","menu").eq(0).attr("aria-activedescendant","active-menuitem").attr("aria-labelledby",caller.attr("id"));
container.find("li").attr("role","menuitem");
container.find("li:has(ul)").attr("aria-haspopup","true").find("ul").attr("aria-expanded","false");
container.find("a").attr("tabindex","-1");
if(container.find("ul").size()>1){if(options.flyOut){menu.flyout(container,options);
}else{menu.drilldown(container,options);
}}else{container.find("a").click(function(){menu.chooseItem(this);
return false;
});
}if(options.linkHover){var allLinks=container.find(".fg-menu li a");
allLinks.hover(function(){var menuitem=$(this);
$("."+options.linkHover).removeClass(options.linkHover).blur().parent().removeAttr("id");
$(this).addClass(options.linkHover).focus().parent().attr("id","active-menuitem");
},function(){$(this).removeClass(options.linkHover).blur().parent().removeAttr("id");
});
}if(options.linkHoverSecondary){container.find(".fg-menu li").hover(function(){$(this).siblings("li").removeClass(options.linkHoverSecondary);
if(options.flyOutOnState){$(this).siblings("li").find("a").removeClass(options.flyOutOnState);
}$(this).addClass(options.linkHoverSecondary);
},function(){$(this).removeClass(options.linkHoverSecondary);
});
}menu.setPosition(container,caller,options);
menu.menuExists=true;
};
this.chooseItem=function(item){menu.kill();
location.href=$(item).attr("href");
};
}Menu.prototype.flyout=function(container,options){var menu=this;
this.resetFlyoutMenu=function(){var allLists=container.find("ul ul");
allLists.removeClass("ui-widget-content").hide();
};
container.addClass("fg-menu-flyout").find("li:has(ul)").each(function(){var linkWidth=container.width();
var showTimer,hideTimer;
var allSubLists=$(this).find("ul");
allSubLists.css({left:linkWidth,width:linkWidth}).hide();
$(this).find("a:eq(0)").addClass("fg-menu-indicator").html("<span>"+$(this).find("a:eq(0)").text()+'</span><span class="ui-icon '+options.nextMenuLink+'"></span>').hover(function(){clearTimeout(hideTimer);
var subList=$(this).next();
if(!fitVertical(subList,$(this).offset().top)){subList.css({top:"auto",bottom:0});
}if(!fitHorizontal(subList,$(this).offset().left+100)){subList.css({left:"auto",right:linkWidth,"z-index":999});
}showTimer=setTimeout(function(){subList.addClass("ui-widget-content").show(options.showSpeed).attr("aria-expanded","true");
},300);
},function(){clearTimeout(showTimer);
var subList=$(this).next();
hideTimer=setTimeout(function(){subList.removeClass("ui-widget-content").hide(options.showSpeed).attr("aria-expanded","false");
},400);
});
$(this).find("ul a").hover(function(){clearTimeout(hideTimer);
if($(this).parents("ul").prev().is("a.fg-menu-indicator")){$(this).parents("ul").prev().addClass(options.flyOutOnState);
}},function(){hideTimer=setTimeout(function(){allSubLists.hide(options.showSpeed);
container.find(options.flyOutOnState).removeClass(options.flyOutOnState);
},500);
});
});
container.find("a").click(function(){menu.chooseItem(this);
return false;
});
};
Menu.prototype.drilldown=function(container,options){var menu=this;
var topList=container.find(".fg-menu");
var breadcrumb=$('<ul class="fg-menu-breadcrumb ui-widget-header ui-corner-all ui-helper-clearfix"></ul>');
var crumbDefaultHeader=$('<li class="fg-menu-breadcrumb-text">'+options.crumbDefaultText+"</li>");
var firstCrumbText=(options.backLink)?options.backLinkText:options.topLinkText;
var firstCrumbClass=(options.backLink)?"fg-menu-prev-list":"fg-menu-all-lists";
var firstCrumbLinkClass=(options.backLink)?"ui-state-default ui-corner-all":"";
var firstCrumbIcon=(options.backLink)?'<span class="ui-icon ui-icon-triangle-1-w"></span>':"";
var firstCrumb=$('<li class="'+firstCrumbClass+'"><a href="#" class="'+firstCrumbLinkClass+'">'+firstCrumbIcon+firstCrumbText+"</a></li>");
container.addClass("fg-menu-ipod");
if(options.backLink){breadcrumb.addClass("fg-menu-footer").appendTo(container).hide();
}else{breadcrumb.addClass("fg-menu-header").prependTo(container);
}breadcrumb.append(crumbDefaultHeader);
var checkMenuHeight=function(el){if(el.height()>options.maxHeight){el.addClass("fg-menu-scroll");
}el.css({height:options.maxHeight});
};
var resetChildMenu=function(el){el.removeClass("fg-menu-scroll").removeClass("fg-menu-current").height("auto");
};
this.resetDrilldownMenu=function(){$(".fg-menu-current").removeClass("fg-menu-current");
topList.animate({left:0},options.crossSpeed,function(){$(this).find("ul").each(function(){$(this).hide();
resetChildMenu($(this));
});
topList.addClass("fg-menu-current");
});
$(".fg-menu-all-lists").find("span").remove();
breadcrumb.empty().append(crumbDefaultHeader);
$(".fg-menu-footer").empty().hide();
checkMenuHeight(topList);
};
topList.addClass("fg-menu-content fg-menu-current ui-widget-content ui-helper-clearfix").css({width:container.width()}).find("ul").css({width:container.width(),left:container.width()}).addClass("ui-widget-content").hide();
checkMenuHeight(topList);
topList.find("a").each(function(){if($(this).next().is("ul")){$(this).addClass("fg-menu-indicator").each(function(){$(this).html("<span>"+$(this).text()+'</span><span class="ui-icon '+options.nextMenuLink+'"></span>');
}).click(function(){var nextList=$(this).next();
var parentUl=$(this).parents("ul:eq(0)");
var parentLeft=(parentUl.is(".fg-menu-content"))?0:parseFloat(topList.css("left"));
var nextLeftVal=Math.round(parentLeft-parseFloat(container.width()));
var footer=$(".fg-menu-footer");
resetChildMenu(parentUl);
checkMenuHeight(nextList);
topList.animate({left:nextLeftVal},options.crossSpeed);
nextList.show().addClass("fg-menu-current").attr("aria-expanded","true");
var setPrevMenu=function(backlink){var b=backlink;
var c=$(".fg-menu-current");
var prevList=c.parents("ul:eq(0)");
c.hide().attr("aria-expanded","false");
resetChildMenu(c);
checkMenuHeight(prevList);
prevList.addClass("fg-menu-current").attr("aria-expanded","true");
if(prevList.hasClass("fg-menu-content")){b.remove();
footer.hide();
}};
if(options.backLink){if(footer.find("a").size()==0){footer.show();
$('<a href="#"><span class="ui-icon ui-icon-triangle-1-w"></span> <span>Back</span></a>').appendTo(footer).click(function(){var b=$(this);
var prevLeftVal=parseFloat(topList.css("left"))+container.width();
topList.animate({left:prevLeftVal},options.crossSpeed,function(){setPrevMenu(b);
});
return false;
});
}}else{if(breadcrumb.find("li").size()==1){breadcrumb.empty().append(firstCrumb);
firstCrumb.find("a").click(function(){menu.resetDrilldownMenu();
return false;
});
}$(".fg-menu-current-crumb").removeClass("fg-menu-current-crumb");
var crumbText=$(this).find("span:eq(0)").text();
var newCrumb=$('<li class="fg-menu-current-crumb"><a href="javascript://" class="fg-menu-crumb">'+crumbText+"</a></li>");
newCrumb.appendTo(breadcrumb).find("a").click(function(){if($(this).parent().is(".fg-menu-current-crumb")){menu.chooseItem(this);
}else{var newLeftVal=-($(".fg-menu-current").parents("ul").size()-1)*180;
topList.animate({left:newLeftVal},options.crossSpeed,function(){setPrevMenu();
});
$(this).parent().addClass("fg-menu-current-crumb").find("span").remove();
$(this).parent().nextAll().remove();
}return false;
});
newCrumb.prev().append(' <span class="ui-icon '+options.nextCrumbLink+'"></span>');
}return false;
});
}else{$(this).click(function(){menu.chooseItem(this);
return false;
});
}});
};
Menu.prototype.setPosition=function(widget,caller,options){var el=widget;
var referrer=caller;
var dims={refX:referrer.offset().left,refY:referrer.offset().top,refW:referrer.getTotalWidth(),refH:referrer.getTotalHeight()};
var options=options;
var xVal,yVal;
var helper=$('<div class="positionHelper"></div>');
helper.css({position:"absolute",left:dims.refX,top:dims.refY,width:dims.refW,height:dims.refH});
el.wrap(helper);
switch(options.positionOpts.posX){case"left":xVal=0;
break;
case"center":xVal=dims.refW/2;
break;
case"right":xVal=dims.refW;
break;
}switch(options.positionOpts.posY){case"top":yVal=0;
break;
case"center":yVal=dims.refH/2;
break;
case"bottom":yVal=dims.refH;
break;
}xVal+=options.positionOpts.offsetX;
yVal+=options.positionOpts.offsetY;
if(options.positionOpts.directionV=="up"){el.css({top:"auto",bottom:yVal});
if(options.positionOpts.detectV&&!fitVertical(el)){el.css({bottom:"auto",top:yVal});
}}else{el.css({bottom:"auto",top:yVal});
if(options.positionOpts.detectV&&!fitVertical(el)){el.css({top:"auto",bottom:yVal});
}}if(options.positionOpts.directionH=="left"){el.css({left:"auto",right:xVal});
if(options.positionOpts.detectH&&!fitHorizontal(el)){el.css({right:"auto",left:xVal});
}}else{el.css({right:"auto",left:xVal});
if(options.positionOpts.detectH&&!fitHorizontal(el)){el.css({left:"auto",right:xVal});
}}if(options.positionOpts.linkToFront){referrer.clone().addClass("linkClone").css({position:"absolute",top:0,right:"auto",bottom:"auto",left:0,width:referrer.width(),height:referrer.height()}).insertAfter(el);
}};
function sortBigToSmall(a,b){return b-a;
}jQuery.fn.getTotalWidth=function(){return $(this).width()+parseInt($(this).css("paddingRight"))+parseInt($(this).css("paddingLeft"))+parseInt($(this).css("borderRightWidth"))+parseInt($(this).css("borderLeftWidth"));
};
jQuery.fn.getTotalHeight=function(){return $(this).height()+parseInt($(this).css("paddingTop"))+parseInt($(this).css("paddingBottom"))+parseInt($(this).css("borderTopWidth"))+parseInt($(this).css("borderBottomWidth"));
};
function getScrollTop(){return self.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop;
}function getScrollLeft(){return self.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft;
}function getWindowHeight(){var de=document.documentElement;
return self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;
}function getWindowWidth(){var de=document.documentElement;
return self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;
}function fitHorizontal(el,leftOffset){var leftVal=parseInt(leftOffset)||$(el).offset().left;
return(leftVal+$(el).width()<=getWindowWidth()+getScrollLeft()&&leftVal-getScrollLeft()>=0);
}function fitVertical(el,topOffset){var topVal=parseInt(topOffset)||$(el).offset().top;
return(topVal+$(el).height()<=getWindowHeight()+getScrollTop()&&topVal-getScrollTop()>=0);
}Number.prototype.pxToEm=String.prototype.pxToEm=function(settings){settings=jQuery.extend({scope:"body",reverse:false},settings);
var pxVal=(this=="")?0:parseFloat(this);
var scopeVal;
var getWindowWidth=function(){var de=document.documentElement;
return self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;
};
if(settings.scope=="body"&&$.browser.msie&&(parseFloat($("body").css("font-size"))/getWindowWidth()).toFixed(1)>0){var calcFontSize=function(){return(parseFloat($("body").css("font-size"))/getWindowWidth()).toFixed(3)*16;
};
scopeVal=calcFontSize();
}else{scopeVal=parseFloat(jQuery(settings.scope).css("font-size"));
}var result=(settings.reverse==true)?(pxVal*scopeVal).toFixed(2)+"px":(pxVal/scopeVal).toFixed(2)+"em";
return result;
};
$(document).ready(function(){});
