var interstitialObject=function(p){var l=this,a={content:{creative:false,width:$(document).width(),height:$(document).height()},wallpaper:{creative:false,width:$(document).width(),height:$(document).height()},navigation:{menu:true,title:"<a href='http://annonseinfo.dagbladet.no/' target='_blank'>Annonse</a>",buttontext:"Fortsett til "+location.host,removeTimeMs:400},maxSafeWidth:1024,autoPosition:true,closeCallback:function(){return null}},f,c,b,m,d,e,h,i,j,n=function(a){var g=$("<iframe/>");g.attr({src:a.creative, width:"100%",height:a.height,frameborder:0,allowtransparency:"true",scrolling:"no",marginwidth:0,marginheight:0});g.css({background:"transparent"});return g},o=function(a){return typeof a=="string"?a.match(/((http|https)(:\/\/))?([a-zA-Z0-9-_]+[.]{1}){2}[a-zA-z0-9-_]+(\/{1}[a-zA-Z0-9-_]+)*\/?/i):false},q=function(){d=$("<div/>");d.attr("id","wallpaper-wrapper");d.css({width:a.wallpaper.width,position:"relative",overflow:"hidden"});d.click(function(a){a.stopPropagation()});if(o(a.wallpaper.creative))a.wallpaper.creative= n(a.wallpaper);m=$(a.wallpaper.creative);d.append(m);c.prepend(d)},r=function(){c=$("<div/>");c.attr({id:"content-container"});c.css({height:"100%",position:"relative",overflow:"hidden"});c.click(function(){l.remove()});if(o(a.content.creative))a.content.creative=n(a.content);$content=$(a.content.creative);b=$("<div/>");b.attr({id:"content-wapper"});b.css({width:a.content.width,position:"absolute",overflow:"hidden",top:0});b.click(function(a){a.stopPropagation()});b.append($content);c.append(b);f.append(c)}, s=function(){e=$("<div/>");e.attr({id:"navigation-container"});e.css({position:"relative","z-index":1});j=$("<span/>");j.addClass("title");j.html(a.navigation.title);h=$("<div/>");h.append(j);h.addClass("navigation");i=$("<div/>");i.addClass("logo");i.click(function(){l.remove()});$closeButton=$("<input/>");$closeButton.attr({type:"button",value:a.navigation.buttontext});$closeButton.click(function(){l.remove()});$closeButton.hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")}); h.append($closeButton);e.append(i);e.append(h);f.append(e)},k=function(a){var g=$(window).width(),c=a.width();a.css("left",(g-c)/2)};this.remove=function(){var b=$({});typeof a.closeCallback=="function"&&b.queue("notAuto",function(g){a.closeCallback();g()});b.queue("notAuto",function(a){c.empty();a()});a.navigation.menu?b.queue("notAuto",function(b){c.fadeOut(a.navigation.removeTimeMs);e.animate({top:-e.outerHeight()},a.navigation.removeTimeMs,function(){b()})}):b.queue("notAuto",function(a){c.fadeOut(200, function(){a()})});b.queue("notAuto",function(a){f.remove();a()});b.queue("notAuto",function(a){$("body").css({height:"auto",overflow:"auto"});a()});b.dequeue("notAuto")};(function(){$.extend(true,a,p);if(a.maxSafeWidth){if(a.content.width>a.maxSafeWidth)a.content.width=a.maxSafeWidth;if(a.wallpaper.width>a.maxSafeWidth)a.wallpaper.width=a.maxSafeWidth}if(a.content.creative)$("body").css({overflow:"hidden"}),f=$("<div/>"),f.attr("id","interstitial-ad"),f.css({width:"100%",height:"100%",position:"fixed", top:0,"z-index":999999}),$("body").prepend(f),a.navigation.menu&&s(),r(),a.autoPosition&&k(b),a.wallpaper.creative&&(q(),a.autoPosition&&k(d)),a.autoPosition&&$(window).resize(function(){k(b);a.wallpaper.creative&&k(d)});else return console.warn("No Creative Set.\nPlease pass creative as constructor when calling Interstial Object:\nnew interstitalObject\n({\n\tcreative :\n\t{\n\t\tcontent : 'URL, string or JQObject'\n\t}\n});"),false})()};
