//
(function(){var debug,enflock_chat,enflock_handlers,enflock_lib,enflock_mice,flash_callbacks,fun,getBrowserVersion,i,match,name,urlFile,urlHost,urlLink,urlProt,urlQuery,xFlash,yFlash;flash_callbacks={getURLParts:function(){var urlFile,urlHost,urlLink,urlProt,urlQuery;urlProt=window.location.protocol;urlHost=window.location.host;urlFile=window.location.pathname;urlLink=urlProt+"//"+urlHost+urlFile;urlQuery=window.location.href.substring(urlLink.length);return document.Enflock.setURLParts(urlHost,urlFile,urlQuery,getBrowserVersion());},selectText:function(id){document.getElementById(id).focus();return document.getElementById(id).select();}};for(name in flash_callbacks){fun=flash_callbacks[name];window[name]=fun;}
getBrowserVersion=function(){var browser,i,j,n,result,u,version,x;x=navigator;n=x.appName;u=x.userAgent;browser="";version="";result="";if(n.indexOf("Microsoft Internet Explorer")!==-1){browser="MSIE";i=u.indexOf("MSIE");if(i!==-1){version=u.substring(i+5,i+8);}else{version="0";}}else{if(n.indexOf("Opera")!==-1){browser="Opera";i=u.indexOf("Opera");if(i!==-1){version=u.substring(i+6,i+10);}else{version="0";}}else{j=u.indexOf("Chrome");if(j!==-1){browser="Chrome";version=u.substring(j+7,j+17);}else{j=u.indexOf("Safari");if(j!==-1){browser="Safari";version=u.substring(j+7,j+15);}else{j=u.indexOf("Firefox");if(j!==-1){browser="Firefox";version=u.substring(j+8,j+16);}else{browser="Dunno";version="0";}}}}}
result=browser+"-"+version;return result;};match="enflock=awesome";urlProt=window.location.protocol;urlHost=window.location.host;urlFile=window.location.pathname;urlLink=urlProt+"//"+urlHost+urlFile;urlQuery=window.location.href.substring(urlLink.length);i=urlQuery.indexOf(match);debug=(i!==-1?true:false);xFlash=(debug?"100%":"125");yFlash=(debug?"100%":"25");document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'\n    id='Enflock'\n    width="+xFlash+"\n    height="+yFlash+"\n    codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>\n        <param name='movie' value='http://enflock.com/enflock.swf' />\n        <param name='quality' value='high' />\n        <param name='bgcolor' value='#869ca7' />\n        <param name='defaultStart' value='yes' />\n        <param name='defaultShadow' value='yes' />\n        <param name='menu' value='false' />\n        <param name='standby' value='loading...' />\n        <param name='allowNetworking' value='all' />\n        <param name='allowScriptAccess' value='always' />\n        <param name='wmode' value='opaque' />\n        <embed src='http://enflock.com/enflock.swf' \n            quality='high'\n            bgcolor='#869ca7'\n            width="+xFlash+"\n            height="+yFlash+"\n            name='Enflock'\n            align='middle'\n            play='true'\n            loop='false'\n            quality='high'\n            menu='false'\n            standby='loading...'\n            allowNetworking='all'\n            allowScriptAccess='always'\n            wmode='opaque'\n            SWLIVECONNECT='true'\n            type='application/x-shockwave-flash'\n            pluginspage='http://www.adobe.com/go/getflashplayer'>\n        </embed>\n</object>");window.onbeforeunload=function(){return document.Enflock.unLoading();};window.onunload=function(){return document.Enflock.unLoading();};enflock_lib=function(){return{vec2:{dist_sqr:function(a,b){return(Math.pow(a[0]-b[0],2))+Math.pow(a[1]-b[1],2);},scale_to:function(v,s){var k;k=s/Math.sqrt(v[0]*v[0]+v[1]*v[1]);return[v[0]*k,v[1]*k];},within_rect:function(v,base,dim){var _ref,_ref2;return(0<=(_ref=v[0]-base[0])&&_ref<=dim[0])&&(0<=(_ref2=v[1]-base[1])&&_ref2<=dim[1]);},pointwise:function(a,b){return[a[0]*b[0],a[1]*b[1]];},add:function(a,b){return[a[0]+b[0],a[1]+b[1]];},sub:function(a,b){return[a[0]-b[0],a[1]-b[1]];}},bridge_up:false};};enflock_lib=enflock_lib();window.enflock_lib=enflock_lib;enflock_mice=function(){var BASE_URL,MOUSE_DIM,add,browserVer,check_info_win,do_no_harm,do_shadow,get_browser,is_disabled_shadow,is_hidden,lup,mouse,old_self_pos,pos_cache,req_win_tos,selfId,target_pos_cache,vec2;BASE_URL="http://enflock.com/";MOUSE_DIM=[12,19];lup={};pos_cache={};target_pos_cache={};old_self_pos=[0,0];req_win_tos={};selfId=void 0;do_shadow=false;get_browser=function(){var re,ua;if(navigator.appName==="Microsoft Internet Explorer"){ua=navigator.userAgent;re=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(re.exec(ua)!=null){return parseFloat(RegExp.$1);}}
return-1;};browserVer=get_browser();vec2=enflock_lib.vec2;add=function(id){$("<div id='mousewin-"+id+"' class='ms-info-win'>\nNo.<span class='text-highlight'>"+id+"</span><br>\n<a href='#' pub='no' class='img-button'\ntitle='Start a private conversation with "+id+".' \nstyle='background:url(\""+BASE_URL+"icon_priv.png\") bottom;'\n></a>\n<a href='#' pub='yes' class='img-button'\ntitle='Join a public discussion with "+id+".'\nstyle='background:url(\""+BASE_URL+"icon_pub.png\");'\n></a>\n</div>").appendTo('#enflock_root');$("#mousewin-"+id+" a").click(function(e){var isPub;e.preventDefault();isPub=$(this).attr('pub')==='yes';enflock_mice.notify(selfId,isPub);return document.Enflock.chatRequest(id,isPub);});$("#mousewin-"+id).offset({left:5,top:5});$("<div id='notifywin-"+id+"' class='ms-chat-req-win'>\n<a href='javascript:;'>\n<img src='"+BASE_URL+"icon_bubble.png' width='16px' height='16px'>\n</img>\n</a>\n</div>").appendTo("#enflock_root");$("#notifywin-"+id).mousedown(function(){return enflock_mice.remove_notify(id,true);});lup[id]=$("<div id='mouse-"+id+"'                   class='ms-mouse'                 ></div>").appendTo("#enflock_root");if(is_disabled_shadow(id)){enflock_mice.hide(id);}
return lup[id];};mouse=function(id){return lup[id]||add(id);};is_hidden={};do_no_harm=function(pointer,other,other_id){var overlap;overlap=vec2.within_rect(pointer,vec2.add(other,[-2,-2]),vec2.add(MOUSE_DIM,[4,4]));if((overlap&&!is_hidden[other_id])||(!overlap&&is_hidden[other_id])){mouse(other_id).css("z-index",(overlap?"-99":"9999"));if(browserVer>0){mouse(other_id).visibility=overlap?"hidden":"visible";}
if(overlap){return is_hidden[other_id]=true;}else{return delete is_hidden[other_id];}}};check_info_win=function(us,other,uid){var center,pos,sqrDist,vec,win;center=vec2.add(other,vec2.pointwise(MOUSE_DIM,[0.5,0.5]));sqrDist=vec2.dist_sqr(us,center);win=$("#mousewin-"+uid);if(sqrDist<1225){if(mouse(uid).css("visibility")==="hidden"){return;}
if(win.css("visibility")!=="visible"){vec=vec2.scale_to([old_self_pos[1]-us[1],us[0]-old_self_pos[0]],10);vec[0]-=vec[0]<0?win.width():0;vec[1]-=vec[1]<0?win.height():0;vec=vec2.add(vec2.add(vec,other),[6,9]);return win.css("visibility","visible").offset({left:vec[0],top:vec[1]});}else{if(win.data("hide")){clearTimeout(win.data("hide"));return win.data("hide",false);}}}else{if(win.css("visibility")==="visible"){pos=win.offset();if(!vec2.within_rect(us,[pos.left,pos.top],[win.width(),win.height()])){if(!win.data("hide")){return win.data("hide",setTimeout(function(){win.css("visibility","hidden");return win.data("hide",false);},350));}}else{if(win.data("hide")){clearTimeout(win.data("hide"));return win.data("hide",false);}}}}};is_disabled_shadow=function(id){return id===selfId&&do_shadow===false;};return{notify:function(id,is_pub){$("#notifywin-"+id).css("visibility","visible").data("is_public",is_pub).children("a").attr("title",(is_pub?id+" is inviting you\nto a discussion!":id+" wants to\nchat with you!"));clearTimeout(req_win_tos[id]);req_win_tos[id]=setTimeout(function(){return enflock_mice.remove_notify(id,false);},15000);return enflock_mice.direct_move(id,pos_cache[id][0],pos_cache[id][1]);},remove_notify:function(id,clicked){var notify;notify=$("#notifywin-"+id);notify.css("visibility","hidden");if(clicked){clearTimeout(req_win_tos[id]);return document.Enflock.chatResponse(id,notify.data("is_public"));}},move:function(id,x,y){target_pos_cache[id]=[x,y];if(!pos_cache[id]){return pos_cache[id]=[x,y];}},interpolate_tick:function(){var at,id,target,_results;_results=[];for(id in target_pos_cache){at=pos_cache[id];target=target_pos_cache[id];if(vec2.dist_sqr(at,target)<25){at=target;delete target_pos_cache[id];}else{at=vec2.add(at,vec2.pointwise(vec2.sub(target,at),[0.35,0.35]));}
_results.push(enflock_mice.direct_move(id,at[0],at[1]));}
return _results;},direct_move:function(id,x,y){var w;mouse(id).offset({left:x,top:y});do_no_harm(old_self_pos,[x,y],id);if(id!==selfId){w=$("#notifywin-"+id);if(w.css("visibility")==="visible"){w.offset({left:x-w.width()/2,top:y-w.height()});}}
return pos_cache[id]=[x,y];},pointer_move:function(x,y){var selfStrId,uid,w;if(selfId===void 0){return;}
selfStrId=selfId.toString();for(uid in pos_cache){if(uid!==selfStrId){check_info_win([x,y],pos_cache[uid],uid);}}
w=$("#notifywin-"+selfId);if(w.css("visibility")==="visible"){w.offset({left:x-w.width()*1.2,top:y-w.height()*0.7});}
return old_self_pos=[x,y];},hide:function(id){return mouse(id).css("visibility","hidden");},show:function(id){if(!is_disabled_shadow(id)){return mouse(id).css("visibility","visible");}},part:function(id){$("#mousewin-"+id).remove();$("#notifywin-"+id).remove();$("#mouse-"+id).remove();delete lup[id];delete pos_cache[id];return delete target_pos_cache[id];},setSelf:function(id){selfId=id;return mouse(id).css("background","url("+BASE_URL+"mouse-self.png)");},getSelf:function(){return selfId;},shadow:function(enable){var vis;do_shadow=enable;vis=enable?"visible":"hidden";return mouse(selfId).css("visibility",vis);}};};enflock_mice=enflock_mice();window.enflock_mice=enflock_mice;enflock_handlers=function(){var mouseX,mouseY,move_ignore_t,move_last_sent,move_latest_pos,move_latest_sent_pos,outTimeout,self_hidden,send_move,tmp_event_count,vec2;vec2=enflock_lib.vec2;mouseX=function(evt){if(!evt){evt=window.event;}
if(evt.pageX){return evt.pageX;}else if(evt.clientX){return evt.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);}else{return 0;}};mouseY=function(evt){if(!evt){evt=window.event;}
if(evt.pageY){return evt.pageY;}else if(evt.clientY){return evt.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);}else{return 0;}};self_hidden=false;outTimeout=false;move_ignore_t=false;move_last_sent=0;move_latest_pos=[0,0];move_latest_sent_pos=[0,0];send_move=function(x,y){if(enflock_lib.bridge_up){document.Enflock.mouseMove(x,y);}
move_latest_sent_pos=[x,y];return move_ignore_t=setTimeout(function(){var delta,now;move_ignore_t=false;delta=vec2.sub(move_latest_sent_pos,move_latest_pos);now=new Date();now=now.getTime();if(Math.round(delta[0])!==0||Math.round(delta[1])!==0||(now-move_last_sent)>10000){send_move(move_latest_pos[0],move_latest_pos[1]);return move_last_sent=now;}},100);};tmp_event_count=0;return{follow:function(evt){var x,y;if(outTimeout){clearTimeout(outTimeout);outTimeout=false;if(self_hidden){if(enflock_lib.bridge_up){document.Enflock.mouseInWindow(true);}
self_hidden=false;}}
if(document.getElementById){x=parseInt(mouseX(evt));y=parseInt(mouseY(evt));move_latest_pos=[x,y];enflock_mice.pointer_move(x,y);if(!move_ignore_t){return send_move(x,y);}}},onmouseout:function(e){if(outTimeout){clearTimeout(outTimeout);}
return outTimeout=setTimeout(function(){if(enflock_lib.bridge_up){document.Enflock.mouseInWindow(false);}
self_hidden=true;return outTimeout=false;},50);},onload:function(){setInterval((function(){tmp_event_count++;return enflock_mice.interpolate_tick();}),33);return setInterval((function(){document.Enflock.log("interp frames/10s: "+tmp_event_count);return tmp_event_count=0;}),10000);}};};enflock_handlers=enflock_handlers();window.enflock_handlers=enflock_handlers;document.onmousemove=enflock_handlers.follow;window.onload=enflock_handlers.onload;document.onmouseout=enflock_handlers.onmouseout;enflock_chat=function(){var update_to;update_to=void 0;return{open:function(id,isPublic){var history,input,win;history="<div class='historyarea'></div>";input="<div class='chatarea'>"+(!isPublic?"<textarea class='chatpreview' disabled=yes></textarea>":"")+"<textarea class='chatinput'>"+"</textarea>"+"</div>";win=$("<div id='mouse-chat-"+id+"' class='chatwindow'>"+history+input+"</div>");if(isPublic){win.children("div.historyarea").css("height","80%");}
win.children("div.chatarea").children("textarea.chatinput").focus().keypress(function(e){if(e.which===13){document.Enflock.chatMessage(id,$(this).val(),false);enflock_chat.message(id,enflock_mice.getSelf(),$(this).val());$(this).val("");return false;}else if(!isPublic){if(update_to===void 0){return update_to=setTimeout(function(){var text_area;text_area=$("#mouse-chat-"+id).children("div.chatarea").children("textarea.chatinput");document.Enflock.chatMessage(id,text_area.val(),true);return update_to=void 0;},250);}}});win.dialog({width:200,height:322,autoOpen:false,closeOnEscape:false,title:(isPublic?"Discussion":"Chatting with "+id)}).css("overflow","hidden").css("opacity",0.8).dialog("open");win.children("div.historyarea").css("overflow-x","hidden").css("overflow-y","scroll");return win.children("div.chatarea").children("textarea.chatinput").focus();},message:function(id,from_id,msg){var lastActive,win;msg=decodeURIComponent(msg);win=$("#mouse-chat-"+id);lastActive=win.data("lastActive");if(lastActive!==from_id){win.children("div.historyarea").append("<div class=\"chatusername\">"+from_id+"</div>");win.data("lastActive",from_id);}
win.children("div.historyarea").append(msg+"<br>").attr({scrollTop:win.children("div.historyarea").attr("scrollHeight")});if(id===from_id){return win.children("div.chatarea").children("textarea.chatpreview").val("");}},update:function(id,msg){msg=decodeURIComponent(msg);return $("#mouse-chat-"+id).children("div.chatarea").children("textarea.chatpreview").val(msg);},close:function(id){return $("#mouse-chat-"+id).dialog("close").remove();},user_state:function(id,has_left){return $("#mouse-chat-"+id).children("div.historyarea").append("<div class=\"chatusername\">"+id+(has_left?" disconnected.":" joined.")+"</div>").attr({scrollTop:win.children("div.historyarea").attr("scrollHeight")});}};};enflock_chat=enflock_chat();window.enflock_chat=enflock_chat;}).call(this);
