(function () {

    var receptureLogo = function () {

        this.logoSrc = "images/newRecepture.png";
        this.logoSrcIE = "images/newRecepture.gif";
        this.isIE = /msie|MSIE 6/.test(navigator.userAgent);
	

	this.parent = document.getElementById("novinky");
        this.parent.style.position = "relative";


        this.count = 0;
        this.defPosition = "800";
        this.maxPos = this.isIE ?370:360;

        /**/
        this.logo = document.createElement("img");
        this.logo.src = this.isIE ? this.logoSrcIE : this.logoSrc;  //check na msie

        this.parent.appendChild(this.logo);

        this.setCss = function (o) {
            for (p in o)
                this.logo.style[p] = o[p];
        }

        this.getReverseVisibility = function () {
            return this.logo.style.visibility == "visible" ? "hidden" : "visible";
        }

        this.animate = function () {
            var that = this;
            if (this.count < 6) {
                this.count++;
                window.setTimeout(function () {
                    that.setCss({ visibility: that.getReverseVisibility() })
                    that.animate.call(that);
                }, 500);
            }
        }
        
        this.move = function () {
            var that = this;
            
            if(that.defPosition >= that.maxPos)
            {
                window.setTimeout(function () {
                    that.defPosition = that.defPosition - 10;
                    that.setCss({ left: that.defPosition + "px", visibility: "visible" });
                    that.move.call(that);
                }, 10);
            }
            else
            {
                that.animate();
            }   
        }
        

        //default set
        this.setCss({ top: "20px", left: this.isIE ?"360px":"350px", position: "absolute", visibility: "hidden" });
    }

    function load() {
        var l = new receptureLogo();
        l.move();
    }

    if (window.attachEvent) {
        window.attachEvent('onload', load);
    }
    else if (window.addEventListener) {
        window.addEventListener('load', load, false);
    }
    else {
        document.addEventListener('load', load, false);
    }
})();
