//
//------------------------------
//
// Do not remove this header.
// Place this script near the top of your page.
//------------------------------
//   Popup Image viewer code by  
//   ShipScript copyright 2005 ISDN*tek
//   http://www.isdntek.com/etools.htm
//   With thanks to CodeLifter.com 
//   and www.howtocreate.co.uk
//   This code has been tested in 
//   Internet Explorer 6, FireFox 1, 
//   Netscape 7, and eBay
//------------------------------
//
//  J. Anthony Fitzgerald NOTE   2007-05-10
//
//    Tried to use as documented, however, javascript Console told me
//    that the puShow function was not defined.  In an attempt to get
//    at this, I unpacked the single line that was writing this out to
//    the document then got rid of the things that caused javascript to
//    complain until it worked.  I am still not sure why the original
//    did not work.  At any rate, please keep the copyrights in place
//    and note that this modified version is based upon the work of the
//    people cited above.
//
//    Only functions which were causing problems were unravelled from
//    being single long lines.  I did separate the functions to into
//    individual lines for some readability and convenience.  Any
//    changes have been commented where the change was made.
//
//------------------------------
//  user editing ~~
//------------------------------
// Add your copyright notice to the Viewer.
// Do not use quotes or apostrophes 
// in the notice. HTML is ok.
//------------------------------
/*
      var puCopyright= "Photos copyright &copy; this eBay user. Do not copy without permission." ;
      var puTheme= "linen" ;
*/
//------------------------------
// PopUp color Themes are: 
//      "gray";  "black";  "blue";  
//	"brick"; "brown";  "linen";  
//	"navy";  "olive";  "pink";  
//------------------------------
// Use with fairly normal click-to-enlarge 
// image links, like this example:
//------------------------------
/*
<a href="http://www.myhost.com/largeimage.jpg" 
    title="Title of this photo"
    onclick="puShow(this.title, this.href); return false;" 
    ><img src="http://www.myhost.com/thumbnail.jpg" ></a>
*/
//------------------------------
//  end of user editing ~~
//------------------------------
//-->
/*  Comment out HTML snippet
</script>
<div style="display: none;">popvu</div>
<script language="JavaScript1.2">
/*
<!--
/* custom designer color themes */
var puTextColor="#ffffff";
var puBkgdColor="#606060";
var puHeadColor="#c0c0c0";
var puButnColor="#c20000";
var puButnText ="#ffffff";
//------------------------------
// the following javascript code 
// must remain as one long sentence 
// to function correctly.
//------------------------------

var puTextSize = "14";
var puTextBold = "normal";
var puTextFace = "verdana";
var isIEpu=document.all;
var puHot=false;
var puStarted=false;
var puColors=new Array( /*theme text bkgd head btn btnTxt*/ "linen","#222222","#d4cfbb","#888877","#c0bba4","#fffff0", "brown","#ffffff","#776644","#999977","#665944","#eeeecc", "brick","#ffeeaa","#993322","#ddbb88","#bb6644","#ffeecc", "gray" ,"#ffffff","#606060","#c0c0c0","#c20000","#ffffff", "black","#e0e0e0","#000000","#999999","#333333","#e0e0e0", "blue" ,"#ffffff","#004090","#ffffff","#c20000","#ffffff", "navy" ,"#ffffff","#333366","#999999","#505080","#dddddd", "pink" ,"#332222","#ffdddd","#a0a0a0","#ddaaaa","#ffffff", "olive","#332222","#999966","#ddddaa","#aaaa88","#ffffff");
if (puTheme!= ""){
    for (var i=0; i<puColors.length; i++){ if (puColors[i]==puTheme){ puTextColor=puColors[i+1]; puBkgdColor=puColors[i+2]; puHeadColor=puColors[i+3]; puButnColor=puColors[i+4]; puButnText =puColors[i+5]; break; }}}
