var Class={create:function(){return function(){this.initialize.apply(this,arguments);}}};Object.extend=function(destination,source){for(var property in source)destination[property]=source[property];return destination;};Function.prototype.bind=function(object){var __method=this;return function(){return __method.apply(object,arguments);}};if(!Array.prototype.forEach){Array.prototype.forEach=function(fn,bind){for(var i=0;i<this.length;i++)fn.call(bind,this[i],i);};}
Array.prototype.each=Array.prototype.forEach;String.prototype.camelize=function(){return this.replace(/-\D/gi,function(match){return match.charAt(match.length-1).toUpperCase();});};var $A=function(iterable){var nArray=[];for(var i=0;i<iterable.length;i++)nArray.push(iterable[i]);return nArray;};function $(){if(arguments.length==1)return get$(arguments[0]);var elements=[];$c(arguments).each(function(el){elements.push(get$(el));});return elements;function get$(el){if(typeof el=='string')el=document.getElementById(el);return el;}};if(!window.Element)var Element={};Object.extend(Element,{remove:function(element){element=$(element);element.parentNode.removeChild(element);},hasClassName:function(element,className){element=$(element);return!!element.className.match(new RegExp("\\b"+className+"\\b"));},addClassName:function(element,className){element=$(element);if(!Element.hasClassName(element,className))element.className=(element.className+' '+className);},removeClassName:function(element,className){element=$(element);if(Element.hasClassName(element,className))element.className=element.className.replace(className,'');}});document.getElementsByClassName=function(className){var elements=[];var all=document.getElementsByTagName('*');$A(all).each(function(el){if(Element.hasClassName(el,className))elements.push(el);});return elements;};var Fx=fx={};Fx.Base=function(){};Fx.Base.prototype={setOptions:function(options){this.options=Object.extend({onStart:function(){},onComplete:function(){},transition:Fx.Transitions.sineInOut,duration:500,unit:'px',wait:true,fps:50},options||{});},step:function(){var time=new Date().getTime();if(time<this.time+this.options.duration){this.cTime=time-this.time;this.setNow();}else{setTimeout(this.options.onComplete.bind(this,this.element),10);this.clearTimer();this.now=this.to;}
this.increase();},setNow:function(){this.now=this.compute(this.from,this.to);},compute:function(from,to){var change=to-from;return this.options.transition(this.cTime,from,change,this.options.duration);},clearTimer:function(){clearInterval(this.timer);this.timer=null;return this;},_start:function(from,to){if(!this.options.wait)this.clearTimer();if(this.timer)return;setTimeout(this.options.onStart.bind(this,this.element),10);this.from=from;this.to=to;this.time=new Date().getTime();this.timer=setInterval(this.step.bind(this),Math.round(1000/this.options.fps));return this;},custom:function(from,to){return this._start(from,to);},set:function(to){this.now=to;this.increase();return this;},hide:function(){return this.set(0);},setStyle:function(e,p,v){if(p=='opacity'){if(v==0&&e.style.visibility!="hidden")e.style.visibility="hidden";else if(e.style.visibility!="visible")e.style.visibility="visible";if(window.ActiveXObject)e.style.filter="alpha(opacity="+v*100+")";e.style.opacity=v;}else e.style[p]=v+this.options.unit;}};Fx.Style=Class.create();Fx.Style.prototype=Object.extend(new Fx.Base(),{initialize:function(el,property,options){this.element=$(el);this.setOptions(options);this.property=property.camelize();},increase:function(){this.setStyle(this.element,this.property,this.now);}});Fx.Styles=Class.create();Fx.Styles.prototype=Object.extend(new Fx.Base(),{initialize:function(el,options){this.element=$(el);this.setOptions(options);this.now={};},setNow:function(){for(p in this.from)this.now[p]=this.compute(this.from[p],this.to[p]);},custom:function(obj){if(this.timer&&this.options.wait)return;var from={};var to={};for(p in obj){from[p]=obj[p][0];to[p]=obj[p][1];}
return this._start(from,to);},increase:function(){for(var p in this.now)this.setStyle(this.element,p,this.now[p]);}});Fx.Transitions={linear:function(t,b,c,d){return c*t/d+b;},sineInOut:function(t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;}};function restyleTopMenu(){var menuCells=document.getElementById('topMenu').rows[0].cells;for(var i in menuCells){if(menuCells[i]&&menuCells[i].nodeName=='TD'){var a=menuCells[i].childNodes[0];a.className='sLink';menuCells[i].appendChild(document.createTextNode(a.innerHTML));a.innerHTML='<span class="link">'+a.innerHTML+'</span>'+a.innerHTML;}}}
function changeLoginForm(obj,panel){var form=document.getElementById('loginForm');var a=form.getElementsByTagName('a');var inputs=form.getElementsByTagName('input');var div=form.getElementsByTagName('div');div[0].style.display=panel=='platform'?'':'none';div[1].style.display=panel=='platform'?'none':'';a[0].style.display=panel=='platform'?'':'none';inputs[2].name=panel=='platform'?'login[email]':'_user';inputs[3].name=panel=='platform'?'login[password]':'_pass';form.action=panel=='platform'?'/':'http://mail.bugvin.ee/';var buttons=obj.parentNode.parentNode.getElementsByTagName('div');for(var i in buttons){if(buttons[i]&&buttons[i].nodeName=='DIV'){buttons[i].className='btn';}}
obj.parentNode.className='btn on'
inputs[2].focus();return false;}
var slideShowInterval=25;var slideShowAcive=true;var last_selected_slide=0;var slideShowActionButton=false;var slideShowPlayButton=false;var slideShowPauseButton=false;var numberButtonsPlace=false;var numberButtons=[];var slidesTable=false;var slides=[];function setSlide(slideNr,silent){if(!silent){timer_sec=0;}
last_selected_slide=slideNr;if(!slidesTable){var oIframe=document.getElementById("pHeader");var oDoc=oIframe.contentWindow||oIframe.contentDocument;if(oDoc.document){oDoc=oDoc.document;}
slidesTable=oDoc.getElementById('slideShowGrid');var height=0;for(var i in slidesTable.rows){if(slidesTable.rows[i]&&slidesTable.rows[i].nodeName=='TR'){slides[i]=height;height+=parseInt(slidesTable.rows[i].clientHeight);}}
numberButtonsPlace=document.getElementById('numberButtonsPlace');numberButtonsPlace.innerHTML='';for(var i in slides){if(i=='each'||i=='forEach'){continue;}
var a=document.createElement('a');a.name=parseInt(i)+1;a.innerHTML=a.name;a.href=location.href+'#'+a.name;a.onclick=function(){return setSlide(parseInt(this.name)-1);}
a.className='num';numberButtonsPlace.appendChild(a);}
numberButtonsPlace.style.display='';numberButtons=numberButtonsPlace.getElementsByTagName('a');slideShowActionButton=document.getElementById('slideShowActionButton');slideShowPlayButton=document.getElementById('slideShowPlayButton');slideShowPauseButton=document.getElementById('slideShowPauseButton');slideShowPlayButton.className='num';slideShowPlayButton.childNodes[0].src='/templates/bugvin_ee/images/play.gif';slideShowPauseButton.onclick=function(){slideShowAcive=false;slideShowPauseButton.className='num on';slideShowPauseButton.childNodes[0].src='/templates/bugvin_ee/images/pause_on.gif';slideShowPlayButton.className='num';slideShowPlayButton.childNodes[0].src='/templates/bugvin_ee/images/play.gif';return false;}
slideShowPlayButton.className='num on';slideShowPlayButton.childNodes[0].src='/templates/bugvin_ee/images/play_on.gif';slideShowPlayButton.onclick=function(){timer_sec=slideShowInterval;slideShowAcive=true;slideShowPauseButton.className='num';slideShowPauseButton.childNodes[0].src='/templates/bugvin_ee/images/pause.gif';slideShowPlayButton.className='num on';slideShowPlayButton.childNodes[0].src='/templates/bugvin_ee/images/play_on.gif';return false;}
slideShowActionButton.style.display='';}
var from=slidesTable.style.top?parseInt(slidesTable.style.top):0;var to=slides[slideNr]*-1;var effect=new Fx.Styles(slidesTable,{duration:500});effect.custom({'top':[from,to]});for(var i=0;i<numberButtons.length;i++){if(numberButtons[i]&&numberButtons[i].nodeName=='A'){numberButtons[i].className=i==slideNr?'num on':'num';}}
return false;}
var timer_sec=0;function slideshowTimer(){++timer_sec;if(slideShowAcive==true&&timer_sec>=slideShowInterval){if(typeof(slides[last_selected_slide+1])=='undefined'){setSlide(0,true);}else{setSlide(last_selected_slide+1,true);}
timer_sec=0;}
setTimeout('slideshowTimer()',1000);}
function include(path){document.write('<script src="'+path+'" type="text/javascript"></script>');}
function initKLayers(){isDOM=document.getElementById?true:false
isOpera=isOpera5=window.opera&&isDOM
isOpera6=isOpera&&window.print
isOpera7=isOpera&&document.readyState
isMSIE=isIE=document.all&&document.all.item&&!isOpera
isStrict=document.compatMode=='CSS1Compat'
isNN=isNC=navigator.appName=="Netscape"
isNN4=isNC4=isNN&&!isDOM
isMozilla=isNN6=isNN&&isDOM
if(!isDOM&&!isNC&&!isMSIE&&!isOpera){KLayers=false
return false}
pageLeft=0
pageTop=0
KL_imgCount=0
KL_imgArray=new Array()
KL_imageRef="document.images[\""
KL_imagePostfix="\"]"
KL_styleSwitch=".style"
KL_layerPostfix="\"]"
if(isNN4){KL_layerRef="document.layers[\""
KL_styleSwitch=""}
if(isMSIE){KL_layerRef="document.all[\""}
if(isDOM){KL_layerRef="document.getElementById(\""
KL_layerPostfix="\")"}
KLayers=true
return true}
initKLayers()
function KL_getBody(w){if(!w)w=window
if(isStrict){return w.document.documentElement}else{return w.document.body}}
function getWindowLeft(w){if(!w)w=window
if(isMSIE||isOpera7)return w.screenLeft
if(isNN||isOpera)return w.screenX}
function getWindowTop(w){if(!w)w=window
if(isMSIE||isOpera7)return w.screenTop
if(isNN||isOpera)return w.screenY}
function getWindowWidth(w){if(!w)w=window
if(isMSIE)return KL_getBody(w).clientWidth
if(isNN||isOpera)return w.innerWidth}
function getWindowHeight(w){if(!w)w=window
if(isMSIE)return KL_getBody(w).clientHeight
if(isNN||isOpera)return w.innerHeight}
function getDocumentWidth(w){if(!w)w=window
if(isMSIE||isOpera7)return KL_getBody(w).scrollWidth
if(isNN)return w.document.width
if(isOpera)return w.document.body.style.pixelWidth}
function getDocumentHeight(w){if(!w)w=window
if(isMSIE||isOpera7)return KL_getBody(w).scrollHeight
if(isNN)return w.document.height
if(isOpera)return w.document.body.style.pixelHeight}
function getScrollX(w){if(!w)w=window
if(isMSIE||isOpera7)return KL_getBody(w).scrollLeft
if(isNN||isOpera)return w.pageXOffset}
function getScrollY(w){if(!w)w=window
if(isMSIE||isOpera7)return KL_getBody(w).scrollTop
if(isNN||isOpera)return w.pageYOffset}
function preloadImage(imageFile){KL_imgArray[KL_imgCount]=new Image()
KL_imgArray[KL_imgCount++].src=imageFile}
var KL_LAYER=0
var KL_IMAGE=1
function KL_findObject(what,where,type){var i,j,l,s
var len=eval(where+".length")
for(j=0;j<len;j++){s=where+"["+j+"].document.layers"
if(type==KL_LAYER){l=s+"[\""+what+"\"]"}
if(type==KL_IMAGE){i=where+"["+j+"].document.images"
l=i+"[\""+what+"\"]"}
if(eval(l))return l
l=KL_findObject(what,s,type)
if(l!="null")return l}
return"null"}
function KL_getObjectPath(name,parent,type){var l=((parent&&isNN4)?(parent+"."):(""))+((type==KL_LAYER)?KL_layerRef:KL_imageRef)+name+((type==KL_LAYER)?KL_layerPostfix:KL_imagePostfix)
if(eval(l))return l
if(!isNN4){return l}else{return KL_findObject(name,"document.layers",type)}}
function layer(name){return new KLayer(name,null)}
function layerFrom(name,parent){if(parent.indexOf("document.")<0)parent=layer(parent).path
return new KLayer(name,parent)}
function image(name){return new KImage(name,null)}
function imageFrom(name,parent){if(parent.indexOf("document.")<0)parent=layer(parent).path
return new KImage(name,parent)}
function KLayer(name,parent){this.path=KL_getObjectPath(name,parent,KL_LAYER)
this.object=eval(this.path)
if(!this.object)return
this.style=this.css=eval(this.path+KL_styleSwitch)}
KLP=KLayer.prototype
KLP.isExist=KLP.exists=function(){return(this.object)?true:false}
function KL_getPageOffset(o){var KL_left=0
var KL_top=0
do{KL_left+=o.offsetLeft
KL_top+=o.offsetTop}while(o=o.offsetParent)
return[KL_left,KL_top]}
KLP.getLeft=function(){var o=this.object
if(isMSIE||isMozilla||isOpera)return o.offsetLeft-pageLeft
if(isNN4)return o.x-pageLeft}
KLP.getTop=function(){var o=this.object
if(isMSIE||isMozilla||isOpera)return o.offsetTop-pageTop
if(isNN4)return o.y-pageTop}
KLP.getAbsoluteLeft=function(){var o=this.object
if(isMSIE||isMozilla||isOpera)return KL_getPageOffset(o)[0]-pageLeft
if(isNN4)return o.pageX-pageLeft}
KLP.getAbsoluteTop=function(){var o=this.object
if(isMSIE||isMozilla||isOpera)return KL_getPageOffset(o)[1]-pageTop
if(isNN4)return o.pageY-pageTop}
KLP.getWidth=function(){var o=this.object
if(isMSIE||isMozilla||isOpera7)return o.offsetWidth
if(isOpera)return this.css.pixelWidth
if(isNN4)return o.document.width}
KLP.getHeight=function(){var o=this.object
if(isMSIE||isMozilla||isOpera7)return o.offsetHeight
if(isOpera)return this.css.pixelHeight
if(isNN4)return o.document.height}
KLP.getZIndex=function(){return this.css.zIndex}
KLP.setLeft=KLP.moveX=function(x){x+=pageLeft
if(isOpera){this.css.pixelLeft=x}else if(isNN4){this.object.x=x}else{this.css.left=x+"px"}}
KLP.setTop=KLP.moveY=function(y){y+=pageTop
if(isOpera){this.css.pixelTop=y}else if(isNN4){this.object.y=y}else{this.css.top=y+"px"}}
KLP.moveTo=KLP.move=function(x,y){this.setLeft(x)
this.setTop(y)}
KLP.moveBy=function(x,y){this.moveTo(this.getLeft()+x,this.getTop()+y)}
KLP.setZIndex=KLP.moveZ=function(z){this.css.zIndex=z}
KLP.setVisibility=function(v){this.css.visibility=(v)?(isNN4?"show":"visible"):(isNN4?"hide":"hidden")}
KLP.show=function(){this.setVisibility(true)}
KLP.hide=function(){this.setVisibility(false)}
KLP.isVisible=KLP.getVisibility=function(){return(this.css.visibility.toLowerCase().charAt(0)=='h')?false:true}
KLP.setBgColor=function(c){if(isMSIE||isMozilla||isOpera7){this.css.backgroundColor=c}else if(isOpera){this.css.background=c}else if(isNN4){this.css.bgColor=c}}
KLP.setBgImage=function(url){if(isMSIE||isMozilla||isOpera6){this.css.backgroundImage="url("+url+")"}else if(isNN4){this.css.background.src=url}}
KLP.setClip=KLP.clip=function(top,right,bottom,left){if(isMSIE||isMozilla||isOpera7){this.css.clip="rect("+top+"px "+right+"px "+bottom+"px "+left+"px)"}else if(isNN4){var c=this.css.clip
c.top=top
c.right=right
c.bottom=bottom
c.left=left}}
KLP.scrollTo=KLP.scroll=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){if(scrollX>this.getWidth()-windowWidth)scrollX=this.getWidth()-windowWidth
if(scrollY>this.getHeight()-windowHeight)scrollY=this.getHeight()-windowHeight
if(scrollX<0)scrollX=0
if(scrollY<0)scrollY=0
var top=0
var right=windowWidth
var bottom=windowHeight
var left=0
left=left+scrollX
right=right+scrollX
top=top+scrollY
bottom=bottom+scrollY
this.moveTo(windowLeft-scrollX,windowTop-scrollY)
this.setClip(top,right,bottom,left)}
KLP.scrollBy=KLP.scrollByOffset=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){var X=-parseInt(this.css.left)+windowLeft+scrollX
var Y=-parseInt(this.css.top)+windowTop+scrollY
this.scroll(windowLeft,windowTop,windowWidth,windowHeight,X,Y)}
KLP.scrollByPercentage=function(windowLeft,windowTop,windowWidth,windowHeight,scrollX,scrollY){var X=(this.getWidth()-windowWidth)*scrollX/100
var Y=(this.getHeight()-windowHeight)*scrollY/100
this.scroll(windowLeft,windowTop,windowWidth,windowHeight,X,Y)}
KLP.write=function(str){var o=this.object
if(isNN4){var d=o.document
d.open()
d.write(str)
d.close()}else{o.innerHTML=str}}
KLP.add=function(str){var o=this.object
if(isNN4){o.document.write(str)}else{o.innerHTML+=str}}
KIP=KImage.prototype
function KImage(name){this.path=KL_getObjectPath(name,false,KL_IMAGE)
this.object=eval(this.path)}
KIP.isExist=KIP.exists=function(){return(this.object)?true:false}
KIP.getSrc=KIP.src=function(){return this.object.src}
KIP.setSrc=KIP.load=function(url){this.object.src=url}
var loadedImages=[];var galleryClass=function(){var shadowDiv,biggestHeight,objects=[];var whiteDiv,bigImage,loadingImage;var borderSize=40;var imageObj,imageSrc,imageWidth,imageHeight,imageAlt;var imagesArray=false;var closeButton,enlargeButton,backButton,forwardButton,commentPlace;var changingImage;this.show=function(getObj,getSrc,getWidth,getHeight,getAlt){changingImage=false;imageObj=getObj;imageSrc=getSrc;imageWidth=parseInt(getWidth);imageHeight=parseInt(getHeight);imageAlt=getAlt;this.objects(1);this.loadingEffect('set');if(bigImage){document.body.removeChild(bigImage);}
bigImage=document.createElement("img");bigImage.id="bigImage";bigImage.border='0';if(loadedImages[bigImage.src]){setTimeout(function(){gallery.loadingEffect();},10);}else{bigImage.onload=function(){gallery.loadingEffect();}}
bigImage.style.display='none';bigImage.style.position='absolute';bigImage.style.left=0;bigImage.style.top=0;bigImage.style.zIndex=27;bigImage.src=imageSrc;document.body.appendChild(bigImage);}
this.change=function(getSrc,getWidth,getHeight,getAlt){changingImage=true;closeButton.style.display='none';enlargeButton.style.display='none';backButton.style.display='none';commentPlace.style.display='none';forwardButton.style.display='none';imageSrc=getSrc;imageWidth=parseInt(getWidth);imageHeight=parseInt(getHeight);imageAlt=getAlt;if(bigImage){bigImage.parentNode.removeChild(bigImage);}
bigImage=document.createElement("img");bigImage.id="bigImage";bigImage.border='0';bigImage.src=imageSrc;if(loadedImages[bigImage.src]){setTimeout(function(){gallery.loadingEffect();},10);}else{bigImage.onload=function(){gallery.loadingEffect();}}
bigImage.style.display='none';bigImage.style.background="url('/scripts/loading.gif') center center no-repeat";bigImage.style.position='absolute';bigImage.style.left=0;bigImage.style.top=0;bigImage.style.zIndex=27;document.body.appendChild(bigImage);}
this.loadingEffect=function(action){if(!loadingImage){loadingImage=document.createElement("img");loadingImage.src="/scripts/loading.gif";loadingImage.width=20;loadingImage.height=20;loadingImage.style.position="absolute";loadingImage.style.zIndex="3";document.body.appendChild(loadingImage);}
var objectData=layer();objectData.object=imageObj;if(action=="set"){loadingImage.style.left=parseInt(objectData.getAbsoluteLeft()+(imageObj.clientWidth/2)-(loadingImage.width/2))+'px';loadingImage.style.top=parseInt(objectData.getAbsoluteTop()+(imageObj.clientHeight/2)-(loadingImage.height/2))+'px';this.setOpacity(imageObj,30);loadingImage.style.display='';}else{this.setOpacity(imageObj,100);loadingImage.style.display='none';this.zoomImage();}}
this.zoomImage=function(){loadedImages[bigImage.src]=true;if(changingImage){bigImage.style.width=imageWidth+'px';bigImage.style.height=imageHeight+'px';bigImage.style.left=((getDocumentWidth()/2)-((imageWidth)/2))+'px';bigImage.style.top=(getScrollY()+((getWindowHeight()/2)-((imageHeight+50)/2)))+'px';bigImage.style.display='';this.setOpacity(bigImage,0);gallery.objectBackground();setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 10)",50);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 20)",75);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 30)",100);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 40)",125);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 50)",150);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 60)",175);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 70)",200);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 80)",225);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 90)",250);setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 100)",275);}else{var objectData=layer();objectData.object=imageObj;var objectLeftOneStep=((getDocumentWidth()/2)-((imageWidth)/2)-objectData.getAbsoluteLeft())/10;var objectTopOneStep=(getScrollY()+((getWindowHeight()/2)-((imageHeight+50)/2)-objectData.getAbsoluteTop()))/10;var objectWidthOneStep=((imageWidth)-imageObj.clientWidth)/10;var objectHeightOneStep=((imageHeight)-imageObj.clientHeight)/10;bigImage.style.width=imageObj.clientWidth+'px';bigImage.style.height=imageObj.clientHeight+'px';bigImage.style.left=objectData.getAbsoluteLeft()+'px';bigImage.style.top=objectData.getAbsoluteTop()+'px';bigImage.style.display='';for(var i=1;i<=10;i++){var timeoutAction="";timeoutAction+="document.getElementById('bigImage').style.left = \""+(objectData.getAbsoluteLeft()+(i*objectLeftOneStep))+"px\";";timeoutAction+="document.getElementById('bigImage').style.top = \""+(objectData.getAbsoluteTop()+(i*objectTopOneStep))+"px\";";timeoutAction+="document.getElementById('bigImage').style.width = \""+(imageObj.clientWidth+(i*objectWidthOneStep))+"px\";";timeoutAction+="document.getElementById('bigImage').style.height = \""+(imageObj.clientHeight+(i*objectHeightOneStep))+"px\";";if(i==10){timeoutAction+="gallery.objectBackground();";}
setTimeout(timeoutAction,i*20);}}}
this.objectBackground=function(){if(!whiteDiv){whiteDiv=document.createElement("div");whiteDiv.id="whiteDiv";whiteDiv.style.display='none';whiteDiv.style.backgroundColor='#FFFFFF';whiteDiv.style.position='absolute';whiteDiv.style.left=0;whiteDiv.style.top=0;whiteDiv.style.zIndex=26;document.body.appendChild(whiteDiv);}
if(changingImage){var objectData=layer();objectData.object=whiteDiv;var objectLeftOneStep=((getDocumentWidth()/2)-((imageWidth+borderSize)/2)-objectData.getAbsoluteLeft())/10;var objectTopOneStep=(getScrollY()-(borderSize/2)+((getWindowHeight()/2)-((imageHeight+50)/2)-objectData.getAbsoluteTop()))/10;var objectWidthOneStep=((imageWidth+borderSize)-objectData.getWidth())/10;var objectHeightOneStep=((imageHeight+borderSize+60)-objectData.getHeight())/10;for(var i=1;i<=10;i++){var timeoutAction="";timeoutAction+="document.getElementById('whiteDiv').style.left = \""+(objectData.getAbsoluteLeft()+(i*objectLeftOneStep))+"px\";";timeoutAction+="document.getElementById('whiteDiv').style.top = \""+(objectData.getAbsoluteTop()+(i*objectTopOneStep))+"px\";";timeoutAction+="document.getElementById('whiteDiv').style.width = \""+(objectData.getWidth()+(i*objectWidthOneStep))+"px\";";timeoutAction+="document.getElementById('whiteDiv').style.height = \""+(objectData.getHeight()+(i*objectHeightOneStep))+"px\";";if(i==10){timeoutAction+="gallery.actionButtons(1);";}
setTimeout(timeoutAction,i*20);}}else{var objectData=layer();objectData.object=bigImage;var objectLeftOneStep=((getDocumentWidth()/2)-((imageWidth+borderSize)/2)-objectData.getAbsoluteLeft())/10;var objectTopOneStep=(getScrollY()-(borderSize/2)+((getWindowHeight()/2)-((imageHeight+50)/2)-objectData.getAbsoluteTop()))/10;var objectWidthOneStep=((imageWidth+borderSize)-bigImage.clientWidth)/10;var objectHeightOneStep=((imageHeight+borderSize+60)-bigImage.clientHeight)/10;whiteDiv.style.width=bigImage.clientWidth+'px';whiteDiv.style.height=bigImage.clientHeight+'px';whiteDiv.style.left=objectData.getAbsoluteLeft()+'px';whiteDiv.style.top=objectData.getAbsoluteTop()+'px';whiteDiv.style.display='';for(var i=1;i<=10;i++){var timeoutAction="";timeoutAction+="document.getElementById('whiteDiv').style.left = \""+(objectData.getAbsoluteLeft()+(i*objectLeftOneStep))+"px\";";timeoutAction+="document.getElementById('whiteDiv').style.top = \""+(objectData.getAbsoluteTop()+(i*objectTopOneStep))+"px\";";timeoutAction+="document.getElementById('whiteDiv').style.width = \""+(bigImage.clientWidth+(i*objectWidthOneStep))+"px\";";timeoutAction+="document.getElementById('whiteDiv').style.height = \""+(bigImage.clientHeight+(i*objectHeightOneStep))+"px\";";if(i==1){timeoutAction+="gallery.shadow(1);";}
setTimeout(timeoutAction,i*20);}}}
this.actionButtons=function(showButtons){if(!imagesArray){imagesArray=[];var img=document.getElementsByTagName("img");for(var i in img){if(img[i]&&img[i].parentNode&&img[i].parentNode.nodeName=="A"&&img[i].parentNode.onclick){var tmp=document.createElement("textarea");tmp.value=img[i].parentNode.onclick;var sep=tmp.value.split('this.childNodes[0], ');if(!sep[1]){continue;}
sep=sep[1].substr(0,1);tmp=tmp.value.split(sep);if(tmp[1]&&tmp[3]&&tmp[5]){imagesArray[imagesArray.length]={"src":tmp[1],"width":tmp[3],"height":tmp[5],"alt":img[i].alt};}}}}
if(!closeButton){closeButton=document.createElement("img");closeButton.src="/scripts/close.gif";closeButton.id="closeButton";closeButton.width="21";closeButton.height="21";closeButton.style.position="absolute";closeButton.style.display="none";closeButton.style.cursor="pointer";closeButton.onclick=function(){gallery.objects(0);closeButton.style.display='none';enlargeButton.style.display='none';whiteDiv.style.display='none';shadowDiv.style.display='none';backButton.style.display='none';commentPlace.style.display='none';forwardButton.style.display='none';bigImage.style.display='none';}
closeButton.style.zIndex=28;document.body.appendChild(closeButton);}
if(!enlargeButton){enlargeButton=document.createElement("img");enlargeButton.src="/scripts/enlarge.gif";enlargeButton.id="enlargeButton";enlargeButton.width="21";enlargeButton.height="23";enlargeButton.style.position="absolute";enlargeButton.style.display="none";enlargeButton.style.cursor="pointer";enlargeButton.style.zIndex=28;enlargeButton.style.visibility='hidden';document.body.appendChild(enlargeButton);}
if(!backButton){backButton=document.createElement("div");backButton.id="backButton";backButton.style.cssText="display:block;position:absolute;background: url('/scripts/back.gif') left 98.5% no-repeat;cursor: pointer;";backButton.style.zIndex=28;document.body.appendChild(backButton);}
if(!forwardButton){forwardButton=document.createElement("div");forwardButton.id="forwardButton";forwardButton.style.cssText="display:block;position:absolute;background: url('/scripts/forward.gif') right 98.5% no-repeat;cursor: pointer;";forwardButton.style.zIndex=29;document.body.appendChild(forwardButton);}
if(!commentPlace){commentPlace=document.createElement("table");commentPlace.style.cssText="display:none;position:absolute;background: #fff;border-collapse: collapse;";commentPlace.style.zIndex=29;row=commentPlace.insertRow(-1);cell=row.insertCell(-1);cell.style.verticalAlign="middle";document.body.appendChild(commentPlace);}
if(showButtons){var objectData=layer();objectData.object=bigImage;closeButton.style.top=objectData.getAbsoluteTop()+(borderSize/2)+"px";closeButton.style.left=(objectData.getAbsoluteLeft()+bigImage.width)-(borderSize/2)-closeButton.width+"px";closeButton.style.display='';enlargeButton.style.top=objectData.getAbsoluteTop()+(borderSize/2)+"px";enlargeButton.style.left=(objectData.getAbsoluteLeft())+(borderSize/2)+"px";enlargeButton.style.display='';var tmpSrc=imageSrc.split("/");var largeSrc="";for(var i in tmpSrc){if(i==tmpSrc.length-2){continue;}
if(tmpSrc[i]){largeSrc+="/"+tmpSrc[i];}}
enlargeButton.setAttribute("largeSrc",largeSrc);enlargeButton.onclick=function(){location.href=this.getAttribute("largeSrc");}
var currentIndex=0;for(var i in imagesArray){if(imagesArray[i]['src']==imageSrc){currentIndex=i;break;}}
if(imagesArray[currentIndex]&&imagesArray[currentIndex]['alt']){commentPlace.style.top=(objectData.getAbsoluteTop()+imageHeight+15)+"px";commentPlace.style.left=(objectData.getAbsoluteLeft()+borderSize*2)+"px";commentPlace.style.width=(imageWidth-borderSize*4)+"px";commentPlace.style.height="50px";commentPlace.rows[0].cells[0].innerHTML=imagesArray[currentIndex]['alt'];commentPlace.style.display="";}else{commentPlace.style.display="none";}
if(imagesArray[parseInt(currentIndex)-1]){backButton.style.display='block';backButton.style.top=(objectData.getAbsoluteTop()+borderSize+enlargeButton.height)+"px";backButton.style.left=objectData.getAbsoluteLeft()+"px";backButton.style.width=(bigImage.width/2)+"px";backButton.style.height=(bigImage.height)-(borderSize+enlargeButton.height)+60+"px";backButton.setAttribute("bigSrc",imagesArray[parseInt(currentIndex)-1]['src']);backButton.setAttribute("bigWidth",imagesArray[parseInt(currentIndex)-1]['width']);backButton.setAttribute("bigHeight",imagesArray[parseInt(currentIndex)-1]['height']);backButton.setAttribute("bigAlt",imagesArray[parseInt(currentIndex)-1]['alt']);var imagePreloader=new Image(imagesArray[parseInt(currentIndex)-1]['width'],imagesArray[parseInt(currentIndex)-1]['height']);imagePreloader.src=imagesArray[parseInt(currentIndex)-1]['src'];imagePreloader.onload=function(){loadedImages[this.src]=true;}
backButton.onclick=function(){gallery.change(this.getAttribute("bigSrc"),this.getAttribute("bigWidth"),this.getAttribute("bigHeight"),this.getAttribute("bigAlt"));this.onclick=function(){return false;}
return false;}}else{backButton.style.display='none';}
if(imagesArray[parseInt(currentIndex)+1]){forwardButton.style.display='block';forwardButton.style.top=(objectData.getAbsoluteTop()+borderSize+enlargeButton.height)+"px";forwardButton.style.left=((bigImage.width/2)+objectData.getAbsoluteLeft())+"px";forwardButton.style.width=(bigImage.width/2)+"px";forwardButton.style.height=(bigImage.height)-(borderSize+enlargeButton.height)+60+"px";forwardButton.setAttribute("bigSrc",imagesArray[parseInt(currentIndex)+1]['src']);forwardButton.setAttribute("bigWidth",imagesArray[parseInt(currentIndex)+1]['width']);forwardButton.setAttribute("bigHeight",imagesArray[parseInt(currentIndex)+1]['height']);forwardButton.setAttribute("bigAlt",imagesArray[parseInt(currentIndex)+1]['alt']);var imagePreloader=new Image(imagesArray[parseInt(currentIndex)+1]['width'],imagesArray[parseInt(currentIndex)+1]['height']);imagePreloader.src=imagesArray[parseInt(currentIndex)+1]['src'];imagePreloader.onload=function(){loadedImages[this.src]=true;}
forwardButton.onclick=function(){gallery.change(this.getAttribute("bigSrc"),this.getAttribute("bigWidth"),this.getAttribute("bigHeight"),this.getAttribute("bigAlt"));this.onclick=function(){return false;}
return false;}}else{forwardButton.style.display='none';}}}
this.getPageSize=function(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
return pageHeight;}
this.shadow=function(showShadow){if(!shadowDiv){shadowDiv=document.createElement("div");shadowDiv.id='shadowDiv';shadowDiv.style.display='none';shadowDiv.style.backgroundColor='#000000';shadowDiv.style.position='absolute';shadowDiv.style.left=0;shadowDiv.style.top=0;shadowDiv.style.zIndex=25;shadowDiv.style.color='#FFFFFF';document.body.appendChild(shadowDiv);}
if(showShadow&&!changingImage){this.setOpacity(shadowDiv,70);shadowDiv.style.width=getDocumentWidth()+'px';shadowDiv.style.height=gallery.getPageSize()+'px';shadowDiv.style.display='';this.setOpacity(shadowDiv,0);setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 10)",50);setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 20)",75);setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 30)",100);setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 40)",125);setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 50)",150);setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 60)",200);setTimeout("gallery.actionButtons(1);",250);}else if(showShadow&&changingImage){gallery.actionButtons(1);}else if(!showShadow){this.setOpacity(shadowDiv,0);document.getElementById('shadowDiv').style.display='none';}}
this.objects=function(hide){if(hide){objects=[];var selector=document.getElementsByTagName('select');for(var i=0;i<selector.length;i++){if(selector[i].style.visibility!="hidden"){objects[objects.length]=selector[i];selector[i].style.visibility='hidden';}}
var object=document.getElementsByTagName('object');for(var i=0;i<object.length;i++){if(object[i].style.visibility!="hidden"){objects[objects.length]=object[i];object[i].style.visibility='hidden';}}
var embed=document.getElementsByTagName('embed');for(var i=0;i<embed.length;i++){if(embed[i].style.visibility!="hidden"){objects[objects.length]=embed[i];embed[i].style.visibility='hidden';}}
var iframe=document.getElementsByTagName('iframe');for(var i=0;i<iframe.length;i++){if(iframe[i].style.visibility!="hidden"){objects[objects.length]=iframe[i];iframe[i].style.visibility='hidden';}}}else{for(var i in objects){if(i&&objects&&objects[i]&&objects[i].style){objects[i].style.visibility='visible';}}}}
this.setOpacity=function(obj,opacity){obj.style.opacity=opacity/100;obj.style.filter='alpha(opacity='+opacity+')';}}
var gallery=new galleryClass();isDOM=document.getElementById
isOpera=isOpera5=window.opera&&isDOM
isOpera6=isOpera&&window.print
isOpera7=isOpera&&document.readyState
isMSIE=document.all&&document.all.item&&!isOpera
isMSIE5=isDOM&&isMSIE
isNetscape4=document.layers
isMozilla=isDOM&&navigator.appName=="Netscape"
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return"";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;function setOpacity(obj,opacity){obj.style.opacity=opacity/100;obj.style.filter='alpha(opacity='+opacity+')';}
function sub_menu(obj,act){var menuDiv=obj.getElementsByTagName("table")[0];if(obj.className!="on"){obj.style.background=(act=="show")?"#8B97A4 url(/templates/default/images/mbgs.gif) repeat-x scroll left top":"";obj.getElementsByTagName("a")[obj.getElementsByTagName("a").length-1].style.color=(act=="show")?"#fff":"";}
if(menuDiv){if(act=="show"){menuDiv.setAttribute("isOver","true");if(menuDiv.style.display){setOpacity(menuDiv,"0");menuDiv.style.display='';setTimeout(function(){setOpacity(menuDiv,"20");},20);setTimeout(function(){setOpacity(menuDiv,"30");},40);setTimeout(function(){setOpacity(menuDiv,"40");},60);setTimeout(function(){setOpacity(menuDiv,"50");},80);setTimeout(function(){setOpacity(menuDiv,"60");},100);setTimeout(function(){setOpacity(menuDiv,"70");},120);setTimeout(function(){setOpacity(menuDiv,"80");},140);setTimeout(function(){setOpacity(menuDiv,"90");},160);setTimeout(function(){setOpacity(menuDiv,"100");},180);}}else{menuDiv.setAttribute("isOver","false");setTimeout(function(){if(menuDiv.getAttribute('isOver')!="true"){setTimeout(function(){setOpacity(menuDiv,"100");},20);setTimeout(function(){setOpacity(menuDiv,"90");},40);setTimeout(function(){setOpacity(menuDiv,"80");},60);setTimeout(function(){setOpacity(menuDiv,"70");},80);setTimeout(function(){setOpacity(menuDiv,"60");},100);setTimeout(function(){setOpacity(menuDiv,"50");},120);setTimeout(function(){setOpacity(menuDiv,"40");},140);setTimeout(function(){setOpacity(menuDiv,"30");},160);setTimeout(function(){setOpacity(menuDiv,"20");},180);setTimeout(function(){menuDiv.style.display='none';},200);}},"10");}}}
function setCities(obj){var curiers_row=document.getElementById("curiers_row");curiers_row.cells[1].innerHTML='';curiers_row.style.display='none';var citiesSelector=document.getElementById("city_selector");var first_option=citiesSelector.getElementsByTagName("option")[0];var option=document.createElement("option");option.value=first_option.value;option.appendChild(document.createTextNode(first_option.innerHTML));citiesSelector.innerHTML='';citiesSelector.appendChild(option);if(obj.value){var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){if(req.responseText&&document.getElementById('debug')){document.getElementById('debug').innerHTML=req.responseText;}
if(req.responseJS&&req.responseJS.cities){for(var key in req.responseJS.cities){if(req.responseJS.cities[key]['id']){var option=document.createElement("option");option.value=req.responseJS.cities[key]['id'];option.appendChild(document.createTextNode(req.responseJS.cities[key]['name']));citiesSelector.appendChild(option);}}}}}
req.caching=false;req.open('GET',location.href,true);req.send({'userAction':'getCities','country':obj.value});}}
function setCuriers(obj){var curiers_row=document.getElementById("curiers_row");curiers_row.cells[1].innerHTML='';if(obj.value){var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){if(req.responseText&&document.getElementById('debug')){document.getElementById('debug').innerHTML=req.responseText;}
if(req.responseJS&&req.responseJS.curiers){for(var key in req.responseJS.curiers){if(req.responseJS.curiers[key]['id']){var p=document.createElement("div");p.innerHTML='<input type="radio" name="delivery_type" value="'+req.responseJS.curiers[key]['id']+'"'+(key<=0?' checked':'')+'>'+req.responseJS.curiers[key]['name']+(req.responseJS.curiers[key]['price']>0?(": "+req.responseJS.curiers[key]['price']+' '+req.responseJS.curiers[key]['currency']):"");curiers_row.cells[1].appendChild(p);}}}}}
req.caching=false;req.open('GET',location.href,true);req.send({'userAction':'getCuriers','city':obj.value});}
curiers_row.style.display='';}
var siteNowClass=function(){var tmplLeftArrow=document.getElementById('tmplLeftArrow').getElementsByTagName('a')[0];var tmplLeftArrowHidden=false;var tmplRightArrow=document.getElementById('tmplRightArrow').getElementsByTagName('a')[0];var tmplRightArrowHidden=false;var preloadedImages=[];var tmplImagePlace=document.getElementById('tmplImagePlace');var tmplImage1,tmplImage2;var namePlace=tmplImagePlace.parentNode.getElementsByTagName('a')[0];var greenButton=tmplImagePlace.parentNode.parentNode.getElementsByTagName('a')[4];var selfObj=this;var working=false;var itemNum=1;var maxItemNum=0;this.init=function(){tmplLeftArrow.onclick=function(){return selfObj.moveBack();}
tmplRightArrow.onclick=function(){return selfObj.moveForward();}
for(var imgSrc in tmplImages){if(imgSrc&&tmplImages[imgSrc]['width']){var img=new Image(1,1);img.src=imgSrc;preloadedImages[preloadedImages.length]={'src':imgSrc,'href':tmplImages[imgSrc]['href'],'create_href':tmplImages[imgSrc]['create_href'],'name':tmplImages[imgSrc]['name'],'width':parseInt(tmplImages[imgSrc]['width']),'height':parseInt(tmplImages[imgSrc]['height'])};maxItemNum++;}}
tmplImagePlace.innerHTML='';tmplImage1=document.createElement('div');tmplImage1.style.cssText='width:150px;height:149px;background-position:center top;background-repeat:no-repeat;';tmplImage2=document.createElement('div');tmplImage2.style.cssText='width:150px;height:149px;;background-position:center top;background-repeat:no-repeat;cursor:pointer';tmplImage1.appendChild(tmplImage2);tmplImagePlace.appendChild(tmplImage1);tmplImage1.style.backgroundImage='url('+preloadedImages[0]['src']+')';tmplImage2.style.backgroundImage='url('+preloadedImages[0]['src']+')';selfObj.setImage();}
this.moveBack=function(){if(working){return false;}
if(itemNum-1>=0){itemNum--;selfObj.setImage();}
return false;}
this.moveForward=function(){if(working){return false;}
if(itemNum+1<maxItemNum){itemNum++;selfObj.setImage();}
return false;}
this.setImage=function(){working=true;if(itemNum<1&&!tmplLeftArrowHidden){tmplLeftArrowHidden=true;var effect=new Fx.Styles(tmplLeftArrow,{duration:200});effect.custom({'opacity':[1,0]});}else if(itemNum>0&&tmplLeftArrowHidden){tmplLeftArrowHidden=false;var effect=new Fx.Styles(tmplLeftArrow,{duration:200});effect.custom({'opacity':[0,1]});}
if(itemNum>=maxItemNum-1&&!tmplRightArrowHidden){tmplRightArrowHidden=true;var effect=new Fx.Styles(tmplRightArrow,{duration:200});effect.custom({'opacity':[1,0]});}else if(itemNum<maxItemNum&&tmplRightArrowHidden){tmplRightArrowHidden=false;var effect=new Fx.Styles(tmplRightArrow,{duration:200});effect.custom({'opacity':[0,1]});}
tmplImage2.style.opacity=0;tmplImage2.style.filter='alpha(opacity=0)';tmplImage2.style.backgroundImage='url('+preloadedImages[itemNum]['src']+')';namePlace.innerHTML=preloadedImages[itemNum]['name'];namePlace.href=preloadedImages[itemNum]['href'];tmplImage2.title=preloadedImages[itemNum]['name'];tmplImage2.setAttribute('href',preloadedImages[itemNum]['href']);tmplImage2.onclick=function(){location.href=this.getAttribute('href');}
var effect=new Fx.Styles(tmplImage2,{duration:500});effect.custom({'opacity':[0,1]});setTimeout(function(){working=false;tmplImage1.style.backgroundImage=tmplImage2.style.backgroundImage;},510);}}
var siteNow;function setTemplateSelector(){siteNow=new siteNowClass();siteNow.init();}
function rnd(x,y,z){var num;do{num=parseInt(Math.random()*z);if(num>=x&&num<=y)break;}while(true);return(num);}
function generate(){var g_pass="";var symb=new Array('','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');for(var s=1;s<=rnd(6,10,80);s++){g_pass+=symb[rnd(1,symb.length-1,80)];}
return g_pass;}
function withoutSpaces(str){for(var i=0;i<str.length;i++){str=str.replace(' ','');str=str.replace(' ','');}
return str;}
function checkForm(form){var backgorundColor='#FFEAEA';var borderColor='#FFBFBF';var submitForm=true;for(var i in form.elements){var element=form.elements[i];if(element&&element.nodeName&&(element.nodeName=='INPUT'||element.nodeName=='TEXTAREA'||element.nodeName=='SELECT')&&element.getAttribute('check')=='true'){if(!withoutSpaces(element.value)){element.style.backgroundColor=backgorundColor;element.style.border='1px solid '+borderColor;if(element.nodeName=='SELECT'){if(!element.onchange){element.onchange=function(){if(this.value){this.style.border='';this.style.backgroundColor='';}else{this.style.border='1px solid '+borderColor;this.style.backgroundColor=backgorundColor;}}}}else{if(!element.onkeyup){element.onkeyup=function(){if(this.value){this.style.border='';this.style.backgroundColor='';}else{this.style.border='1px solid '+borderColor;this.style.backgroundColor=backgorundColor;}}}}
submitForm=false;}else{element.style.backgroundColor='';element.style.border='';}}}
if(submitForm){form.submit();}}


