/*
 * jQuery wrapper around standard Open AdStream and Google Doubleclick for Publishers functions
 * do get a delayed load of ad server tags after DOMcontentLoaded
 *
 * Copyright 2010-2011 by COMMUNITOR Internetservice GmbH
 * All rights reserved.
 * http://www.communitor.com/
 */
(function(h){var k=(window.location.href.indexOf("cms.siteware.at")>0?"":"/")+"javascripts/jq142pC/";var a=/partner\.googleadservices\.com\/gampad\/google_service\.js/i;var g="dfp/$pub/$pos.html";var c=25;var j=100;var e=[];window.OAS_NORMAL=n=function(){};window.OAS_AD=function(o,p){var m={id:p};if(h.isFunction(o)){m.fn=o}else{m.pos=o;if(typeof p==="undefined"){m.id="idAd"+o}}e.push(m)};var f=function(m,o){if(window.onload!==null&&h.isFunction(window.onload)){window.OAS_AD(window.onload,m);window.onload=null}};var l=function(o,r){var m="",t={cache:true},v={},p="",q,u,s;if(q=/<script/i.exec(r)){p+=r.substring(0,q.index);r=r.substr(q.index);if(q=/<\/script>/i.exec(r)){m=r.substr(q.index+9);u=r.substring(0,r.indexOf(">"));if(s=u.match(a)){v.src=k+g;if(s=m.match(/GS_googleAddAdSenseService\(["']ca-pub-([^"']+)/i)){v.src=v.src.replace(/\$pub/,s[1])}if(s=m.match(/GA_googleFillSlot\(["']([^"']+)/i)){v.src=v.src.replace(/\$pos/,s[1])}m=""}else{if(s=u.match(/src=["']?([^ "'>]+)/i)){t.src=s[1].replace(/%%/g,"%25%25");if(s=u.match(/language=["']?([^ "'>]+)/i)){t.lang=s[1]}if(s=u.match(/type=["']?([^ "'>]+)/i)){t.type=s[1]}if(t.type&&t.type.toLowerCase()!=="text/javascript"&&!h.browser.msie){t={}}else{if(t.lang&&!t.lang.match(/javascript/i)&&!h.browser.msie){t={}}}if(t.src){if(t.src.match(/ad\.adworx\.at/i)&&t.src.match(/ext-alt\.js/)){t.src=k+"ext-alt.js"}else{if(t.src.match(/adspirit\.de/i)&&t.src.match(/flashme\.js/)){t.src=k+"flashme.js"}else{if(t.src.match(/adsfac\.eu/i)&&t.src.match(/clickTag\.js/)){t.src=k+"clickTag.js"}else{if(t.src.match(/ads\.newtention\.net\/ads/i)&&t.src.match(/rt=2&et=1&bi=55167/)){t.src=k+"ads.js"}}}}}}else{p+=r.substring(0,q.index+9)}}}else{p+=r}}else{p+=r}if(h.browser.msie){if(s=p.match(/if *\((extFlash([^.]*))\.readyState *== *\"complete\" *\)/i)){p='<script type="text/javascript">'+s[1]+' = {readyState: "complete", readystate: "complete"};<\/script><div id="FinContent'+s[2]+'"></div>'+p.replace(/document\.write\("<div id=\\"FinContent[^\\"]*\\"><\/div>"\);/i,"")}if(/var fd_wdt/i.exec(p)){if(q=/var plugin *= */i.exec(p)){p=p.substring(0,q.index)+"<\/script>";m='<script type="text/javascript" src="'+k+'clickTag.js"><\/script>'+m}else{if(/ adserververordner/i.exec(p)){if(q=/var plugin *= *0;/i.exec(p)){p=p.substring(0,q.index)+"<\/script>";m='<script type="text/javascript" src="'+k+'ext-alt.js"><\/script>'+m}else{if(/streaming.ad-balancer.at\/opel\/2010-10-insignia-4x4\/728x400_opel_insignia.swf/i.exec(p)){p="<!-- disabled opel flap ad -->"}}}}}}return{content_to_append:p,script_to_load:t,dfp_to_load:v,leftover:m}};var b=function(o){var m=h(o.target).contents();h(m).ready(function(){var p=[o.target,h(m).find("div").get(0),h(m).find("iframe").get(0),j];return window.setTimeout(function(){return d.apply(this,p)},c)})};var d=function(t,s,p,r){var q,o,m=h(p).contents().find("div, a").get(0);if(!m){r-=c;if(r>0){return window.setTimeout(function(){return d.apply(this,[t,s,p,r])},c)}return}if(m.tagName&&m.tagName.toLowerCase()=="a"){o=h("<p/>").append(h(m).clone()).html()}else{o=h(m).html()}q="span_"+t.id;h(p).replaceWith('<span id="'+q+'"/>');h(t.parentNode).html(h(s).html());h("#"+q).replaceWith(o)};var i=function(z,s,r,m){var w=s.toString(),o=s.id,y,u,q,t=false;if(m&&m!=""){w+=m}if(w.length==0&&m!==null){window.OAS_RUN_ADS();return}q=l(o,w);if(q.content_to_append.trim()!=""){var y=document.write,x=window.setTimeout,u=new window.SW_write_buffer();document.write=window.SW_get_buffered_writer(u);window.setTimeout=function(){window.OAS_AD(arguments[0],o)};try{z.target.append(q.content_to_append)}catch(v){}window.setTimeout=x;document.write=y;f(z.id,o);i(z,u,o,(q.script_to_load.src?null:q.leftover));t=true}if(q.script_to_load.src){var y=document.write,x=window.setTimeout,u=new window.SW_write_buffer();document.write=window.SW_get_buffered_writer(u);window.setTimeout=function(){window.OAS_AD(arguments[0],o)};try{h.getScript(q.script_to_load.src,function(){window.setTimeout=x;document.write=y;f(z.id,o);i(z,u,o,q.leftover)},q.script_to_load)}catch(v){}t=true}if(q.dfp_to_load.src){var p=h("<iframe/>",{style:"width:1px;height:1px;border:none;",id:"dfp_"+z.id});p.get(0).src=q.dfp_to_load.src;z.target.append(p);p.load(b)}if(!t){s.set(q.leftover);i(z,s,o,"")}};window.OAS_RUN_RICH=function(o){if(o.id){o.target=h("#"+o.id)}if(!o.target||o.target.length==0){o.target=h("body")}var m=document.write,p=new window.SW_write_buffer();document.write=window.SW_get_buffered_writer(p);if(h.isFunction(o.fn)){o.fn()}else{if(typeof window.OAS_RICH!=="undefined"){window.OAS_RICH(o.pos)}}document.write=m;i(o,p)};window.OAS_RUN_ADS=function(){if(e.length>0){try{window.OAS_RUN_RICH(e.shift())}catch(m){}}};window.SW_write_buffer=function(m){if(typeof m==="undefined"){m=""}this.set(m);this.id=(new String(Math.random())).substring(2,11)};window.SW_write_buffer.prototype={set:function(m){this.buffer=m},append:function(m){this.buffer+=m},toString:function(){return this.buffer}};window.SW_buffered_writer=function(){for(var o=0,m=arguments.length;o<m;++o){this.append(arguments[o])}};window.SW_get_buffered_writer=function(m){if(typeof m==="undefined"||!h.isFunction(m.append)){m=h("body")}return function(){return window.SW_buffered_writer.apply(m,Array.prototype.slice.call(arguments))}};if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^[^\S]+/,"").replace(/[^\S]+$/,"")}}h(document).ready(function(){document.write=window.SW_get_buffered_writer();document.writeln=function(m){document.write(m+"\n")};document.open=n;document.close=n;window.onload=null})}(jQuery));
