/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

/**
 * Modifications by Patrick Nelson (pat@catchyour.com -- patricksmedium.com)
 *
 * Copied from iStockPhoto and modified to:
 *
 * Allow up to two images, vertically or side by side and to
 * automatically calculate image height without receiving parameters for height.
 * Also modified to better reposition image when mouse in ANY location. 
 * Also added preload code to show "wait.gif" image while image loads. Tested
 * and compatible with IE6, IE7, IE8, Firefox, Opera and Chrome.
 */
typeof jQuery!="undefined"&&$(function(){$("a.trailimage").mouseover(function(){var a=$(this).attr("img");showtrail(a)});$("a.trailimage").mouseout(function(){hidetrail()});$("a.trailimage").click(function(){return true})});var offsetfrommouse=15,displayduration=0,waitimgsource="http://2011wpfg.org/img/wait.gif",usewaitimg=true,waitimg=new Image;waitimg.onload=function(){usewaitimg=true};waitimg.src=waitimgsource; if(document.getElementById||document.all){document.write('<div id="trailimageid" style="position: absolute; display: none; left: 0px; top: 0px; z-index: 200;">');document.write("</div>")}function gettrailobj(){if(document.getElementById)return document.getElementById("trailimageid").style;else if(document.all)return document.all.trailimagid.style} function gettrailobjnostyle(){if(document.getElementById)return document.getElementById("trailimageid");else if(document.all)return document.all.trailimagid}function truebody(){return!window.opera&&document.compatMode&&document.compatMode!="BackCompat"?document.documentElement:document.body} function showtrail(a,b,c){document.onmousemove=followmouse;if(typeof c=="undefined")c=true;newHTML='<div style="padding: 5px; background-color: #FFF; border: 1px solid #888;">';newHTML+='<div align="center" style="padding: 2px 2px 2px 2px;">';if(typeof b!="undefined")if(c){newHTML+='<table border="0" cellspacing="0" cellpadding="0"><tr>';newHTML=newHTML+'<td valign="top"><img src="'+a+'" border="0"></td>';newHTML+="<td>&nbsp;&nbsp;&nbsp;</td>";newHTML=newHTML+'<td valign="top"><img src="'+b+'" border="0"></td>'; newHTML+="</tr></table>"}else{newHTML=newHTML+'<div><img src="'+a+'" border="0"></div>';newHTML=newHTML+'<div style="padding-top: 8px;"><img src="'+b+'" border="0"></div>'}else{useimg=a;if(usewaitimg)useimg=waitimgsource;newHTML=newHTML+'<img src="'+useimg+'" border="0" id="trailimage_image">'}newHTML+="</div>";newHTML+="</div>";gettrailobjnostyle().innerHTML=newHTML;gettrailobj().display="inline";typeof b=="undefined"&&trail_preload(a)} function hidetrail(){gettrailobj().display="none";document.onmousemove="";gettrailobj().left="-1000px";gettrailobj().top="-1000px"} function followmouse(a){var b=offsetfrommouse,c=offsetfrommouse;scrolltop=jQuery?Math.max(truebody().scrollTop,$("body").scrollTop()):truebody().scrollTop;b=document.all?truebody().scrollLeft+truebody().clientWidth:pageXOffset+window.innerWidth-15;c=document.all?Math.min(truebody().scrollHeight,truebody().clientHeight):Math.min(window.innerHeight);var e=gettrailobjnostyle().offsetHeight+16,d=gettrailobjnostyle().offsetWidth+16;if(typeof a!="undefined"){mousex=a.pageX;mousey=a.pageY}else if(typeof window.event!= "undefined"){mousex=event.clientX+truebody().scrollLeft;mousey=event.clientY+scrolltop}xbalancing=false;mousexWin=mousex+truebody().scrollLeft;if(b-mousex<d)if(mousex>d)b=mousex-d;else{xbalancing=true;b=b-d+offsetfrommouse}else b=mousex+offsetfrommouse;mouseyWin=mousey-scrolltop;c=c-mouseyWin<e?xbalancing?mouseyWin>c-mouseyWin?mousey-e:mousey+offsetfrommouse:c+scrolltop-e+offsetfrommouse:mousey+offsetfrommouse;gettrailobj().left=b+"px";gettrailobj().top=c+"px"}var loadedimgs=[]; function trail_preload(a){for(i=0;i<loadedimgs.length;i++)if(loadedimgs[i][0]==a){document.getElementById("trailimage_image").src=loadedimgs[i][1];debug("set image to previously loaded: "+loadedimgs[i][1]);return true}debug("creating new image to load: "+a);loadimg=new Image;loadimg.onload=function(){document.getElementById("trailimage_image").src=this.src;debug("loaded: "+this.src);followmouse()};loadimg.src=a;loadedimgs[loadedimgs.length]=[a,loadimg.src];return true} function debug(a){typeof console!="undefined"&&console.log(a)};
