Language='';IMAGE_WIDTH=614;IMAGE_HEIGHT=815;asyncState=new Object();function convcur(a)
{var b=a.toFixed(2).toString()
var i=b.length-1;var started=false;var kc=0;var d=new Array();if(Language=='russian')
{d.push(' $');}
for(i;i>=0;i--)
{var c=b.charAt(i);if(c=='.')
{started=true;if(Language=='russian')
{c=',';}
d.push(c);continue;}
d.push(c);if(started)
{kc++;kc=kc%3;if(kc==0&&i!=0)
{if(Language=='russian')
{d.push(' ');}
else
{d.push(',');}}}}
if(Language=='english')
{d.push('$');}
return d.reverse().join('');}
function localizeThis(selector,callback)
{if(callback==undefined)
{callback=false;}
if(selector!='*'&&$(selector).length==1&&$(selector).is('.monetizable'))
{var res=convcur(parseInt($(selector).attr('v')));$(selector).text(res);}
else
{$('.monetizable[v]',$(selector)).each(function()
{var res=convcur(parseInt($(this).attr('v')));$(this).text(res);});}
var rids=new Array();$(selector+' .localizable[v]').each(function()
{rids.push($(this).attr('v'));});$.ajax({url:'tr',type:'POST',data:{rids:JSON.stringify(rids),lang:Language},success:function(data,textStatus)
{for(i in data)
{var rid=data[i][0];var value=data[i][1];$(selector+' .localizable[v="{0}"]:not(.hrefonly)'.format(rid)).html(value);$(selector+' .hrefonly[v="{0}"]'.format(rid)).attr('href',value);}
if(callback)
{callback();}},error:function(XMLHttpRequest,textStatus,errorThrown)
{},dataType:'json'});}
function getMeRetrievec()
{var self=new Object();var tmid;var running=false;self.retrievec=function()
{retrievec(asyncState);}
self.start=function()
{if(!running)
{tmid=setInterval('retrievec(asyncState);',30000);running=true;}}
self.stop=function()
{clearTimeout(tmid);running=false;}
return self;}
$(document).ready(function()
{$('#contribute').hide();asyncState.curTid=0;asyncState.selecting=false;asyncState.contributionsSoFar=0;takens=new Array(IMAGE_WIDTH);var i=0;for(i;i<takens.length;i++)
{takens[i]=new Array(IMAGE_HEIGHT);}
asyncState.contributions=new Array();asyncState.retrievec=getMeRetrievec();asyncState.retrievec.retrievec();asyncState.contributionsByMoney=new Array();$('#contribute_submit').click(function(e)
{var ms=$('#moneyShare');var left=$('#moneyShare').css('left').split('px')[0]-houseXY[0];var width=ms.width();var top=$('#moneyShare').css('top').split('px')[0]-houseXY[1];var height=ms.height();$.ajax({url:'ppsec',type:'POST',data:{p:asyncState.contributionAmount,left:left,width:width,top:top,height:height,hash:window.location.hash.substring(1)},complete:function(XMLHttpRequest,textStatus)
{},beforeSend:function(XMLHttpRequest)
{$('#ajax_loader').show(0.4);},success:function(data)
{var result=data;if(result)
{if(result.ACK=='Success')
{window.location="{0}/cgi-bin/webscr?cmd=_express-checkout&token={1}".format(PaypalUserUrl,result.TOKEN);}
else if(result=='Collision')
{$('#ajax_loader').hide(0.4);$('#collision_dialog').dialog('open');}}
else
{$('#ajax_loader').hide(0.4);$('#ppsec_error_dialog').dialog('open');}},error:function(XMLHttpRequest,textStatus,errorThrown)
{$('#ajax_loader').hide(0.4);$('#ppsec_error_dialog').dialog('open');},dataType:"json"});$('#contribute').hide();});$('#contribute :input').select(function(e)
{return false;});handleMovement(asyncState);var slider_options={orientation:'horizontal',animate:true,max:500000,step:1};var slider=$('#slider');slider.slider(slider_options);var positionSliderMoney=function()
{var sx=$('#slider_container').position().left;var sy=$('#slider_container').position().top;var x=$('.ui-slider-handle').position().left;var y=$('.ui-slider-handle').position().top;$('#slider_money').css({'left':sx+x+'px','top':sy+y-20+'px'});}
var f=function(event,ui)
{positionSliderMoney();var curprice=ui.value;$('#slider_money').attr('v',curprice);$('#slider_money').html('{0}'.format(convcur(curprice)));if(event.originalEvent!=undefined)
{var c;var i,start,finish,step;start=asyncState.prevCurprice;finish=curprice;if(asyncState.prevCurprice<=curprice)
{for(i=start;i<=finish;i++)
{if((c=asyncState.contributionsByMoney[i])!=undefined)
{c.show(1000);}}}
else
{for(i=start;i>finish;i--)
{if((c=asyncState.contributionsByMoney[i])!=undefined)
{c.hide(1000);}}}
asyncState.prevCurprice=curprice;}}
var slidestop=function(event,ui)
{if(ui.value>asyncState.contributionsSoFar)
{$(this).slider('option','value',asyncState.contributionsSoFar);}
f(event,ui);}
slider.bind('slidechange',f);slider.bind('slide',f);slider.bind('slidestop',slidestop);var houseLeft=$('#house').position().left;var houseTop=$('#house').position().top;houseXY=[]
houseXY.push(houseLeft,houseTop,houseLeft+IMAGE_WIDTH,houseTop+IMAGE_HEIGHT);asyncState.houseXY=houseXY;$('#contributor_info').bind('mousedown',asyncState,handleMouseDown);$('#contributor_info').mouseenter(function()
{if(asyncState.selecting==false)
{$(this).data('contribution').o.addClass('innerborder');var timeout=$(this).data('timeout');if(timeout)
{var timeoutId=timeout.id;if(timeoutId)
{clearTimeout(timeoutId);}}}}).mouseleave(function()
{$(this).data('contribution').o.removeClass('innerborder');var id=setTimeout('$("#contributor_info").hide(1000);',3000);$(this).data('timeout',{id:id});});$('#kill_contribute').click(function()
{$('#contribute').hide();$('#moneyShare').hide();});$('#contributor_info a').live('mouseover',function()
{$('#contributor_info').unbind('mousedown');$(this).mouseout(function()
{$('#contributor_info').bind('mousedown',asyncState,handleMouseDown);});});$('#contributors_table:has(tbody tr)').tablesorter({sortList:[[3,1]]});$('.formatted_contribution_amount').each(function()
{$(this).text(convcur(parseInt($(this).attr('v'))));});localizeThis('#contributors');asyncState.videos=new Array();asyncState.curvideo=0;$('.navbutton').css('opacity',0.25);$.ajax({url:'recordings',data:{tid:asyncState.curTid},success:function(data,textStatus)
{$('#recordings').html(data);$('#recordings > .recording').each(function()
{var url=$(this).attr('url');var i=$(this).attr('i');asyncState.videos.push([url,i]);$(this).hover(function()
{$(this).addClass('recording-hover');},function()
{$(this).removeClass('recording-hover');});$(this).click(function(e)
{var ind=$('.recording').index(this);asyncState.curvideo=ind-1;setMovie(true);});});if(asyncState.videos.length!=0)
{$('.navbutton').css('opacity',1.0);var f=window.location.hash.toString();if(f.length!=0)
{var fs=f.substring(1).split('/');var ind=-1;var dind=-1;jQuery.each(fs,function(i,val)
{if(val.startsWith('play:'))
{var play_id=val.substring(5);jQuery.each(asyncState.videos,function(y,innerval)
{if(innerval[1]==play_id)
{asyncState.curvideo=y;return false;}});return false;}});}}
localizeThis('#recordings',setMovie);},dataType:'html'});function setMovie(permalink)
{if(permalink==undefined)
{permalink=false;}
if(asyncState.videos[asyncState.curvideo]==undefined)
{return;}
$('#current_recording .recording').remove();$('#recordings .current').removeClass('current');var r=$('.recording[url="{0}"]'.format(asyncState.videos[asyncState.curvideo][0]));r.addClass('current');r=r.clone(false);r.removeClass('current');r.removeClass('recording-hover');var recording_id=r.attr('i');$('#current_recording').prepend(r);var autoplay='';if(permalink)
{autoplay='&autoplay=1';}
var html='<object id="mtv" width="425" height="344"><param name="movie" value="{0}&rel=0{1}" ></param><param name="wmode" value="opaque"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="{0}&rel=0{1}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="false" width="425" height="344" wmode="opaque"></embed></object>'.format(asyncState.videos[asyncState.curvideo][0],autoplay);$('#movie').html(html);if(permalink)
{var f=window.location.hash.toString();if(f.length!=0)
{var fs=f.substring(1).split('/');var ind=-1;var dind=-1;jQuery.each(fs,function(i,val)
{if(val.startsWith('play:'))
{ind=i;return false;}});$('.directlinkable a[v]').each(function()
{if((dind=jQuery.inArray($(this).attr('v'),fs))!=-1)
{return false;}});var play='play:{0}'.format(recording_id);if(dind!=-1&&ind==-1)
{fs[dind]='{0}/{1}'.format(fs[dind],play);}
else if(ind!=-1)
{fs[ind]=play;}
else if(ind==-1)
{fs.unshift(play);}
window.location.hash='#{0}'.format(fs.join('/'));}}};$('#nav_next').click(function(e)
{if(asyncState.videos.length!=0)
{asyncState.curvideo++;asyncState.curvideo=asyncState.curvideo%asyncState.videos.length;setMovie(true);}});$('#nav_previous').click(function(e)
{if(asyncState.videos.length!=0)
{asyncState.curvideo--;if(asyncState.curvideo<0)
{asyncState.curvideo=asyncState.videos.length-1;}
setMovie(true);}});$('#slider').slider('value',0);});$(document).ready(function()
{$.ajax({url:'about',data:{tid:asyncState.curTid},success:function(data,textStatus)
{$('#about').html(data);localizeThis('#about');},dataType:'html'});$.ajax({url:'faq',data:{tid:asyncState.curTid},success:function(data,textStatus)
{$('#faq').html(data);localizeThis('#faq');},dataType:'html'});localizeThis('#highlight_all');$('#highlight_all').toggle(function()
{$('.contribution').addClass('highlighted');$('*[v="no_highlight"]',$(this)).show();$('*[v="highlight_all"]',$(this)).hide();},function()
{$('.contribution').removeClass('highlighted');$('*[v="no_highlight"]',$(this)).hide();$('*[v="highlight_all"]',$(this)).show();});});function retrievec(asyncState)
{if($('#contribute').is(':visible'))
{return;}
$.ajax({url:'retrievec',data:{tid:asyncState.curTid},success:function(data,textStatus)
{var keep_going=data[0];var contributions=data[1];var contributionsSoFar=asyncState.contributionsSoFar;for(i in contributions)
{var c=contributions[i];if(c.id>asyncState.curTid)
{asyncState.curTid=c.id;}
else
{keep_going=false;}
contributionsSoFar+=parseInt(c.width)*parseInt(c.height);c.left+=houseXY[0];c.top+=houseXY[1];asyncState.contributionsSoFar=contributionsSoFar;addContribution(c);}
if(keep_going)
{retrievec(asyncState);}
else
{$('#highlight_all').trigger('click');}},error:function(XMLHttpRequest,textStatus,errorThrown)
{},dataType:'json'});}
function addContribution(c)
{var ms=$('#moneyShare');var contribution=ms.clone(false);contribution.removeClass('innerborder');contribution.css('top',c.top+'px');contribution.css('left',c.left+'px');contribution.width(c.width);contribution.height(c.height);contribution.bind('mousedown',asyncState,handleMouseDown);contribution.addClass('contribution');contribution.attr('id','contribution'+asyncState.contributions.length);contribution.data('sofar',asyncState.contributionsSoFar);asyncState.contributionsByMoney[asyncState.contributionsSoFar]=contribution;$('#slider').slider('value',asyncState.contributionsSoFar);asyncState.prevCurprice=asyncState.contributionsSoFar;contribution.mouseenter(function()
{if(asyncState.selecting==false)
{var info=JSON.parse(c.info);var contributor_info=$('#contributor_info');var url=info.url;if(url.length>50)
{url=url.substring(0,50)+'...';}
contributor_info.html('<span class="thank_you">{0}</span><br />{1}{2}{3}{4}'.format(convcur(parseInt(c.width)*parseInt(c.height)),info.name.length!=0?'{0}<br />'.format(info.name):'Anonymous<br />',info.from.length!=0?'{0}<br />'.format(info.from):'',c.ts,info.url.length!=0?'<br /><a href="{0}")">{1}</a>'.format(info.url,url):''));contributor_info.css({'left':$(this).position().left-contributor_info.width()});var t0=$(this).position().top-contributor_info.height();if(t0<$('#house').position().top)
{t0=$(this).position().top+$(this).height();}
contributor_info.css({'top':t0});$(this).addClass('innerborder');contributor_info.show(1000);contributor_info.data('contribution',{o:$(this)});var timeout=contributor_info.data('timeout');if(timeout)
{var timeoutId=timeout.id;if(timeoutId)
{clearTimeout(timeoutId);}}}}).mouseleave(function()
{$(this).removeClass('innerborder');var id=setTimeout('$("#contributor_info").hide(1000);',3000);$('#contributor_info').data('timeout',{id:id});});contribution.prependTo('#canvas');contribution.show();showBackground(contribution);asyncState.contributions.push(contribution);addTaken(moneyShareRelativeToHouse(contribution));}
function showMoney(amount,asyncState)
{$('#moveinfo').html('{0}'.format(convcur(amount)));}
function handleMouseDown(e)
{$('#contribute').hide();$('#contributor_info').hide();e.data.selecting=true;e.data.cursorEastWest='east';e.data.cursorNorthSouth='south';e.data.startingPoint={x:e.pageX,y:e.pageY};var ms=$('#moneyShare');ms.css({'left':e.data.startingPoint.x+'px','top':e.data.startingPoint.y+'px'});ms.css({'right':e.data.startingPoint.x+'px','bottom':e.data.startingPoint.y+'px'});ms.width(1);ms.height(1);ms.show();showMoney(1,e.data);$('#moveinfo').show();return false;}
function truncateMsOnCollisions(asyncState)
{var ms=$('#moneyShare');var houseXY=asyncState.houseXY;$('#info3').html('{0}'.format(houseXY));var left=ms.css('left').split('px')[0]-houseXY[0];var width=ms.width();var right=left+width;var top=ms.css('top').split('px')[0]-houseXY[1];var height=ms.height();var bottom=top+height;var ams={left:left,right:right,top:top,bottom:bottom,width:width,height:height};var ams0={left:left,right:right,top:top,bottom:bottom,width:width,height:height};var i=0,k=0,y=0;$('#info4').html('le:{0} to:{1} bo:{2} ri:{3} wi:{4} he:{5} hX:{6} xY:{7}'.format(left,top,bottom,right,width,height,houseXY[0],houseXY[1]));var noProblemsWithSelection=true;var seekingB=true;var seekingT=false;var seekingR=false;var seekingL=false;var done=false;if(asyncState.cursorNorthSouth=='north')
{for(i=bottom;!done&&i>=top;i--)
{if(asyncState.cursorEastWest=='west')
{if(seekingL)
{seekingL=false;seekingT=true;}
for(k=right;!done&&k>=left;k--)
{if(takens[k][i]!=undefined)
{if(seekingL)
{ams.left=k+1;seekingL=false;seekingT=true;break;}
else if(seekingT)
{if(k>=ams.left&&k<ams.right||(width==1&&k==ams.right))
{ams.top=i+1;done=true;break;}}}
else
{if(seekingB)
{ams.right=k;ams.bottom=i;seekingB=false;seekingL=true;if(ams.right!=right)
{ams.right+=1;}
if(ams.bottom!=bottom)
{ams.bottom+=1;}}
else if(seekingL)
{ams.left=k;}
else if(seekingT)
{ams.top=i;}}}}
else if(asyncState.cursorEastWest=='east')
{if(seekingR)
{seekingR=false;seekingT=true;}
for(k=left;!done&&k<=right;k++)
{if(k==IMAGE_WIDTH||takens[k][i]!=undefined)
{if(seekingR)
{ams.right=k;seekingR=false;seekingT=true;break;}
else if(seekingT)
{if(k>=ams.left&&k<ams.right||(width==1&&k==ams.right))
{ams.top=i+1;done=true;break;}}}
else
{if(seekingB)
{ams.left=k;ams.bottom=i;seekingB=false;seekingR=true;if(ams.bottom!=bottom)
{ams.bottom+=1;}}
else if(seekingR)
{ams.right=k;}
else if(seekingT)
{ams.top=i;}}}}}
if(seekingB)
{noProblemsWithSelection=false;}}
else if(asyncState.cursorNorthSouth=='south')
{seekingB=false;seekingT=true;seekingR=false;seekingL=false;for(i=top;i<=bottom;i++)
{if(asyncState.cursorEastWest=='west')
{if(seekingL)
{seekingL=false;seekingB=true;}
for(k=right;!done&&k>=left;k--)
{if(i==IMAGE_HEIGHT||takens[k][i]!=undefined)
{if(seekingL)
{ams.left=k+1;seekingL=false;seekingB=true;break;}
else if(seekingB)
{if(k>=ams.left&&k<ams.right||(width==1&&k==ams.left))
{ams.bottom=i;done=true;break;}}}
else
{if(seekingT)
{ams.right=k;ams.top=i;seekingT=false;seekingL=true;if(ams.right!=right)
{ams.right+=1;}
if(ams.bottom!=bottom)
{ams.bottom+=1;}}
else if(seekingL)
{ams.left=k;}
else if(seekingB)
{ams.bottom=i;}}}}
else if(asyncState.cursorEastWest=='east')
{if(seekingR)
{seekingR=false;seekingB=true;}
for(k=left;!done&&k<=right;k++)
{if(k==IMAGE_WIDTH||i==IMAGE_HEIGHT||takens[k][i]!=undefined)
{if(seekingR)
{ams.right=k;seekingR=false;seekingB=true;break;}
else if(seekingB)
{if(k>=ams.left&&k<ams.right||(width==1&&k==ams.left))
{ams.bottom=i;done=true;break;}}}
else
{if(seekingT)
{ams.left=k;ams.top=i;seekingT=false;seekingR=true;if(ams.bottom!=bottom)
{ams.bottom+=1;}}
else if(seekingR)
{ams.right=k;}
else if(seekingB)
{ams.bottom=i;}}}}}
if(seekingT)
{noProblemsWithSelection=false;}}
if(asyncState.cursorEastWest=='west')
{if(asyncState.cursorNorthSouth=='north')
{seekingB=true;seekingT=false;}
else if(asyncState.cursorNorthSouth=='south')
{seekingB=false;seekingT=true;}
seekingR=false;seekingL=false;done=false;for(k=right;!done&&k>=left;k--)
{if(asyncState.cursorNorthSouth=='north')
{if(seekingT)
{seekingT=false;seekingL=true;}
for(i=bottom;!done&&i>=top;i--)
{if(takens[k][i]!=undefined)
{if(seekingT)
{ams0.top=i+1;seekingT=false;seekingL=true;break;}
else if(seekingL)
{if(i>=ams0.top&&i<ams0.bottom)
{ams0.left=k+1;done=true;break;}}}
else
{if(seekingB)
{ams0.right=k;ams0.bottom=i;seekingB=false;seekingT=true;if(ams0.right!=right)
{ams0.right+=1;}
if(ams0.bottom!=bottom)
{ams0.bottom+=1;}}
else if(seekingL)
{ams0.left=k+1;}
else if(seekingT)
{ams0.top=i+1;}}}}
else if(asyncState.cursorNorthSouth=='south')
{if(seekingB)
{seekingB=false;seekingL=true;}
for(i=top;i<=bottom;i++)
{if(takens[k][i]!=undefined)
{if(seekingB)
{ams0.bottom=i;seekingB=false;seekingL=true;break;}
else if(seekingL)
{if(i>=ams0.top&&i<ams0.bottom)
{ams0.left=k+1;done=true;break;}}}
else
{if(seekingT)
{ams0.right=k;ams0.top=i;seekingT=false;seekingB=true;if(ams0.right!=right)
{ams0.right+=1;}}
else if(seekingL)
{ams0.left=k+1;}
else if(seekingB)
{ams0.bottom=i;}}}}}
if(seekingB)
{}}
else if(asyncState.cursorEastWest=='east')
{if(asyncState.cursorNorthSouth=='north')
{seekingB=true;seekingT=false;}
else if(asyncState.cursorNorthSouth=='south')
{seekingB=false;seekingT=true;}
seekingR=false;seekingL=false;done=false;for(k=left;!done&&k<=right;k++)
{if(asyncState.cursorNorthSouth=='north')
{if(seekingT)
{seekingT=false;seekingR=true;}
for(i=bottom;!done&&i>=top;i--)
{if(k==IMAGE_WIDTH||takens[k][i]!=undefined)
{if(seekingT)
{ams0.top=i+1;seekingT=false;seekingR=true;break;}
else if(seekingR)
{if(i>=ams0.top&&i<ams0.bottom)
{ams0.right=k;done=true;break;}}}
else
{if(seekingB)
{ams0.left=k;ams0.bottom=i;seekingB=false;seekingT=true;if(ams0.bottom!=bottom)
{ams0.bottom+=1;}}
else if(seekingR)
{ams0.right=k;}
else if(seekingT)
{ams0.top=i+1;}}}}
else if(asyncState.cursorNorthSouth=='south')
{if(seekingB)
{seekingB=false;seekingR=true;}
for(i=top;i<=bottom;i++)
{if(k==IMAGE_WIDTH||takens[k][i]!=undefined)
{if(seekingB)
{ams0.bottom=i;seekingB=false;seekingR=true;break;}
else if(seekingR)
{if(i>=ams0.top&&i<ams0.bottom)
{ams0.right=k;done=true;break;}}}
else
{if(seekingT)
{ams0.left=k;ams0.top=i;seekingT=false;seekingB=true;}
else if(seekingR)
{ams0.right=k;}
else if(seekingB)
{ams0.bottom=i;}}}}}
if(seekingB)
{}}
ams.left+=houseXY[0];ams.right+=houseXY[0];ams.top+=houseXY[1];ams.bottom+=houseXY[1];ams.width=ams.right-ams.left;ams.height=ams.bottom-ams.top;ams0.left+=houseXY[0];ams0.right+=houseXY[0];ams0.top+=houseXY[1];ams0.bottom+=houseXY[1];ams0.width=ams0.right-ams0.left;ams0.height=ams0.bottom-ams0.top;if(ams.width*ams.height>ams0.width*ams0.height)
{ms.css({'left':ams.left+'px'});ms.css({'right':ams.right+'px'});ms.css({'top':ams.top+'px'});ms.css({'bottom':ams.bottom+'px'});ms.width(ams.right-ams.left);ms.height(ams.bottom-ams.top);}
else
{ms.css({'left':ams0.left+'px'});ms.css({'right':ams0.right+'px'});ms.css({'top':ams0.top+'px'});ms.css({'bottom':ams0.bottom+'px'});ms.width(ams0.right-ams0.left);ms.height(ams0.bottom-ams0.top);}
return noProblemsWithSelection;}
function handleMovement(asyncState)
{$('#moveinfo').hide();$('#house').bind('mousedown',asyncState,handleMouseDown);$('body').bind('mouseup',asyncState,function(e)
{if(e.data.selecting==true)
{var houseXY=asyncState.houseXY;e.data.selecting=false;$('#moveinfo').hide();var ms=$('#moneyShare');if(ms.position().left<houseXY[0])
{ms.width(ms.width()-(houseXY[0]-ms.position().left));ms.css({'left':houseXY[0]});}
if(ms.position().top<houseXY[1])
{ms.height(ms.height()-(houseXY[1]-ms.position().top))
ms.css({'top':houseXY[1]});}
if(ms.position().left+ms.width()>houseXY[2])
{var right=ms.position().left+ms.width();ms.width(ms.width()-(right-houseXY[2]));}
if(ms.position().top+ms.height()>houseXY[3])
{var bottom=ms.position().top+ms.height();ms.height(ms.height()-(bottom-houseXY[3]))}
if(truncateMsOnCollisions(asyncState))
{$('#moneyShare').addClass('innerborder');showBackground($('#moneyShare'));showContribute(e.data);}}});$('body').bind('mousemove',asyncState,function(e)
{if(e.data.selecting)
{var ms={left:e.data.startingPoint.x,right:e.data.startingPoint.x,top:e.data.startingPoint.y,bottom:e.data.startingPoint.y,width:1,height:1};var moneyX=1,moneyY=1;if(e.pageX<e.data.startingPoint.x)
{ms.left=e.pageX;ms.right=e.data.startingPoint.x;ms.width=moneyX=e.data.startingPoint.x-ms.left;if(e.pageX<houseXY[0])
{moneyX=e.data.startingPoint.x-houseXY[0];}
e.data.cursorEastWest='west';}
else if(e.pageX>e.data.startingPoint.x)
{ms.right=e.pageX;ms.left=e.data.startingPoint.x;ms.width=moneyX=ms.right-e.data.startingPoint.x;if(e.pageX>houseXY[2])
{moneyX=houseXY[2]-e.data.startingPoint.x;}
e.data.cursorEastWest='east';}
if(e.pageY<e.data.startingPoint.y)
{ms.top=e.pageY;ms.bottom=e.data.startingPoint.y;ms.height=moneyY=e.data.startingPoint.y-ms.top;if(e.pageY<houseXY[1])
{moneyY=e.data.startingPoint.y-houseXY[1];}
e.data.cursorNorthSouth='north';}
else if(e.pageY>e.data.startingPoint.y)
{ms.bottom=e.pageY;ms.top=e.data.startingPoint.y;ms.height=moneyY=ms.bottom-e.data.startingPoint.y;if(e.pageY>houseXY[3])
{moneyY=houseXY[3]-e.data.startingPoint.y;}
e.data.cursorNorthSouth='south';}
var msc0=clone(ms);var msc1=clone(ms);var moneyShare=$('#moneyShare');moneyShare.css({'top':ms.top+'px'});moneyShare.css({'bottom':ms.bottom+'px'});moneyShare.height(ms.height);moneyShare.css({'left':ms.left+'px'});moneyShare.css({'right':ms.right+'px'});moneyShare.width(ms.width);showBackground(moneyShare);showMoney(ms.height*ms.width,e.data);}
else
{$('#moveinfo').html('{0},{1}'.format(e.pageX,e.pageY));}
$('#moveinfo').css({'left':e.pageX+15+'px','top':e.pageY+25+'px'});$('#moveinfo').css('z-index',999);});}
function showContribute(asyncState)
{var ms=$('#moneyShare');var midpointX=ms.position().left+ms.width()/2+5;var midpointY=ms.position().top+ms.height()/2+5;$('#contribute').css({'left':midpointX});$('#contribute').css({'top':midpointY});var amount=$(ms).width()*$(ms).height();if(amount==1)
{$('#shameless_hint').show();}
else
{$('#shameless_hint').hide();}
$('#contribute_amount').attr('v',amount);localizeThis('#contribute_amount');$('#contribute').show();asyncState.contributionAmount=amount;}
function showBackground(ms)
{var moneyShareCurLeft=ms.position().left;var moneyShareCurTop=ms.position().top;var ix=(moneyShareCurLeft-houseXY[0])*-1;var iy=(moneyShareCurTop-houseXY[1])*-1;ms.css('background-position',ix+'px '+iy+'px');}
function clone(o0)
{var o=new Object();for(attr in o0)
{o[attr]=o0[attr];}
return o;}
function moneyShareRelativeToHouse(ms)
{var moneyShareLeft=parseInt(ms.position().left-houseXY[0]);var moneyShareTop=parseInt(ms.position().top-houseXY[1]);var moneyShareWidth=ms.width();var moneyShareHeight=ms.height();return{left:moneyShareLeft,top:moneyShareTop,width:moneyShareWidth,height:moneyShareHeight};}
function addTaken(moneyShare)
{var left=moneyShare.left;var width=moneyShare.width;var right=left+width;var top=moneyShare.top;var height=moneyShare.height;var bottom=top+height;var w,h;var p=0;for(w=left;w<right;w++)
{for(h=top;h<bottom;h++)
{takens[w][h]={left:left,width:width,top:top,height:height};p++;}}}