function templatesListClass(){
	
	var cellsOnPage = 3;
	
	var templatesTable,templatesLeftButton,templatesRightButton;
	var leftMargin = 0;
	var cellWidth = 0;
	var cellsMoveWidth = 0;
	var totalCells = 0;
	var criticalLeft = 0;
	var allreadyInit = false;
	
	var selfObj = this;
	
	var moveEffect;
	
	this.init = function(){
		
		templatesTable = document.getElementById('templatesTable');
		templatesLeftButton = document.getElementById('templatesLeftButton');
		templatesRightButton = document.getElementById('templatesRightButton');
		
		moveEffect = new Fx.Styles(templatesTable, {duration: 700});
		
		templatesTableWidth = templatesTable.clientWidth;
		cellWidth = templatesTable.rows[0].cells[0].clientWidth;
		cellsOnPage = Math.round(templatesTable.parentNode.clientWidth/cellWidth);
		
		//cellsMoveWidth = cellWidth * cellsOnPage;
		cellsMoveWidth = parseInt(cellWidth);
		
		totalCells = templatesTable.rows[0].cells.length;
		criticalLeft = (templatesTableWidth-cellWidth*cellsOnPage)*-1;
		
		allreadyInit = true;
		
	}
	
	this.moveRow = function(direction){
		
		if(!allreadyInit){selfObj.init();}
		
		// Setting new left margin
			
			var newleftMargin = leftMargin;
			
			gallery.setOpacity(templatesRightButton, 100);
			gallery.setOpacity(templatesLeftButton, 100);
			
			if(direction=='right'){
				
				newleftMargin = leftMargin - cellsMoveWidth;
				
				if(newleftMargin<=criticalLeft){
					gallery.setOpacity(templatesRightButton, 30);
					newleftMargin = criticalLeft;
				}
				
			}else{
				
				newleftMargin = leftMargin + cellsMoveWidth;
				
				if(newleftMargin>=0){
					gallery.setOpacity(templatesLeftButton, 30);
					newleftMargin = 0;
				}
				
			}
			
		
		if(leftMargin!=newleftMargin){
			moveEffect.custom({'marginLeft': [leftMargin, newleftMargin]})
			leftMargin = newleftMargin;
		}
		
		return false;
		
	}
	
	
}

