/* Expandable Banners | Push Down Banners | Slide Banners Are rich media products by Melodic Media Copyright 2013 Melodic Media visit www.expandbalebanners.com for more info. */ var SlideBanner = function(a){ var sb = {}; if(a.image_url){ var imgId = a.image_url.replace(/[\/.]/g,''); /* Cache/Get the image first */ var img = document.getElementById(imgId),m = document.createElement('img');m.id=imgId;m.src = a.image_url;m.setAttribute('style','position:absolute;top:0;left:-2000px'); m.onload=function(){ createSlide(); };document.body.appendChild(m); }else{ createSlide(); } sb.id = a.bannerid ? a.bannerid : ((a.html_id||false) ? a.html_id : ('s'+Math.random()).replace(/\./g,"")); sb.open = function(){ }; function createSlide(){ var is_html = (a.html_id||false),width = is_html ? a.html_width : a.image_width,height = is_html ? a.html_height : a.image_height; document.body.style.overflowX = 'hidden'; sb.window = { height:document.documentElement.clientHeight,width:document.documentElement.clientWidth,top:document.body.offsetTop,left:document.body.offsetLeft }; sb.center = (function(){ var w = sb.window; var ccx = ((w.width/2)-((is_html ? a.html_width : a.image_width)/2)),ccy = ((w.height/2)-(is_html ? a.html_height : a.image_height)/2); return {x:ccx,y:(ccy<1?0:ccy)}; })(); sb.init = function(){ var w = sb.window,center = sb.center,d = a.direction, pos = (a.scrollwithpage || d=='bottom' || d=='top') ? 'fixed' : 'absolute'; var c = a.html_id ? document.getElementById(a.html_id) : document.createElement('div');if(!is_html)c.id = this.id; sb.banner = c; if(a.image_url){ if(d=='left'||d=='right'){ c.setAttribute('style','position:'+pos+';'+( df(a.bottom) ? ('bottom:'+(a.bottom-5)+'px;') : ('top:'+(df(a.top) ? a.top : center.y)+'px;') )+d+':'+(-(a.image_width*3))+'px;'); }else{ c.setAttribute('style','position:'+pos+';'+d+':'+(-(w.height*2))+'px;'+( df(a.right) ? ('right:'+(a.right)+'px;') : ('left:'+(df(a.left) ? a.left : center.x)+'px;') )); } var s = document.createElement('img');s.src=a.image_url;c.appendChild(s);document.body.appendChild(c); }else{ if(d=='left'||d=='right'){ c.style.cssText += ";"+'position:'+pos+';'+( df(a.bottom) ? ('bottom:'+(a.bottom-5)+'px;') : ('top:'+(df(a.top) ? a.top : center.y)+'px;') )+d+':'+(-(a.html_width*3))+'px;'; }else{ c.style.cssText += ";"+'position:'+pos+';'+d+':'+(-(w.height*2))+'px;'+( df(a.right) ? ('right:'+(a.right)+'px;') : ('left:'+(df(a.left) ? a.left : center.x)+'px;') ); } } if(a.closebutton){ var xb = a.closebutton,x = document.createElement('span');sb.xid = x.id = a.closebuttonid ? a.closebuttonid : 'x'+sb.id;x.innerHTML = '';x.style.cssText += ";z-index:7000;cursor:pointer;position:absolute;"; sb.closebutton = x; if(xb.className) x.className = xb.className; c.appendChild(x); if(d=='left')x.style.cssText += "top:0;left:"+width+"px"; else if(d=='right')x.style.cssText += "top:0;left:-"+(x.offsetWidth)+"px"; else if(d=='bottom'){ x.style.cssText += "right:0;top:-"+(x.offsetHeight-1)+"px"; } else if(d=='top'){ x.style.cssText += "right:0;bottom:-"+(x.offsetHeight-5)+"px"; } x.onclick = function(){ sb.hide(); if(a.closebuttonclick) a.closebuttonclick(this,c,sb); }; } if(d=='left'){ sb.position = [d,(df(a.left) ? a.left : center.x)]; }else if(d=='top'){ sb.position = [d,(df(a.top) ? a.top : center.y)]; }else if(d=='right'){ sb.position = [d,(df(a.right) ? a.right : center.x)]; }else if(d=='bottom'){ sb.position = [d,(df(a.bottom) ? a.bottom-5 : center.y)]; } setTimeout(function(){ eval('if( anim(c,{'+d+':'+sb.position[1]+'},1) ){ if(a.autoclose){setTimeout(function(){sb.hide();},a.autoclose);} if(a.onload){ a.onload(); } sb.success = true; }'); },(a.delay ? a.delay : 0)); }; sb.init(); } sb.hide = function(){ var w = sb.window; var o = document.getElementById(sb.id); var d = sb.settings.direction; var plus = 0;//(window.navigator.userAgent.match('Firefox')) ? (sb.window.width - document.body.scrollWidth - 1) : 0; if(sb.close){ var pos = {}; if(d=='right'||d=='left'){ pos['margin'+sb.position[0].capitalize()] = sb.position[1]; }else pos[sb.position[0]] = sb.position[1]; anim(o,pos,1); if(a.onshow){ a.onshow(this); } sb.close = false; }else{ var prop = {}; if(d=='right'||d=='left'){ prop['margin'+d.capitalize()] = -(o.offsetWidth); } else if(d=='bottom'||d=='top'){ prop[d] = -(o.offsetHeight); } anim(o,prop,1); if(a.onclose){ a.onclose(this); } sb.close = true; } }; sb.settings = a; sb.close = false; sb.success = false; sb.css = function(o,s,rpx){ var s = document.documentMode ? o.currentStyle[s] : getComputedStyle(o,s)[s]; return rpx ? s.replace('px','') : ''; }; function df(s){ return (typeof s != 'undefined'); } return sb; }; /* https://github.com/relay/anim */ var anim=function(h){h=function(a,e,f,b){var g,d,c=[],j=function(a){if(a=c.shift())a[1]?h.apply(this,a).anim(j):0g){for(d in a)d=a[d],d.p=1,d.fn(d,d.n,d.to,d.fr,d.a,d.e);f&&f()}else{g/=e;for(d in a){d=a[d];if(d.n[d.mx]!=d.mxv)return;h=d.e;c=g;"lin"==h?c=1-c:"ease"==h?(c=2*(0.5-c),c=1-(c*c*c-3*c+2)/4):"ease-in"==h?(c= 1-c,c*=c*c):c=1-c*c*c;d.p=c;d.fn(d,d.n,d.to,d.fr,d.a,d.e)}s?s(b):setTimeout(b,20,0)}};b()};h.fx={_:function(a,e,f,b,g){b=parseFloat(b)||0;f=parseFloat(f)||0;a.s[g]=(1<=a.p?f:a.p*(f-b)+b)+a.u},width:function(a,e,f,b,g,d){0<=a._fr||(a._fr=!isNaN(b=parseFloat(b))?b:"width"==g?e.clientWidth:e.clientHeight);h.fx._(a,e,f,a._fr,g,d)},opacity:function(a,e,f,b,g){if(isNaN(b=b||a._fr))b=e.style,b.zoom=1,b=a._fr=(/alpha\(opacity=(\d+)\b/i.exec(b.filter)||{})[1]/100||1;b*=1;f=a.p*(f-b)+b;e=e.style;g in e?e[g]= f:e.filter=1<=f?"":"alpha("+g+"="+Math.round(100*f)+")"},color:function(a,e,f,b,g,d,c,j){a.ok||(f=a.to=h.toRGBA(f),b=a.fr=h.toRGBA(b),0==f[3]&&(f=[].concat(b),f[3]=0),0==b[3]&&(b=[].concat(f),b[3]=0),a.ok=1);j=[0,0,0,a.p*(f[3]-b[3])+1*b[3]];for(c=2;0<=c;c--)j[c]=Math.round(a.p*(f[c]-b[c])+1*b[c]);(1<=j[3]||h.rgbaIE)&&j.pop();try{a.s[g]=(3a;a++)k[a]=parseInt(k[a],16),b[a]=Math.round(2.55*b[a]);e=[k[0]||b[0]||q||0,k[1]||b[1]||r||0,k[2]||b[2]||s||0,p||t||1]});return e};return h}(); String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }