/** * Beágyazott slideshow * * Üres slideshow beillesztése: var myInSlide1=new IncSlideShow(1,'slideshow',320,140,[],[],myImageBox); **/ function IncSlideShow(id,container,width,height,images,desc,imageBox,initAjax,preview){ this.id = id; this.name = 'myInSlide'+id; this.width = (width)?width:'auto'; this.height = (height)?height:'auto'; this.contID = (container)?container:null; this.imageBox = (imageBox)?imageBox:null; this.preview = preview; this.container; this.canvas; this.roller; this.leftBtn; this.rightBtn; this.images = new Array; this.loaded = new Array; this.imgleft = new Array; this.description = new Array; this.loadThumb = true; this.relPath = ''; this.incdir = 'inc'; this.directory = this.relPath+'images/inslideshow'; this.thumbsdir = this.relPath+'images/inslideshow/thumbs'; this.suffix = '_thumb'; this.margin = 5; this.rollwidth = 0; this.pos = 0; this.tmppos = 0; this.maxpos = 0; this.shadowColor = 'gray'; this.btnWidth = 25; this.borderWidth = 1; this.borderColor = 'black'; this.borderOverColor = 'blue'; this.backColor = '#F2F2F2'; this.canvasColor = '#EEEEEE'; this.current = -1; this.autoTimeout; this.autodir = 1; this.autoDelay = 3000; this.doAuto = true; this.timeout; this.xmlHttp = null; this.zIndex = 0; this.init=function(){ this.container=document.getElementById(this.contID); if(this.width=='auto') this.width=this.container.parentNode.offsetWidth; this.container.style.border='solid 1px #E6E6E6'; this.container.style.position='relative'; this.container.style.zIndex=this.zIndex; if(this.isIE()) this.leftBtn=document.createElement('
'); else { this.leftBtn=document.createElement('div'); this.leftBtn.setAttribute('onclick',this.name+'.scrollLeft()'); this.leftBtn.setAttribute('onmouseover',this.name+'.btnOver(this,"left")'); this.leftBtn.setAttribute('onmouseout',this.name+'.btnOut(this,"left")'); } this.leftBtn.style.background='url('+this.relPath+'images/inslideshow/leftarrow.gif) no-repeat 50% 50%'; this.leftBtn.style.borderRight='solid 1px #E6E6E6'; this.leftBtn.style.cursor=(this.isIE())?'hand':'pointer'; this.leftBtn.style.position='absolute'; this.leftBtn.style.zIndex=this.zIndex+5; this.container.appendChild(this.leftBtn); this.canvas=document.createElement('div'); this.canvas.style.position='absolute'; this.canvas.style.background=this.canvasColor; this.canvas.style.overflow='hidden'; this.canvas.style.zIndex=this.zIndex+5; this.container.appendChild(this.canvas); if(this.isIE()) this.rightBtn=document.createElement('
'); else { this.rightBtn=document.createElement('div'); this.rightBtn.setAttribute('onclick',this.name+'.scrollRight()'); this.rightBtn.setAttribute('onmouseover',this.name+'.btnOver(this,"right")'); this.rightBtn.setAttribute('onmouseout',this.name+'.btnOut(this,"right")'); } this.rightBtn.style.background='url('+this.relPath+'images/inslideshow/rightarrow.gif) no-repeat 50% 50%'; this.rightBtn.style.borderLeft='solid 1px #E6E6E6'; this.rightBtn.style.cursor=(this.isIE())?'hand':'pointer'; this.rightBtn.style.position='absolute'; this.rightBtn.style.zIndex=this.zIndex+5; this.container.appendChild(this.rightBtn); this.roller=document.createElement('div'); this.roller.style.position='relative'; this.roller.style.textAlign='left'; this.roller.style.zIndex=this.zIndex+1; this.canvas.appendChild(this.roller); this.setSize(this.width,this.height); this.loadThubnails(); if(initAjax){ this.xmlHttp=this.getXmlHttpObject(); if(this.xmlHttp!=null){ var url=this.incdir+'/'+"InSlideShow.php?id="+this.id+"&do=getparams&rnd="+Math.random(); if(this.preview) url+='&preview'; this.xmlHttp.onreadystatechange=this.stateChanged; this.xmlHttp.open("GET",url,true); this.xmlHttp.send(null); if(!document.inSlideXmlObject) document.inSlideXmlObject=new Array; document.inSlideXmlObject[this.id]=this.xmlHttp; } } } this.stateChanged=function(){ var obj; if(!document.inSlideXmlObject) return true; for(var i=0;i0) this.current--; this.scrollTo(this.imgleft[this.current]); this.autodir=-1; } this.scrollRight=function(){ clearTimeout(this.timeout); if(this.current-1) this.imageBox.show(this.directory+'/'+src,this.description[j]); else this.imageBox.show(this.directory+'/'+src); } else { var imgBox=document.createElement('div'); imgBox.setAttribute('id','imgBoxLite'); imgBox.setAttribute('onclick','document.body.removeChild(document.getElementById("imgBoxLite"));document.body.removeChild(document.getElementById("bigImg"));'); imgBox.style.position='absolute'; imgBox.style.zIndex='10000'; imgBox.style.top='0px'; imgBox.style.left='0px'; imgBox.style.width='100%'; imgBox.style.height='100%'; imgBox.style.background='black'; this.opacity(imgBox,80); var img=document.createElement('img'); img.setAttribute('id','bigImg'); img.setAttribute('src',this.directory+'/'+src); img.style.position='absolute'; img.style.zIndex='10001'; document.body.appendChild(img); document.body.appendChild(imgBox); img.style.width='600px'; img.style.top='25%'; img.style.left=((imgBox.offsetWidth-600)/2)+'px'; } } this.scrollTo=function(x){ this.tmppos=this.pos; if(x>=this.maxpos){ this.pos=this.maxpos; this.autodir=-1; } else if(x<=0){ this.pos=0; this.autodir=1; } else this.pos=x; this.scroll(); } this.scroll=function(){ if(Math.abs(this.tmppos-this.pos)>0.2){ this.tmppos=this.tmppos+((this.pos-this.tmppos)/6); this.roller.style.left=-this.tmppos+'px'; this.timeout=setTimeout(this.name+'.scroll()',50); } } this.refresh=function(){ for(var i=0; i'); } else { thumb=document.createElement('img'); thumb.setAttribute('src',this.thumbsdir+'/'+this.prepareSuffix(this.images[i],this.suffix)); thumb.setAttribute('onclick',this.name+'.zoomImage("'+this.images[i]+'")'); thumb.setAttribute('onload',this.name+'.imgOnLoad(this)'); thumb.setAttribute('onmouseover',this.name+'.imgOver(this)'); thumb.setAttribute('onmouseout',this.name+'.imgOut(this)'); } thumb.style.cursor=(this.isIE())?'hand':'pointer'; thumb.style.display='none'; thumb.style.position='relative'; thumb.style.border='solid '+this.borderWidth+'px '+this.borderColor; thumb.style.zIndex=this.zIndex+4; thumbCont.appendChild(thumb); this.roller.appendChild(thumbCont); } } this.imgOnLoad=function(img){ img.style.display='block'; this.rollwidth+=img.width+2*this.margin; this.roller.style.width=this.rollwidth+'px'; var i,src,testsrc; for(i=0; iheight) height=arImages[i].parentNode.offsetHeight; } if(this.width=='auto'){ this.width=(width<=this.container.parentNode.offsetWidth)?width:this.container.parentNode.offsetWidth; this.container.style.width=this.width+'px'; } if(this.height=='auto'){ this.height=height; this.container.style.height=(this.height+2*this.margin)+'px'; } this.maxpos=this.rollwidth-this.canvas.offsetWidth+this.margin; if(this.rollwidth>this.canvas.offsetWidth) this.timeout=setTimeout(this.name+'.autoscroll()',10); } } this.add=function(imgs,desc){ if(imgs instanceof Array){ for(var i=0;i1){value/=100;} element.style.opacity=value; return value; } else if(typeof element.style.filter!="undefined"){ if(value<=1 && value>0){value*=100;} element.style.filter="alpha(opacity="+value+")"; return value; } return null; } this.getXmlHttpObject=function(){ var xmlHttp=null; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } this.isIE=function(){ return (this.strpos(navigator.userAgent.toLowerCase(),"msie",0)>0); } this.strpos=function( haystack, needle, offset){ var i = haystack.indexOf( needle, offset ); // returns -1 return i >= 0 ? i : false; } this.in_array=function(needle, haystack, strict) { var found = false, key, strict = !!strict; for (key=0; key