/*
 * jQuery wrapper around standard Open AdStream functions
 * do get a delayed load of ad server tags after DOMcontentLoaded
 *
 * Copyright 2010 by COMMUNITOR Internetservice GmbH
 * All rights reserved.
 * http://www.communitor.com/
 */
var OAS_NORMAL=function(){};var OAS_ads=[];var OAS_AD=function(b,c){var a={id:c};if($.isFunction(b)){a.fn=b}else{a.pos=b;if(typeof c==="undefined"){a.id="idAd"+b}}OAS_ads.push(a)};var OAS_EXTRACT_CONTENT=function(f){var b="",e={cache:true},a="",d,g,c;if(d=/<script/i.exec(f)){a+=f.substring(0,d.index);f=f.substr(d.index);if(d=/<\/script>/i.exec(f)){b=f.substr(d.index+9);g=f.substring(0,f.indexOf(">"));if(c=g.match(/src=["']?([^ "'>]+)/i)){e.src=c[1];if(c=g.match(/language=["']?([^ "'>]+)/i)){e.lang=c[1]}if(c=g.match(/type=["']?([^ "'>]+)/i)){e.type=c[1]}if(e.type&&e.type.toLowerCase()!=="text/javascript"&&!$.browser.msie){e={}}else{if(e.lang&&!e.lang.match(/javascript/i)&&!$.browser.msie){e={}}}if(e.src&&e.src.match(/ad\.adworx\.at/i)&&e.src.match(/ext-alt\.js/)){e.src="http://www.auto-motor.at/javascripts/jq142p2/ext-alt.js"}}else{a+=f.substring(0,d.index+9)}}else{a+=f}}else{a+=f}return{content_to_append:a,script_to_load:e,leftover:b}};var OAS_RUN_BUFFER=function(g,d,c){var h=d.toString(),a,f;if(c&&c!=""){h+=c}if(h.length==0&&c!==null){OAS_RUN_ADS();return}var b=OAS_EXTRACT_CONTENT(h);if(b.content_to_append.trim()!=""){a=document.write;f=new WriteBuffer();document.write=$.swGetWriter(f);try{g.target.append(b.content_to_append)}catch(i){}document.write=a;OAS_RUN_BUFFER(g,f,(b.script_to_load.src?null:b.leftover))}if(b.script_to_load.src){a=document.write;f=new WriteBuffer();document.write=$.swGetWriter(f);$.getScript(b.script_to_load.src,function(){document.write=a;OAS_RUN_BUFFER(g,f,b.leftover)},b.script_to_load)}};var OAS_RUN_RICH=function(c){if(c.id){c.target=$("#"+c.id)}if(!c.target||c.target.length==0){c.target=$("body")}var a=document.write;var b=new WriteBuffer();document.write=$.swGetWriter(b);if($.isFunction(c.fn)){c.fn()}else{if(typeof OAS_RICH!=="undefined"){OAS_RICH(c.pos)}}document.write=a;OAS_RUN_BUFFER(c,b)};var OAS_RUN_ADS=function(){if(typeof(OAS_RICH)=="function"&&OAS_ads.length>0){OAS_RUN_RICH(OAS_ads.shift())}};$(document).ready(function(){$.swWrite=function(){for(var b=0,a=arguments.length;b<a;++b){this.append(arguments[b])}};$.swGetWriter=function(a){if(typeof a==="undefined"||!$.isFunction(a.append)){a=$("body")}return function(){return $.swWrite.apply(a,Array.prototype.slice.call(arguments))}};document.write=$.swGetWriter()});var WriteBuffer=function(a){if(typeof a==="undefined"){a=""}this.set(a)};WriteBuffer.prototype={set:function(a){this.buffer=a},append:function(a){this.buffer+=a},toString:function(){return this.buffer}};if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^[^\S]+/,"").replace(/[^\S]+$/,"")}};