var templatesList = new templatesListClass();


function setCities(obj){
	
	setPriceWithDelivery(0);
	
	var curiers_row = document.getElementById("curiers_row");
		
		//-------- Removing curiers ------|
			
			curiers_row.cells[1].innerHTML = '';
			
		//-------- Removing curiers ------|
		
	curiers_row.style.display = 'none';
	
	var citiesSelector = document.getElementById("city_selector");
		
		//-------- Removing all city options ---------|
			
			var first_option = citiesSelector.getElementsByTagName("option")[0];
			
			var option = document.createElement("option");
			option.value = first_option.value;
			option.appendChild(document.createTextNode(first_option.innerHTML));
			
			citiesSelector.innerHTML = '';
			citiesSelector.style.display = 'none';
			citiesSelector.appendChild(option);
			
		//-------- Removing all city options ---------|
		
		if(obj.value){
			
			//------ Getting new city options ---------|
				
				var req = new JsHttpRequest();
				req.onreadystatechange = function(){
					if(req.readyState == 4){
						
						if(req.responseText && document.getElementById('debug')){
							document.getElementById('debug').innerHTML = req.responseText;
						}
						
						if(req.responseJS && req.responseJS.cities){
							
							var totalOptions = 0;
							var firstOption = false;
							
							for(var key in req.responseJS.cities){
								
								if(req.responseJS.cities[key]['id']){
									
									var option = document.createElement("option");
									option.value = req.responseJS.cities[key]['id'];
									option.appendChild(document.createTextNode(req.responseJS.cities[key]['name']));
									citiesSelector.appendChild(option);
									
									if(!firstOption){
										firstOption = option;
									}
									
									totalOptions++;
									
								}
								
							}
							
							if(totalOptions>1){
								citiesSelector.style.display = '';
							}else if(firstOption){
								setCuriers(firstOption);
							}
							
						}
						
					}
				}
				
				req.caching = false;
				req.open('GET', location.href, true);
				req.send({'userAction': 'getCities', 'country': obj.value});
				
			//------ Getting new city options ---------|
			
		}
		
	
}


