//<[!CDATA[
var JobAd = Class.create({
    initialize: function() {
        this.flowdiv = null;
        this.step_x = 10;
        this.step_y = 5;
        this.forwards_x = true;
        this.forwards_y = true;
        this.move_w = document.viewport.getWidth();
        this.move_h = document.viewport.getHeight();
        this.Periodical = null;
    },

    build: function() {
        var win = window.open('TZ/ZP/ÕÐÆ¸¹«¸æ.htm', 'ad', 'width=816px,height=600px,scrollbars=yes');
        var h = document.viewport.getHeight() - 600;
        var w = document.viewport.getWidth() - 816;
        Try.these(
            win.moveTo(w / 2, h / 2)
        )
    },

    frame: function() {
        this.flowdiv = new Element('div').addClassName('addiv');//, zIndex: 9999, position:'absolute', left:'0px', top:'0px'});
        var _src = 'TZ/ZP/logo.jpg';
        //this.flowdiv.update(AC_FL_RunContent2( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','75','height','75','src',_src,'quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie',_src ));
        this.flowdiv.update(new Element('a',{href:'TZ/ZP/ÕÐÆ¸¹«¸æ.htm',target:'_blank'}).insert(new Element('img', { src: _src})));//, width: '189px', height: '141px' })));
        document.body.appendChild(this.flowdiv);
	//this.flowdiv.absolutize();

        this.Periodical = new PeriodicalExecuter(this.flow.bind(this), 0.15);

        Event.observe(window, 'scroll', this.change_move.bind(this));
        Event.observe(window, 'resize', this.change_move.bind(this));
        //closediv.observe('click',JobAd.close.bind(this));
        this.flowdiv.observe('mouseover', function() {
            this.Periodical.stop();
        } .bind(this));
        this.flowdiv.observe('mouseout', function() {
            this.Periodical.registerCallback();
        } .bind(this));
    },

    change_move: function() {
        this.move_w = document.viewport.getWidth() + document.viewport.getScrollOffsets()[0];
        this.move_h = document.viewport.getHeight() + document.viewport.getScrollOffsets()[1];
    },

    flow: function() {
        this.flowtox();
        this.flowtoy();
    },

    // true: ++ || false:--
    flowtox: function() {
        if (this.flowdiv.offsetLeft + this.flowdiv.getWidth() >= this.move_w) {
            this.forwards_x = false;
        }
        else if (this.flowdiv.offsetLeft <= 0) {
            this.forwards_x = true;
        }
        if (this.forwards_x) {
            this.flowdiv.setStyle({ 'left': parseInt(this.flowdiv.offsetLeft) + this.step_x + "px" });
        } else {
            this.flowdiv.setStyle({ 'left': parseInt(this.flowdiv.offsetLeft) - this.step_x + "px" });
        }
    },

    // true: ++ || false:--
    flowtoy: function() {
        if (this.flowdiv.offsetTop + this.flowdiv.getHeight() >= this.move_h) {
            this.forwards_y = false;
        } else if (this.flowdiv.offsetTop <= 0) {
            this.forwards_y = true;
        }
        if (this.forwards_y) {
            this.flowdiv.setStyle({ 'top': parseInt(this.flowdiv.offsetTop) + this.step_y + "px" });
        } else {
            this.flowdiv.setStyle({ 'top': parseInt(this.flowdiv.offsetTop) - this.step_y + "px" });
        }
    },

    register: function() {
        if (location.search.empty()) {
            var url = 'UserReg.aspx';
            setTimeout(function() {
                window.open(url);
                close();
            }, 5000);
        }
    },

    show: function() {
        Event.observe(window, 'load', this.build.bind(this));
    },

    showframe: function() {
	this.frame(this);
//        Event.observe(window, 'load', this.frame.bind(this));
    },

    toRegister: function() {
        Event.observe(window, 'load', this.register.bind(this));
    },

    ad: function() {
        Event.observe(window, 'load', this.frame.bind(this));
    },

    close: function() {
        this.Periodical.stop();
        document.body.removeChild(this.flowdiv);
    }

});
JobAd = new JobAd();
//]]>
