function TopLayer(o,s)
{
    this.obj = o;
    this.timeout = parseInt(s)*1000;
    this.left = false;
    this.top = false;
    this.show_times = 0;
    this.show_per_time = 1;
    this.width = 0;
    this.height = 0;
    
    this.close = function()
    {
        this.obj.style.visibility = "hidden";
    }

    this.setWidth = function(w)
    {
        this.width = w;
    }

    this.setHeight = function(h)
    {
        this.height = h;
    }

    this.show = function()
    {
        this.obj.style.visibility = "visible";
    }

    this.setLeft = function(l)
    {
        this.left = l;
    }

    this.setCookie = function(cookieName,cookieValue,time) {
        var today = new Date();
        var expire = new Date();
        if (time==null || time==0) time=3600000;

        expire.setTime(today.getTime() + time);
        document.cookie = cookieName+"="+escape(cookieValue)
        + ";expires="+expire.toGMTString();
    }


   this.readCookie = function(n) {
        var cookiecontent = new String();
        if(document.cookie.length > 0) {
                var cookiename = n+ '=';
                var cookiebegin = document.cookie.indexOf(cookiename);
                var cookieend = 0;
                if(cookiebegin > -1) {
                        cookiebegin += cookiename.length;
                        cookieend = document.cookie.indexOf(";",cookiebegin);
                        if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
                        cookiecontent = document.cookie.substring(cookiebegin,cookieend);
                        }
                }
        return unescape(cookiecontent);
    }

    this.setTop = function(t)
    {
        this.top = t;
    }

    this.getWindowSize = function() {
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
      }
      return new Array(myWidth,myHeight);
    }


    this.showPer = function(per,sec)
    {
        this.show_per_time = sec * 1000;
        this.show_times = per;
    }

    this.start = function(name)
    {
         if(this.show_time!=0)
         {
            cv = this.readCookie("show_toplayer_"+name);
            if(cv){
                this.obj.style.display="none";
            }else{
                this.setCookie("show_toplayer_"+name, 1, this.show_per_time);
            }
         }

         size = this.getWindowSize();

         szer = size[0];
         var szer2 = parseInt(this.obj.offsetWidth);
         if(szer2==0)
            szer2 = 555;
        
         wys =  size[1];
         wys2 = parseInt(this.obj.offsetHeight);

        if(this.checkBrowser(6)){
            return 1;
            div = '<div style="z-index:5;position:absolute;right: auto; bottom: auto;  left: expression( (  ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth )/2 - (this.offsetWidth/2) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + \'px\' );top: expression( (  ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight )/2 - this.offsetHeight/2 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + \'px\' );">'+this.obj.innerHTML+'</div>';
            this.obj.innerHTML = div;
            this.obj.margin="";
            var iFrame = document.createElement("IFRAME");
          
            //Match IFrame position with divPopup
            iFrame.style.position="absolute";
            iFrame.style.left =this.obj.offsetLeft + 'px';
            
            iFrame.style.top =this.obj.offsetTop + 'px';        

            iFrame.style.width = '555 px';
            iFrame.style.height = '244 px';
            iFrame.style.zIndex = 3;
            iframe = '<iframe src="http://www.bukmacherzy.com/blank.html" width="535" height="234" frameborder="0" style="position:absolute;left: expression( (  (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth )/2 - (this.offsetWidth/2) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + \'px\' );top: expression( (  ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight )/2 - this.offsetHeight/2 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + \'px\' );"></iframe>';
            this.obj.innerHTML+=iframe;
        }else{

            this.obj.style.position="fixed";
            if(this.left===false)
                this.obj.style.right = parseInt((szer/2) - (szer2/2))+"px";
            else
                this.obj.style.right = this.left+"px";

            if(this.top===false)
                this.obj.style.top = parseInt((wys/2) - (wys2/2))+"px";
            else
                this.obj.style.top = this.top+"px";    
        }
        
        this.obj.style.zIndex = 6000;
        var thisObj = this;

        if(this.timeout!=-1)
            setTimeout(function(){thisObj.close()},this.timeout);
    }

    this.checkBrowser = function(ver)
    {
        browserName=navigator.appName;
        browserVer=parseInt(navigator.appVersion.split("MSIE")[1]);

        if(browserName == "Microsoft Internet Explorer" && browserVer <= ver)
        {
            return true;
        }
        
        return false;
    }


}

function getStyle(element, styleProperty) {
var computedStyle = null;
if (typeof element.currentStyle != "undefined")   {
    computedStyle = element.currentStyle;
    }
else {
    computedStyle = document.defaultView.getComputedStyle(element, null);
    }
return computedStyle[styleProperty];
}