function SC_Smartstitial(_debug){if(SC_Smartstitial.singleton==null){SC_Smartstitial.singleton=new SC_SmartstitialClass(_debug);}return SC_Smartstitial.singleton;}function SC_SmartstitialClass(_debug){this.debugLayer=document.getElementById("SC_DEBUGLAYER");this.browser="UNKNOWN";this.version=0;this.opacity=0;this.mediaPlayerClassId="6BF52A52-394A-11D3-B153-00C04F79FAA6";this.flashClassId="D27CDB6E-AE6D-11CF-96B8-444553540000";this.cdnBase="http://cdn.smartclip.net/smartstitial/";this.miniPlayerUrl=this.cdnBase+"smartstitial.swf";this.headerBackgroundUrl=this.cdnBase+"header_bg.png";this.logoUrl=this.cdnBase+"sc_logo.png";this.backgroundColor="000000";this.audioVolume=100;this.videoAdUrl=null;this.header=null;this.layer=null;this.playerLayer=null;this.player=null;this.adWidth=512;this.adHeight=288;this.zIndex=10000;this.wrapperImageUrl=null;this.wrapperImageWidth=0;this.wrapperClickThru=null;this.playerLeftOffset=0;this.wrapperImageHeight=0;this.playerTopOffset=0;this.autoStart=true;this.onStartCallback=null;this.onEndCallback=null;this.closeLink=null;this.adText="Advertisement";this.closeText="Skip Ad >>";this.closeDelay=0;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.setDimension=function(_width,_height){this.debug("- setDimension("+_width+", "+_height+")");this.adWidth=_width;this.adHeight=_height;return this;};this.setAdText=function(_text){this.debug("- setAdText("+_text+")");this.adText=_text;return this;};this.setCloseText=function(_text){this.debug("- setCloseText("+_text+")");this.closeText=_text;return this;};this.setCloseDelay=function(_delay){this.debug("- setCloseDelay("+_delay+")");this.closeDelay=_delay;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+".");}else{this.zIndex=parseInt(_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.5;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.setWrapper=function(_url,_width,_height,_leftOffset,_topOffset,_clickThru){this.debug("- setWrapper("+_url+", "+_width+", "+_height+", "+_leftOffset+", "+_topOffset+")");this.wrapperImageUrl=_url;this.wrapperImageWidth=_width;this.wrapperImageHeight=_height;this.wrapperClickThru=_clickThru;this.playerLeftOffset=_leftOffset;this.playerTopOffset=_topOffset;return this;};this.isAutoStart=function(){return this.autoStart;};this.init=function(_autoStart){this.debug("- init("+_autoStart+")");if(_autoStart!=null){this.autoStart=_autoStart;}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.autoStart){var onLoad=this.addEvent(window,"load",SC_run);if(!onLoad){this.removeEvent(window,"load",_run);this.removeEvent(window,"resize",SC_onResize);this.removeEvent(window,"scroll",SC_onResize);this.endAd();}}};this.loadAd=function(){this.debug("- loadAd("+this.videoAdUrl+", "+this.audioVolume+", "+this.adWidth+", "+this.adHeight+")");this.player.loadVideoAd(this.videoAdUrl,this.audioVolume,this.adWidth,this.adHeight);};this.startingAd=function(_width,_height){this.debug("- startingAd()");this.onResize();this.layer.style.visibility="visible";this.makeTransparent(this.playerLayer,1);if(this.closeDelay>0){window.setTimeout(function(){SC_showCloseLink();},this.closeDelay*1000);}if(this.onStartCallback!=null){try{this.onStartCallback();}catch(e){this.debug("- Couldn't call on start callback function - "+e);}}};this.showCloseLink=function(){if(this.closeLink!=null){this.closeLink.style.display="block";}};this.endAd=function(){this.debug("- endAd()");if(this.layer!=null){this.layer.style.visibility="hidden";}if(this.playerLayer){this.playerLayer.style.visibility="hidden";}if(this.onEndCallback!=null){try{this.onEndCallback();}catch(e){this.debug("- Couldn't call on end callback function");}}};this.stopAd=function(){this.debug("- stopAd()");this.player.stopVideoAd();};this.onResize=function(){var scroll=null;var viewport=null;if(this.layer!=null&&this.playerLayer!=null){viewport=this.getViewport();this.layer.style.width=viewport[0]+"px";this.layer.style.height=viewport[1]+"px";scroll=this.getScrolling();viewport=this.getViewport();this.layer.style.width=viewport[0]+15+"px";this.layer.style.height=viewport[1]+15+"px";this.playerLayer.style.height=this.wrapperImageHeight+"px";this.playerLayer.style.width=this.wrapperImageWidth+"px";this.playerLayer.style.left=Math.round(scroll[0]+(viewport[0]+15-this.wrapperImageWidth)/2)+"px";this.playerLayer.style.top=Math.round(scroll[1]+(viewport[1]+15-this.wrapperImageHeight)/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(){if(this.browser=="IE"){this.player=document.createElement("<object id=\"SC_SmartstitialPlayer\" 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_SmartstitialPlayer");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="+"smartstitial"+"&audioVolume="+this.audioVolume));var link=null;var image=null;var table=null;var row=null;var cell=null;var header=null;var playerDiv=null;var wrapperDiv=null;var wrapperImg=null;var wrapperLnk=null;if(this.browser=="IE"){header=document.createElement("<div style=\"width:100%; height:25px; background: transparent url("+this.headerBackgroundUrl+") repeat-x;\">");image=document.createElement("<img src=\""+this.logoUrl+"\" style=\"border:none;\">");link=document.createElement("<a style=\"color:white; font-family:helvetica,arial; font-size:8pt; text-decoration:none;\" href=\"http://www.smartclip.com\" title=\"Smartclip Homepage\">");link.appendChild(image);cell=document.createElement("<div style=\"position:absolute; width:100%; height:100%; padding:5px 0px 0px 20px;\">");cell.appendChild(link);header.appendChild(cell);link=document.createElement("<a style=\"color:white; font-family:helvetica,arial; font-size:8pt; text-decoration:none;\" href=\"http://www.smartclip.com\" title=\"Smartclip Homepage\">");link.appendChild(document.createTextNode("Smartclip"));cell=document.createElement("<div style=\"position:absolute; width:100%; height:100%; padding:8px 0px 0px 50px;\">");cell.appendChild(link);header.appendChild(cell);cell=document.createElement("<div style=\"position:absolute; width:100%; height:100%; text-align:center; font-family:helvetica,arial; font-size:8pt; color:white; padding:8px 0px 0px 20px;\">");cell.appendChild(document.createTextNode(this.adText));header.appendChild(cell);if(this.closeDelay==0){this.closeLink=document.createElement("<a style=\"color:white; font-family:helvetica,arial; font-size:8pt; text-decoration:none;\" href=\"javascript:SC_stopVideoAd();\" title=\"Fenster schliessen\">");}else{this.closeLink=document.createElement("<a style=\"color:white; font-family:helvetica,arial; font-size:8pt; text-decoration:none; display:none;\" href=\"javascript:SC_stopVideoAd();\" title=\"Fenster schliessen\">");}this.closeLink.appendChild(document.createTextNode(this.closeText));cell=document.createElement("<div style=\"position:absolute; width:100%; height:100%; text-align:right; padding:8px 20px 0px 0px;\">");cell.appendChild(this.closeLink);header.appendChild(cell);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.layer.appendChild(header);playerDiv=document.createElement("<div style=\"position:absolute; top:"+Math.round((this.wrapperImageHeight-this.adHeight)/2+this.playerTopOffset)+"px; left:"+Math.round((this.wrapperImageWidth-this.adWidth+this.playerLeftOffset)/2)+"px; width:"+this.adWidth+"px; height:"+this.adHeight+"px; padding:0px; z-index:2;\">");playerDiv.appendChild(this.player);wrapperImg=document.createElement("<img style=\"position:absolute; z-index:1; border:none;\" src=\""+this.wrapperImageUrl+"\">");if(this.wrapperClickThru!=null){wrapperLnk=document.createElement("<a href=\""+this.wrapperClickThru+"\" target=\"_blank\" style=\"position:absolute; z-index:1;\">");wrapperLnk.appendChild(wrapperImg);}wrapperDiv=document.createElement("<div style=\"width:"+this.wrapperImageWidth+"px; height:"+this.wrapperImageHeight+"px; padding:0px; margin:0px auto;\">");wrapperDiv.appendChild(playerDiv);if(this.wrapperClickThru!=null){wrapperDiv.appendChild(wrapperLnk);}else{wrapperDiv.appendChild(wrapperImg);}this.playerLayer=document.createElement("<div style=\"filter:alpha(opacity=1); position:absolute; z-index:"+(this.zIndex+1)+"; left:0px; top:0px; width:"+this.wrapperImageWidth+"px; height:"+this.wrapperImageHeight+"; padding:0px 0px;\">");this.playerLayer.appendChild(wrapperDiv);}else{row=document.createElement("tr");image=document.createElement("img");image.setAttribute("src",this.logoUrl);image.setAttribute("style","border:none;");link=document.createElement("a");link.setAttribute("href","http://www.smartclip.com");link.setAttribute("title","Smartclip Homepage");link.appendChild(image);cell=document.createElement("td");cell.setAttribute("style","text-align:left; padding:0px 0px 0px 20px; width:25px;");cell.appendChild(link);row.appendChild(cell);link=document.createElement("a");link.setAttribute("style","color:white; font-family:helvetica,arial; font-size:8pt; text-decoration:none; vertical-align:middle;");link.setAttribute("href","http://www.smartclip.com");link.setAttribute("title","Smartclip Homepage");link.appendChild(document.createTextNode("Smartclip"));cell=document.createElement("td");cell.setAttribute("style","width:33%; text-align:left;");cell.appendChild(link);row.appendChild(cell);cell=document.createElement("td");cell.setAttribute("style","width:33%; text-align:center; font-family:helvetica,arial; font-size:8pt; color:white;");cell.appendChild(document.createTextNode(this.adText));row.appendChild(cell);this.closeLink=document.createElement("a");if(this.closeDelay==0){this.closeLink.setAttribute("style","color:white; font-family:helvetica,arial; font-size:8pt; text-decoration:none;");}else{this.closeLink.setAttribute("style","color:white; font-family:helvetica,arial; font-size:8pt; text-decoration:none; display:none;");}this.closeLink.setAttribute("href","javascript:SC_stopVideoAd();");this.closeLink.setAttribute("title","Fenster schliessen");this.closeLink.appendChild(document.createTextNode(this.closeText));cell=document.createElement("td");cell.setAttribute("style","width:33%; text-align:right; padding:0px 20px 0px 0px;");cell.appendChild(this.closeLink);row.appendChild(cell);table=document.createElement("table");table.setAttribute("cellpadding","5");table.setAttribute("style","width:100%");table.appendChild(row);header=document.createElement("div");header.setAttribute("style","width:100%; height:25px; background: URL("+this.headerBackgroundUrl+") repeat-x;");header.appendChild(table);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.layer.appendChild(header);playerDiv=document.createElement("div");playerDiv.setAttribute("style","position:absolute; top:"+Math.round((this.wrapperImageHeight-this.adHeight)/2+this.playerTopOffset)+"px; left:"+Math.round((this.wrapperImageWidth-this.adWidth)/2+this.playerLeftOffset)+"px; width:"+this.adWidth+"px; height:"+this.adHeight+"px; padding:0px; z-index:2;");playerDiv.appendChild(this.player);wrapperImg=document.createElement("img");wrapperImg.setAttribute("src",this.wrapperImageUrl);wrapperImg.setAttribute("style","position:absolute; z-index:1; border:none;");if(this.wrapperClickThru!=null){wrapperLnk=document.createElement("a");wrapperLnk.setAttribute("href",this.wrapperClickThru);wrapperLnk.setAttribute("target","_blank");wrapperLnk.setAttribute("style","position:absolute; z-index:1;");wrapperLnk.appendChild(wrapperImg);}wrapperDiv=document.createElement("div");wrapperDiv.setAttribute("style","width:"+this.wrapperImageWidth+"px; height:"+this.wrapperImageHeight+"px; padding:0px; margin:0px auto;");wrapperDiv.appendChild(playerDiv);if(this.wrapperClickThru!=null){wrapperDiv.appendChild(wrapperLnk);}else{wrapperDiv.appendChild(wrapperImg);}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.wrapperImageWidth+"px; height:"+this.wrapperImageHeight+"; padding:0px 0px;");this.playerLayer.appendChild(wrapperDiv);}document.body.appendChild(this.playerLayer);document.body.appendChild(this.layer);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("\nSC_Smartstitial()");}function SC_run(){SC_Smartstitial().debug("\nSC_run()");if(SC_Smartstitial().initLayers()){SC_Smartstitial().onResize();}}function SC_initDone(){SC_Smartstitial().debug("\nSC_initDone()");SC_Smartstitial().loadAd();}function SC_startingVideoAd(_width,_height){SC_Smartstitial().debug("\nSC_startingVideoAd()");SC_Smartstitial().startingAd(_width,_height);}function SC_onResize(){SC_Smartstitial().debug("\nSC_onResize()");SC_Smartstitial().onResize();}function SC_endVideoAd(){SC_Smartstitial().debug("\nSC_endVideoAd()");SC_Smartstitial().endAd();}function SC_stopVideoAd(){SC_Smartstitial().debug("\nSC_stopVideoAd()");SC_Smartstitial().stopAd();}function SC_showCloseLink(){SC_Smartstitial().showCloseLink();}
