
var clickError=false;var clickReaction=function(){};var wCookieOpts={path:"/",domain:"pastemagazine.com"};function getClickedObject(x,y,_react){var self=this;self.mouseX=x;self.mouseY=y;self.react=_react;self.targetFound=false;self.diveDownFailed=false;self.domWalk=function(node){var $node=(node==null)?$("body"):node;var numChildren=$node.children().length;if($node[0].tagName!=="SCRIPT"){if(self.hitTest($node)||($node[0].tagName=="BODY")){if(numChildren>0&&$node[0].tagName!=="A"){$node.children().each(function(index){return self.domWalk($(this));});if(self.targetFound==false&&self.diveDownFailed==false){self.diveDownFailed=true;self.reverseDomWalk($node);}
return false;}else{self.setTargetTag($node);self.targetFound=true;return false;}}else{return true;}}}
self.reverseDomWalk=function($node,skipNode){var $foundATags=$node.find("a");if($foundATags.length>0){$foundATags.each(function(index){var $aTag=$(this);self.targetFound=self.hitTest($aTag);if(self.targetFound){self.setTargetTag($aTag);return false;}else if($aTag.children().length>0){$aTag.find("*").each(function(index){self.targetFound=self.hitTest($(this));if(self.targetFound){self.setTargetTag($aTag);return false;}});if(self.targetFound){return false;}}});}
if(self.targetFound){return false;}else if($node.get(0)!==$("body").get(0)){self.reverseDomWalk($node.parent(),$node.get(0));}else{getMovie('incantation').clickNotFound();}}
self.hitTest=function($obj){var lX=$obj.offset().left;var tY=$obj.offset().top;var rX=lX+$obj.outerWidth();var bY=tY+$obj.outerHeight();if(self.mouseX>=lX&&self.mouseX<=rX&&self.mouseY>=tY&&self.mouseY<=bY){return true;}else{return false;}}
self.setTargetTag=function($obj){self.react($obj);$obj.css("border","1px dotted red");}
self.domWalk();}
$.fn.cloneCSS=function(objToClone,args){var property=null,style={display:"block",overflow:"hidden"};for(var i=0;i<args.length;i++){property=args[i];style[property]=objToClone.css(property);}
this.css(style);}
function getMovie(movieName){if(navigator.appName.indexOf("Microsoft")!=-1){return window[movieName];}else{return document[movieName];}}
function getCallbackObj(){callbackObj.clickError=(clickError)?true:false;clickError=false;return callbackObj;}
function updateScrollPos(){var ofs=$('#incantation').offset();getMovie('incantation').newScrollPos(ofs.left,ofs.top);}
function updateScale(){getMovie("incantation").refreshScale();}
function hideOverlays(){$("#search").css("visibility","hidden");}
function showOverlays(){$("#search").css("visibility","visible")}
var enchanted=false;var winWidth=$(window).width();var winHeight=$(window).height();function enchant(){var v=1;enchanted=true;$.cookie('hpsh',isMinimized,wCookieOpts);var scavhuntDiv=document.getElementById('scavhunt');scavhuntDiv.innerHTML=('<object id="incantation" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" style="position:fixed; top:0px; left:0px; z-index:100; width:100%; height:100%; visibility:visible !important;" width="100%" height="100%"><param name="movie" value="http://scavenger.pastemagazine.com/flash/incantation.swf?r=1258409722"></param><param name="wmode" value="transparent"</param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed name="incantation" style="position:fixed; top:0px; left:0px; z-index:100; visibility:visible !important;" width="100%" height="100%" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://scavenger.pastemagazine.com/flash/incantation.swf?r=1258409722"></embed></object>');var $searchDiv=$("#search");var searchPos=$searchDiv.offset();$containerDiv=$("#container");containerOffset=$containerDiv.offset();$searchDiv.css({position:"absolute",top:(searchPos.top-containerOffset.top),left:(searchPos.left-containerOffset.left),zIndex:101});$searchDiv.remove().appendTo($containerDiv);}
function unenchant(){enchanted=false;$.cookie('hpsh',null,wCookieOpts);$('#incantation').remove();}
var isMinimized=false;function getIsMinimized(){return isMinimized;}
function minimizeApp(){$.cookie('hpsh','true',wCookieOpts);var bottomPosition=winHeight-108;$('#incantation, #incantation embed').css({width:"562px",height:"108px",top:bottomPosition+"px"});}
function maximizeApp(){$.cookie('hpsh','false',wCookieOpts);$('#incantation, #incantation embed').css({width:"100%",height:"100%",top:"0px"});}
function flashInitialized(){updateScrollPos();updateScale();$('#incantation').focus();$(window).scroll(function(){updateScrollPos();});$(window).resize(function(){winWidth=$(window).width();winHeight=$(window).height();$("#incantation").width(winWidth);$("#incantation").height(winHeight);updateScale();});}
$(document).ready(function(){$('body').append('<div id="scavhunt""></div>');var currentFocus=null;$(':input').focus(function(){currentFocus=this;}).blur(function(){currentFocus=null;});var cmndDown=false;$(document).keydown(function(e){if(e.keyCode==91||e.keyCode==224){cmndDown=true;}
if(e.keyCode==27){if(enchanted==true){unenchant();}}});$(document).keypress(function(e){if(currentFocus==null){var code=(document.all)?e.keyCode:e.which;var ctrl=e.ctrlKey;var envokeKey1=(ctrl&&code==22);var envokeKey2=(ctrl&&code==118);var envokeKey3=(cmndDown&&code==118)
if(envokeKey1||envokeKey2||envokeKey3){if(enchanted==false){enchant();}else{unenchant();}}}
cmndDown=false;});var enchantedCookie;if(enchantedCookie=$.cookie('hpsh')){isMinimized=false;enchant();}else{}});jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};