﻿// Loaded javascript files 
if (typeof (jsload) != 'object') {
    setTimeOut("jsload.load('jquery.plugin.flash', 'widget.banner')", 1000);
}
else {
    jsload.load('jquery.plugin.flash', 'widget.banner');
}

// main script;
var main = {
    name: 'main',
    version: '0.1',

    gamemate: function () {
        $("#slider").bannerRotator({
            btnNext: "#nextBtn>a",
            btnPrev: "#prevBtn>a",

            auto: 5000,

            speed: 500,
            easing: null,

            vertical: false,
            visible: 1,
            start: 1,
            scroll: 1,

            beforeStart: null,
            afterEnd: null,
            onLoad: null
        });

    },

    test: function () { }
};

function Floating(FloatingObj, MarginY, TopLimit, Percentage, setTime) {
	this.FloatingObj = FloatingObj;
	this.MarginY = (MarginY) ? MarginY : 0;
	this.TopLimit = (TopLimit) ? TopLimit : 0;
	this.Percentage = (Percentage) ? Percentage : 20;
	this.setTime = (setTime) ? setTime : 10;
	this.FloatingObj.style.position = "relative";
	this.Body = null;
	this.setTimeOut = null;
	this.Run();
}
Floating.prototype.Run = function () {
	this.Body = document.documentElement.scrollTop > document.body.scrollTop ? document.documentElement : document.body;

	var This = this;
	var FloatingObjTop = (this.FloatingObj.style.top) ? parseInt(this.FloatingObj.style.top, 10) : this.FloatingObj.offsetTop;
	var DocTop = this.Body.scrollTop + this.MarginY;
	var MoveY = Math.abs(FloatingObjTop - DocTop);
	var clWid = document.documentElement.clientWidth;

	if (DocTop > this.TopLimit) {
		if (FloatingObjTop < DocTop) {
			this.FloatingObj.style.top = FloatingObjTop + Math.ceil(MoveY / this.Percentage) + "px";
		} else {
			this.FloatingObj.style.top = FloatingObjTop - Math.ceil(MoveY / this.Percentage) + "px";
		}
	} else {
		this.FloatingObj.style.top = this.TopLimit + "px";
	}
	/*
	if ( clWid > 730 ) {
	var centerWidth = (clWid / 2 + 365) +"px" ;
	this.FloatingObj.style.left = centerWidth ;
	} else {
	this.FloatingObj.style.left = "730px" ;
	}
	*/
	window.clearTimeout(this.setTimeOut);
	this.setTimeOut = window.setTimeout(function () { This.Run(); }, this.setTime);
}

