function SC_Interstitial(){if(SC_Interstitial.singleton==null){SC_Interstitial.singleton=new SC_InterstitialClass;}return SC_Interstitial.singleton;}function SC_InterstitialClass(){this.debugLayer=document.getElementById("SC_DEBUGLAYER");this.browser="UNKNOWN";this.version=0;this.opacity=0.8;this.mediaPlayerClassId="6BF52A52-394A-11D3-B153-00C04F79FAA6";this.flashClassId="D27CDB6E-AE6D-11CF-96B8-444553540000";this.cdnBase="http://cdn.smartclip.net/interstitial/";this.miniPlayerUrl=this.cdnBase+"interstitial.swf";this.backgroundColor="000000";this.audioVolume=100;this.videoAdUrl=null;this.videoAdXML=null;this.layer=null;this.playerLayer=null;this.player=null;this.adWidth=640;this.adHeight=360;this.zIndex=10000;this.flashHiding=true;this.polite=true;this.onStartCallback=null;this.onEndCallback=null;this.headerText="Weiter geht es nach einem kurzen Werbespot";this.headerTextColor="FFFFFF";this.closeText="Schliessen";this.borderWidth=12;this.controlHeight=30;this.colorSet=0;this.timeText="Sekunden";this.setDimension=function(_width,_height){this.debug("- setDimension("+_width+", "+_height+")");this.adWidth=_width;this.adHeight=_height;return this;};this.setColorSet=function(_colorSet){this.debug("- setColorSet("+_colorSet+")");this.colorSet=_colorSet;return this;};this.setBorderWidth=function(_width){this.debug("- setBorderWidth("+_width+")");this.borderWidth=_width;return this;};this.setTimeText=function(_text){this.debug("- setTimeText("+_text+")");this.timeText=_text;return this;};this.setHeaderText=function(_text){this.debug("- setHeaderText("+_text+")");this.headerText=_text;return this;};this.setHeaderTextColor=function(_color){this.debug("- setHeaderTextColor("+_color+")");this.headerTextColor=_color;return this;};this.setCloseText=function(_text){this.debug("- setCloseText("+_text+")");this.closeText=_text;return this;};this.setOnStartCallback=function(_onStartCallback){this.debug("- setOnStartCallback("+typeof _onStartCallback+")");this.onStartCallback=_onStartCallback;return this;};this.setOnEndCallback=function(_onEndCallback){this.debug("- setOnEndCallback("+typeof _onEndCallback+")");this.onEndCallback=_onEndCallback;return this;};this.setPolite=function(_polite){this.debug("- setPolite("+_polite+")");this.polite=_polite;return this;};this.setZIndex=function(_zIndex){this.debug("- setZIndex("+_zIndex+")");this.zIndex=new String(_zIndex);if(this.zIndex==null||!this.zIndex.match(/^[1-9][0-9]*$/)){this.zIndex=10000;this.debug("- Redefining z-index "+_zIndex+" with "+this.zIndex+".");}return this;};this.setBackgroundColor=function(_color){this.debug("- setBackgroundColor("+_color+")");this.backgroundColor=_color;if(this.backgroundColor==null||typeof this.backgroundColor.match=="undefined"||!this.backgroundColor.match(/^[A-Fa-f0-9]{6}$/)){this.backgroundColor="000000";this.debug("- Redefining invalid color "+_color+" with "+this.backgroundColor+".");}return this;};this.setAudioVolume=function(_volume){this.debug("- setAudioVolume("+_volume+")");this.audioVolume=_volume;if(isNaN(this.audioVolume)){this.audioVolume=100;this.debug("- Redefining invalid volume "+_volume+" with "+this.audioVolume);}return this;};this.setOpacity=function(_opacity){this.debug("- setOpacity("+_opacity+")");this.opacity=_opacity;if(isNaN(this.opacity)||this.opacity<0||this.opacity>1){this.opacity=0.8;this.debug("- Redefining invalid opacity "+_opacity+" with "+this.opacity);}return this;};this.setVideoAdUrl=function(_url){this.debug("- setVideoAdUrl("+_url+")");this.videoAdUrl=_url;return this;};this.setVideoAdXML=function(_xml){this.debug("- setVideoAdXML("+_xml+")");this.videoAdXML=_xml;return this;};this.disableFlashHiding=function(){this.flashHiding=false;return this;};this.init=function(){this.debug("- init(polite = "+this.polite+")");var onLoad=false;var onResize=this.addEvent(window,"resize",SC_onResize);var onScroll=this.addEvent(window,"scroll",SC_onResize);var flashVer=this.getFlashVersion();if(!onResize||!onScroll||flashVer<9||!this.detectBrowser()){this.removeEvent(window,"resize",SC_onResize);this.removeEvent(window,"scroll",SC_onResize);this.endAd();}else if(this.polite){onLoad=this.addEvent(window,"load",SC_onLoad);if(!onLoad){this.removeEvent(window,"load",SC_onLoad);this.removeEvent(window,"resize",SC_onResize);this.removeEvent(window,"scroll",SC_onResize);this.endAd();}}else{this.initLayers();}};this.loadAd=function(){this.debug("- loadAd("+this.videoAdUrl+", "+this.adWidth+", "+this.adHeight+")");if(this.videoAdUrl!=null){this.player.loadVideoAdFromUrl(this.videoAdUrl,this.audioVolume);}else{this.player.loadVideoAdFromXML(this.videoAdXML,this.audioVolume);}};this.startingAd=function(_width,_height){this.debug("- startingAd(P["+this.adWidth+","+this.adHeight+"], V["+_width+","+_height+"])");this.onResize();if(this.flashHiding){this.hideObjectsAndEmbeds();}this.layer.style.visibility="visible";this.makeTransparent(this.playerLayer,1);if(this.onStartCallback!=null){try{this.onStartCallback();}catch(e){this.debug("Couldn't call on start callback function - "+e);}}};this.hideObjectsAndEmbeds=function(){if(typeof document.getElementsByTagName!="undefined"&&document.getElementsByTagName!=null){var tags=["object","embed"];for(var j=0;j<tags.length;j++){var objects=document.getElementsByTagName(tags[j]);for(var i=0;i<objects.length;i++){if(objects[i].getAttribute("id")!="SC_InterstitialPlayer"){objects[i].setAttribute("sc_ov",objects[i].style.visibility==null?"visible":objects[i].style.visibility);objects[i].style.visibility="hidden";}}}}};this.endAd=function(){this.debug("- endAd()");if(this.layer!=null){this.layer.style.visibility="hidden";}if(this.playerLayer!=null){this.playerLayer.style.visibility="hidden";}if(this.flashHiding){this.showObjectsAndEmbeds();}if(this.onEndCallback!=null){try{this.onEndCallback();}catch(e){this.debug("Couldn't call on end callback function");}}};this.showObjectsAndEmbeds=function(){if(typeof document.getElementsByTagName!="undefined"&&document.getElementsByTagName!=null){var tags=["object","embed"];for(var j=0;j<tags.length;j++){var objects=document.getElementsByTagName(tags[j]);for(var i=0;i<objects.length;i++){var ov=objects[i].getAttribute("sc_ov");if(ov!=null){objects[i].style.visibility=ov;}}}}};this.stopAd=function(){this.debug("- stopAd()");this.player.stopVideoAd();};this.onResize=function(){this.debug("- onResize()");if(this.layer!=null&&this.playerLayer!=null){var scroll=this.getScrolling();var viewport=this.getViewport();var popWidth=viewport[0];if(popWidth<scroll[2]){popWidth=scroll[2];}var popHeight=viewport[1];if(popHeight<scroll[3]){popHeight=scroll[3];}this.layer.style.height=popHeight+"px";this.layer.style.width=popWidth+"px";this.playerLayer.style.width=this.adWidth+2*this.borderWidth+"px";this.playerLayer.style.height=this.adHeight+2*this.borderWidth+this.controlHeight+"px";this.playerLayer.style.left=Math.round(scroll[0]+(viewport[0]-this.adWidth-2*this.borderWidth)/2)+"px";this.playerLayer.style.top=Math.round(scroll[1]+(viewport[1]-this.adHeight-2*this.borderWidth-this.controlHeight)/2)+"px";}};this.addEvent=function(_obj,_event,_func){if(_obj.addEventListener){_obj.addEventListener(_event,_func,false);return true;}else if(_obj.attachEvent){return _obj.attachEvent("on"+_event,_func);}return false;};this.removeEvent=function(_obj,_event,_func){if(typeof _obj.removeEventListener!="undefined"){_obj.removeEventListener(_event,_func,false);return true;}else if(typeof _obj.detachEvent!="undefined"){return _obj.detachEvent("on"+_event,_func);}return false;};this.getViewport=function(){if(window.innerHeight!=window.undefined){return[window.innerWidth-15,window.innerHeight-15];}else if(document.compatMode=="CSS1Compat"){return[document.documentElement.clientWidth-15,document.documentElement.clientHeight-15];}else if(document.body){return[document.body.clientWidth-15,document.body.clientHeight-15];}return false;};this.makeTransparent=function(_obj,_value){if(this.browser=="IE"){_obj.style.filter="alpha(opacity="+_value*100+")";}else{_obj.style.opacity=_value;}};this.getScrolling=function(){if(document.compatMode=="CSS1Compat"){return[document.documentElement.scrollLeft,document.documentElement.scrollTop,document.documentElement.scrollWidth,document.documentElement.scrollHeight];}else{return[document.body.scrollLeft,document.body.scrollTop,document.body.scrollWidth,document.body.scrollHeight];}};this.initLayers=function(){this.debug("- initLayers()");if(this.browser=="IE"){this.player=document.createElement("<object id=\"SC_InterstitialPlayer\" classid=\"clsid:"+this.flashClassId+"\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" width=\"100%\" height=\"100%\" type=\"application/x-shockwave-flash\">");}else{this.player=document.createElement("object");this.player.setAttribute("id","SC_InterstitialPlayer");this.player.setAttribute("width","100%");this.player.setAttribute("height","100%");this.player.setAttribute("type","application/x-shockwave-flash");this.player.setAttribute("data",this.miniPlayerUrl);}this.player.appendChild(this.createParam("movie",this.miniPlayerUrl));this.player.appendChild(this.createParam("menu","false"));this.player.appendChild(this.createParam("scale","noscale"));this.player.appendChild(this.createParam("wmode","transparent"));this.player.appendChild(this.createParam("bgcolor","#"+this.backgroundColor));this.player.appendChild(this.createParam("allowScriptAccess","always"));this.player.appendChild(this.createParam("FlashVars","adWidth="+this.adWidth+"&adHeight="+this.adHeight+"&format="+"interstitial"+"&audioVolume="+this.audioVolume+"&frameThickness="+this.borderWidth+"&closeText="+this.closeText+"&frameTextColor="+this.headerTextColor+"&frameText="+this.headerText+"&colorSet="+this.colorSet+"&timeText="+this.timeText));if(this.browser=="IE"){this.layer=document.createElement("<div style=\"position:absolute; z-index:"+this.zIndex+"; top:0px; left:0px; width:100%; height:100%; filter:alpha(opacity="+this.opacity*100+"); background-color:#"+this.backgroundColor+"; visibility:hidden;\">");this.playerLayer=document.createElement("<div style=\"filter:alpha(opacity=1); position:absolute; z-index:"+(this.zIndex+1)+"; left:0px; top:0px; width:"+this.adWidth+"px; height:"+this.adHeight+"px; padding:0px 0px;\">");this.playerLayer.appendChild(this.player);}else{this.layer=document.createElement("div");this.layer.setAttribute("style","position:absolute; z-index:"+this.zIndex+"; top:0px; left:0px; width:100%; height:100%; opacity:"+this.opacity+"; background-color:#"+this.backgroundColor+"; visibility:hidden;");this.playerLayer=document.createElement("div");this.playerLayer.setAttribute("style","opacity:0.01; position:absolute; z-index:"+(this.zIndex+1)+"; left:0px; top:0px; width:"+this.adWidth+"px; height:"+this.adHeight+"px; padding:0px 0px;\">");this.playerLayer.appendChild(this.player);}document.body.insertBefore(this.playerLayer,document.body.firstChild);document.body.insertBefore(this.layer,document.body.firstChild);return true;};this.detectBrowser=function(){var agent=navigator.userAgent;if(agent.match(/Firefox.(\d.\d)/i)!=null){this.browser="FIREFOX";return true;}else if(agent.match(/MSIE.(\d.\d)/i)!=null){this.browser="IE";return true;}else if(agent.match(/Opera.(\d.\d)/i)!=null){this.browser="OPERA";return true;}else if(agent.match(/Safari.(\d)/i)!=null){this.browser="SAFARI";return true;}return false;};this.createParam=function(_name,_value){var param=null;if(this.browser=="IE"){param=document.createElement("<param name=\""+_name+"\" value=\""+_value+"\">");}else{param=document.createElement("param");param.setAttribute("name",_name);param.setAttribute("value",_value);}return param;};this.getFlashVersion=function(){var isIE=navigator.appVersion.indexOf("MSIE")!=-1?true:false;var isWin=navigator.appVersion.toLowerCase().indexOf("win")!=-1?true:false;var isOpera=navigator.userAgent.indexOf("Opera")!=-1?true:false;var descr=null;var versions=null;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins['Shockwave Flash 2.0']||navigator.plugins['Shockwave Flash']){descr=navigator.plugins["Shockwave Flash"+(navigator.plugins['Shockwave Flash 2.0']?" 2.0":"")].description.split(" ");versions=descr[2].split(".");return versions[0];}}else if(isIE&&isWin&&!isOpera){try{versions=(new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")).GetVariable("$version").split(",");return versions[0].substr(4);}catch(exception){}}return 7;};this.debug=function(_message){if(this.debugLayer!=null){if(this.debugLayer.innerHTML==""){this.debugLayer.innerHTML=_message;}else{this.debugLayer.innerHTML=this.debugLayer.innerHTML+"<br>"+_message.replace("\n","<br>");}}};this.debug("SC_Interstitial()");}function SC_onLoad(){SC_Interstitial().debug("\nSC_onLoad()");SC_Interstitial().initLayers();}function SC_initDone(){SC_Interstitial().debug("\nSC_initDone()");SC_Interstitial().loadAd();}function SC_startingVideoAd(_width,_height){SC_Interstitial().debug("\nSC_startingVideoAd()");SC_Interstitial().startingAd(_width,_height);}function SC_onResize(){SC_Interstitial().debug("\nSC_onResize()");SC_Interstitial().onResize();}function SC_endVideoAd(){SC_Interstitial().debug("\nSC_endVideoAd()");SC_Interstitial().endAd();}function SC_stopVideoAd(){SC_Interstitial().debug("\nSC_stopVideoAd()");SC_Interstitial().stopAd();}