/**
 * shiftzoom.js 1.8 (09-Aug-2008)
 * (c) by Christian Effenberger 
 * All Rights Reserved
 * Source: shiftzoom.netzgesta.de
 * Distributed under Netzgestade Software License Agreement
 * http://www.netzgesta.de/cvi/LICENSE.txt
 * License permits free of charge
 * use on non-commercial and 
 * private web sites only 
 * syntax:
        shiftzoom.defaultFading = true;         //BOOLEAN startup fading
        shiftzoom.defaultButtons = true;        //BOOLEAN left top info & zoom buttons
        shiftzoom.defaultZoom = 100;                    //INT/FLOAT 0-100 (%) zooming percentage
        shiftzoom.defaultXpos = 50;                     //INT/FLOAT 0-100 (%) horizontal position
        shiftzoom.defaultYpos = 50;                     //INT/FLOAT 0-100 (%) vertical position
        shiftzoom.defaultOpacity = 90;          //INT 0-100 (%) zoom button opacity
        shiftzoom.defaultMillisec = 40;         //INT 5-100 zoom interval delay
        shiftzoom.defaultIntitle = '';          //STR 'click or press shift key to zoom in'
        shiftzoom.defaultOuttitle = '';         //STR 'click or press alt key to zoom out'
        shiftzoom.defaultCurpath = '';          //STR cursor path (*.cur) IE only
        shiftzoom.defaultShowcoords = false;//BOOLEAN show coordinates
        shiftzoom.defaultPixelcoords = true;//BOOLEAN Pixel instead of Latitude/Longitude coordinates
        shiftzoom.defaultOverview = true;       //BOOLEAN show overview
        shiftzoom.defaultOvsfact = 25;          //INT 10-50 (%) overview size percentage
        shiftzoom.defaultOvaopac = 75;          //INT 0-100 (%) overview area opacity
        shiftzoom.defaultOvacolor = 'red';      //STR overview area css color 
        shiftzoom.defaultOvbcolor = 'white';//STR overview border css color
        shiftzoom.defaultOvborder = '';         //INT 0-20 (px) or "" overview border width
        shiftzoom.add( image, options );
        shiftzoom.add( image, { fading: value, overview: value, curpath: value, intitle: value, outtitle: value, millisec: value, ovaopac: value, opacity: value, ovborder: value, ovacolor: value, ovbcolor: value, ovsfact: value } );
        shiftzoom.remove( image );
        shiftzoom.set( image, ['buttons'|'overview'|'showcoords'|'pixelcoords'], [true|false] );
INT=shiftzoom.get( image, ['maxzoomx'|'maxzoomy'|'maxwidth'|'maxheight'] );
        shiftzoom.zooming( image, value );      //INT 0 - 100 (%) zoom factor (e.g. 33.33)
        shiftzoom.moveto( image, x ,y );        //INT x|y from within natural image dimension (e.g. 400,297) or
                                                                                //STR Lon|Lat (e.g. '52.04','-23.4405') or
                                                                                //STR %|% (e.g. '50%','50%')
 *
**/

