
var _loadEvent=0;$(document).ready(function(){jQuery.extend(jQuery.expr[":"],{innerHtmlEquals:function(a,i,m){return a.innerHTML==m[3];}});$('.dpTags .dpTag').click(tagSelected);$('#ldRecent').click(function(){changeList($(this),'Recently viewed',function(){resetProcesses('#ldRecent','GetRecentlyViewed','topProcViewed',6);})});$('#ldNew').click(function(){changeList($(this),'New processes',function(){resetProcesses('#ldNew','GetNewProcesses','topProcNew',6);})});$('#ldUpdated').click(function(){changeList($(this),'Updated processes',function(){resetProcesses('#ldUpdated','GetUpdatedProcesses','topProcUpdated',6);})});$('#ldExplorer').click(function()
{changeList($(this),'Process structure',function()
{loadStructure(_loadEvent);});});$('#ldSummary').click(function()
{changeList($(this),'Library summary',function()
{loadSummary(_loadEvent);});});$('#ldHome').click(function()
{changeList($(this),'Home',function()
{loadHome(_loadEvent);});});if((window.location.hash!=null)&&(window.location.hash.length>0))
{_loadEvent++;var hashVal=window.location.hash.substring(1);if(hashVal.substring(0,1)=="$")
$("#ld"+hashVal.substring(1)).click();else
$(".dpTags .dpTag:innerHtmlEquals('"+hashVal+"')").click();}
else
{if($('#ldHome').length>0)
$('#ldHome').click();else
$('#ldSummary').click();}});function loadRelationships(loadEvent){if(loadEvent!=_loadEvent)return;$.get(_reposRoot+'/files/'+reposName+_explorerOffset+'?t='+cBypass(),function(data){loadExplorerData(data,"homeProcList");});}
var explorerPinned=false;function loadStructure(loadEvent)
{if(loadEvent!=_loadEvent)return;$.get(_reposRoot+'/files/'+reposName+_explorerOffset+'?t='+cBypass(),function(data){loadedStructure(data,loadEvent);});explorerPinned=false;}
function loadedStructure(data,loadEvent)
{if(loadEvent!=_loadEvent)return;$('#homeProcList').append(data);$('.stepExplorer .step').mouseover(highlightStep);$('.stepExplorer .step').mouseout(unhighlightStep);$('.stepExplorer .step .pin').click(toggleExplorerPin);}
function loadSummary(loadEvent)
{if(loadEvent!=_loadEvent)return;$.get(_reposRoot+'/subpages/summary.aspx?t='+cBypass(),function(data){loadedSummary(data,loadEvent);});}
function loadedSummary(data,loadEvent)
{if(loadEvent!=_loadEvent)return;$('#homeProcList').append(data);$('#homeProcList .sline').sparkline('html',{spotColor:false,chartRangeMin:0,minSpotColor:false,maxSpotColor:false,height:30,defaultPixelsPerValue:5});}
function toggleExplorerPin()
{explorerPinned=!explorerPinned;if(explorerPinned)
{$(this).addClass('pinned');$('.stepExplorer .step:not(:has(.stepName.stepHi,.stepName.stepDep))').fadeOut('fast');}
else
{$(this).removeClass('pinned');$('.stepExplorer .step:not(:has(.stepName.stepHi,.stepName.stepDep))').fadeIn('fast');}}
function unhighlightStep()
{if(explorerPinned)
return;$('#homeProcList table.stepExplorer .stepName.stepHi').removeClass('stepHi');$('#homeProcList table.stepExplorer .stepName.stepDep').removeClass('stepDep');}
function highlightStep()
{if(explorerPinned)
return;unhighlightStep();highlightDep(this);$('.stepName',this).addClass('stepHi');}
function highlightDep(dep)
{var jDep=$(dep);if(!$('.stepName',jDep).hasClass('stepDep')&&!$('.stepName',jDep).hasClass('stepHi'))
{$('.stepName',jDep).addClass('stepDep');var targetId=jDep.attr('targetId');if(targetId!=undefined){var targets=targetId.split(',');for(var i=0;i<targets.length;i++){if(targets[i].length>0){$("#homeProcList table.stepExplorer .step[nodeId='"+targets[i]+"']").each(function(i){highlightDep(this);});}}}}}
var selectedTag=null;function tagSelected()
{var selTag=$(this);changeList(selTag,"Tagged as: "+selTag.text(),function(){selectTag(selTag);});}
function changeList(itmClicked,ttle,cback)
{_loadEvent++;$('.btnSel').removeClass("btnSel");if(itmClicked.parent().hasClass('btn'))
{itmClicked.parent().addClass("btnSel");}
$('.dpTags .dpTag').removeClass('tagSelected');$('#homeProcList').fadeOut('fast',function()
{$('#homeProcList').empty();$('#homeProcList').fadeIn(0);$('#homeProcTitle').text(ttle);if(itmClicked.parent().hasClass('btn'))
{var mnuClass=$('span.ui-icon',itmClicked.parent()).attr('class');$("<span class='"+mnuClass+"'></span>").prependTo($('#homeProcTitle'));}
cback();});}
function selectTag(selTag)
{selTag.addClass('tagSelected');window.location.hash=selTag.text();selTag.show('transfer',{to:"#homeProcTitle"},300);$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:"{'tagName':'"+selTag.text()+"'}",url:_reposRoot+'/ProcessDefinition.asmx/GetTaggedProcesses',success:function(data){loadedProcesses(data);}});}
function loadedProcesses(data)
{var html='<ul>';for(var i=0;i<data.d.length;i++)
{var ad=data.d[i];html+="<li class='pSum'><a href='"+_reposRoot+"/"+ad.PrettyPostTitle+"' class='pName'>"+htmlEncode(ad.ProcessTitle)+"</a><span class='pSnip'>"+ad.DescriptionSnippet+"</span></li>";}
html+="</ul>";$('#homeProcList').html(html);}
function loadProcesses(serviceName,cName,numToLoad,loadEvent)
{$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:"{'maxReturn':"+numToLoad.toString()+"}",url:_reposRoot+'/ProcessDefinition.asmx/'+serviceName,success:function(data){showProcesses(data,cName,loadEvent);}});}
function loadHome(loadEvent)
{$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:"{'processTitle':'Home'}",url:_reposRoot+'/ProcessDefinition.asmx/GetProcessContent',success:function(data){loadedHome(data,loadEvent);}});}
function loadedHome(data,loadEvent)
{if(loadEvent!=_loadEvent)return;$('#homeProcList').html("<div class='postBody'>"+data.d+"</div>");}
function loadShortProcesses(serviceName,cName,numToLoad,loadEvent)
{$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:"{'maxReturn':"+numToLoad.toString()+"}",url:'ProcessDefinition.asmx/'+serviceName,success:function(data){showShortProcesses(data,cName,loadEvent);}});}
function loadSentProcesses(serviceName,cName,numToLoad,loadEvent)
{$.ajax({type:'POST',contentType:"application/json; charset=utf-8",dataType:"json",data:"{'maxReturn':"+numToLoad.toString()+"}",url:'ProcessDefinition.asmx/'+serviceName,success:function(data){showSentProcesses(data,cName,loadEvent);}});}
function resetProcesses(menuItem,serviceName,cName,numToLoad)
{$(menuItem).show('transfer',{to:"#homeProcTitle"},300);loadProcesses(serviceName,cName,numToLoad,_loadEvent);}
function resetShortProcesses(menuItem,serviceName,cName,numToLoad)
{$(menuItem).show('transfer',{to:"#homeProcTitle"},300);loadShortProcesses(serviceName,cName,numToLoad,_loadEvent);}
function resetSentProcesses(menuItem,serviceName,cName,numToLoad)
{$(menuItem).show('transfer',{to:"#homeProcTitle"},300);loadSentProcesses(serviceName,cName,numToLoad,_loadEvent);}
function showProcesses(data,cName,loadEvent)
{if(loadEvent!=_loadEvent)return;for(var i=0;i<data.d.length;i++)
{var ad=data.d[i];if(loadEvent!=_loadEvent)return;if($("#homeProcList .mruFullPreview[ptitle='"+ad.PrettyPostTitle+"']").length==0)
{var iHtml="<h2 class='mruTitle'><a href='"+_reposRoot+"/"+ad.PrettyPostTitle+"'>"+htmlEncode(ad.ProcessTitle)+"</a></h2>"+"<div class='mruFullPreview ui-corner-all' ptitle='"+ad.PrettyPostTitle+"'><div class='postBody ui-corner-all'>"+ad.ProcessDescription+"<br class='clear' /></div></div>"+"<a href='"+_reposRoot+"/"+ad.PrettyPostTitle+"'><div class='mruOverlay ui-corner-all'></div></a>";if(loadEvent!=_loadEvent)return;var newItem=$("<div class='mruFullItem ui-corner-all "+cName+"'></div>").html(iHtml);if(loadEvent!=_loadEvent)return;$('#homeProcList').append(newItem);newItem.hover(function(){$(this).addClass('hovering');},function(){$(this).removeClass('hovering');});}}}
function htmlEncode(str)
{return str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br />");}