var objAdb={container_id:"adb_widget_container",script_id:"adbox_widget_id",host:"",key:"",language:"lt",browsers:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"}],start:function(){document.write('<div id="'+this.container_id+'"></div>');this.getKey();this.detectBrowser();switch(this.browser){case"Firefox":document.addEventListener("DOMContentLoaded",this.renderWidget,false);break;case"Chrome":document.addEventListener("DOMContentLoaded",this.renderWidget,false);break;case"Opera":document.addEventListener("DOMContentLoaded",this.renderWidget,false);break;case"Explorer":this.ieLoaded(this.renderWidget);break;case"Safari":this.safariLoaded();break;default:this.addLoadEvent(this.renderWidget);break}},getKey:function(){var a=document.getElementById(this.script_id);var c=a.getAttribute("src").split("#");this.key=c[1];var b=c[0].split("__");var d="";if(b[1]!=undefined){d="__"+b[1]}else{d=".js"}if(c[2]!=undefined){this.language=c[2]}this.host=c[0].replace("scripts/engine"+d,"")},detectBrowser:function(){for(var b=0;b<this.browsers.length;b++){var a=this.browsers[b].string;var c=this.browsers[b].prop;this.versionSearchString=this.browsers[b].versionSearch||this.browsers[b].identity;if(a){if(a.indexOf(this.browsers[b].subString)!=-1){this.browser=this.browsers[b].identity}}else{if(c){this.browser=this.browsers[b].identity}}}},ieLoaded:function(d){var c=window.document;var b=false;var a=function(){if(!b){b=true;d()}};(function(){try{c.documentElement.doScroll("left")}catch(e){setTimeout(arguments.callee,30);return}a()})();c.onreadystatechange=function(){if(c.readyState=="complete"){c.onreadystatechange=null;a()}}},safariLoaded:function(){if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,30);return}objAdb.renderWidget()},addLoadEvent:function(b){var a=window.onload;if(typeof a!="function"){window.onload=b}else{window.onload=function(){if(a){a()}b()}}},renderWidget:function(){objAdb.widget=new objWidget();objAdb.widget.start()}};var objWidget=function(){this.title_text="Reklama";this.buy_text="Pirkite reklam\u0105 čia";this.close_text="U\u017edaryti";this.cancel_text="At\u0161aukti";this.footer_text="AdBox.lt";this.loading_text="Kraunasi";this.background_color="#EBEAEA";this.border_color="#767575";this.border_size=1;this.open_widget_min_width=420;this.open_widget_min_height=697;this.image_width=125;this.image_margin=10;this.closed_widget_min_width=this.image_width+2*this.image_margin;this.uri_new=[];this.uri_new.lt="lt/valdiklis/";this.uri_new.en="en/widget/";this.start=function(){this.showWidget();this.showTitle();this.showImages();this.showBuyButton();this.showFooter();this.loadData()};this.showWidget=function(){this.body=this.resetElement("div");this.body.style.position="relative";this.body.style.display="block";this.body.style.borderStyle="solid";this.body.style.styleFlot="left";this.body.style.backgroundColor=this.background_color;this.body.style.borderColor=this.border_color;this.body.style.borderWidth=this.border_size+"px";this.container=document.getElementById(objAdb.container_id);this.container.style.position="relative";this.container.style.display="block";this.container.style["float"]="none";this.container.style.overflow="hidden";this.container.style.zIndex=1;this.container.appendChild(this.body);this.adjustSize();var a=this;window.onresize=function(){a.adjustSize()}};this.resetElement=function(a){var b=document.createElement(a);b.setAttribute("style","position: relative; display: block; font-weight: normal; text-align: left; width: auto; height: auto; background: none; padding: 0; margin: 0;");return b};this.adjustSize=function(){this.container.style.width="100%";var a=this.container.offsetWidth;this.container.style.width=a+"px";this.width=a-2*this.border_size;if(this.width>this.open_widget_min_width){this.open_widget_width=this.width}else{this.open_widget_width=this.open_widget_min_width}if(this.width<this.closed_widget_min_width){this.width=this.closed_widget_min_width}if(this.body){this.body.style.width=this.width-2*this.border_size+"px"}if(this.buy_button){this.buy_button.style.width=this.width-8-2*this.image_margin+"px"}if(this.links){this.showImages(this.links)}};this.showTitle=function(){this.title=this.resetElement("span");this.title.style.position="relative";this.title.style.marginTop="10px";this.title.style.marginLeft="10px";this.title.style.marginBottom="0px";this.title.style.display="block";this.title.style.color="#2F2F2B";this.title.style.fontFamily='"Lucida Grande",verdana,arial,helvetica,sans-serif';this.title.style.fontSize="13px";this.title.style.fontWeight="normal";this.title.style.height="18px";this.title.style.overflow="hidden";this.title.style.styleFloat="left";this.title.className="adb_widget_title";var a=document.createTextNode(this.title_text);this.title.appendChild(a);this.body.appendChild(this.title)};this.showImages=function(d){if(this.images!=null){this.body.removeChild(this.images);this.images=null}if(this.images==null){this.body.style.display="block";this.images=this.resetElement("div");this.images.style.clear="left";this.images.style.overflow="hidden";if(this.buy_button){this.body.insertBefore(this.images,this.buy_button)}else{this.body.appendChild(this.images)}}if(this.images!=null&&d!=undefined){this.images.style.marginTop="10px"}if(d!=undefined&&this.width&&this.images!=null){var h=d.length;var b=Math.floor((this.width-this.image_margin)/(this.image_width+this.image_margin));var a=Math.floor((this.width-b*this.image_width)/(b+1));var g=Math.ceil(h/b);var k=g*this.image_width+(g-1)*this.image_margin;this.images.style.height=k+"px";for(var e=0;e<b;e++){var f=this.resetElement("div");f.style.width=this.image_width+"px";f.style.cssFloat="left";f.style.styleFloat="left";f.style.marginLeft=a+"px";f.style.height=k+"px";f.style.display="inline";f.style.position="relative";f.style.border="0";f.style.padding="0";this.images.appendChild(f)}for(var e=0;e<h;e++){if(d[e].link!=undefined){var j=this.createImageLink(d[e]);this.images.childNodes[e%b].appendChild(j)}}}};this.createImageLink=function(e){var f=this.resetElement("a");if(e!=null){if(e.link!=undefined){f.href=e.link}if(e.title!=undefined){f.title=e.title}if(e.click&&e.click!=undefined){var c=e.click;f.onmousedown=function(){this.href=c;return true}}f.style.marginBottom=this.image_margin+"px";f.style.display="block";f.style.width=this.image_width+"px";f.style.height=this.image_width+"px";f.rel="nofollow";f.target="_blank";f.onmouseover=function(){this.style.filter="alpha(opacity=80)";this.style.MozOpacity="0.8";this.style.opacity="0.8"};f.onmouseout=function(){this.style.filter="alpha(opacity=100)";this.style.MozOpacity="1.0";this.style.opacity="1.0"};var g=this.resetElement("img");if(e.title!=undefined){g.alt=e.title}g.style.border="none";g.style.height=this.image_width+"px";g.style.width=this.image_width+"px";g.src=e.image;if(this.data.settings.special===true){var d=this,b=objAdb.host+this.uri_new[objAdb.language]+"?key="+objAdb.key;f.onclick=function(){d.openWidget();d.loadUrl(b);return false}}f.appendChild(g)}return f};this.showBuyButton=function(){this.buy_button=this.resetElement("a");var e=document.createTextNode(this.buy_text);this.buy_button.className="adb_widget_buy";this.buy_button.style.display="block";this.buy_button.style.marginBottom="5px";this.buy_button.style.marginLeft="8px";this.buy_button.style.marginRight="8px";this.buy_button.style.marginTop="0";this.buy_button.style.paddingBottom="6px";this.buy_button.style.paddingTop="8px";this.buy_button.style.paddingLeft="3px";this.buy_button.style.paddingRight="6px";this.buy_button.style.fontFamily='"Lucida Grande",verdana,arial,helvetica,sans-serif';this.buy_button.style.fontSize="13px";this.buy_button.style.fontWeight="normal";this.buy_button.style.textAlign="left";this.buy_button.style.width=this.width-8-2*this.image_margin+"px";this.buy_button.style.overflow="hidden";var d=this;var b=objAdb.host+this.uri_new[objAdb.language]+"?key="+objAdb.key;this.buy_button.href=b;this.buy_button.onclick=function(){d.openWidget();d.loadUrl(b);return false};this.buy_button.appendChild(e);this.body.appendChild(this.buy_button)};this.showFooter=function(){this.footer_link=this.resetElement("a");this.footer_link.className="adb_widget_logo";var b=document.createTextNode(this.footer_text);this.footer_link.href="http://www.adbox.lt/lt/parduotuve/";this.footer_link.target="_blank";this.footer_link.rel="nofollow";this.footer_link.title="Super reklama per adbox.lt";this.footer_link.style.fontSize="11px";this.footer_link.style.fontFamily="Arial, sans-serif";this.footer_link.style.color="black";this.footer_link.style.textDecoration="none";this.footer_link.style.padding="4px";this.footer_link.display="inline";this.footer_link.style.filter="alpha(opacity=40)";this.footer_link.style.MozOpacity="0.4";this.footer_link.style.opacity="0.4";this.footer_link.style.position="absolute";this.footer_link.style.right="10px";this.footer_link.style.bottom="6px";this.footer_link.appendChild(b);this.footer_link.onmouseover=function(){this.style.textDecoration="underline"};this.footer_link.onmouseout=function(){this.style.textDecoration="none"};this.body.appendChild(this.footer_link);if(this.width<this.open_widget_min_width-this.footer_link.offsetWidth){this.buy_button.style.marginBottom="29px";this.buy_button.style.width=this.width-8-2*this.image_margin+"px"}};this.openWidget=function(){document_width=Math.max(Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),Math.max(document.body.clientWidth,document.documentElement.clientWidth));document_height=Math.max(Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),Math.max(document.body.offsetHeight,document.documentElement.offsetHeight),Math.max(document.body.clientHeight,document.documentElement.clientHeight));this.layer=this.resetElement("div");this.layer.id="adb_widget_layer";this.layer.style.height=this.open_widget_min_height+"px";this.layer.style.width=this.open_widget_min_width+"px";this.layer.style.backgroundColor=this.background_color;this.layer.style.borderStyle="solid";this.layer.style.borderWidth=this.border_size+"px";this.layer.style.borderColor=this.border_color;this.layer.style.overflow="hidden";this.layer.style.display="block";this.layer.style.position="absolute";this.layer.style.zIndex=99999;this.body.style.visibility="hidden";this.showCloseButton();document.body.appendChild(this.layer);this.setWidgetPosition(document_width,document_height)};this.setWidgetPosition=function(f,b){var e=this.getCurrentPosition(this.body).left+this.layer.offsetWidth;var a=this.getCurrentPosition(this.body).top+this.layer.offsetHeight;var c=0;var d=0;if(e>f){c=f-this.layer.offsetWidth;if(c<0){c=0}}else{c=this.getCurrentPosition(this.body).left}if(a>b){d=b-this.layer.offsetHeight;if(d<0){d=0}}else{d=this.getCurrentPosition(this.body).top}this.layer.style.top=d+"px";this.layer.style.left=c+"px"};this.showCloseButton=function(){this.close_button=this.resetElement("span");this.close_button.type="button";this.close_button.title=this.close_text;this.close_button.style.position="absolute";this.close_button.style.top="0";this.close_button.style.right="0";this.close_button.style.border=0;this.close_button.style.display="block";this.close_button.style.overflow="hidden";this.close_button.style.padding="6px";this.close_button.style.zIndex=1;this.close_button.style.backgroundAttachment="scroll";this.close_button.style.backgroundColor="transparent";this.close_button.style.background="url("+objAdb.host+"images/close2.gif) no-repeat center";this.close_button.style.cursor="pointer";this.close_button.style.width="27px";this.close_button.style.height="25px";var a=this;this.close_button.onclick=function(){a.closeWidget()};this.layer.appendChild(this.close_button)};this.closeWidget=function(){if(this.close_button){this.layer.removeChild(this.close_button);this.close_button=null}if(this.iframe){this.layer.removeChild(this.iframe);this.iframe=null}if(this.layer){document.body.removeChild(this.layer);this.layer=null}if(this.body){this.body.style.visibility="visible"}};this.loadUrl=function(a){this.iframe=this.resetElement("iframe");this.iframe.id="adb_widget_frame";this.iframe.style.height=this.open_widget_min_height+"px";this.iframe.style.width=this.open_widget_min_width+"px";this.iframe.frameBorder="0";this.iframe.scrolling="no";this.iframe.src=a+"&rand="+Math.floor(Math.random()*11);this.iframe.allowTransparency="false";this.iframe.style.height="100%";this.iframe.style.width=this.open_widget_width+"px";this.layer.appendChild(this.iframe)};this.loadData=function(){this.body.style.visibility="hidden";var a=document.createElement("script");a.type="text/javascript";a.src=objAdb.host+"engine/show.php?key="+objAdb.key;var b=document.getElementsByTagName("head")[0];b.appendChild(a)};this.init=function(a){this.data=a;this.body.style.height="auto";this.body.style.visibility="visible";this.body.style.backgroundColor=a.settings.background_color;this.body.style.borderColor=a.settings.border_color;this.title.innerHTML=a.settings.title_main;this.buy_button.innerHTML=a.settings.title_new;this.footer_link.title=a.settings.title_home;this.links=a.links;if(a.settings.active=="no"){this.buy_button.innerHTML="";this.buy_button.href="";this.buy_button.style.cursor="default";this.buy_button.onclick=function(){return false}}this.showImages(a.links)};this.position=function(b,a){this.top=b;this.left=a};this.getCurrentPosition=function(c){var a=0,e=0;for(var d=c;d!=null;d=d.offsetParent){a+=d.offsetLeft;e+=d.offsetTop}return new this.position(e,a)}};objAdb.start();
