﻿/*
author:chen yi hong
date:2011/8/25
*/

var isIE = (document.all) ? true : false;

var $ = function (id) {
    return "string" == typeof id ? document.getElementById(id) : id;
}

var Class = {
    create: function () {
        return function () { this.initialize.apply(this, arguments); }
    }
}
var Bind = function (object, fun) {
    return function () { fun.apply(object, arguments); }
}

var Extend = function (destination, source) {
    for (var property in source) {
        destination[property] = source[property];
    }
}

function AddEventHandler(oTarget, sEventType, fnHandler) {
    if (oTarget.addEventListener) {
        oTarget.addEventListener(sEventType, fnHandler, false);
    } else if (oTarget.attachEvent) {
        oTarget.attachEvent("on" + sEventType, fnHandler);
    }
    else {
        oTarget["on" + sEventType] = fnHandler;
    }

}


function RemoveEventHandler(oTarget, sEventType, fnHandler) {
    if (oTarget.removeEventListener) {
        oTarget.removeEventListener(sEventType, fnHandler, false);
    } else if (oTarget.detachEvent) {
        oTarget.detachEvent("on" + sEventType, fnHandler);
    } else {
        oTarget["on" + sEventType] = null;
    }
};

var BindAsEventListener = function (object, fun) {
    var args = Array.prototype.slice.call(arguments).slice(2);
    return function (event) {
        return fun.apply(object, [event || window.event].concat(args));
    }
}



var tlist = new Array();
var mytop = Class.create();
mytop.prototype = {
    initialize: function (obj, options) {
        tlist[0] = $(obj);
        window.onscroll = this.Myscroll;
        window.onresize = this.Myscroll;
        window.onload = this.Myscroll;

    },
    Myscroll: function () {
        var aa = document.documentElement.scrollTop + document.body.scrollTop;
        this.topbut = tlist[0];
        this.topbut.style.top = (aa + (document.documentElement.clientHeight - parseInt(this.topbut.offsetHeight)) * 60 / 100) + "px";
        this.topbut.style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - parseInt(this.topbut.offsetWidth)) * 100 / 100) + "px";
        
    }


}
 