var cvi_sztimer, cvi_szactive, cvi_szimage=null, shiftzoom = { _shiftzoom : null,
        defaultFading : true, defaultButtons : true, defaultOverview : true, 
        defaultShowcoords : false, defaultPixelcoords : true,    
        defaultMillisec : 40, defaultOpacity : 0,
        defaultOvsfact : 25, defaultOvaopac : 75,               
        defaultOvacolor : 'red', defaultOvbcolor : 'white',
        defaultIntitle : 'nhấp vào đây & click chuột phải ở bản đồ để phóng lớn',
        defaultOuttitle : 'nhấp vào đây & click chuột trái ở bản đồ để thu nhỏ',
        defaultOvborder : '', defaultCurpath : '', 
        defaultZoom : 0, defaultXpos : 50, defaultYpos : 50,
        add : function(img,opts) {
                function roundTo(val,dig) {var num=val; if(val>8191&&val<10485) {val=val-5000; num=Math.round(val*Math.pow(10,dig))/Math.pow(10,dig); num=num+5000;}else {num=Math.round(val*Math.pow(10,dig))/Math.pow(10,dig);} return num;}
                function uniqueID() {var val=Date.parse(new Date())+Math.floor(Math.random()*100000000000); return val.toString(16);}
                if(!img.ctrlid) {
                        var defopts={"curpath" : shiftzoom.defaultCurpath, "opacity" : shiftzoom.defaultOpacity, "millisec" : shiftzoom.defaultMillisec, "intitle" : shiftzoom.defaultIntitle, "outtitle" : shiftzoom.defaultOuttitle, "ovsfact" : shiftzoom.defaultOvsfact, "ovaopac" : shiftzoom.defaultOvaopac, "ovacolor" : shiftzoom.defaultOvacolor, "ovbcolor" : shiftzoom.defaultOvbcolor, "zoom" : shiftzoom.defaultZoom, "xpos" : shiftzoom.defaultXpos, "ypos" : shiftzoom.defaultYpos };
                        if(opts) {for(var i in defopts){if(!opts[i]){opts[i]=defopts[i];}}}else{opts=defopts;}
                        if(document.images&&document.createElement&&document.getElementById&&document.getElementsByTagName) {img.opts=defopts;
                                if(img.naturalWidth && img.naturalHeight) {img.xfactor=roundTo(img.naturalWidth/img.width,4); img.yfactor=roundTo(img.naturalHeight/img.height,4); img.maxwidth=img.naturalWidth; img.maxheight=img.naturalHeight;}
                                else {var tmp=new Image; tmp.src=img.src; img.xfactor=roundTo(tmp.width/img.width,4); img.yfactor=roundTo(tmp.height/img.height,4); img.maxwidth=tmp.width; img.maxheight=tmp.height; delete tmp;}
                                if(img.width>=100&&img.width<img.maxwidth&&img.height>=100&&img.height<img.maxheight){
                                        img.fading=(typeof opts['fading']==='boolean'?opts['fading']:shiftzoom.defaultFading);
                                        img.buttons=(typeof opts['buttons']==='boolean'?opts['buttons']:shiftzoom.defaultButtons);
                                        img.overview=(typeof opts['overview']==='boolean'?opts['overview']:shiftzoom.defaultOverview);
                                        img.showcoords=(typeof opts['showcoords']==='boolean'?opts['showcoords']:shiftzoom.defaultShowcoords);
                                        img.pixelcoords=(typeof opts['pixelcoords']==='boolean'?opts['pixelcoords']:shiftzoom.defaultPixelcoords);
                                        img.curpath=(typeof opts['curpath']==='string'?opts['curpath']:img.opts['curpath']);
                                        img.intitle=(typeof opts['intitle']==='string'?opts['intitle']:img.opts['intitle']);
                                        img.outtitle=(typeof opts['outtitle']==='string'?opts['outtitle']:img.opts['outtitle']);
                                        img.ovacolor=(typeof opts['ovacolor']==='string'?opts['ovacolor']:img.opts['ovacolor']);
                                        img.ovbcolor=(typeof opts['ovbcolor']==='string'?opts['ovbcolor']:img.opts['ovbcolor']);
                                        img.ovsfact=(typeof opts['ovsfact']==='number'?parseInt(Math.min(Math.max(10,opts['ovsfact']),50)):img.opts['ovsfact'])/100;
                                        img.millisec=(typeof opts['millisec']==='number'?parseInt(Math.min(Math.max(5,opts['millisec']),100)):img.opts['millisec']);
                                        img.ovaopac=(typeof opts['ovaopac']==='number'?parseInt(Math.min(Math.max(0,opts['ovaopac']),100)):img.opts['ovaopac']);
                                        img.opacity=(typeof opts['opacity']==='number'?parseInt(Math.min(Math.max(0,opts['opacity']),100)):img.opts['opacity']);
                                        img.ovborder=(typeof opts['ovborder']==='number'?parseInt(Math.min(Math.max(0,opts['ovborder']),20)):Math.min(Math.round(img.width/100),Math.round(img.height/100)));
                                        img.zoom=(typeof opts['zoom']==='number'?parseFloat(Math.min(Math.max(0,opts['zoom']),100)):img.opts['zoom']);
                                        img.xpos=(typeof opts['xpos']==='number'?parseFloat(Math.min(Math.max(0,opts['xpos']),100)):img.opts['xpos']);
                                        img.ypos=(typeof opts['ypos']==='number'?parseFloat(Math.min(Math.max(0,opts['ypos']),100)):img.opts['ypos']);
                                        img.opts=null; defopts=null; img.bc="1px white solid"; img.dc="1px gray solid"; img.zoomin=false; img.zoomout=false;
                                        if(img.fading) {if(img.trident) {img.style.filter="alpha(opacity=0)";}else{img.style.opacity=0;}} img.style.visibility='visible';
                                        img.parentNode.style.position=(img.parentNode.style.position=='static'||img.parentNode.style.position==''?'relative':img.parentNode.style.position);
                                        img.parentNode.style.height=img.height+'px'; img.parentNode.style.width=img.width+'px'; img.parentNode.style.padding='0px'; img.parentNode.style.overflow='hidden';
                                        img.parentNode.style.MozUserSelect="none"; img.parentNode.style.KhtmlUserSelect="none"; img.parentNode.unselectable="on"; img.parentNode.style.border="none";
                                        img.style.MozUserSelect="none"; img.style.KhtmlUserSelect="none"; img.unselectable="on"; img.style.display="block";
                                        img.style.position="absolute"; img.left=0; img.top=0; img.style.left='0px'; img.style.top='0px';
                                        img.minwidth=img.width; img.minheight=img.height; img.maxleft=img.maxwidth-img.minwidth; img.maxtop=img.maxheight-img.minheight;
                                        img.style.width=img.width+'px'; img.style.height=img.height+'px'; img.style.cursor="crosshair"; img.pointer=img.style.cursor;
                                        img.trident=document.all&&!window.opera?1:0; img.webkit=window.atob!=undefined&&!window.updateCommands?1:0; 
                                        img.gecko=navigator.userAgent.indexOf('Gecko')>-1&&window.updateCommands?1:0; img.presto=window.opera?1:0;
                                        img.bmode=(img.trident&&(document.compatMode=='BackCompat'||document.compatMode=='QuirksMode')?true:false);
                                        if(img.id!=""){}else {img.id=uniqueID();}
                                        var over=shiftzoom.E('div'); over.id=img.id+'_xyco'; if(img.trident) {over.style.backgroundColor='black';}
                                        over.style.height='auto'; over.style.width='auto'; over.style.display='block'; over.style.position='absolute'; over.style.left='0px'; 
                                        over.style.bottom='0px'; over.style.MozUserSelect="none"; over.style.KhtmlUserSelect="none"; over.unselectable="on"; 
                                        if(img.fading&&img.showcoords||!img.showcoords) {over.style.visibility='hidden';} img.parentNode.appendChild(over); img.xycoid=over.id; 
                                        if(!img.trident) {var view=shiftzoom.E('div'); view.style.height='100%'; view.style.width='100%'; view.style.left='0px'; 
                                        view.style.bottom='0px'; view.style.position='absolute'; view.style.backgroundColor='black'; view.style.opacity=0.5; over.appendChild(view);}
                                        view=shiftzoom.E('div'); view.id=img.id+'_cpos'; view.innerHTML="x:0 y:0"; view.unselectable="on";
                                        view.style.textAlign='left'; view.style.verticalAlign='middle'; view.style.left='0px'; view.style.bottom='0px';
                                        view.style.position='relative'; view.style.display='block'; view.style.color='white'; view.style.fontSize='10px'; 
                                        view.style.fontFamily='Arial, Helvetica, sans-serif'; view.style.fontStyle='normal'; view.style.fontWeight='bold'; 
                                        view.style.whiteSpace='nowrap'; view.style.padding='2px 4px'; view.style.textShadow='0px 0px 4px black'; over.appendChild(view); img.cposid=view.id;
                                        var over=shiftzoom.E('div'); if(img.fading&&img.buttons||!img.buttons) {over.style.visibility='hidden';} 
                                        over.id=img.id+'_ctrl'; over.style.height='16px'; over.style.width='42px'; over.style.display="block"; over.style.position='absolute';
                                        over.style.lineHeight='1px'; over.style.fontSize='1px'; over.style.backgroundColor="#FFCC00";
                                        if(img.trident) {over.style.filter="alpha(opacity="+img.opacity+")";}else{over.style.opacity=img.opacity;}
                                        over.style.cursor='pointer'; over.style.left='0px'; over.style.top='0px'; over.style.boxShadow="0px 0px 8px black"; 
                                        over.style.MozBoxShadow="0px 0px 8px black"; over.style.KhtmlBoxShadow="0px 0px 8px black"; 
                                        over.style.WebkitBoxShadow="0px 0px 8px black"; img.parentNode.appendChild(over); img.ctrlid=over.id;
                                        var view=shiftzoom.E('div'); view.style.height='2px'; view.style.width='2px'; view.style.position='absolute'; view.style.lineHeight='1px'; 
                                        view.style.fontSize='1px'; view.style.left='4px'; view.style.top='3px'; view.style.backgroundColor="black"; over.appendChild(view);
                                        view=shiftzoom.E('div'); view.style.height='6px'; view.style.width='2px'; view.style.position='absolute'; view.style.lineHeight='1px'; 
                                        view.style.fontSize='1px'; view.style.left='4px'; view.style.top='7px'; view.style.backgroundColor="black"; over.appendChild(view);
                                        view=shiftzoom.E('div'); view.style.height='2px'; view.style.width='8px'; view.style.position='absolute'; view.style.lineHeight='1px'; 
                                        view.style.fontSize='1px'; view.style.left='14px'; view.style.top='7px'; view.style.backgroundColor="black"; over.appendChild(view);
                                        view=shiftzoom.E('div'); view.style.height='8px'; view.style.width='2px'; view.style.position='absolute'; view.style.lineHeight='1px'; 
                                        view.style.fontSize='1px'; view.style.left='17px'; view.style.top='4px'; view.style.backgroundColor="black"; over.appendChild(view);
                                        view=shiftzoom.E('div'); view.style.height='2px'; view.style.width='8px'; view.style.position='absolute'; view.style.lineHeight='1px'; 
                                        view.style.fontSize='1px'; view.style.left='30px'; view.style.top='7px'; view.style.backgroundColor="black"; over.appendChild(view);
                                        view=shiftzoom.E('div'); view.id=img.id+'_kbin'; view.style.height=(img.bmode?16:14)+'px'; view.style.cursor='help';
                                        view.style.width=(img.bmode?10:8)+'px'; view.style.display="block"; view.style.position='absolute'; view.style.border=img.bc;
                                        view.style.borderBottom=img.dc; view.style.borderRight=img.dc; view.style.left='0px'; view.style.top='0px'; img.ttipid=img.id+'_ttip';
                                        if(img.trident) {view.onmouseover=new Function('shiftzoom._showTooltip("'+img.id+'");'); view.onmouseout=new Function('shiftzoom._killTooltip("'+img.id+'");');}
                                        else {view.setAttribute("onmouseover","shiftzoom._showTooltip('"+img.id+"');"); view.setAttribute("onmouseout","shiftzoom._killTooltip('"+img.id+"');");} 
                                        over.appendChild(view); img.kbinid=view.id;
                                        view=shiftzoom.E('div'); view.id=img.id+'_zoin'; view.title=img.intitle; view.style.height=(img.bmode?16:14)+'px';
                                        view.style.width=(img.bmode?16:14)+'px'; view.style.display="block"; view.style.position='absolute'; view.style.border=img.bc;
                                        view.style.borderBottom=img.dc; view.style.borderRight=img.dc; view.style.left='10px'; view.style.top='0px';
                                        if(img.trident) {view.onclick=new Function('shiftzoom._setCursor(this,1,"'+img.id+'");');}else {view.setAttribute("onclick","shiftzoom._setCursor(this,1,'"+img.id+"');");}
                                        over.appendChild(view); img.zoinid=view.id;
                                        view=shiftzoom.E('div'); view.id=img.id+'_zout'; view.title=img.outtitle; view.style.height=(img.bmode?16:14)+'px';
                                        view.style.width=(img.bmode?16:14)+'px'; view.style.display="block"; view.style.position='absolute'; view.style.border=img.bc;
                                        view.style.borderBottom=img.dc; view.style.borderRight=img.dc; view.style.left='26px'; view.style.top='0px';
                                        if(img.trident) {view.onclick=new Function('shiftzoom._setCursor(this,0,"'+img.id+'");');}else {view.setAttribute("onclick","shiftzoom._setCursor(this,0,'"+img.id+"');"); }
                                        over.appendChild(view); img.zoutid=view.id;
                                        over=shiftzoom.E('div'); over.style.visibility='hidden'; 
                                        over.id=img.id+'_info'; over.style.height='16px'; over.style.width='7em'; over.style.left=(img.buttons?'42px':'0px'); over.style.top='0px';
                                        over.style.display="block"; view.style.overflow='hidden'; over.style.position='absolute'; over.style.lineHeight='16px'; over.style.fontSize='10px'; 
                                        over.style.fontFamily='Arial, Helvetica, sans-serif'; over.style.fontStyle='normal'; over.style.fontWeight='bold'; over.style.textShadow='0px 0px 4px black';
                                        over.style.color="#ffffff"; if(img.trident) {over.style.filter="alpha(opacity=100)";}else{over.style.opacity=1;}
                                        over.style.cursor='default'; img.parentNode.appendChild(over); img.infoid=over.id; view=shiftzoom.E('div'); 
                                        view.style.position='absolute'; view.style.height='16px'; view.style.width='7em'; view.style.left='0px'; view.style.top='0px';
                                        view.style.display="block"; view.style.backgroundColor="#000000"; if(img.trident) {view.style.filter="alpha(opacity=50)";}else{view.style.opacity=0.50;}
                                        over.appendChild(view); view=shiftzoom.E('div'); view.id=img.id+'_text'; view.style.position='absolute';
                                        view.style.height='16px'; view.style.width='7em'; view.style.left='0px'; view.style.top='0px'; view.style.textAlign='center';
                                        view.style.verticalAlign='middle'; view.style.overflow='hidden'; view.style.display="block"; view.style.color="#ffffff";
                                        if(img.trident) {view.style.filter="alpha(opacity=100)";} over.appendChild(view); img.textid=view.id; view.innerHTML="100 / "+parseInt(img.xfactor*100)+" %";
                                        over=shiftzoom.E('div'); over.id=img.id+'_over'; over.style.height=(img.height*img.ovsfact)+'px'; 
                                        over.style.width=(img.width*img.ovsfact)+'px'; over.style.display="block"; over.style.position='absolute'; over.style.bottom='0px'; 
                                        over.style.right='0px'; over.style.borderLeft=img.ovborder+'px solid '+img.ovbcolor; over.style.borderTop=img.ovborder+'px solid '+img.ovbcolor;
                                        if(img.webkit) {over.style.borderLeft='0px solid '+img.ovbcolor; over.style.borderTop='0px solid '+img.ovbcolor; over.style.WebkitBoxShadow="0px 0px 8px black"; over.style.KhtmlBoxShadow="0px 0px 8px black";}
                                        over.style.MozUserSelect="none"; over.style.KhtmlUserSelect="none"; over.style.visibility="hidden"; over.unselectable="on"; img.parentNode.appendChild(over);
                                        view=shiftzoom.E('img'); view.src=img.src; view.style.height=(img.height*img.ovsfact)+'px'; view.style.width=(img.width*img.ovsfact)+'px';
                                        view.style.display="block"; view.style.position='absolute'; view.style.bottom='0px'; view.style.right='0px'; over.appendChild(view);
                                        view.onmousedown=shiftzoom._catchDrag; view=shiftzoom.E('div'); view.id=img.id+'_view'; view.maxleft=0; view.maxtop=0;
                                        view.style.lineHeight='1px'; view.style.fontSize='1px'; view.style.display="block"; view.style.position='absolute'; view.style.left='0px'; view.style.top='0px'; 
                                        view.style.border='1px solid '+img.ovacolor; view.style.height=parseInt((img.height*img.ovsfact)-(img.bmode?0:2))+'px'; view.style.width=parseInt((img.width*img.ovsfact)-(img.bmode?0:2))+'px';
                                        if(img.trident){view.style.background="url('"+img.curpath+"nop.gif') transparent"; view.style.filter="alpha(opacity="+img.ovaopac+")";}else{view.style.opacity=img.ovaopac/100;}
                                        over.appendChild(view); img.overid=over.id; img.viewid=view.id; view.onmousedown=shiftzoom._startMove;
                                        img.oncontextmenu=function() {return false;}; img.onmousedown=shiftzoom._catchKey; img.onmouseover=shiftzoom._catchOver; img.onmouseout=shiftzoom._catchOut;                                    
                                        if(img.showcoords) {img.onmousemove=(img.pixelcoords?shiftzoom._showCoords:shiftzoom._showLatLon);} if(img.zoom>0) {shiftzoom.zooming(img,img.zoom);}
                                        if(img.xpos!=50||img.ypos!=50) {shiftzoom.moveto(img,img.xpos+'%',img.ypos+'%');} if(img.fading) {shiftzoom._fadeImage(img.id,0);}
                                }else {img.style.visibility='visible';}
                        }else {img.style.visibility='visible';}
                } return false;
        },
        remove : function(img) {
                if(img&&typeof(img.ctrlid)==="string") {var ele,obj=img.parentNode; img.onmousedown=null; img.onmousemove=null; 
                        document.onmousemove=null; document.onmouseup=null; document.onkeydown=null; document.onkeyup=null; document.onkeypress=null;
                        if(img.gecko) {window.removeEventListener('DOMMouseScroll', shiftzoom._catchWheel, false);}else {window.onmousewheel=null;}
                        ele=shiftzoom.G(img.overid); if(ele) {obj.removeChild(ele);} ele=shiftzoom.G(img.infoid); if(ele) {obj.removeChild(ele);}
                        ele=shiftzoom.G(img.ctrlid); if(ele) {obj.removeChild(ele);} ele=shiftzoom.G(img.xycoid); if(ele) {obj.removeChild(ele);}
                        img.width=img.minwidth; img.height=img.minheight; img.left=0; img.top=0; img.style.width=img.minwidth+'px'; img.style.height=img.minheight+'px'; 
                        img.style.left='0px'; img.style.top='0px'; img.style.cursor="default"; img.ctrlid=false;
                }return false;
        },
        moveto : function(img,x,y) {
                if(img&&x&&y&&typeof(img.ctrlid)==="string") {
                        if(img.width>img.minwidth||img.height>img.minheight) {
                                function LFL(v,i,x){var d=parseFloat(v); if(d>x){d=x;}else if(d<i){d=i;} return d;}     
                                if(typeof(x)=="string") {if(x.match(/^([+-])?\d*([\.])?\d*$/)) {x=Math.round((LFL(x,-180,180)+180)*(img.maxwidth/360));}else if(x.match(/^\d*([\.])?\d*([%]){1,1}$/)) {x=Math.round(img.maxwidth*(Math.max(0,Math.min(100,parseFloat(x)))/100));}else {x=0;}}
                                if(typeof(y)=="string") {if(y.match(/^([+-])?\d*([\.])?\d*$/)) {y=Math.round(((LFL(y,-90,90)*-1)+90)*(img.maxheight/180));}else if(y.match(/^\d*([\.])?\d*([%]){1,1}$/)) {y=Math.round(img.maxheight*(Math.max(0,Math.min(100,parseFloat(y)))/100));}else {y=0;}}
                                var h=Math.max(0,Math.min(img.maxleft,(x*(img.width/img.maxwidth))-(img.minwidth/2)));
                                var v=Math.max(0,Math.min(img.maxtop,(y*(img.height/img.maxheight))-(img.minheight/2)));
                                img.style.left=(h*-1)+'px'; img.style.top=(v*-1)+'px'; img.left=(h*-1); img.top=(v*-1);
                                if(img.overview) {var view=shiftzoom.G(img.viewid).style;
                                        view.left=Math.round((Math.abs(parseInt(img.style.left))/(img.width/img.minwidth))*img.ovsfact)-(img.bmode?2:0)+'px';
                                        view.top=Math.round((Math.abs(parseInt(img.style.top))/(img.height/img.minheight))*img.ovsfact)-(img.bmode?2:0)+'px';
                                }
                        }
                }return false;
        },
        zooming : function(img,v) {
                if(img&&typeof(img.ctrlid)==="string") {
                        if(typeof(v)==="number") {var mw,mh,mx,my,f; v=Math.max(0,Math.min(100,parseFloat(v))); f=v>0?v/100:0;
                                mw=Math.round(f*(img.maxwidth-img.minwidth))+img.minwidth; mh=Math.round(f*(img.maxheight-img.minheight))+img.minheight;
                                mx=Math.round((mw/2)-(img.minwidth/2))*-1; my=Math.round((mh/2)-(img.minheight/2))*-1;
                                img.style.width=mw+'px'; img.style.height=mh+'px'; img.style.left=mx+'px'; img.style.top=my+'px'; 
                                img.width=mw; img.height=mh; img.left=mx; img.top=my; img.maxleft=img.width-img.minwidth; img.maxtop=img.height-img.minheight;
                                if(img.width>img.minwidth||img.height>img.minheight) {
                                        if(img.trident) {img.style.cursor="url('"+img.curpath+"grab.cur'),move";}else {img.style.cursor="move";}
                                        if(img.overview) {shiftzoom._setOverview(img); shiftzoom.G(img.overid).style.visibility="visible";}
                                }else {img.style.cursor="crosshair"; if(img.overview) {shiftzoom.G(img.overid).style.visibility="hidden";}}
                        }
                }return false;
        },
        set : function(img,d,v) {
                if(img&&typeof(img.ctrlid)==="string") {
                        if(d&&typeof(v)==="boolean") {
                                if(d.toLowerCase()=="overview") {
                                        if(v==false&&img.overview==true) {shiftzoom.G(img.overid).style.visibility="hidden";}else if(v==true&&img.overview==false) {
                                        if(img.width>img.minwidth||img.height>img.minheight) {shiftzoom._setOverview(img); shiftzoom.G(img.overid).style.visibility="visible";}else {shiftzoom.G(img.overid).style.visibility="hidden";}}img.overview=v; 
                                }else if(d.toLowerCase()=="showcoords") {
                                        if(v==false&&img.showcoords==true) {img.onmousemove=null; shiftzoom.G(img.xycoid).style.visibility="hidden";}else 
                                        if(v==true&&img.showcoords==false) {shiftzoom.G(img.xycoid).style.visibility="visible"; img.onmousemove=shiftzoom._showCoords;}img.showcoords=v;
                                }else if(d.toLowerCase()=="pixelcoords") {
                                        if(v==false&&img.pixelcoords==true&&img.showcoords==true) {img.onmousemove=shiftzoom._showLatLon;}else 
                                        if(v==true&&img.pixelcoords==false&&img.showcoords==true) {img.onmousemove=shiftzoom._showCoords;}img.pixelcoords=v;
                                }else if(d.toLowerCase()=="buttons") {
                                        if(v==false) {shiftzoom.G(img.ctrlid).style.visibility="hidden"; shiftzoom.G(img.infoid).style.left='0px';}else 
                                        if(v==true) {shiftzoom.G(img.infoid).style.left='42px'; shiftzoom.G(img.ctrlid).style.visibility="visible";}
                                }
                        }
                }return false;
        },
        get : function(img,d) {
                if(img&&d&&typeof(img.ctrlid)==="string") {
                        if(d.toLowerCase()=="maxzoomx") {return img.xfactor;}else if(d.toLowerCase()=="maxzoomy") {return img.yfactor;}else
                        if(d.toLowerCase()=="maxwidth") {return img.maxwidth;}else if(d.toLowerCase()=="maxheight") {return img.maxheight;}
                }return false;
        },
        G : function(v) {return(document.getElementById(v));},
        E : function(v) {return(document.createElement(v));},
        _setOverview : function(img) {var view=shiftzoom.G(img.viewid);
                view.style.width=(Math.round((img.ovsfact*img.minwidth)/(img.width/img.minwidth))-(img.bmode?0:2))+'px';
                view.style.height=(Math.round((img.ovsfact*img.minheight)/(img.height/img.minheight))-(img.bmode?0:2))+'px';
                view.style.left=Math.round((Math.abs(img.left)/(img.width/img.minwidth))*img.ovsfact)-(img.bmode?2:0)+'px';
                view.style.top=Math.round((Math.abs(img.top)/(img.height/img.minheight))*img.ovsfact)-(img.bmode?2:0)+'px';
                view.maxleft=(img.minwidth*img.ovsfact)-(img.bmode?0:2)-parseInt(view.style.width); 
                view.maxtop=(img.minheight*img.ovsfact)-(img.bmode?0:2)-parseInt(view.style.height);
        },
        _findPosXY : function(ele) {var t,d={x:ele.offsetLeft, y:ele.offsetTop}; if(ele.offsetParent) { t=shiftzoom._findPosXY(ele.offsetParent); d.x+=t.x; d.y+=t.y;} return d;},
        _getMousePos : function (ex,ey,px,py) {var ox,oy,k={ox:0,oy:0,ex:ex,ey:ey };
                if(self.pageXOffset||self.pageYOffset) {ox=self.pageXOffset; if(ox>0&&px==ex) {ex-=ox;} oy=self.pageYOffset; if(oy>0&&py==ey) {ey-=oy;}}else 
                if(document.documentElement) {ox=document.documentElement.scrollLeft; oy=document.documentElement.scrollTop;}else 
                if(document.body) {ox=document.body.scrollLeft; oy=document.body.scrollTop;} k.ox=ox; k.oy=oy; k.ex=ex; k.ey=ey; return k;
        },      
        _showCoords : function(e) {
                if(cvi_szactive!=null) {var k,t,x,y,ex,ey,px=0,py=0,o=shiftzoom.G(cvi_szactive),w=o.width,h=o.height;
                        e=e?e:window.event; ex=e.clientX; ey=e.clientY; if(e.pageX||e.pageY) {px=e.pageX; py=e.pageY;} k=shiftzoom._getMousePos(ex,ey,px,py); 
                        t=shiftzoom._findPosXY(o); x=Math.min(Math.max(k.ex+k.ox-t.x,0),w); y=Math.min(Math.max(k.ey+k.oy-t.y,0),h);
                        shiftzoom.G(o.cposid).innerHTML='<span>x:'+x+' y:'+y+'<\/span>';
                }
        },
        _showLatLon : function(e) {
                if(cvi_szactive!=null) {function parseDMS(v,n){var d,m,s; d=parseInt(v); m=Math.abs(parseFloat(v-d)*60); s=Math.abs(parseFloat(parseInt(m)-m)*60); return Math.abs(d)+"°"+parseInt(m)+"'"+parseInt(s)+"'' "+n;} 
                        var k,t,x,y,lat,lon,ex,ey,px=0,py=0,o=document.getElementById(cvi_szactive),w=o.width,h=o.height;
                        e=e?e:window.event; ex=e.clientX; ey=e.clientY; if(e.pageX||e.pageY) {px=e.pageX; py=e.pageY;} k=shiftzoom._getMousePos(ex,ey,px,py); 
                        t=shiftzoom._findPosXY(o); x=Math.min(Math.max(k.ex+k.ox-t.x,0),w); y=Math.min(Math.max(k.ey+k.oy-t.y,0),h);
                        lon=(x*360/w)-180; lat=90-(y*180/h); lon=parseDMS(lon,lon!=0?(lon<0?"W":"E"):""); lat=parseDMS(lat,lat!=0?(lat<0?"S":"N"):"");
                        shiftzoom.G(o.cposid).innerHTML='<span>Lat: '+lat+' &bull; Lon: '+lon+'<\/span>';
                }
        },
        _killTooltip : function(id) {var ison,img=shiftzoom.G(id); ison=shiftzoom.G(img.ttipid); if(ison) {document.getElementsByTagName("body")[0].removeChild(ison);}},
        _showTooltip : function(id) {var ison,over,view,img=shiftzoom.G(id); ison=shiftzoom.G(img.ttipid);
                if(!ison) {var t=shiftzoom._findPosXY(img.parentNode); over=shiftzoom.E('div'); if(img.trident) {over.style.backgroundColor='black';}
                        over.id=img.ttipid; over.style.height='auto'; over.style.width='auto'; over.style.display='block'; over.style.position='absolute'; 
                        over.style.left=(t.x+10)+'px'; over.style.top=t.y+'px'; over.style.visibility='visible'; over.style.border='solid 2px white';
                        over.style.borderRadius='6px'; over.style.MozBorderRadius='6px'; over.style.KhtmlBorderRadius='6px'; over.style.WebkitBorderRadius='6px';
                        over.style.boxShadow='0px 0px 8px black'; over.style.MozBoxShadow='0px 0px 8px black'; over.style.WebkitBoxShadow='0px 0px 8px black';
                        over.style.MozUserSelect="none"; over.style.KhtmlUserSelect="none"; over.unselectable="on"; document.getElementsByTagName("body")[0].appendChild(over); 
                        if(!img.trident) {view=shiftzoom.E('div'); view.style.height='100%'; view.style.width='100%'; view.style.left='0px'; view.style.top='0px'; view.style.position='absolute'; view.style.opacity=0.5; 
                        view.style.backgroundColor='90B3F5'; view.style.borderRadius='4px'; view.style.MozBorderRadius='4px'; view.style.KhtmlBorderRadius='4px'; view.style.WebkitBorderRadius='4px'; over.appendChild(view);} 
                        view=shiftzoom.E('div'); view.style.display='block'; view.style.left='0px'; view.style.top='0px'; view.style.position='relative'; 
                        view.style.textAlign='left'; view.style.verticalAlign='middle'; view.style.color='white'; view.style.fontSize='12px'; view.style.fontFamily='Arial,Helvetica,sans-serif';
                        view.style.fontStyle='normal'; view.style.fontWeight='bold'; view.style.whiteSpace='nowrap'; view.style.textShadow='black 0px 0px 4px'; view.style.margin='10px';
                        view.innerHTML='<dl><div align="right"><big>Hướng dẫn sử dụng<\/big><\/div><dt>Phóng to <em>(dùng các phím sau)<\/em>:<\/dt><dd>[+] / [PgDn] / [End] <em>(nhanh)<\/em> /<br \/> [shift] + <u>chuột trái</u> /<br \/><u>chuột giữa (cuộn xuống)</u> / <u>nút cuộn</u> <small><br \/><br \/><\/small><\/dd><dt>Thu nhỏ <em>(dùng các phím sau)<\/em>:<\/dt><dd>[–] / [PgUp] / [Home] <em>(nhanh)<\/em> /<br \/> [alt] + <u>chuột trái</u>/<br \/><u>chuột phải</u> / chuột giữa (cuộn lên) <small><br \/><br \/><\/small><\/dd><dt>Di chuyển vùng ảnh khuất:<\/dt><dd>Sử dụng các phím mũi tên<br \/>nhấp giữ [shift] <em>(nhanh hơn)</em> hoặc [alt] <em>(chậm hơn)<\/em><\/dd><\/dl>';
                        over.appendChild(view);
                }
        },
        _setCursor : function(ele,d,id) {
                var img=shiftzoom.G(id), butt=shiftzoom.G(d==1?img.zoutid:img.zoinid).style; img.zoomin=false; img.zoomout=false;
                ele.style.border=img.bc; ele.style.borderBottom=img.dc; ele.style.borderRight=img.dc;
                butt.border=img.bc; butt.borderBottom=img.dc; butt.borderRight=img.dc;
                if(d==1&&(parseInt(img.style.width)<img.maxwidth||parseInt(img.style.height)<img.maxheight)) {
                        ele.style.border=img.bc; ele.style.borderTop=img.dc; ele.style.borderLeft=img.dc; img.zoomin=true;
                        if(img.gecko) {img.style.cursor="-moz-zoom-in";}else if(img.webkit) {img.style.cursor="-webkit-zoom-in";}
                        else if(img.trident) {img.style.cursor="url('"+img.curpath+"zoom-in.cur'),crosshair";}else {img.style.cursor="crosshair";}  
                }else if(d==0&&(parseInt(img.style.width)>img.minwidth||parseInt(img.style.height)>img.minheight)) {
                        ele.style.border=img.bc; ele.style.borderTop=img.dc; ele.style.borderLeft=img.dc; img.zoomout=true;
                        if(img.gecko) {img.style.cursor="-moz-zoom-out";}else if(img.webkit) {img.style.cursor="-webkit-zoom-out";}
                        else if(img.trident) {img.style.cursor="url('"+img.curpath+"zoom-out.cur'),crosshair";}else {img.style.cursor="crosshair";}
                }else {img.style.cursor=img.pointer;}
        },
        _zoomIn : function(id,ct,st,sw,ew,sh,eh,sx,ex,sy,ey) {
                var mw,mh,mx,my,obj=shiftzoom.G(id);
                if(parseInt(obj.style.width)<obj.maxwidth||parseInt(obj.style.height)<obj.maxheight) {clearInterval(cvi_sztimer);
                        mw=Math.max(obj.minwidth,Math.min(obj.maxwidth,Math.round(ew*ct/st+sw))); mx=Math.round(ex*ct/st+sx);
                        mh=Math.max(obj.minheight,Math.min(obj.maxheight,Math.round(eh*ct/st+sh))); my=Math.round(ey*ct/st+sy);
                        obj.style.width=mw+'px'; obj.style.height=mh+'px'; obj.style.left=mx+'px'; obj.style.top=my+'px'; ct++;
                        shiftzoom.G(obj.textid).innerHTML=parseInt((mw/obj.minwidth)*100)+" / "+parseInt(obj.xfactor*100)+" %";
                        cvi_sztimer=setInterval("shiftzoom._zoomIn('"+id+"',"+ct+","+st+","+sw+","+ew+","+sh+","+eh+","+sx+","+ex+","+sy+","+ey+")",obj.millisec);
                }else {clearInterval(cvi_sztimer);}
        },
        _zoomOut : function(id,rm,ct,st,sw,ew,sh,eh,sx,ex,sy,ey) {
                var mw,mh,mx,my,obj=shiftzoom.G(id); 
                if(parseInt(obj.style.width)>obj.minwidth||parseInt(obj.style.height)>obj.minheight) {clearInterval(cvi_sztimer);
                        mw=Math.max(obj.minwidth,Math.min(obj.maxwidth,Math.round(ew*ct/st+sw))); mx=Math.round(ex*ct/st+sx); 
                        mh=Math.max(obj.minheight,Math.min(obj.maxheight,Math.round(eh*ct/st+sh))); my=Math.round(ey*ct/st+sy);
                        obj.style.width=mw+'px'; obj.style.height=mh+'px'; obj.style.left=mx+'px'; obj.style.top=my+'px'; ct++;
                        shiftzoom.G(obj.textid).innerHTML=parseInt((mw/obj.minwidth)*100)+" / "+parseInt(obj.xfactor*100)+" %";
                        cvi_sztimer=setInterval("shiftzoom._zoomOut('"+id+"',"+rm+","+ct+","+st+","+sw+","+ew+","+sh+","+eh+","+sx+","+ex+","+sy+","+ey+")",obj.millisec);
                }else {clearInterval(cvi_sztimer); if(obj.webkit&&rm){shiftzoom._stopZoom();}}
        },      
        _stopZoom : function() {
                var view, butt, img=shiftzoom._shiftzoom; document.onmouseup=null;
                clearInterval(cvi_sztimer); img.zoomin=false; img.zoomout=false;
                img.left=parseInt(img.style.left); img.top=parseInt(img.style.top);
                img.width=parseInt(img.style.width); img.height=parseInt(img.style.height);
                img.maxleft=img.width-img.minwidth; img.maxtop=img.height-img.minheight;
                if(img.width>img.minwidth||img.height>img.minheight) {
                        if(img.trident) {img.style.cursor="url('"+img.curpath+"grab.cur'),move";}else {img.style.cursor="move";}
                        if(img.overview) {shiftzoom._setOverview(img); shiftzoom.G(img.overid).style.visibility="visible";}
                }else {img.style.cursor="crosshair"; if(img.overview) {shiftzoom.G(img.overid).style.visibility="hidden";}}
                butt=shiftzoom.G(img.zoinid).style; butt.border=img.bc; butt.borderBottom=img.dc; butt.borderRight=img.dc;
                butt=shiftzoom.G(img.zoutid).style; butt.border=img.bc; butt.borderBottom=img.dc; butt.borderRight=img.dc;
                img.pointer=img.style.cursor; shiftzoom.G(img.textid).innerHTML=parseInt((img.width/img.minwidth)*100)+" / "+parseInt(img.xfactor*100)+" %";
                cvi_sztimer=setInterval("shiftzoom._fadeInfo('"+img.id+"',100)",30); shiftzoom._shiftzoom=null;
        },
        _catchDrag : function(e) {return false; },
        _catchWheel : function(e){
                var d,v=0; e=e?e:window.event; if(e.wheelDelta) {v=e.wheelDelta/120; d=(v<0?1:0);}else if (e.detail) {v=-e.detail/3; d=(v<0?1:0);}
                if(cvi_szactive!=null&&v!=0) {cvi_szimage=true; shiftzoom._initZoom(d,(d==1?2:1),true);} if(e.preventDefault) {e.preventDefault();}else {e.returnValue=false;} return false;
        },
        _catchOver : function(e) {
                cvi_szactive=this.id; if(this.gecko) {window.addEventListener('DOMMouseScroll', shiftzoom._catchWheel, false);}else {window.onmousewheel=shiftzoom._catchWheel;}
                document.onkeyup=shiftzoom._upKey; document.onkeypress=shiftzoom._pressKey; document.onkeydown=shiftzoom._downKey; return false; 
        },
        _catchOut : function() {
                cvi_szactive=null; if(this.gecko) {window.removeEventListener('DOMMouseScroll', shiftzoom._catchWheel, false);}else {window.onmousewheel=null;} document.onkeydown=null; document.onkeypress=null; document.onkeyup=null; 
        }, 
        _catchKey : function(e) { clearInterval(cvi_sztimer);
                var img=shiftzoom._shiftzoom=this; var rm=false,mm=false,k,t,ex,ey,px=0,py=0,obj=shiftzoom.G(img.infoid).style; 
                e=e?e:window.event; if(e.which) {mm=(e.which==2); rm=(e.which==3);}else if(e.button) {mm=(e.button==4); rm=(e.button==2);}
                if(img.trident) {obj.filter="alpha(opacity=100)";}else {obj.opacity=1;} obj.visibility='hidden';
                ex=e.clientX; ey=e.clientY; if(e.pageX||e.pageY) {px=e.pageX; py=e.pageY;} k=shiftzoom._getMousePos(ex,ey,px,py); t=shiftzoom._findPosXY(img.parentNode); 
                img.mouseX=Math.min(Math.max(k.ex+k.ox-t.x,0),img.minwidth); img.mouseY=Math.min(Math.max(k.ey+k.oy-t.y,0),img.minheight);
                if(((e.altKey&&!e.shiftKey)||rm||img.zoomout)&&(img.width>img.minwidth||img.height>img.minheight)) {
                        var butt,sw,ew,sh,eh,sx,ex,sy,ey,st; if(img.gecko) {img.style.cursor="-moz-zoom-out";}else if(img.webkit) {img.style.cursor="-webkit-zoom-out";}
                        else if(img.trident) {img.style.cursor="url('"+img.curpath+"zoom-out.cur'),crosshair";}else {img.style.cursor="crosshair";}img.pointer=img.style.cursor;
                        if(!img.zoomout) {butt=shiftzoom.G(img.zoutid).style; butt.border=img.bc; butt.borderLeft=img.dc; butt.borderTop=img.dc; img.zoomout=true;}
                        sw=img.width; ew=(img.width-img.minwidth)*-1; sh=img.height; eh=(img.height-img.minheight)*-1; sx=parseInt(img.style.left); ex=sx*-1; sy=parseInt(img.style.top); ey=sy*-1;
                        st=Math.max(1,Math.round((img.width/img.minwidth)*3)); document.onmouseup=shiftzoom._stopZoom; obj.visibility='visible';
                        cvi_sztimer=setInterval("shiftzoom._zoomOut('"+img.id+"',"+rm+","+(img.webkit&&rm?1:0)+","+st+","+sw+","+ew+","+sh+","+eh+","+sx+","+ex+","+sy+","+ey+")",img.millisec);
                }else if(((!e.altKey&&e.shiftKey)||mm||img.zoomin)&&(img.width<img.maxwidth||img.height<img.maxheight)) {
                        var butt,sw,ew,sh,eh,sx,ex,sy,ey,st; if(img.gecko) {img.style.cursor="-moz-zoom-in";}else if(img.webkit) {img.style.cursor="-webkit-zoom-in";}
                        else if(img.trident) {img.style.cursor="url('"+img.curpath+"zoom-in.cur'),crosshair";}else {img.style.cursor="crosshair";}img.pointer=img.style.cursor; 
                        if(!img.zoomin) {butt=shiftzoom.G(img.zoinid).style; butt.border=img.bc; butt.borderLeft=img.dc; butt.borderTop=img.dc; img.zoomin=true;}
                        sw=img.width; ew=img.maxwidth-img.width; sh=img.height; eh=img.maxheight-img.height; sx=parseInt(img.style.left); sy=parseInt(img.style.top);
                        ex=Math.max(0,Math.min(ew,Math.round(((img.mouseX-sx)*(img.maxwidth/img.width))-(img.minwidth*0.5)+sx)))*-1; 
                        ey=Math.max(0,Math.min(eh,Math.round(((img.mouseY-sy)*(img.maxheight/img.height))-(img.minheight*0.5)+sy)))*-1; 
                        st=Math.max(1,Math.round((img.maxwidth/img.width)*3)); document.onmouseup=shiftzoom._stopZoom; obj.visibility='visible';
                        cvi_sztimer=setInterval("shiftzoom._zoomIn('"+img.id+"',0,"+st+","+sw+","+ew+","+sh+","+eh+","+sx+","+ex+","+sy+","+ey+")",img.millisec);
                }else if(img.width>img.minwidth||img.height>img.minheight) {                    
                        if(img.gecko) {img.style.cursor="-moz-grabbing";}else if(img.trident) {img.style.cursor="url('"+img.curpath+"grabbing.cur'),move";}else {img.style.cursor="move";}
                        var x=parseInt(img.style.left), y=parseInt(img.style.top); img.mouseX=e.clientX; img.mouseY=e.clientY;
                        document.onmousemove=shiftzoom._whilePan; document.onmouseup=shiftzoom._stopPan;
                }return false;
        },
        _downKey : function(e) {
                if(cvi_szactive!=null) {
                        e=e?e:window.event; var k=(e.keyCode?e.keyCode:e.which),s=e.shiftKey,a=e.altKey,w=false,AL=37,AU=38,AR=39,AD=40,HO=36,EN=35,PD=34,PU=33,PL=187,MN=189;
                        switch(k) {
                                case AL : cvi_szimage=true; shiftzoom._panKey(8,0,s,a); break;
                                case AR : cvi_szimage=true; shiftzoom._panKey(-8,0,s,a); break;
                                case AU : cvi_szimage=true; shiftzoom._panKey(0,8,s,a); break;
                                case AD : cvi_szimage=true; shiftzoom._panKey(0,-8,s,a); break;
                                case HO : if(cvi_szimage==null) {cvi_szimage=true; shiftzoom._initZoom(0,1,w); }break;
                                case EN : if(cvi_szimage==null) {cvi_szimage=true; shiftzoom._initZoom(1,1,w); }break;
                                case MN : case PU : if(cvi_szimage==null) {cvi_szimage=true; shiftzoom._initZoom(0,4,w); }break;
                                case PL : case PD : if(cvi_szimage==null) {cvi_szimage=true; shiftzoom._initZoom(1,4,w); }break;
                        } return false;
                }
        },
        _pressKey : function(e) {return false; },
        _upKey : function() {if(cvi_szactive!=null) {cvi_szimage=null; }},
        _initZoom : function(d,v,w) {var sw,ew,sh,eh,sx,ex,sy,ey,st,img=shiftzoom.G(cvi_szactive);
                if(d==0&&(parseInt(img.style.width)>img.minwidth||parseInt(img.style.height)>img.minheight)) {
                        if(img.gecko) {img.style.cursor="-moz-zoom-out";}else if(img.webkit) {img.style.cursor="-webkit-zoom-out";}
                        else if(img.trident) {img.style.cursor="url('"+img.curpath+"zoom-out.cur'),crosshair";}else {img.style.cursor="crosshair";}img.pointer=img.style.cursor;
                        sw=img.width; ew=(img.width-img.minwidth)*-1; sh=img.height; eh=(img.height-img.minheight)*-1; 
                        sx=parseInt(img.style.left); ex=sx*-1; sy=parseInt(img.style.top); ey=sy*-1;
                        st=Math.max(1,Math.round((img.width/img.minwidth)*v)); shiftzoom._zoomKey(d,(w?1:0),w,st,sw,ew,sh,eh,sx,ex,sy,ey);
                }else if(d==1&&(parseInt(img.style.width)<img.maxwidth||parseInt(img.style.height)<img.maxheight)) {
                        if(img.gecko) {img.style.cursor="-moz-zoom-in";}else if(img.webkit) {img.style.cursor="-webkit-zoom-in";}
                        else if(img.trident) {img.style.cursor="url('"+img.curpath+"zoom-in.cur'),crosshair";}else {img.style.cursor="crosshair";}img.pointer=img.style.cursor; 
                        sw=img.width; ew=img.maxwidth-img.width; sh=img.height; eh=img.maxheight-img.height; sx=parseInt(img.style.left); sy=parseInt(img.style.top);
                        ex=Math.max(0,Math.min(ew,Math.round((((img.minwidth/2)-sx)*(img.maxwidth/img.width))-(img.minwidth*0.5)+sx)))*-1; 
                        ey=Math.max(0,Math.min(eh,Math.round((((img.minheight/2)-sy)*(img.maxheight/img.height))-(img.minheight*0.5)+sy)))*-1; 
                        st=Math.max(1,Math.round((img.maxwidth/img.width)*v)); shiftzoom._zoomKey(d,(w?1:0),w,st,sw,ew,sh,eh,sx,ex,sy,ey);
                }
        },
        _zoomKey : function(d,ct,ww,st,sw,ew,sh,eh,sx,ex,sy,ey) {
                if(cvi_szactive!=null) {var view,mw,mh,mx,my,img=shiftzoom.G(cvi_szactive);
                        if(!img.zoomout&&!img.zoomin) {
                                function setoverview() {
                                        if(img.width>img.minwidth||img.height>img.minheight) {
                                                if(img.trident) {img.style.cursor="url('"+img.curpath+"grab.cur'),move";}else {img.style.cursor="move";}
                                                if(img.overview) {shiftzoom._setOverview(img); shiftzoom.G(img.overid).style.visibility="visible";}
                                        }else {img.style.cursor="crosshair"; if(img.overview) {shiftzoom.G(img.overid).style.visibility="hidden";}}
                                        img.pointer=img.style.cursor; shiftzoom.G(img.infoid).style.visibility='hidden';
                                }
                                if(d==0&&(parseInt(img.style.width)>img.minwidth||parseInt(img.style.height)>img.minheight)) {
                                        mw=Math.max(img.minwidth,Math.min(img.maxwidth,Math.round(ew*ct/st+sw))); mx=Math.round(ex*ct/st+sx); mh=Math.max(img.minheight,Math.min(img.maxheight,Math.round(eh*ct/st+sh))); my=Math.round(ey*ct/st+sy); 
                                        shiftzoom.G(img.infoid).style.visibility='visible'; shiftzoom.G(img.textid).innerHTML=parseInt((mw/img.minwidth)*100)+" / "+parseInt(img.xfactor*100)+" %";
                                        img.style.width=mw+'px'; img.style.height=mh+'px'; img.style.left=mx+'px'; img.style.top=my+'px'; img.width=mw; img.height=mh; img.left=mx; img.top=my; img.maxleft=img.width-img.minwidth; img.maxtop=img.height-img.minheight; ct++;
                                        if((cvi_szimage||ww)&&(img.width>img.minwidth||img.height>img.minheight)) {
                                                if(!ww) {setTimeout("shiftzoom._zoomKey("+d+","+ct+","+ww+","+st+","+sw+","+ew+","+sh+","+eh+","+sx+","+ex+","+sy+","+ey+")",50);}
                                                else {setoverview(); if(cvi_szactive!=null) {cvi_szimage=null;}}
                                        }else {setoverview();}
                                }else if(d==1&&(parseInt(img.style.width)<img.maxwidth||parseInt(img.style.height)<img.maxheight)) {
                                        mw=Math.max(img.minwidth,Math.min(img.maxwidth,Math.round(ew*ct/st+sw))); mx=Math.round(ex*ct/st+sx); mh=Math.max(img.minheight,Math.min(img.maxheight,Math.round(eh*ct/st+sh))); my=Math.round(ey*ct/st+sy); 
                                        shiftzoom.G(img.infoid).style.visibility='visible'; shiftzoom.G(img.textid).innerHTML=parseInt((mw/img.minwidth)*100)+" / "+parseInt(img.xfactor*100)+" %";
                                        img.style.width=mw+'px'; img.style.height=mh+'px'; img.style.left=mx+'px'; img.style.top=my+'px'; img.width=mw; img.height=mh; img.left=mx; img.top=my; img.maxleft=img.width-img.minwidth; img.maxtop=img.height-img.minheight; ct++;
                                        if((cvi_szimage||ww)&&(img.width<img.maxwidth||img.height<img.maxheight)) {
                                                if(!ww) {setTimeout("shiftzoom._zoomKey("+d+","+ct+","+ww+","+st+","+sw+","+ew+","+sh+","+eh+","+sx+","+ex+","+sy+","+ey+")",50);}
                                                else {setoverview(); if(cvi_szactive!=null) {cvi_szimage=null;}}
                                        }else {setoverview();}
                                }else {setoverview();}
                        }
                }
        },
        _panKey : function(h,v,s,a) {
                if(cvi_szactive!=null) {var img=shiftzoom.G(cvi_szactive);
                        if(img.width>img.minwidth||img.height>img.minheight) {
                                var x=Math.max(0,Math.min(img.maxleft,Math.abs(parseInt(img.style.left))-(s?4*h:a?h/4:h)));
                                var y=Math.max(0,Math.min(img.maxtop,Math.abs(parseInt(img.style.top))-(s?4*v:a?v/4:v)));
                                img.style.left=(x*-1)+'px'; img.style.top=(y*-1)+'px'; img.left=(x*-1); img.top=(y*-1);
                                if(img.overview) {var view=shiftzoom.G(img.viewid).style;
                                        view.left=Math.round((Math.abs(parseInt(img.style.left))/(img.width/img.minwidth))*img.ovsfact)-(img.bmode?2:0)+'px';
                                        view.top=Math.round((Math.abs(parseInt(img.style.top))/(img.height/img.minheight))*img.ovsfact)-(img.bmode?2:0)+'px';
                                } if(cvi_szimage) {setTimeout("shiftzoom._panKey("+h+","+v+","+s+","+a+")",50);}
                        }
                }
        },
        _fadeImage : function(id,o) {
                var img=shiftzoom.G(id); if(o<=100) {if(img.trident) {img.style.filter="alpha(opacity="+o+")";}else {img.style.opacity=o/100;} o+=10;
                window.setTimeout("shiftzoom._fadeImage('"+id+"',"+o+")",30);}else {if(img.buttons) {shiftzoom.G(img.ctrlid).style.visibility='visible';} 
                if(img.showcoords) {shiftzoom.G(img.xycoid).style.visibility='visible';}}
        },
        _fadeInfo : function(id,o) {
                clearInterval(cvi_sztimer); var img=shiftzoom.G(id), obj=shiftzoom.G(img.infoid); if(o>0&&cvi_szactive==img.id&&!img.zoomin&&!img.zoomout){
                if(img.trident) {obj.style.filter="alpha(opacity="+o+")";}else {obj.style.opacity=o/100;} o-=5; cvi_sztimer=setInterval("shiftzoom._fadeInfo('"+id+"',"+o+")",50);}
                else {if(img.trident) {obj.style.filter="alpha(opacity=100)";}else {obj.style.opacity=1;} obj.style.visibility='hidden';}
        }, 
        _whilePan : function(e) {
                var img=shiftzoom._shiftzoom; e=e?e:window.event;
                var x=Math.max(0,Math.min(img.maxleft,Math.abs(parseInt(img.style.left))-(e.clientX-img.mouseX)));
                var y=Math.max(0,Math.min(img.maxtop,Math.abs(parseInt(img.style.top))-(e.clientY-img.mouseY)));
                img.style.left=(x*-1)+'px'; img.style.top=(y*-1)+'px'; img.left=(x*-1); img.top=(y*-1); img.mouseX=e.clientX; img.mouseY=e.clientY;
                return false;
        },
        _stopPan : function() {
                var view, butt, img=shiftzoom._shiftzoom; document.onmousemove=null; document.onmouseup=null;
                if(img.gecko||img.presto) {img.style.cursor="move";} else {img.style.cursor=img.pointer;}if(img.overview) { view=shiftzoom.G(img.viewid).style;
                        view.left=Math.round((Math.abs(parseInt(img.style.left))/(img.width/img.minwidth))*img.ovsfact)-(img.bmode?2:0)+'px';
                        view.top=Math.round((Math.abs(parseInt(img.style.top))/(img.height/img.minheight))*img.ovsfact)-(img.bmode?2:0)+'px';
                } shiftzoom._shiftzoom=null;
        },
        _startMove : function(e) {
                if(!e) {e=window.event; var view=e.srcElement;}else {var view=e.target;}
                var l=parseInt(view.style.left), t=parseInt(view.style.top); cvi_szimage=view.parentNode.parentNode.getElementsByTagName("img")[0].id;
                view.style.cursor="default"; view.mouseX=e.clientX; view.mouseY=e.clientY;
                document.onmousemove=shiftzoom._whileMove; document.onmouseup=shiftzoom._stopMove;
                return false;
        },
        _whileMove : function(e) {
                if(!e) {e=window.event; var view=e.srcElement;}else {var view=e.target;}
                var cen=view.id.split("_"), img=shiftzoom.G(cvi_szimage); 
                if(view && cen[cen.length-1]=='view' && view.maxleft && view.maxtop) {
                        var l=Math.max(0,Math.min(view.maxleft,Math.abs(parseInt(view.style.left))+(e.clientX-view.mouseX)));
                        var t=Math.max(0,Math.min(view.maxtop,Math.abs(parseInt(view.style.top))+(e.clientY-view.mouseY)));
                        view.style.left=(l-(img.bmode?2:0))+'px'; view.style.top=(t-(img.bmode?2:0))+'px'; view.mouseX=e.clientX; view.mouseY=e.clientY;
                        var x=Math.max(0,Math.min(img.maxleft,Math.abs(l*(img.width/img.minwidth)*(1/img.ovsfact))));
                        var y=Math.max(0,Math.min(img.maxtop,Math.abs(t*(img.height/img.minheight)*(1/img.ovsfact))));
                        img.style.left=(x*-1)+'px'; img.style.top=(y*-1)+'px'; img.left=(x*-1); img.top=(y*-1);
                }else {document.onmousemove=null; document.onmouseup=null; img.onmousedown=shiftzoom._catchKey; cvi_szimage=null;} 
                return false;
        },
        _stopMove : function() {document.onmousemove=null; document.onmouseup=null; shiftzoom.G(cvi_szimage).onmousedown=shiftzoom._catchKey; cvi_szimage=null;}
}