function setCuriers(obj){
	
	setPriceWithDelivery(0);
	
	var curiers_row = document.getElementById("curiers_row");
		
		//-------- Removing curiers ------|
			
			curiers_row.cells[1].innerHTML = '';
			
		//-------- Removing curiers ------|
		
		if(obj.value){
			
			//--------- Getting curiers list ----------|
				
				var req = new JsHttpRequest();
				req.onreadystatechange = function(){
					if(req.readyState == 4){
						
						if(req.responseText && document.getElementById('debug')){
							document.getElementById('debug').innerHTML = req.responseText;
						}
						
						if(req.responseJS && req.responseJS.curiers){
							
							var firstCurier = false;
							
							for(var key in req.responseJS.curiers){
								
								if(req.responseJS.curiers[key]['id']){
									
									var tmpPrice = parseFloat(req.responseJS.curiers[key]['price'].split(' ').join(''));
									
									var p = document.createElement("div");
										
										var input = document.createElement('input');
											
											input.type = 'radio';
											input.name = 'delivery_type';
											input.value = req.responseJS.curiers[key]['id'];
											input.checked = parseInt(key)<1?true:false;
											input.setAttribute('price', tmpPrice);
											input.onchange = input.onclick = function(){
												setPriceWithDelivery(this.getAttribute('price'));
											}
											
											if(!firstCurier){
												firstCurier = input;
											}
											
										p.appendChild(input);
										p.appendChild(document.createTextNode(req.responseJS.curiers[key]['name']));
										
										if(tmpPrice>0){
											p.appendChild(document.createTextNode(': '));
											
											p.appendChild(document.createTextNode(req.responseJS.curiers[key]['price']));
											p.appendChild(document.createTextNode(' '));
											p.appendChild(document.createTextNode(req.responseJS.curiers[key]['currency']));
											
										}
										
									curiers_row.cells[1].appendChild(p);
									
								}
								
							}
							
							if(firstCurier){
								setPriceWithDelivery(firstCurier.getAttribute('price'));
							}
							
						}
						
					}
				}
				
				req.caching = false;
				req.open('GET', location.href, true);
				req.send({'userAction': 'getCuriers', 'city': obj.value});
				
			//--------- Getting curiers list ----------|
			
		}
		
	curiers_row.style.display = '';
	
}


