/*
 * snapbot.js
 *
 * V.1.0.1
 *
 * Copyright © TENSQUARE gmbh, www.tensquare.com
 */
var Snapbot={version:"1.0.1",initialized:false,jsFileNameMatch:/snapbot\.js(\?.*)?$/,cssFileName:"snapbot.css",cssFileNameNoShadow:"snapbot_noshadow.css",defaultTheme:"default",snapshotBaseURL:"http://www.snapbot.de/snap/",basePath:"",alignment:"",defaultAlignment:"bottom right",adjustAlignment:true,position:null,hotspotX:0,hotspotY:0,hideOnMouseOut:true,active:false,fadeEffect:false,showDelay:500,delayCounter:0,containers:{},currentEl:null,currentImage:null,busyImages:[],errorImages:[],timers:{show:0,hide:0,fade:0,loadImage:0},attachEvent:function(B,A,C){B["on"+A]=C;
},browser:{IE:!!(document.all&&!window.opera),IE7up:!!(document.all&&!window.opera&&window.XMLHttpRequest),Opera:!!window.opera,Gecko:navigator.userAgent.indexOf("Gecko")>=0&&navigator.userAgent.indexOf("KHTML")<0,Safari:navigator.userAgent.indexOf("AppleWebKit/")>=0,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},initialize:function(elements,theme){if(this.initialized){return ;}this.initialized=true;if(!this.isSupported()){return ;}with(this){browser.IE6dn=browser.IE&&!browser.IE7up;
}var selfPath=this.getSelfPath();if(selfPath){this.basePath=this.getParentPath(selfPath);}if(!theme||(theme==="")){theme=this.defaultTheme;}this.loadTheme(this.basePath,theme);this.createSnapLayer();if(!elements){elements="a.snapbot";}this.attach(elements);if(!window.console){window.console={log:function(){},debug:function(){}};}},createSnapLayer:function(){var E=this.createEl("div");E.id="snapbotlayer";E.setAttribute("id","snapbotlayer");E.style.position="absolute";E.style.top="0";E.style.visibility="hidden";
var D=this.createEl("div","top");E.appendChild(D);this.containers.top=D;var C=this.createEl("div","titlebar");var A=this.createEl("div","caption");A.innerHTML="Vorschau";C.appendChild(A);var B=this.createEl("div","buttons");B.innerHTML='<div id="snapbotzoom" onclick="Snapbot.zoom()" title="Zoom"></div><div id="snapbotclose" onclick="Snapbot.hide()" title="Schlie&szlig;en"></div>';C.appendChild(B);D.appendChild(C);E.appendChild(D);D=this.createEl("div","body");E.appendChild(D);this.containers.snapshot=D;
D=this.createEl("div","bottomleft");E.appendChild(D);this.containers.bottom=D;this.containers.bgIFrame=(this.isIE6())?this.applyIEZIndexFix(E):null;document.getElementsByTagName("body")[0].appendChild(E);this.containers.main=E;this.attachEvent(E,"mouseover",this.mouseover);this.attachEvent(E,"mouseout",this.mouseout);this.attachEvent(E,"mousemove",this.mousemove);},zoom:function(){if(!this.containers.main){return ;}var C=this.containers.main;var B=C.className;var A=(B&&(B.indexOf("big")>=0));this.hide();
if(A){C.className="";}else{C.className="big";}this.hideOnMouseOut=false;Snapbot.showSnapshot(this.currentEl,false,100);},attach:function(C){C=this.getElements(C);if(!C){return ;}for(var A=0;A<C.length;A++){var B=C[A];this.attachEvent(B,"mouseover",this.mouseover);this.attachEvent(B,"mouseout",this.mouseout);this.attachEvent(B,"mousemove",this.mousemove);}},mouseover:function(A){Snapbot.hideOnMouseOut=true;if(!A){A=window.event;}if(Snapbot.timers.show||Snapbot.timers.fade){return ;}Snapbot.clearTimers();
if(Snapbot.containers.main.style.visibility=="visible"){if((this==Snapbot.currentEl)||(this==Snapbot.containers.main)){return ;}else{Snapbot.hide();}}Snapbot.position=Snapbot.getEventCoordinates(A);Snapbot.showSnapshot(this,true,Snapbot.showDelay);},mouseout:function(A){if(!A){A=window.event;}if(!Snapbot.hideOnMouseOut){return ;}Snapbot.clearTimers();Snapbot.timers.hide=window.setTimeout("Snapbot.hide()",200);},mousemove:function(A){if(!A){A=window.event;}},getImageURL:function(B,A){var D;if(A){D="&size=big";
}else{D="";}var E=unescape(B);var C=E.indexOf("dest=http:");if(C>0){B=E.substring(C+5);}return this.snapshotBaseURL+"?url="+escape(B)+D;},imageLoaded:function(){Snapbot.checkImage();},imageError:function(){window.clearTimeout(Snapbot.timers.loadImage);Snapbot.timers.loadImage=0;var A=Snapbot.isBigSize()?1:0;Snapbot.setCurrentImage(Snapbot.errorImages[A].src,false);Snapbot.showImage(Snapbot.currentImage.src);},setCurrentImage:function(B,C){var A=new Image();this.currentImage=A;if(C){A.onload=this.imageLoaded;
A.onerror=this.imageError;}A.src=B;},showImage:function(B,C){if(!B){B=this.currentImage.src;}if(!C){if(this.currentEl){C=this.currentEl.href;}}var A=this.containers.snapshot;A.innerHTML='<img id="snapbotimg" src="'+B+'" onclick="location.href=\''+C+"'\">";},replaceImage:function(B){var A=document.getElementById("snapbotimg");if(A){A.src=B;}else{this.showImage(B);}},checkImage:function(){if(this.currentImage){if(this.currentImage.complete){this.showImage();this.timers.loadImage=0;}else{this.timers.loadImage=window.setTimeout("Snapbot.checkImage()",300);
}}},isBigSize:function(){var A=this.containers.main;return(A&&(A.className.indexOf("big")>=0));},showSnapshot:function(D,B,C){this.currentEl=D;this.adjustAlignment=B;var A=this.getImageURL(D.href,this.isBigSize());this.setCurrentImage(A,true);this.showImage("");this.showDeferred(C);},showDeferred:function(A){if(this.timers.show){window.clearTimeout(this.timers.show);}this.delayCounter=3;A=Math.floor(A/3);this.timers.show=window.setTimeout("Snapbot.showDeferredPoll("+A+")",A);},showDeferredPoll:function(A){if(--this.delayCounter<0){this.timers.show=0;
this.show();}else{this.timers.show=window.setTimeout("Snapbot.showDeferredPoll("+A+")",A);}},show:function(){var E,D,J,I;this.timers.show=0;var A=this.containers.main;var B=A.style;var C=this.currentEl.href;var U=this.isBigSize();var L;if(this.currentImage){if(this.currentImage.complete){L=this.currentImage.src;}else{L=(U)?this.busyImages[1].src:this.busyImages[0].src;this.timers.loadImage=window.setTimeout("Snapbot.checkImage()",100);}}else{L=this.getImageURL(C,U);}this.showImage(L);if(A.parentNode!=null){A.parentNode.removeChild(A);
}document.getElementsByTagName("body")[0].appendChild(A);E=this.position.x;D=this.position.y;J=this.hotspotX;I=this.hotspotY;if(document.all){B.left="-1000px";B.visibility="visible";}var F=A.offsetWidth;var N=A.offsetHeight;var R=document.documentElement;var T=R.scrollLeft;var P=R.scrollTop;var Q=parseInt(R.clientWidth+T);var O=parseInt(R.clientHeight+P);var S=this.containers;if(this.adjustAlignment){this.alignment=this.defaultAlignment;}var K=this.alignment.split(" ");var H=K[0];var M=K[1];if(this.adjustAlignment){if(((M=="left")||(E+F-J>Q))&&(E-F+J>=0)){M="left";
}else{M="right";}if(((H=="top")||(D-I+N>O))&&(D-N+I>=P)){H="top";}else{H="bottom";}}if(M=="left"){E-=(F-J);}else{E-=J;}if(H=="top"){D-=(N-I);}else{D-=I;}this.alignment=H+" "+M;var G=(M=="left")?"right":"left";if(H=="bottom"){S.top.className="top"+G;S.bottom.className="bottom";}else{S.bottom.className="bottom"+G;S.top.className="top";}B.left=E+"px";B.top=D+"px";B.visibility="visible";if(this.fadeEffect&&!S.bgIFrame){this.fade(10);}},hide:function(){this.clearTimers();var A=this.containers.main.style;
A.visibility="hidden";A.left="0px";A.top="0px";},fade:function(C){var A=this.containers.main.style;var B=parseInt(C);if(isNaN(B)){B=100;}A.opacity=(B<100)?"."+B:"1.0";A.filter="alpha(opacity:"+B+")";if(B<90){B+=10;this.timers.fade=window.setTimeout("Snapbot.fade('"+B+"')",20);}else{this.timers.fade=0;}},clearTimers:function(){var B=this.timers;for(var A in B){var C=B[A];if(C!=0){window.clearTimeout(C);B[A]=0;}}},getEventCoordinates:function(C){var A,D;if(!C){C=window.event;}if(!C){return this._pos(0,0);
}if(C.pageX||C.pageY){A=C.pageX;D=C.pageY;}else{if(C.clientX||C.clientY){A=C.clientX;D=C.clientY;var B=(document.documentElement)?document.documentElement:document.body;A+=B.scrollLeft;D+=B.scrollTop;}}return this._pos(A,D);},getElements:function(J){var L=new Array();J=J.split(",");for(var F=0;F<J.length;F++){var A=this.splitSelector(J[F]);if(A==null){continue;}var B=null;if(A.id){B=document.getElementById(A.id);if(!B){continue;}}else{B=document;}if(A.tag){B=B.getElementsByTagName(A.tag);if(!B){continue;
}}else{B=new Array(B);}for(var E=0;E<B.length;E++){var G;if(A.childTag){G=B[E].getElementsByTagName(A.childTag);}else{G=new Array(B[E]);}if(!G){continue;}for(var C=0;C<G.length;C++){var H=G[C];if(A.className){if(!H.className){continue;}var I=H.className.split(" ");var D=false;for(var K=0;K<I.length;K++){if(I[K]==A.className){D=true;break;}}if(!D){continue;}}L.push(H);}}}return L;},splitSelector:function(B){var D,A=null,E=null,H=null,C=null,F=false,G=false;while((B.length>0)&&(B.charAt(0)==" ")){B=B.substr(1);
}if(B.length==0){return null;}D=B.indexOf("#");F=(D>=0);if(D<0){D=B.indexOf(".");G=(D>=0);}if(D>=0){A=B.substring(0,D);B=B.substr(D+1);}D=B.indexOf(" ");if(D>=0){C=B.substr(D+1);B=B.substring(0,D);}if(F){H=B;}else{if(G){E=B;}else{A=B;}}return{tag:(A!="")?A:null,className:(E!="")?E:null,id:(H!="")?H:null,childTag:(C!="")?C:null};},isSupported:function(){return(document.getElementById&&document.createElement&&document.getElementsByTagName);},isIE6:function(){return(document.all&&!window.opera&&typeof XMLHttpRequest=="function");
},_pos:function(A,B){return{x:A,y:B};},createEl:function(C,B){var A=document.createElement(C);if(B){A.className=B;}return A;},applyIEZIndexFix:function(C){if(!this.isIE6()){return null;}var B='<iframe class="bgiframe" scrolling="no" frameborder="0" src="about:blank" tabindex="-1" style="display:block; position:absolute; left: expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\'); top: expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\'); margin: 0px; padding: 0px; border: none; z-index:-1; filter:Alpha(Opacity=\'0\'); width:expression(this.parentNode.offsetWidth + \'px\'); height:expression(this.parentNode.offsetHeight + \'px\')"/></iframe>';
var A=document.createElement(B);C.appendChild(A);return A;},getSelfPath:function(){var A=this.getSelfScriptEl();if(A){return A.src.replace(this.jsFileNameMatch,"");}return null;},getParentPath:function(B){var A=B.lastIndexOf("/");if(A>0){A=B.lastIndexOf("/",A-1);if(A>=0){return B.substring(0,A+1);}}return B;},getSelfParams:function(){var A=null;var C=this.getSelfScriptEl();if(C){A={};var F=C.src.match(/\?(.*)/);if(F&&(F.length>0)){F=F[0].split("&");for(var E=0;E<F.length;E++){var B=F[E].split("=");
var D=B[0];var G=(B.length>1)?B[1]:null;A[D]=G;}}}return A;},getSelfScriptEl:function(){var A=document.getElementsByTagName("script");for(var C=0;(A)&&(C<A.length);C++){var B=A[C];if(B.src&&B.src.match(this.jsFileNameMatch)){return B;}}return null;},getThemePath:function(B,A){return B+"themes/"+A+"/";},loadTheme:function(E,D){var A=this.getThemePath(E,D);var B=A+"css/";this.loadCSS(B+this.cssFileName);if(this.browser.IE6dn){this.loadCSS(B+this.cssFileNameNoShadow);}var C=A+"img/loading_";this.busyImages[0]=new Image();
this.busyImages[0].src=C+"01.gif";this.busyImages[1]=new Image();this.busyImages[1].src=C+"02.gif";C=A+"img/error_";this.errorImages[0]={};this.errorImages[0].src=C+"01.gif";this.errorImages[1]={};this.errorImages[1].src=C+"02.gif";},loadCSS:function(A){var B=this.createEl("link");B.setAttribute("type","text/css");B.setAttribute("rel","stylesheet");B.setAttribute("href",A);B.setAttribute("media","screen");document.getElementsByTagName("head")[0].appendChild(B);}};function ImageLoader(A,B){this.onComplete=B;
this.processedCount=0;this.successCount=0;this.errorCount=0;this.images=new Array();this.load(A);}ImageLoader.prototype.load=function(A){if(!A){return ;}if(typeof A=="string"){A=[A];}for(var C=0;C<A.length;C++){var B=new Image();B.onload=ImageLoader.prototype.imgLoad;B.onerror=ImageLoader.prototype.imgError;B.onabort=ImageLoader.prototype.imgAbort;B.isLoading=true;B.success=false;B.loader=this;this.images.push(B);}for(var C=0;C<A.length;C++){this.images[C].src=A[C];}};ImageLoader.prototype.get=function(B){for(var C=0,A=this.images.length;
C<A;C++){if(this.images[C].src==B){return this.images[C];}}return null;};ImageLoader.prototype.isBusy=function(){return(this.processedCount<this.images.length);};ImageLoader.prototype.imgDone=function(A,B){if(B){++this.successCount;A.success=true;}else{++this.errorCount;}A.isLoading=false;if((++this.processedCount==this.images.length)&&this.onComplete){this.onComplete(this.images);}};ImageLoader.prototype.imgLoad=function(){this.loader.imgDone(this,true);};ImageLoader.prototype.imgError=function(){this.loader.imgDone(this,false);
};ImageLoader.prototype.imgAbort=function(){this.loader.imgDone(this,false);};var DOMLoadedWatch={listeners:[],savedonload:null,loaded:function(A){if(!A){A=window.event;}if(A&&A.type&&(A.type=="onload")&&savedonload){savedonload(A);}if(arguments.callee.done){return ;}arguments.callee.done=true;for(i=0;i<DOMLoadedWatch.listeners.length;i++){DOMLoadedWatch.listeners[i]();}},addListener:function(listener){this.listeners.push(listener);if(document.addEventListener){document.addEventListener("DOMContentLoaded",this.loaded,null);
}if(/KHTML|WebKit/i.test(navigator.userAgent)){var _timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(_timer);delete _timer;DOMLoadedWatch.loaded({type:"DOMContentLoaded"});}},10);
/*@cc_on
		@if (@_win32)
		var proto = "src='javascript:void(0)'";
		if (location.protocol == "https:") proto = "src=//0";
		document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
		    if (this.readyState == "complete") {
		        DOMLoadedWatch.loaded();
		    }
		};
		@end
		@*/
}if(window.onload!=this.loaded){this.savedonload=window.onload;
window.onload=this.loaded;}}};if(Snapbot.isSupported()){DOMLoadedWatch.addListener(function(){Snapbot.initialize();});}