var dba;var baseserverurl;var baseserverip;var oldhash=window.location.hash;var hashcheck=setInterval("checkHash()",500);var prefs="00000000000000000000000000000000000000000000000000";function checkHash(){if(oldhash!=window.location.hash){oldhash=window.location.hash;displayDashboard()}}var PERM_NOACCESS=10,PERM_CLIENT=30,PERM_TEAM=60,PERM_ADMIN=100;var STATUS_NONE=0,STATUS_INPROGRESS=1,STATUS_PROBLEM=2,STATUS_COMPLETE=3;var PREF_DATEFORMAT=0,PREF_TIMEFORMAT=1,PREF_HIDEFAQ=2,PREFS_DEFAULTALERTSSTART=10;var JSC_UPLOADSTATUS=0,JSC_LOGIN=1,JSC_LOGOUT=2,JSC_SIGNUP=3,JSC_SIGNUPEMAIL=4,JSC_FORGOTPASSWORD=5,JSC_DASHBOARD_MESSAGES=11,JSC_DASHBOARD_ITEMS=12,JSC_PROFILE=16,JSC_ADMIN_USERS=17,JSC_ITEM_ITEM=18,JSC_ITEM_REVISIONS=19,JSC_ITEM_MESSAGES=20,JSC_ADMIN_SUBSCRIPTION=21,JSC_DASHBOARD_WIDGET=22,JSC_THREAD_MESSAGES=23,JSC_ADDTHREADMESSAGE=24,JSC_ADDITEMMESSAGE=25,JSC_ADMIN_NUMBERS=27,JSC_ADMIN_ITEMS=28,JSC_ADMIN_PREFS=29,JSC_SAVEITEMNOTMEMBER=100,JSC_ADDFILES=101,JSC_EDITITEM=102,JSC_SAVEITEM=103,JSC_SAVEITEM_FILE=104,JSC_DELETEITEM=106,JSC_DELETEREVISION=107,JSC_SAVEREVISION=108,JSC_BADDOWNLOAD=110,JSC_ADDITEM=111,JSC_NONE=1000;var currjson,currpw,currmessages,curritems,curritem,curruserid,currperm=0,myprofilejson,currrevisions,currwidget,isloggedin=false;var STATUS=new Array("None","Active","Problem","Complete");var START=new Array();function includeCSS(B){var A=document.getElementsByTagName("head").item(0);if(!A){alert("Ooops. Your page must have a <head> element.")}if(document.getElementById(B)!=null){return}var C=document.createElement("link");C.setAttribute("rel","stylesheet");C.setAttribute("type","text/css");C.setAttribute("href",B);C.setAttribute("id",B);A.appendChild(C)}function includeJS(A,C){if(C){C=$(C);empty(C)}else{C=document.getElementsByTagName("head").item(0);if(!C){alert("Ooops. Your page must have a <head> element.")}if(document.getElementById(A)!=null){return}}var B=document.createElement("script");B.setAttribute("language","javascript");B.setAttribute("type","text/javascript");B.setAttribute("id",A);if(A.charAt(0)=="/"){A="http://flowthingy.resources.s3.amazonaws.com"+A}B.setAttribute("src",A);C.appendChild(B)}function flowThingy(){var A=sitecode.indexOf(".");dba="s1";if(A!=-1){dba=sitecode.substring(0,A);sitecode=sitecode.substring(A+1)}baseserverurl="http://"+dba+".flowthingy.com";baseserverip=baseserverurl;includeJS("/flowthingy_tools.js");includeCSS("http://flowthingy.resources.s3.amazonaws.com/flowthingy_widget.css");includeJS("/flowthingy_dashboard.js");includeJS("/flowthingy_item.js");includeJS("/flowthingy_login.js")}function getStatus(B,A,C){return'<a href="javascript:editStatus('+B+",'"+A+"',"+C+');" id=href'+A+"status"+C+"><img src='http://flowthingy.images.s3.amazonaws.com/status_"+B+".gif' title='Status: "+STATUS[B]+", click to edit' border=0 width=14 height=14 id=image"+A+"status"+C+"></a> <span id=edit"+A+"status"+C+"></span><img src=http://flowthingy.images.s3.amazonaws.com/transparent.gif width=6>"}function editStatus(is,type,id){if(is==STATUS_COMPLETE&&currwidget!=null&&eval(currwidget.max_items)<=eval(currwidget.active_items)){alert("Ooops. You have reached the maximum number of active items ("+currwidget.max_items+"). You can't change the status of this item until you've set at least one other item's status to complete");return}if($("edit"+type+"status"+id).innerHTML.length==0){var h=" <select id=selectstatus"+type+"status"+id+" onchange=\"saveStatus('"+type+"',"+id+');">';for(i=0;i<STATUS.length;i++){h+="<option name=status"+i+" value="+i;if(is==i){h+=" selected"}h+=">"+STATUS[i]}h+="</select> ";setHTML("edit"+type+"status"+id,h)}else{setHTML("edit"+type+"status"+id,"")}}function saveStatus(type,id){var u="/widget?c="+sitecode+"&a="+type+"&d=savestatus";var s=$("selectstatus"+type+"status"+id).value;if(type=="item"&&s==STATUS_COMPLETE){alert("You are setting the status of this item to complete. Completed items can't be edited or added to. You can always change it back to a non-complete status")}u+="&status="+s;if(type=="message"){u+="&messageid="+id}else{u+="&itemid="+id}sendCommand(baseserverip,u);$("href"+type+"status"+id).href="javascript:editStatus("+s+",'"+type+"',"+id+");";$("image"+type+"status"+id).src="http://flowthingy.images.s3.amazonaws.com/status_"+s+".gif";$("image"+type+"status"+id).title="Status: "+STATUS[eval(s)];setHTML("edit"+type+"status"+id,"")}function handleJSON(command,json,json2){if(--remainingcommands<=0){remainingcommands=0;setHTML("loading","");if(commandchecker!=null){clearTimeout(commandchecker)}commandchecker=null;currcommands=null;retrying=false}if(json.s){currjson=json;if(json.s=="badcode"){var m="Ooops. The sitecode supplied with this page will not work with this domain. Please make sure you entered the correct domain when you grabbed the code for this flowthingy at flowthingy.com.";setHTML("pt_apparea",m)}else{if(json.s=="notactive"){var m="Ooops. This FlowThingy has been deactivated.";setHTML("pt_apparea",m)}else{if(json.s=="noauth"){logout(false);displayLogin(false);alert("Ooops. Your login failed or your session has expired.")}else{if(json.s=="notfound"){window.location.hash="";displayDashboard()}else{if(json.s=="notmember"){alert("Ooops. You are not a member of this item.");window.location.hash="";displayDashboard()}else{if(command==JSC_LOGIN){if(json.s=="pending"){logout(false);displayLogin(false);alert("Ooops. Your account has not yet been approved by the site administrator.")}else{curruserid=json.id;currperm=eval(json.permission);if(currperm>=PERM_ADMIN){includeJS("/flowthingy_admin.js")}isloggedin=true;displayDashboard()}}else{if(command==JSC_LOGOUT){displayLogin(false)}else{if(command==JSC_SIGNUP){if(json.s=="ok"){if(json.as&&eval(json.as)>=PERM_CLIENT){displayLogin(false,"Thanks for signing up. ")}else{setHTML("pt_apparea","Thanks for signing up! Your account is awaiting approval by the site administrator. You'll receive an email at "+json.eml+" when your account is approved.<br><br><a href='javascript:displayLogin(false)'>Login here</a>.")}}else{displaySignup();alert("Oops. That username has already been registered")}}else{if(command==JSC_FORGOTPASSWORD){if(json.s=="ok"){setHTML("pt_apparea","Please check your email inbox for a message with your new password.<br><br><a href='javascript:displayLogin(false)'>Login here</a>.")}else{displayForgotPassword();alert("Oops. That couldn't find that email address.")}}else{if(command==JSC_SIGNUPEMAIL){setHTML("pt_apparea","Great! You'll be notified at "+json.em+" when your account has been approved. <a href='javascript:displayLogin(false)'>Login here</a>.")}else{if(command==JSC_NONE){}else{alert("Ooops. Something went wrong. Please try again.")}}}}}}}}}}}}else{if(command==JSC_DASHBOARD_MESSAGES){displayDashboardMessages(json.data)}else{if(command==JSC_DASHBOARD_ITEMS){displayDashboardItems(json.data)}else{if(command==JSC_DASHBOARD_WIDGET){displayDashboardDashboard(json)}else{if(command==JSC_DELETEITEM){window.location.hash="";displayDashboard()}else{if(command==JSC_DELETEREVISION){displayItem(json.id)}else{if(command==JSC_SAVEREVISION){displayItem(json.id)}else{if(command==JSC_ADDFILES){uploadFile(json,"revision")}else{if(command==JSC_SAVEITEM_FILE){uploadFile(json,"item")}else{if(command==JSC_ADDITEM){displayItem(json.id)}else{if(command==JSC_SAVEITEM){displayItem(json.id)}else{if(command==JSC_SAVEITEMNOTMEMBER){displayDashboard(json.id)}else{if(command==JSC_ITEM_ITEM){displayItemItem(json)}else{if(command==JSC_ITEM_REVISIONS){displayItemRevisions(json.data)}else{if(command==JSC_ITEM_MESSAGES){displayItemMessages(json.data)}else{if(command==JSC_THREAD_MESSAGES){displayThreadMessages(json.data,json2.data2)}else{if(command==JSC_PROFILE){displayProfileProfile(json)}else{if(command==JSC_EDITITEM){displayEditItem(json.data)}else{if(command==JSC_ADMIN_USERS){displayAdminUsers(json.data,json2.data2)}else{if(command==JSC_ADMIN_ITEMS){displayAdminItems(json.data)}else{if(command==JSC_ADMIN_SUBSCRIPTION){displayAdminSubscription(json)}else{if(command==JSC_ADMIN_PREFS){displayAdminPrefs(json)}else{if(command==JSC_ADMIN_NUMBERS){displayAdminNumbers(json)}else{if(command==JSC_UPLOADSTATUS){uploadStatus(json)}else{if(command==JSC_ADDITEMMESSAGE){displayAddItemMessage(json.data)}else{if(command==JSC_BADDOWNLOAD){alert("Ooops. Download failed: "+json.reason)}}}}}}}}}}}}}}}}}}}}}}}}}}if(--remainingcommands<=0){remainingcommands=0;setHTML("loading","")}}function expand(D,C,B,A){if(C!=null){$(B+C).innerHTML=doBRs(d(D[C][A]))}else{$(B).innerHTML=doBRs(d(D[A]))}$(B+"_l"+C).innerHTML=""}var hidefaq=false;function getNav(){var A="<table width=100%><tr valign=top><td><p style='margin-bottom:12px;'><a href='javascript:displayDashboard(0);' style='font-size:larger;'>Dashboard</a>";A+=" &nbsp; &nbsp;<a href=\"javascript:displayProfile('mine');\" style='font-size:larger;'>My Profile</a>";if(currperm>=100){A+=" &nbsp; &nbsp;<a href=\"javascript:displayAdmin();\" style='font-size:larger;'>Admin</a>"}if(!hidefaq){A+=" &nbsp; &nbsp;<a href='http://www.flowthingy.com/faq.html' target='ftfaq' style='font-size:larger;'>FAQ</a>"}A+=" &nbsp; &nbsp;<a href='javascript:logout(true);' style='font-size:larger;'>Logout</a>";A+="<span id=loading></span></p><span id=addnav></span></td><td align=right><form onsubmit='search(); return false;' class=ptf><input type=text id=searchwords";if(searchwords!=null){A+=" value='"+searchwords+"'"}A+=" style='width:100px'> <input type=submit value=Search>&nbsp;</td></form></tr></table>";return A}function load(B,G,F,D,E,A){if(D==1){setHTML(G+"morelink",loadimage)}var H=START[B+G]+10*D;START[B+G]=H;if(G=="items"){F=itemfilter}else{if(G=="messages"){F=messagefilter}}var C="/widget?c="+sitecode+"&a="+B+"&d="+G+"&which="+F+"&start="+H;if(E){C+="&itemid="+E}if(A){C+="&messageid="+A}if(B=="dashboard"&&searchwords!=null){C+="&search="+escape(searchwords)}sendCommand(baseserverip,C)}function pagination(B,F,E,D,A){if(START[B+F]==0&&E.length<11){return""}var C="<span id="+F+"list"+(START[B+F]+10)+"><br><center><span id="+F+"morelink>";C+='<a href="javascript:scroll(0,0);">[top]</a>';if(E.length==11){C+=" &nbsp; &nbsp; &nbsp <a href=\"javascript:load('"+B+"', '"+F+"', 'all', 1,"+D+","+A+');">[more...]</a>'}C+="</span></center></span>";return C}function mouseList(A,C,B){if(B=="in"){$("ml_"+A+"_l"+C).style.display="block";$("ml_"+A+"_n"+C).style.display="none"}else{if(B=="out"){$("ml_"+A+"_l"+C).style.display="none";$("ml_"+A+"_n"+C).style.display="block"}}}function filterItems(A,B){START.dashboarditems=0;if(itemfilter=="all"){itemfilter="mine"}else{itemfilter="all"}load(A,B,itemfilter,0)}function filterMessages(A,C){START.dashboardmessages=0;START.itemmessages=0;if(messagefilter=="all"){messagefilter="mine"}else{messagefilter="all"}var B=null;if(curritem){B=curritem.id}load(A,C,messagefilter,0,B)};