var basketTotalCost = false;
var basketTotalCostObj = false;

function setPriceWithDelivery(price){
	
	if(!basketTotalCostObj){
		basketTotalCostObj = document.getElementById('basketTotalCost');
	}
	
	if(basketTotalCostObj){
		
		if(!basketTotalCost){
			basketTotalCost = parseFloat(basketTotalCostObj.innerHTML.split(' ').join(''));
		}
		
		basketTotalCostObj.innerHTML = basketTotalCost + parseFloat(price);
		//basketTotalCostObj.innerHTML = number_format((basketTotalCost + parseFloat(price)), 2, '.', ' ');
		
	}
	
}

function number_format(number, decimals, point, separator)
{
	if(!isNaN(number))
	{
		
		number = number.toString()
		
		point = point ? point : '.';
		number = number.split('.');
		
		if(separator)
		{
			var tmp_number = new Array();
			for(var i = number[0].length, j = 0; i > 0; i -= 3)
			{
				var pos = i > 0 ? i - 3 : i;
				tmp_number[j++] = number[0].substring(i, pos);
			}
			number[0] = tmp_number.reverse().join(separator);
		}
		
		if(decimals)
		{
			number[1] = number[1] ? number[1] : '0';
			number[1] = Math.round(parseFloat(number[1].substr(0, decimals) + '.' + number[1].substr(decimals, number[1].length), 10));
			var size = decimals - number[1].toString().length;
			for(var i = 0; i < size; i++) number[1] += '0';
		}
		
		return(number.join(point));
		
	}
	else return(null);
}