function puStartDrag(e){ puPage=isIEpu ? "BODY" : "HTML"; puViewer=document.getElementById("puLayer"); activeItem=isIEpu ? event.srcElement : e.target; while (activeItem.id!="puMoveBar" && activeItem.id!="puPuller" && activeItem.tagName!=puPage){ activeItem=isIEpu ? activeItem.parentElement : activeItem.parentNode; } if (activeItem.id=="puPuller"){ offsetx=isIEpu ? event.clientX : e.clientX; offsety=isIEpu ? event.clientY : e.clientY; nowWid=parseInt(puImg.offsetWidth); nowHt= parseInt(puImg.offsetHeight); puRatio=nowWid/nowHt; puStretchEnabled=true; document.onmousemove=puStretch; } else if (activeItem.id=="puMoveBar"){ offsetx=isIEpu ? event.clientX : e.clientX; offsety=isIEpu ? event.clientY : e.clientY; nowX=parseInt(puViewer.style.left); nowY=parseInt(puViewer.style.top); puDragEnabled=true; document.onmousemove=puDrag; }}
function puDrag(e){ if (!puDragEnabled) return; puViewer.style.left=isIEpu ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; puViewer.style.top=isIEpu ? nowY+event.clientY-offsety : nowY+e.clientY-offsety; return false; }
function puStretch(e){ if (!puStretchEnabled) return; /* use only the width to prevent defining the height */ puImg.width=isIEpu ? (nowHt+event.clientY-offsety)*puRatio : (nowHt+e.clientY-offsety)*puRatio; puViewer.style.width=parseInt(puImg.offsetWidth); return false; }
function puHelp(){
    alert(
	/*  JAF - 2007-05-10
	 *  See comment in MakePuViewer, probably intend - for %u2013
	 *    GOK what %u2022 is supposed to be.  The script used to
	 *    unravel this thing only unescaped the %XX escapes, not
	 *    the %uXXXX unicode thingies.  Presumably these are some
	 *    sort of Micro$lothism but single hyphens should look OK
	 *    the -- in following line was originally %u2013%u2013
	 */
	'\nAnother cool ShipScript tool -- isdntek.com © 2005. \n'+
	/* In each of following, initial - replaces %u2022 */
	'\n- Drag the viewer to move it. '+
	'\n- Double-click image for full-screen and half-screen.'+
	'\n- Use the Plus and Minus buttons to zoom or shrink,'+
	'\n- or use the lower corner puller to resize.'+
	'\n- Click the corner X buttons to close the viewer.'+
	'\n- Click the © button to get your own free viewer.'
    );
}
function puResize(){ if (puImg.width>=screen.availWidth-50){puImg.width=screen.availWidth/2}else{puImg.width=screen.availWidth-50} if (puViewer.offsetLeft+puViewer.offsetWidth<50){puViewer.style.left=0} if (puViewer.offsetTop+puViewer.offsetHeight<50){puViewer.style.top=0} }
function puShrink(){ if (puImg.width >10) {puImg.width=puImg.width*.833;}}
function puGrow(){ puImg.width=puImg.width*1.2;}
function puHide(){puViewer.style.visibility="hidden";}
function puShow(title, url){ document.getElementById('puDescription').innerHTML=title; puImg.src=url; puPosition(); puViewer.style.visibility="visible"; return false;}
function puPosition(){ var X=0; var Y=1; scrollAmt=puGetScrollXY(); scrSize=puGetScreenSize(); baseoffsetX=document.getElementById('puHomebase').offsetLeft; baseoffsetY=document.getElementById('puHomebase').offsetTop; if ((parseInt(puViewer.style.top) +puViewer.offsetHeight+baseoffsetY)< (scrollAmt[Y]+100)){puStarted=false} if ((parseInt(puViewer.style.left)+puViewer.offsetWidth+baseoffsetX) < (scrollAmt[X]+100)){puStarted=false} if ((parseInt(puViewer.style.top) +baseoffsetY)> (scrollAmt[Y]+scrSize[Y]-100)){puStarted=false} if ((parseInt(puViewer.style.left)+baseoffsetX)> (scrollAmt[X]+scrSize[X]-100)){puStarted=false} if (puStarted==false ){ puViewer.style.top = scrollAmt[Y]-baseoffsetY +(scrSize[Y]-puViewer.offsetHeight)/2 ; puViewer.style.left = scrollAmt[X]-baseoffsetX +(scrSize[X]-puViewer.offsetWidth)/2 ; puStarted=true; }}
function puGetScreenSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == 'number' ) { /*Non-IE*/ myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { /*IE 6+ in 'standards compliant mode'*/ myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { /*IE 4 compatible*/ myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } return [ myWidth, myHeight ];}
function puGetScrollXY() { var scrollXamt = 0, scrollYamt = 0; if( typeof( window.pageYOffset ) == 'number' ) { /*Netscape compliant*/ scrollYamt = window.pageYOffset; scrollXamt = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { /*DOM compliant*/ scrollYamt = document.body.scrollTop; scrollXamt = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { /*IE6 standards compliant mode*/ scrollYamt = document.documentElement.scrollTop; scrollXamt = document.documentElement.scrollLeft; } return [ scrollXamt, scrollYamt ];}
MakePuViewer();
var puImg=document.getElementById('puImage');
document.onmousedown=puStartDrag;
document.onmouseup=Function("puDragEnabled=false; puStretchEnabled=false;");
//* Unrolled this function looking for cause of JavaScript Console error message
//*      JAF - 2007-05-10
function MakePuViewer(){
    document.write(
	'<div id=puHomebase style="position:relative; left:0px; top:0px;z-index:99; ">'+
	'<style>'+
	'.puTbl {font-family:arial; }'+
	'td.puTitle {font-weight:bold;font-size:'+
	puTextSize+
	'px;border:2px solid gray;border-top-color:silver;border-bottom-color:black;color:'+
	puHeadColor+
	';}'+
	'td.puBtn {font-weight:bold;border:2px solid gray;border-top-color:silver;border-bottom-color:black;background-color:'+
	puButnColor+
	';}'+
	'a.puBtn {text-decoration:none;font-size:16px;font-weight:bold;cursor:pointer;color:'+
	puButnText+
	';}'+
	'.puCopy {font-size:10px;color:'+
	puHeadColor+
	';}'+
	'#puDescription {font-weight:'+
	puTextBold+
	';color:'+
	puTextColor+
	';font-family:'+
	puTextFace+
	';padding:5px;padding-left:5px;border-top:1px white solid;border-bottom:2px black groove;}'+
	'#puPuller {border-right:1px solid silver; border-bottom:1px solid gray; width:14px; height:15px; cursor: se-resize; }'+
	'#puPuller td.x {width:1px; height:1px; background-color:'+
	puBkgdColor+
	'; font-size:1px;}'+
	'#puPuller td.o {width:1px; height:1px; '+
	/* background-color:none  appears to be causing JavaScript
	   to generate error messages to console, try commenting out
	   JAF - 2007-05-10
	'background-color:none;'+
	/**/
	'font-size:1px;}'+
	'#puPuller td.d {width:1px; height:1px; background-color:'+
	puTextColor+
	'; font-size:1px;}'+
	'</style>'+
	' <div id="puLayer" style="position:absolute; '+
	' left:0; top:0; visibility:hidden;">'
    );
    document.write(
	'<table id="puMoveBar" border="0" width="100" bgcolor="'+
	puBkgdColor+
	'" '+
	'cellspacing="0" cellpadding="4" style="cursor:move;"'+
	'onSelectStart="return false" onMouseover="puHot=true;" onMouseout="puHot=false"> '+
	'<tr><td width="100%"> '+
	'<table class="puTbl" border="0" width="100%" cellspacing="0" '+
	' cellpadding="0" height="36"><tr>'+
	'<td class="puBtn" valign="top" align=left width=10 title="close"> '+
	'<a class="puBtn" href="#" onClick="puHide();return false" >&nbsp;X&nbsp;</a></td>'+
	'<td class="puBtn" valign="top" align=left width=10 title="reduce">'+
	'<a class="puBtn" href="#" onClick="puShrink(); return false">'+
	/*
	   Replaced %u2013 in following by hyphen which would
	   appear to make more sense  JAF 2007-05-10
	*/
	'<nobr>&nbsp;-&nbsp;</nobr></a></td>'+
	'<td class="puBtn" valign="top" align=left width=10 title="enlarge">'+
	'<a class="puBtn" href="#" onClick="puGrow(); return false">&nbsp;+&nbsp;</a></td>'+
	'<td class="puTitle" id="titleBar" align=center width=2000 onmousedown="return false" '+
	' title="drag to move"><span style="font-size:9px;">popup '+
	'<span style="font-size:16px;"><b> &nbsp;Viewer&nbsp; </b></span>'+
	' from ISDN*tek</a></span></td>'+
	'<td class="puBtn" valign="top" align=right width=10 '+
	' title="get your free viewer here">'+
	'<a class="puBtn" href="http://www.isdntek.com/etools.htm" '+
	' target="_blank">&nbsp;©&nbsp;</a></td>'+
	'<td class="puBtn" valign="top" align=right width=10 '+
	' title="help with this tool">'+
	'<a class="puBtn" href="javascript:puHelp()" '+
	' >&nbsp;?&nbsp;</a></td>'+
	'<td class="puBtn" valign="top" align=right width=10 title="close">'+
	'<a class="puBtn" href="#" onClick="puHide(); return false">&nbsp;X&nbsp;</a></td>'+
	'</tr>'+
	'<tr><td class="puTitle" colspan="7" align=left>'+
	'<div id="puDescription" style="text-align:center">Click +/- Buttons to resize image</div>'+
	'<div style="position:relative; left:0px; top:0px;">'+
	'<img id=puImage src="" title="Drag to move Image Viewer or pull corner to Resize" '+
	' oncontextmenu="return false" galleryimg="no" onmousedown="return false;" '+
	' ondblclick="puResize()" ></div>'+
	/* important to return-false on the img mousedown event to prevent jerky motion in gecko.*/
	'<div style="position:relative; width:100%; height:1px; border:0px solid yellow">'+
	'<div style="position:absolute;top:-15px; left:0px; border:0px solid red">'+
	'<table id=puPuller class=t align="right" cols=14 rows=15 cellspacing="0" cellpadding="0" border=0 onmousedown="return false;" >'+
	' <tr><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td><td class=o></td>'+
	'</tr><tr><td class=o colspan=13></td><td class=x></td>'+
	'</tr><tr><td class=o colspan=12></td><td class=x></td><td class=d></td>'+
	'</tr><tr><td class=o colspan=11></td><td class=x></td><td class=d></td><td class=o></td>'+
	'</tr><tr><td class=o colspan=10></td><td class=x></td><td class=d></td><td class=o colspan=2></td>'+
	'</tr><tr><td class=o colspan=9 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td>'+
	'</tr><tr><td class=o colspan=8 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td>'+
	'</tr><tr><td class=o colspan=7 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o></td>'+
	'</tr><tr><td class=o colspan=6 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td>'+
	'</tr><tr><td class=o colspan=5 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td>'+
	'</tr><tr><td class=o colspan=4 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td>'+
	'</tr><tr><td class=o colspan=3 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o></td>'+
	'</tr><tr><td class=o colspan=2 ></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td>'+
	'</tr><tr><td class=o></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td>'+
	'</tr><tr><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td><td class=o colspan=2></td><td class=x></td><td class=d></td>'+
	'</tr></table></div></div>'+
	'</td></tr>'
    );
    if (puCopyright){
	document.write('<tr><td class=puCopy colspan="7" align=center>'+puCopyright+'</td></tr>');
    }
    document.write('</td></tr></table></td></tr></table></div></div>');
}

