cssmenutools/scripts/mtlb.js
// Copyright(C)2010 CSSMenuTools. All rights reserved.
// http://www.cssmenutools.com
//ProductID:MTLB
// Registered to:PatriciaGeary
var eUOSVVA={dummy:0,
VERSION:'1.1.0.3',
CSS_Placement:2,
PreloadImage:'&../ajax-loader.gif',
Position:0,
X:100,
Y:100,
Is_Fixed:false,
Width:450,
Height:300,
IsClickClose:false,
BGColor:'#282828',
BorderStyle:'solid',
BorderColor:'#FFFFFF',
BorderWidth:5,
ShadeColor:'#000000',
ShadeOpacity:70,
TBarHeight:35,
TBarAlignment:1,
TBarColor:'#e2e2e2',
TBarImage:'',
TBarFont:'Verdana,Arial,Helvetica,sans-serif',
TBarFontSize:12,
TBarItalic:false,
TBarBold:false,
TBarFontColor:'#282828',
TBarIconPrev:'',
TBarIconPrevMO:'&../mtlb_prevmo.gif',
TBarIconNext:'',
TBarIconNextMO:'&../mtlb_nextmo.gif',
TBarIconClose:'&../mtlb_close.gif',
TBarIconCloseMO:'&../mtlb_closemo.gif',
HTImage:0,
HBImage:0,
WLImage:0,
WRImage:0,
END_PARAMETERS:1,
CurrList:null,
CurrInd:0,
imgH:0,
imgW:0,
bFirstOpen:true,
xB:0,
yB:0,
PreloadImg:null,
BWidth:100,
BHeight:100,
time:null,
browser:function(){var ua=navigator.userAgent.toLowerCase()
var ind=ua.indexOf('gecko')
this.opera=ua.indexOf('opera')>=0
this.safari=ua.indexOf('safari')>=0
this.ie=document.all&&!this.opera
this.ie6=this.ie&&ua.indexOf('msie 6')>0
this.ie7=this.ie&&ua.indexOf('msie 7')>0
this.compatMode=document.compatMode=="CSS1Compat"
this.ieCanvas=this.compatMode?document.documentElement:document.body
return this},
setPathAdjustment:function(ID){var sl=''
var sc=document.getElementsByTagName('script')
for(var i=0;i<sc.length;i++){if(sc[i].innerHTML.search(ID)>-1)sl=sc[i].src}this.SCRIPT_LOCATION=sl.substr(0, sl.lastIndexOf('/')+1)},
adjustPath:function(path){var idf=path.charAt(0)
if(idf=='*'||idf=='&')return this.SCRIPT_LOCATION+path.substr(1)
return path},
addLoadEvent:function(f){var done=0
function w(){if(!done){done=1
f()}}if(document.addEventListener){document.addEventListener('DOMContentLoaded', w, false)}if(this.br.ie&&window==top)(function(){try{document.documentElement.doScroll('left')}catch(e){setTimeout(arguments.callee, 0)
return}w()})()
var oldf=window.onload
if(typeof oldf!='function'){window.onload=w}else{window.onload=function(){try{oldf()}catch(e){}w()}}},
addResizeEvent:function(f){var oldf=window.onresize
if(typeof oldf!='function'){window.onresize=f}else{window.onresize=function(){try{oldf()}catch(e){}f()}}},
addScrollEvent:function(f){var oldf=window.onscroll
if(typeof oldf!='function'){window.onscroll=f}else{window.onscroll=function(){try{oldf()}catch(e){}f()}}},
init:function(){var m=this
m.br=new m.browser
this.setPathAdjustment('MTLB_eUOSVVA')
m.addLoadEvent(m.onload)
m.addResizeEvent(m.oResize)
m.addScrollEvent(m.oScroll)},
onload:function(){setTimeout('eUOSVVA.start()',0)},
start:function(){var m=this
m.TBarIconPrev=m.adjustPath(m.TBarIconPrev)
m.TBarIconPrevMO=m.adjustPath(m.TBarIconPrevMO)
m.TBarIconNext=m.adjustPath(m.TBarIconNext)
m.TBarIconNextMO=m.adjustPath(m.TBarIconNextMO)
m.TBarIconClose=m.adjustPath(m.TBarIconClose)
m.TBarIconCloseMO=m.adjustPath(m.TBarIconCloseMO)
var targets=document.getElementsByName('MTLB_eUOSVVA')
for(var i=0;i<targets.length;i++){targets[i].onclick=this.show}},
show:function(){var m=eUOSVVA
var e=this
m.CurrList=eval(e.id+'list');var len=m.CurrList.length; if(len==0)return false;for(var i=0;i<len;i++)m.CurrList[i][0]=m.adjustPath(m.CurrList[i][0])
m.CurrInd=0;if(!m.lbox){m.create();}if(m.lbox){m.ShowOverlay(m.overlay, m.ShadeOpacity, 1000)}var et=e.firstChild;if(!et||(et&&et.tagName!='IMG'))et=e;m.xB=m.getLeft(et);m.yB=m.getTop(et);m.lbox.style.top=m.yB+'px';m.lbox.style.left=m.xB+'px';m.lbox.style.margin='0px';m.bFirstOpen=true;if(m.tbar)m.tbar.style.display='none';m.setSize(100,100,false);m.changeImage(m.CurrList[m.CurrInd]);return false;},
ShowOverlay:function(o, opacity, t){var old=parseFloat(o.style.opacity)*100;if(o.style.display!='block')o.style.display='block';var tbeg=new Date;if(!t)t=1000;if(o.tmr)clearTimeout(o.tmr);o.tmr=setTimeout(function(){var p=(new Date-tbeg)/t;if(p>1)p=1;var d=old+(opacity-old)*p;o.style.opacity=d/100;o.style.filter='alpha(opacity='+d+')';if(p==1){clearTimeout(o.tmr);if(0==d)o.style.display='none';}else o.tmr=setTimeout(arguments.callee, 10)}, 10);},
zoomLb:function(o, pos, img, ipos, tb, dur, f){var oldpos=new Object;var oldipos=new Object;for(var i in pos)oldpos[i]=parseInt(o.style[i]);for(var i in ipos)oldipos[i]=parseInt(img.style[i]);var tbeg=new Date;if(o.ztmr)clearTimeout(o.ztmr);o.ztmr=setTimeout(function(){var p=(new Date-tbeg)/dur;if(p>1)p=1;var d=((Math.sin((p-0.5)*Math.PI)/2)+0.5);for(var i in pos)o.style[i]=(pos[i]-oldpos[i])*d+oldpos[i]+'px';for(var i in ipos)img.style[i]=(ipos[i]-oldipos[i])*d+oldipos[i]+'px';img.parentNode.style.height=parseInt(o.style.height)-tb+'px';eUOSVVA.setImagePos(parseInt(img.style.width), parseInt(img.style.height), tb);if(p==1){clearTimeout(o.ztmr);if(f)f();}else o.ztmr=setTimeout(arguments.callee, 10);}, 10);},
create:function(){var m=this;m.PreloadImg=new Image();m.PreloadImg.onload=m.onloadImg;m.overlay=document.createElement('div');var stl=m.overlay.style;stl.display='none';stl.opacity=0;if(m.br.ie){var pageSize=new m.getPageSize();var scrollPos=new m.getScrollPos();stl.left=scrollPos.scrollX+'px';stl.top=scrollPos.scrollY+'px';stl.position='absolute';stl.width=pageSize.winWidth+scrollPos.scrollX+'px';stl.height=pageSize.winHeight+scrollPos.scrollY+'px';}else{stl.position='fixed';stl.left='0px';stl.top='0px';stl.width='100%';stl.height='100%';}stl.zIndex=1000
stl.backgroundColor='#000000'
m.lbox=document.createElement('div')
stl=m.lbox.style
stl.position='absolute'
stl.width=m.BWidth+'px';stl.height=m.BHeight+'px';stl.top=m.HTImage+'px'; stl.left=m.WLImage+'px';stl.zIndex=1001;stl.borderStyle='solid'
stl.borderColor='#FFFFFF'
stl.borderWidth='5px'
var lboxHTML="<div class=\"MTLBeUOSVVAcontent\"><div class=\"MTLBeUOSVVApreloader\" id=\"MTLBeUOSVVApreloader\"></div><img class=\"MTLBeUOSVVAimage\" id=\"MTLBeUOSVVAimg\" src=\"\" alt=\"\"/></div><div id=\"MTLBeUOSVVAtitlebar\"  class=\"MTLBeUOSVVAtitlebar\"><div class=\"MTLBeUOSVVAtext\" id=\"MTLBeUOSVVAtext\">"+m.CurrList[0][1]+"</div><div class=\"MTLBeUOSVVAicons\" id=\"MTLBeUOSVVAicons\"><img class=\"MTLBeUOSVVAicon MTLBeUOSVVAprev\" src=\""+m.TBarIconPrev+"\" alt=\"Previous\" onmouseover=\"this.src='"+m.TBarIconPrevMO+"'\" onmouseout=\"this.src='"+m.TBarIconPrev+"'\" onclick=\"eUOSVVA.prev();\" /><img class=\"MTLBeUOSVVAicon MTLBeUOSVVAnext\" src=\""+m.TBarIconNext+"\" alt=\"Next\" onmouseover=\"this.src='"+m.TBarIconNextMO+"'\" onmouseout=\"this.src='"+m.TBarIconNext+"'\" onclick=\"eUOSVVA.next();\" /><img class=\"MTLBeUOSVVAicon MTLBeUOSVVAclose\" src=\""+m.TBarIconClose+"\" alt=\"Close\" onmouseover=\"this.src='"+m.TBarIconCloseMO+"'\" onmouseout=\"this.src='"+m.TBarIconClose+"'\" onclick=\"eUOSVVA.close();\" /></div></div>";m.lbox.innerHTML=lboxHTML;document.body.appendChild(m.overlay);document.body.appendChild(m.lbox);m.image=document.getElementById('MTLBeUOSVVAimg');m.image.onload=m.onloadImage;m.tbar=document.getElementById('MTLBeUOSVVAtitlebar');m.preloader=document.getElementById('MTLBeUOSVVApreloader')
m.tbar.style.display='none';m.text=document.getElementById('MTLBeUOSVVAtext')
m.icons=document.getElementById('MTLBeUOSVVAicons')},
prev:function(){var m=eUOSVVA;window.clearTimeout(m.time);if(m.CurrList!=null){var len=m.CurrList.length;m.CurrInd=m.CurrInd>0 ? m.CurrInd-1:len-1;if(m.CurrInd>=0&&m.CurrInd<len){this.changeImage(m.CurrList[m.CurrInd]);}}},
next:function(){var m=eUOSVVA;window.clearTimeout(m.time);if(m.CurrList!=null){var len=m.CurrList.length;m.CurrInd=m.CurrInd<len-1 ? m.CurrInd+1:0;if(m.CurrInd>=0&&m.CurrInd<len){this.changeImage(m.CurrList[m.CurrInd]);}}},
close:function(){var m=eUOSVVA
window.clearTimeout(m.time)
m.image.src=''
m.image.style.display='none'
m.lbox.style.display='none'
m.ShowOverlay(m.overlay,0,800)
m.CurrList=null;m.BWidth=100
m.BHeight=100
m.setSize(100, 100)},
changeImage:function(arr){var m=this
if(m.lbox.style.display=='none')m.lbox.style.display='block'
if(m.image)m.image.style.display='none'
m.preloader.style.display='block'
if(m.text)m.text.innerHTML='';m.PreloadImg.src=''
m.PreloadImg.src=arr[0]},
setSize:function(imgWidth, imgHeight, showTB){var m=this
var tbWidth=(m.text?m.text.offsetWidth:0)+(m.icons?m.icons.offsetWidth:0)
m.Width=tbWidth>imgWidth?tbWidth:imgWidth
m.Height=imgHeight+(showTB?m.TBarHeight:0)
if(m.image)m.image.parentNode.style.height=imgHeight+'px'
m.lbox.style.width=m.Width+'px';m.lbox.style.height=m.Height+'px';m.image.style.width=imgWidth+'px';m.image.style.height=imgHeight+'px';},
setImagePos:function(imgWidth, imgHeight, tb){var m=this;if(!m.image)return;var W=parseInt(m.lbox.style.width);var H=parseInt(m.lbox.style.height)-tb;m.image.style.left=(W>imgWidth?(W-imgWidth)/2:0)+'px';m.image.style.top=(H>imgHeight?(H-imgHeight)/2:0)+'px';},
showTBar:function(){var m=eUOSVVA
m.text.innerHTML=m.CurrList[m.CurrInd][1]
m.tbar.style.display=''
m.text.style.marginTop=((m.TBarHeight-m.text.offsetHeight)/2)+'px'
var tbWidth=(m.text?m.text.offsetWidth:0)+(m.icons?m.icons.offsetWidth:0)
while(tbWidth>parseInt(m.lbox.style.width)){m.lbox.style.width=tbWidth+'px'
tbWidth=(m.text?m.text.offsetWidth:0)+(m.icons?m.icons.offsetWidth:0)}m.image.style.display='inline'},
onloadImg:function(){var m=eUOSVVA
if(m.image)m.image.src=m.CurrList[m.CurrInd][0]},
onloadImage:function(){var m=eUOSVVA;m.preloader.style.display='none';var ih=m.PreloadImg.height;var iw=m.PreloadImg.width;m.imgH=ih;m.imgW=iw;var scrollPos=new m.getScrollPos();var pageSize=new m.getPageSize();var LimitHeight=pageSize.winHeight-10;var maxH=LimitHeight-m.HTImage-m.HBImage-m.TBarHeight;if(maxH<ih){iw=Math.round(iw*maxH / ih);ih=maxH;}var Hlb=ih+m.HTImage+m.HBImage+m.TBarHeight;var Wlb=iw+m.WLImage+m.WRImage;var yEnd=Math.round(pageSize.winHeight/2+scrollPos.scrollY-Hlb/2)+m.HTImage;var xEnd=Math.round(pageSize.winWidth/2+scrollPos.scrollX-Wlb/2)+m.WLImage;m.image.style.width=m.BWidth+'px';m.image.style.left='0px';m.image.style.top='0px';if(m.bFirstOpen){m.BHeight=m.BWidth / iw*ih;m.image.style.height=m.BHeight+'px';m.lbox.style.height=m.BHeight+'px';if(m.image)m.image.style.display='inline';m.zoomLb(m.lbox,{top:yEnd,left:xEnd,height:ih,width:iw},m.image,{height:ih,width:iw}, 0,500,function(){var m=eUOSVVA;m.bFirstOpen=false;m.lbox.style.height=ih+m.TBarHeight+'px';m.showTBar();m.setImagePos(iw, ih, m.TBarHeight);m.BWidth=parseInt(m.lbox.style.width);m.BHeight=parseInt(m.lbox.style.height);})}else{m.image.style.height=m.BHeight-m.TBarHeight+'px';m.zoomLb(m.lbox,{top:yEnd,left:xEnd,height:ih+m.TBarHeight,width:iw},m.image,{height:ih,width:iw}, m.TBarHeight,500,function(){var m=eUOSVVA;m.showTBar();m.setImagePos(iw, ih, m.TBarHeight);m.BWidth=parseInt(m.lbox.style.width);m.BHeight=parseInt(m.lbox.style.height);})}},
updatePos:function(){var m=eUOSVVA;if(m.lbox&&m.lbox.style.display!='none'){var ih=m.imgH;var iw=m.imgW;var scrollPos=new m.getScrollPos();var pageSize=new m.getPageSize();var LimitHeight=pageSize.winHeight-10;var maxH=LimitHeight-m.HTImage-m.HBImage-m.TBarHeight;if(maxH<ih){iw=Math.round(iw*maxH / ih);ih=maxH;}var Hlb=ih+m.HTImage+m.HBImage+m.TBarHeight;var tbWidth=(m.text?m.text.offsetWidth:0)+(m.icons?m.icons.offsetWidth:0);var Wlb=iw+m.WLImage+m.WRImage;var ew=iw;if(tbWidth>iw)ew=tbWidth;var yEnd=Math.round(pageSize.winHeight/2+scrollPos.scrollY-Hlb/2)+m.HTImage;var xEnd=Math.round(pageSize.winWidth/2+scrollPos.scrollX-Wlb/2)+m.WLImage;m.zoomLb(m.lbox,{top:yEnd,left:xEnd,height:ih+m.TBarHeight,width:ew},m.image,{height:ih,width:iw}, m.TBarHeight,500,function(){var m=eUOSVVA;m.showTBar();m.setImagePos(iw, ih, m.TBarHeight);m.BWidth=parseInt(m.lbox.style.width);m.BHeight=parseInt(m.lbox.style.height);});}},
updateOverlay:function(isResize){var m=eUOSVVA
if(m.lbox&&m.lbox.style.display!='none'){if(m.br.ie){var pageSize=new m.getPageSize()
var scrollPos=new m.getScrollPos()
m.overlay.style.left=scrollPos.scrollX+'px'
m.overlay.style.top=scrollPos.scrollY+'px'
m.overlay.style.width=pageSize.winWidth+'px'
m.overlay.style.height=pageSize.winHeight+'px'}}},
oResize:function(){var m=eUOSVVA
m.updatePos()
m.updateOverlay()},
oScroll:function(){var m=eUOSVVA
m.updatePos()
m.updateOverlay()},
getPageSize:function(){var xScroll, yScroll
var d=document
var docElem=d.documentElement
if(self.innerHeight&&self.scrollMaxY){yScroll=self.innerHeight+self.scrollMaxY}else if(d.body.scrollHeight>d.body.offsetHeight){yScroll=d.body.scrollHeight}else if(docElem&&docElem.scrollHeight>docElem.offsetHeight){yScroll=docElem.scrollHeight}else{yScroll=d.body.offsetHeight}if(self.innerWidth&&self.scrollMaxX){xScroll=self.innerWidth+self.scrollMaxX}else if(d.body.scrollWidth>d.body.offsetWidth){xScroll=d.body.scrollWidth}else if(docElem&&docElem.scrollWidth>docElem.offsetWidth){xScroll=docElem.scrollWidth}else{xScroll=d.body.offsetWidth}var windowWidth, windowHeight
if(self.innerHeight){windowWidth=self.innerWidth
windowHeight=self.innerHeight}else if(docElem&&docElem.clientHeight){windowWidth=docElem.clientWidth
windowHeight=docElem.clientHeight}else if(d.body){windowWidth=d.body.clientWidth
windowHeight=d.body.clientHeight}this.winHeight=windowHeight
this.winWidth=windowWidth
this.pageHeight=yScroll
this.pageWidth=xScroll},
getScrollPos:function(){var docElem=document.documentElement
this.scrollX=self.scrollX||(docElem&&docElem.scrollLeft)||document.body.scrollLeft
this.scrollY=self.scrollY||(docElem&&docElem.scrollTop)||document.body.scrollTop},
getTop:function(e){var top=0;var abs=false;while(e&&((e.tagName!='BODY')||!abs)){if(e.style.position=='absolute')abs=true;top+=e.offsetTop;e=e.offsetParent;}return top;},
getLeft:function(e){var left=0;var abs=false;while(e&&((e.tagName!='BODY')||!abs)){if(e.style.position=='absolute')abs=true;left+=e.offsetLeft;e=e.offsetParent;}return left;},
dummy:null};eUOSVVA.init()