//------------ Info -------------/
//
//		Gallery Class v 1.2
//		Writed by Kirill Bugvin
//		Used: KLayers
//
//------------ Info -------------/

var loadedImages = [];

var galleryClass = function(){
	
	var shadowDiv, biggestHeight, objects = [];
	var whiteDiv, bigImage, loadingImage;
	
	var borderSize = 40;
	
	var imageObj, imageSrc, imageWidth, imageHeight, imageAlt;
	var imagesArray = false;
	var closeButton, enlargeButton, backButton, forwardButton, commentPlace;
	var changingImage;
	
	this.show = function(getObj, getSrc, getWidth, getHeight, getAlt){
		
		changingImage = false;
		
		imageObj = getObj;
		imageSrc = getSrc;
		imageWidth = parseInt(getWidth);
		imageHeight = parseInt(getHeight);
		imageAlt = getAlt;
		
		this.objects(1);
		this.loadingEffect('set');
		
		if(!bigImage){
			bigImage = document.createElement("img");
			bigImage.id = "bigImage";
			bigImage.border = '0';
			document.body.appendChild(bigImage);
		}
		
		if(loadedImages[bigImage.src]){
			setTimeout(function(){gallery.loadingEffect();}, 10);
		}else{
			bigImage.onload = function(){gallery.loadingEffect();}
		}
		
		bigImage.style.display = 'none';
		
		bigImage.style.position = 'absolute';
		bigImage.style.left = 0;
		bigImage.style.top = 0;
		bigImage.style.zIndex = 27;
		
		bigImage.src = imageSrc;
		
	}
	
	
	this.change = function(getSrc, getWidth, getHeight, getAlt){
		
		changingImage = true;
		
		closeButton.style.display = 'none';
		enlargeButton.style.display = 'none';
		backButton.style.display = 'none';
		commentPlace.style.display = 'none';
		forwardButton.style.display = 'none';
		
		imageSrc = getSrc;
		imageWidth = parseInt(getWidth);
		imageHeight = parseInt(getHeight);
		imageAlt = getAlt;
		
		if(bigImage){
			bigImage.parentNode.removeChild(bigImage);
		}
		
		bigImage = document.createElement("img");
		bigImage.id = "bigImage";
		bigImage.border = '0';
		bigImage.src = imageSrc;
		
		if(loadedImages[bigImage.src]){
			setTimeout(function(){gallery.loadingEffect();}, 10);
		}else{
			bigImage.onload = function(){gallery.loadingEffect();}
		}
		
		bigImage.style.display = 'none';
		bigImage.style.background = "url('/scripts/loading.gif') center center no-repeat";
		
		bigImage.style.position = 'absolute';
		bigImage.style.left = 0;
		bigImage.style.top = 0;
		bigImage.style.zIndex = 27;
		document.body.appendChild(bigImage);
		
	}
	
	
	this.loadingEffect = function(action){
		
		if(!loadingImage){
			
			loadingImage = document.createElement("img");
			loadingImage.src = "/scripts/loading.gif";
			loadingImage.width = 20;
			loadingImage.height = 20;
			loadingImage.style.position = "absolute";
			loadingImage.style.zIndex = "3";
			document.body.appendChild(loadingImage);
			
		}
		
		var objectData = layer();
		objectData.object = imageObj;
		
		if(action=="set"){
			loadingImage.style.left = parseInt(objectData.getAbsoluteLeft()+(imageObj.clientWidth/2)-(loadingImage.width/2))+'px';
			loadingImage.style.top = parseInt(objectData.getAbsoluteTop()+(imageObj.clientHeight/2)-(loadingImage.height/2))+'px';
			this.setOpacity(imageObj, 30);
			loadingImage.style.display = '';
		}else{
			this.setOpacity(imageObj, 100);
			loadingImage.style.display = 'none';
			this.zoomImage();
		}
		
	}
	
	
	this.zoomImage = function(){
		
		loadedImages[bigImage.src] = true;
		
		if(changingImage){
			
			bigImage.style.width = imageWidth+'px';
			bigImage.style.height = imageHeight+'px';
			
			bigImage.style.left = ((getDocumentWidth() / 2) - ((imageWidth) / 2))+'px';
			bigImage.style.top = (getScrollY() + ((getWindowHeight() / 2) - ((imageHeight+50) / 2)))+'px';
			
			bigImage.style.display = '';
			
			this.setOpacity(bigImage, 0);
			
			gallery.objectBackground();
			
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 10)", 50);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 20)", 75);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 30)", 100);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 40)", 125);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 50)", 150);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 60)", 175);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 70)", 200);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 80)", 225);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 90)", 250);
			setTimeout("gallery.setOpacity(document.getElementById('bigImage'), 100)", 275);
			
		}else{
			
			var objectData = layer();
			objectData.object = imageObj;
			
			var objectLeftOneStep = ((getDocumentWidth() / 2) - ((imageWidth) / 2) - objectData.getAbsoluteLeft()) / 10;
			var objectTopOneStep = (getScrollY() + ((getWindowHeight() / 2) - ((imageHeight+50) / 2) - objectData.getAbsoluteTop())) / 10;
			
			var objectWidthOneStep = ((imageWidth) - imageObj.clientWidth) / 10;
			var objectHeightOneStep = ((imageHeight) - imageObj.clientHeight) / 10;
			
			bigImage.style.width = imageObj.clientWidth+'px';
			bigImage.style.height = imageObj.clientHeight+'px';
			bigImage.style.left = objectData.getAbsoluteLeft()+'px';
			bigImage.style.top = objectData.getAbsoluteTop()+'px';
			bigImage.style.display = '';
			
			for(var i=1;i<=10;i++){
				
				var timeoutAction = "";
				
				timeoutAction += "document.getElementById('bigImage').style.left = \""+(objectData.getAbsoluteLeft()+(i*objectLeftOneStep))+"px\";";
				timeoutAction += "document.getElementById('bigImage').style.top = \""+(objectData.getAbsoluteTop()+(i*objectTopOneStep))+"px\";";
				timeoutAction += "document.getElementById('bigImage').style.width = \""+(imageObj.clientWidth+(i*objectWidthOneStep))+"px\";";
				timeoutAction += "document.getElementById('bigImage').style.height = \""+(imageObj.clientHeight+(i*objectHeightOneStep))+"px\";";
				
				if(i==10){
					timeoutAction += "gallery.objectBackground();";
				}
				
				setTimeout(timeoutAction, i*20);
				
			}
			
		}
		
	}
	
	
	this.objectBackground = function(){
		
		if(!whiteDiv){
			whiteDiv = document.createElement("div");
			whiteDiv.id = "whiteDiv";
			whiteDiv.style.display = 'none';
			whiteDiv.style.backgroundColor = '#FFFFFF';
			whiteDiv.style.position = 'absolute';
			whiteDiv.style.left = 0;
			whiteDiv.style.top = 0;
			whiteDiv.style.zIndex = 26;
			document.body.appendChild(whiteDiv);
		}
		
		if(changingImage){
			
			var objectData = layer();
			objectData.object = whiteDiv;
			
			var objectLeftOneStep = ((getDocumentWidth() / 2) - ((imageWidth + borderSize) / 2) - objectData.getAbsoluteLeft()) / 10;
			var objectTopOneStep = (getScrollY() - (borderSize/2) + ((getWindowHeight() / 2) - ((imageHeight+50) / 2) - objectData.getAbsoluteTop())) / 10;
			
			var objectWidthOneStep = ((imageWidth + borderSize) - objectData.getWidth()) / 10;
			var objectHeightOneStep = ((imageHeight + borderSize + 60) - objectData.getHeight()) / 10;
			
			for(var i=1;i<=10;i++){
				
				var timeoutAction = "";
				
				timeoutAction += "document.getElementById('whiteDiv').style.left = \""+(objectData.getAbsoluteLeft()+(i*objectLeftOneStep))+"px\";";
				timeoutAction += "document.getElementById('whiteDiv').style.top = \""+(objectData.getAbsoluteTop()+(i*objectTopOneStep))+"px\";";
				timeoutAction += "document.getElementById('whiteDiv').style.width = \""+(objectData.getWidth()+(i*objectWidthOneStep))+"px\";";
				timeoutAction += "document.getElementById('whiteDiv').style.height = \""+(objectData.getHeight()+(i*objectHeightOneStep))+"px\";";
				
				if(i==10){
					timeoutAction += "gallery.actionButtons(1);";
				}
				
				setTimeout(timeoutAction, i*20);
				
			}
			
			
		}else{
			
			var objectData = layer();
			objectData.object = bigImage;
			
			var objectLeftOneStep = ((getDocumentWidth() / 2) - ((imageWidth + borderSize) / 2) - objectData.getAbsoluteLeft()) / 10;
			var objectTopOneStep = (getScrollY() - (borderSize/2) + ((getWindowHeight() / 2) - ((imageHeight+50) / 2) - objectData.getAbsoluteTop())) / 10;
			
			var objectWidthOneStep = ((imageWidth + borderSize) - bigImage.clientWidth) / 10;
			var objectHeightOneStep = ((imageHeight + borderSize + 60) - bigImage.clientHeight) / 10;
			
			whiteDiv.style.width = bigImage.clientWidth+'px';
			whiteDiv.style.height = bigImage.clientHeight+'px';
			whiteDiv.style.left = objectData.getAbsoluteLeft()+'px';
			whiteDiv.style.top = objectData.getAbsoluteTop()+'px';
			whiteDiv.style.display = '';
			
			for(var i=1;i<=10;i++){
				
				var timeoutAction = "";
				
				timeoutAction += "document.getElementById('whiteDiv').style.left = \""+(objectData.getAbsoluteLeft()+(i*objectLeftOneStep))+"px\";";
				timeoutAction += "document.getElementById('whiteDiv').style.top = \""+(objectData.getAbsoluteTop()+(i*objectTopOneStep))+"px\";";
				timeoutAction += "document.getElementById('whiteDiv').style.width = \""+(bigImage.clientWidth+(i*objectWidthOneStep))+"px\";";
				timeoutAction += "document.getElementById('whiteDiv').style.height = \""+(bigImage.clientHeight+(i*objectHeightOneStep))+"px\";";
				
				if(i==1){
					timeoutAction += "gallery.shadow(1);";
				}
				
				setTimeout(timeoutAction, i*20);
				
			}
			
		}
		
	}
	
	
	this.actionButtons = function(showButtons){
		
		if(!imagesArray){
			
			imagesArray = [];
			
			var img = document.getElementsByTagName("img");
			
			for(var i in img){
				
				if(img[i] && img[i].parentNode && img[i].parentNode.nodeName=="A" && img[i].parentNode.onclick){
					
					var tmp = document.createElement("textarea");
					tmp.value = img[i].parentNode.onclick;
					
					var sep = tmp.value.split('this.childNodes[0], ');
					
					if(!sep[1]){continue;}
					sep = sep[1].substr(0, 1);
					
					tmp = tmp.value.split(sep);
					if(tmp[1] && tmp[3] && tmp[5]){
						imagesArray[imagesArray.length] = {"src": tmp[1], "width": tmp[3], "height": tmp[5], "alt": img[i].alt};
					}
					
				}
				
			}
			
		}
		
		if(!closeButton){
			closeButton = document.createElement("img");
			closeButton.src = "/scripts/close.gif";
			closeButton.id = "closeButton";
			closeButton.width = "21";
			closeButton.height = "21";
			closeButton.style.position = "absolute";
			closeButton.style.display = "none";
			closeButton.style.cursor = "pointer";
			
			closeButton.onclick = function(){
				
				gallery.objects(0);
				
				closeButton.style.display = 'none';
				enlargeButton.style.display = 'none';
				
				whiteDiv.style.display = 'none';
				shadowDiv.style.display = 'none';
				
				backButton.style.display = 'none';
				commentPlace.style.display = 'none';
				forwardButton.style.display = 'none';
				
				bigImage.style.display = 'none';
				
			}
			
			closeButton.style.zIndex = 28;
			document.body.appendChild(closeButton);
		}
		
		
		if(!enlargeButton){
			enlargeButton = document.createElement("img");
			enlargeButton.src = "/scripts/enlarge.gif";
			enlargeButton.id = "enlargeButton";
			enlargeButton.width = "21";
			enlargeButton.height = "23";
			enlargeButton.style.position = "absolute";
			enlargeButton.style.display = "none";
			enlargeButton.style.cursor = "pointer";
			enlargeButton.style.zIndex = 28;
			enlargeButton.style.visibility = 'hidden';
			document.body.appendChild(enlargeButton);
		}
		
		if(!backButton){
			backButton = document.createElement("div");
			backButton.id = "backButton";
			backButton.style.cssText = "display:block;position:absolute;background: url('/scripts/back.gif') left 98.5% no-repeat;cursor: pointer;";
			backButton.style.zIndex = 28;
			document.body.appendChild(backButton);
		}
		
		if(!forwardButton){
			forwardButton = document.createElement("div");
			forwardButton.id = "forwardButton";
			forwardButton.style.cssText = "display:block;position:absolute;background: url('/scripts/forward.gif') right 98.5% no-repeat;cursor: pointer;";
			forwardButton.style.zIndex = 29;
			document.body.appendChild(forwardButton);
		}
		
		
		if(!commentPlace){
			commentPlace = document.createElement("table");
			commentPlace.className = "galleryCommentPlace";
			commentPlace.style.cssText = "display:none;position:absolute;background: #fff;border-collapse: collapse;";
			commentPlace.style.zIndex = 29;
				
				row = commentPlace.insertRow(-1);
				cell = row.insertCell(-1);
				cell.style.verticalAlign = "middle";
				
			document.body.appendChild(commentPlace);
		}
		
		
		if(showButtons){
			
			var objectData = layer();
			objectData.object = bigImage;
			
			
			//--- Close button ---/
				
				closeButton.style.top = objectData.getAbsoluteTop()+(borderSize/2)+"px";
				closeButton.style.left = (objectData.getAbsoluteLeft()+bigImage.width)-(borderSize/2)-closeButton.width+"px";
				closeButton.style.display = '';
				
			
			
			//--- Enlarge button ---/
				
				enlargeButton.style.top = objectData.getAbsoluteTop()+(borderSize/2)+"px";
				enlargeButton.style.left = (objectData.getAbsoluteLeft())+(borderSize/2)+"px";
				enlargeButton.style.display = '';
				
				var tmpSrc = imageSrc.split("/");
				var largeSrc = "";
				for(var i in tmpSrc){
					if(i==tmpSrc.length-2){continue;}
					if(tmpSrc[i]){
						largeSrc += "/"+tmpSrc[i];
					}
				}
				
				enlargeButton.setAttribute("largeSrc", largeSrc);
				enlargeButton.onclick = function(){location.href = this.getAttribute("largeSrc");}
				
			
			
			//----- Getting current image position ------|
				
				var currentIndex = 0;
				
				for(var i in imagesArray){
					if(imagesArray[i]['src']==imageSrc){
						currentIndex = i;
						break;
					}
				}
				
			
			
			//--- Comment place ---|	
				
				if(imagesArray[currentIndex] && imagesArray[currentIndex]['alt']){
					
					commentPlace.style.top = (objectData.getAbsoluteTop()+imageHeight+15)+"px";
					commentPlace.style.left = (objectData.getAbsoluteLeft()+borderSize*2)+"px";
					
					commentPlace.style.width = (imageWidth-borderSize*4)+"px";
					commentPlace.style.height = "50px";
					
					commentPlace.rows[0].cells[0].innerHTML = imagesArray[currentIndex]['alt'];
					commentPlace.style.display = "";
					
				}else{
					commentPlace.style.display = "none";
				}
				
			
			
			//--- Back button ---/
				
				if(imagesArray[parseInt(currentIndex)-1]){
					
					backButton.style.display = 'block';
					
					backButton.style.top = (objectData.getAbsoluteTop()+borderSize+enlargeButton.height)+"px";
					backButton.style.left = objectData.getAbsoluteLeft()+"px";
					backButton.style.width = (bigImage.width/2)+"px";
					backButton.style.height = (bigImage.height)-(borderSize+enlargeButton.height)+60+"px";
					
					backButton.setAttribute("bigSrc", imagesArray[parseInt(currentIndex)-1]['src']);
					backButton.setAttribute("bigWidth", imagesArray[parseInt(currentIndex)-1]['width']);
					backButton.setAttribute("bigHeight", imagesArray[parseInt(currentIndex)-1]['height']);
					backButton.setAttribute("bigAlt", imagesArray[parseInt(currentIndex)-1]['alt']);
					
					var imagePreloader = new Image(imagesArray[parseInt(currentIndex)-1]['width'], imagesArray[parseInt(currentIndex)-1]['height']);
					imagePreloader.src = imagesArray[parseInt(currentIndex)-1]['src'];
					
					imagePreloader.onload = function(){loadedImages[this.src] = true;}
					
					backButton.onclick = function(){
						gallery.change(this.getAttribute("bigSrc"), this.getAttribute("bigWidth"), this.getAttribute("bigHeight"), this.getAttribute("bigAlt"));
						this.onclick = function(){return false;}
						return false;
					}
					
				}else{
					
					backButton.style.display = 'none';
					
				}
				
			
			
			//--- Forward button ---/
				
				if(imagesArray[parseInt(currentIndex)+1]){
					
					forwardButton.style.display = 'block';
					
					forwardButton.style.top = (objectData.getAbsoluteTop()+borderSize+enlargeButton.height)+"px";
					forwardButton.style.left = ((bigImage.width/2)+objectData.getAbsoluteLeft())+"px";
					
					forwardButton.style.width = (bigImage.width/2)+"px";
					forwardButton.style.height = (bigImage.height)-(borderSize+enlargeButton.height)+60+"px";
					
					forwardButton.setAttribute("bigSrc", imagesArray[parseInt(currentIndex)+1]['src']);
					forwardButton.setAttribute("bigWidth", imagesArray[parseInt(currentIndex)+1]['width']);
					forwardButton.setAttribute("bigHeight", imagesArray[parseInt(currentIndex)+1]['height']);
					forwardButton.setAttribute("bigAlt", imagesArray[parseInt(currentIndex)+1]['alt']);
					
					var imagePreloader = new Image(imagesArray[parseInt(currentIndex)+1]['width'], imagesArray[parseInt(currentIndex)+1]['height']);
					imagePreloader.src = imagesArray[parseInt(currentIndex)+1]['src'];
					
					imagePreloader.onload = function(){loadedImages[this.src] = true;}
					
					forwardButton.onclick = function(){
						gallery.change(this.getAttribute("bigSrc"), this.getAttribute("bigWidth"), this.getAttribute("bigHeight"), this.getAttribute("bigAlt"));
						this.onclick = function(){return false;}
						return false;
					}
					
				}else{
					
					forwardButton.style.display = 'none';
					
				}
				
			
		}
		
		
	}
	
	
	this.getPageSize = function(){
		var xScroll, yScroll;
		if(window.innerHeight && window.scrollMaxY){        
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		}else if(document.body.scrollHeight > document.body.offsetHeight){
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		}else{ 
		xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if(self.innerHeight){        
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		}else if(document.documentElement && document.documentElement.clientHeight){ 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		}else if(document.body){
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}        
		if(yScroll < windowHeight){
			 pageHeight = windowHeight;
		}else{ 
			pageHeight = yScroll;
		}
		return pageHeight;
	}

	
	this.shadow = function(showShadow){
		
		if(!shadowDiv){
			shadowDiv = document.createElement("div");
			shadowDiv.id = 'shadowDiv';
			shadowDiv.style.display = 'none';
			shadowDiv.style.backgroundColor = '#000000';
			shadowDiv.style.position = 'absolute';
			shadowDiv.style.left = 0;
			shadowDiv.style.top = 0;
			shadowDiv.style.zIndex = 25;
			shadowDiv.style.color = '#FFFFFF';
			document.body.appendChild(shadowDiv);
		}
		
		if(showShadow && !changingImage){
			
			this.setOpacity(shadowDiv, 70);
			
			shadowDiv.style.width = getDocumentWidth()+'px';
			shadowDiv.style.height = gallery.getPageSize()+'px';
			shadowDiv.style.display = '';
			
			this.setOpacity(shadowDiv, 0);
			
			setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 10)", 50);
			setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 20)", 75);
			setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 30)", 100);
			setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 40)", 125);
			setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 50)", 150);
			setTimeout("gallery.setOpacity(document.getElementById('shadowDiv'), 60)", 200);
			setTimeout("gallery.actionButtons(1);", 250);
			
		}else if(showShadow && changingImage){
			
			gallery.actionButtons(1);
			
		}else if(!showShadow){
			
			this.setOpacity(shadowDiv, 0);
			document.getElementById('shadowDiv').style.display = 'none';
			
		}
		
	}
	
	this.objects = function(hide){
		
		if(hide){
			
			objects = [];
			
			var selector = document.getElementsByTagName('select');
			for(var i=0;i<selector.length;i++){
				if(selector[i].style.visibility!="hidden"){
					objects[objects.length] = selector[i];
					selector[i].style.visibility = 'hidden';
				}
			}
			
			var object = document.getElementsByTagName('object');
			for(var i=0;i<object.length;i++){
				if(object[i].style.visibility!="hidden"){
					objects[objects.length] = object[i];
					object[i].style.visibility = 'hidden';
				}
			}
			
			var embed = document.getElementsByTagName('embed');
			for(var i=0;i<embed.length;i++){
				if(embed[i].style.visibility!="hidden"){
					objects[objects.length] = embed[i];
					embed[i].style.visibility = 'hidden';
				}
			}
			
			var iframe = document.getElementsByTagName('iframe');
			for(var i=0;i<iframe.length;i++){
				if(iframe[i].style.visibility!="hidden"){
					objects[objects.length] = iframe[i];
					iframe[i].style.visibility = 'hidden';
				}
			}
			
		}else{
			
			for(var i in objects){
				if(i && objects && objects[i] && objects[i].style){
					objects[i].style.visibility = 'visible';
				}
			}
			
		}
		
		
	}
	
	this.setOpacity = function(obj, opacity){
		obj.style.opacity = opacity/100;
		obj.style.filter = 'alpha(opacity='+opacity+')';
	}
	
}

var gallery = new galleryClass();


