//ukk_effects.js
//version 1.0.0

var ukk = {};
ukk.UA = (function () {
    var g = document;
    var c = navigator.userAgent.toUpperCase();
    var a = navigator.appName.toUpperCase();
    var i = navigator.appVersion;
    var f = [];
    var d = c.indexOf("MAC", 0) >= 0;
    var h = c.indexOf("WIN", 0) >= 0;
    if (h) {
        f.os = "windows"
    } else {
        if (d) {
            f.os = "mac"
        } else {
            f.os = "other"
        }
    }
    if (window.attachEvent && !window.opera) {
        f.name = "IE";
if (typeof document.createElement("div").style.opacity != 'undefined'){
f.ver = "9"
} else if (typeof g.documentElement.style.msInterpolationMode != "undefined") {
            if (typeof document.documentMode != "undefined") {
                f.ver = "8"
            } else {
                f.ver = "7"
            }
        } else {
            if (h && c.indexOf("MSIE 6", 0) >= 0) {
                f.ver = "6"
            } else {
                f.ver = "5"
            }
        }
    } else {
        if (c.indexOf("SAFARI", 0) >= 0 && c.indexOf("APPLEWEBKIT/", 0) >= 0) {
            f.name = "Safari";
            f.ver = (function () {
                var j = c.split("/");
                var k = j[j.length - 1];
                k = k.replace(/\./g, "");
                k = k.slice(0, 3);
                var l = parseInt(k, 10);
                if (l >= 412 && l < 522) {
                    return "2"
                } else {
                    if (l >= 522) {
                        return "3"
                    } else {
                        return "1"
                    }
                }
            })()
        } else {
            if (c.indexOf("GECKO", 0) >= 0 && c.indexOf("FIREFOX", 0) >= 0) {
                f.name = "Firefox";
                var e = c.split("/");
                var b = parseInt(e[e.length - 1].slice(0, 1), 10);
                if (typeof window.postMessage != "undefined" && b >= 3) {
                    f.ver = "3"
                } else {
                    if (b == "2") {
                        f.ver = "2"
                    } else {
                        f.ver = "1"
                    }
                }
            } else {
                if (window.opera) {
                    f.name = "Opera"
                } else {
                    if (c.indexOf("NETSCAPE", 0) >= 0) {
                        f.name = "Netscape";
                        if (i == "5") {
                            f.ver = "6"
                        }
                    } else {
                        f.name = "unknown"
                    }
                }
            }
        }
    }
    return f
})();
ukk.Browser = function (d, c) {
    if (typeof d == "undefined") {
        return null
    }
    if (!ukk.stringChk(d)) {
        return null
    }
    if (typeof c == "undefined") {
        var b = false
    } else {
        var b = true
    }
    var a = ukk.UA.name.toUpperCase();
    var d = d.toUpperCase();
    if (a.search(d) != -1) {
        if (b) {
            if (ukk.UA.ver.search(c, "i") != -1) {
                return true
            } else {
                return false
            }
        }
        return true
    } else {
        return false
    }
};
ukk.copy_properties = function (b, a) {
    for (var c in b) {
        if (typeof(a[c]) == "undefined") {
            a[c] = b[c]
        }
    }
};
ukk.inherit = function (b, a) {
    ukk.copy_properties(a.prototype, b.prototype)
};
ukk.Style = {
    add: function (c, b) {
        var d = "";
        var f = c.style;
        for (var e in b) {
            if (e == "float") {
                if (ukk.UA.name == "IE" && (ukk.UA.ver == "7" || ukk.UA.ver == "6")) {
                    d = "styleFloat"
                } else {
                    d = "cssFloat"
                }
            } else {
                if (e == "opacity") {
                    if (ukk.UA.name == "IE" && ukk.UA.ver < 9) {
                        d = "filter";
                        var a = b[e];
                        if (a * 100 > 100) {
                            continue
                        }
                        b[e] = "alpha(" + e + "=" + a * 100 + ")";
                        if (c.currentStyle) {
                            if (!c.currentStyle.hasLayout) {
                                f.zoom = 1
                            }
                        }
                    } else {
                        d = "opacity"
                    }
                } else {
                    d = e
                }
            }
            f[d] = b[e]
        }
    }
};
ukk.Effect = {};
ukk.Effect.Core = function () {};
ukk.Effect.Core.prototype = {
    prop: function () {
        this.x = 0;
        this.y = 0;
        this.px = "px";
        this.pi = Math.PI;
        this.deftime = new Date().getTime()
    }
};
ukk.stringChk = function (a) {
    if (typeof a == "string" || a instanceof String) {
        return a
    }
    return null
};

ukk.Effect.Fade = function (d, a, c, b) {
    this.initialize.apply(this, arguments)
};
ukk.Effect.Fade.flg = false;
ukk.Effect.Fade.elm = "";
ukk.Effect.Fade.alpha = 0;
ukk.Effect.Fade.prototype = {
    initialize: function (elm, option, vis, func) {
        var pre = this;
        this.elm = elm;
        this.elmst = elm.style;
        ukk.Effect.Fade.elm = elm;
        this.StartValue = option[0];
        this.EndValue = option[1];
        this.time = option[2];
        this.edging = option[3];
        ukk.Effect.Fade.alpha = option[1];
        if (vis == "block" || vis == "none") {
            this.vis = "display"
        } else {
            if (vis == "hidden" || vis == "visible") {
                this.vis = "visibility"
            }
        }
        if (func) {
            this.nextfunc = eval(func[0]);
            this.funcdelay = func[1]
        }
        this.interval = null;
        this.prop();
        this.visp = vis;
        this.endtime = this.deftime + this.time;
        this.value = this.EndValue - this.StartValue;
        this.egnum = this.edging / (100 * this.pi);
        this.time2 = this.endtime - this.deftime;
        if (!this.interval) {
            this.interval = setTimeout(function () {
                pre.funcFade()
            }, 10)
        }
    },
    funcFade: function () {
        var a = this;
        var d = new Date().getTime();
        if (this.endtime >= d) {
            var b = (d - this.deftime) / this.time2;
            this.x = Math.round(this.value * (b + this.egnum * Math.sin(this.pi * b)) + this.StartValue);
            ukk.Style.add(this.elm, {
                opacity: this.x / 100
            });
            this.interval = setTimeout(function () {
                a.funcFade()
            }, 10)
        } else {
            ukk.Style.add(this.elm, {
                opacity: this.EndValue / 100
            });
            this.elmst[this.vis] = this.visp;
            this.StartValue = this.x;
            clearTimeout(this.interval);
            if (this.nextfunc) {
                setTimeout(function () {
                    a.nextfunc.call()
                }, this.funcdelay)
            }
        }
    }
};
ukk.inherit(ukk.Effect.Fade, ukk.Effect.Core);ukk.Effect.Size = function (c, a, b) {
    this.initialize.apply(this, arguments)
};
ukk.Effect.Size.flg = false;
ukk.Effect.Size.elm = "";
ukk.Effect.Size.elmX = 0;
ukk.Effect.Size.elmY = 0;
ukk.Effect.Size.prototype = {
    initialize: function (elm, option, func) {
        var pre = this;
        this.elm = elm;
        this.elmst = elm.style;
        ukk.Effect.Size.elm = elm;
        this.EndWidth = option[0];
        this.EndHeight = option[1];
        this.time = option[2];
        this.edging = option[3];
        this.interval = null;
        this.k = 0.95;
        this.StartWidth = elm.offsetWidth;
        this.StartHeight = elm.offsetHeight;
        ukk.Effect.Size.elmX = option[0];
        ukk.Effect.Size.elmY = option[1];
        if (func) {
            this.nextfunc = eval(func[0]);
            this.funcdelay = func[1]
        }
        this.interval = null;
        this.prop();
        this.endtime = this.deftime + this.time;
        this.valueW = this.EndWidth - this.StartWidth;
        this.valueH = this.EndHeight - this.StartHeight;
        this.time2 = this.endtime - this.deftime;
        this.egnum = this.edging * this.k;
        if (!this.interval) {
            this.interval = setTimeout(function () {
                pre.sizefunc()
            }, 10)
        }
    },
    sizefunc: function () {
        var b = this;
        var e = new Date().getTime();
        if (this.endtime >= e) {
            var d = (e - this.deftime) / this.time2;
            var a = (100 + this.egnum) * d / (2 * this.egnum * d + 100 - this.egnum);
            if (this.EndWidth) {
                this.x = this.valueW * (d + this.egnum * Math.sin(this.pi * d)) + this.StartWidth;
                this.elmst.width = Math.floor(this.x) + this.px
            }
            if (this.EndHeight) {
                this.y = this.StartHeight + (this.EndHeight - this.StartHeight) * a;
                this.elmst.height = Math.floor(this.y) + this.px
            }
            this.interval = setTimeout(function () {
                b.sizefunc()
            }, 10)
        } else {
            if (this.EndWidth) {
                this.elmst.width = this.EndWidth + this.px
            }
            if (this.EndHeight) {
                this.elmst.height = this.EndHeight + this.px
            }
            this.StartWidth = this.x;
            this.StartHeight = this.y;
            clearTimeout(this.interval);
            if (this.nextfunc) {
                setTimeout(function () {
                    b.nextfunc.call()
                }, this.funcdelay)
            }
        }
    }
};
ukk.inherit(ukk.Effect.Size, ukk.Effect.Core);
ukk.Effect.Clip = function (c, a, b) {
    this.initialize.apply(this, arguments)
};
ukk.Effect.Clip.prototype = {
    initialize: function (elm, option, func) {
        var pre = this;
        this.elm = elm;
        this.elmst = elm.style;
        this.EndTop = option[0];
        this.EndRight = option[1];
        this.EndBottom = option[2];
        this.EndLeft = option[3];
        this.time = option[4];
        this.edging = option[5];
        this.interval = null;
        this.k = 0.95;
        var estarray = [];
        estarray = elm.style.clip.match(/\d+/gi);
        this.StartTop = parseInt(estarray[0], 10);
        this.StartRight = parseInt(estarray[1], 10);
        this.StartBottom = parseInt(estarray[2], 10);
        this.StartLeft = parseInt(estarray[3], 10);
        if (func) {
            this.nextfunc = eval(func[0]);
            this.funcdelay = func[1]
        }
        this.interval = null;
        this.prop();
        this.endtime = this.deftime + this.time;
        this.valueT = this.EndTop - this.StartTop;
        this.valueR = this.EndRight - this.StartRight;
        this.valueB = this.EndBottom - this.StartBottom;
        this.valueL = this.EndLeft - this.StartLeft;
        this.time2 = this.endtime - this.deftime;
        this.egnum = this.edging * this.k;
        if (!this.interval) {
            this.interval = setTimeout(function () {
                pre.sizefunc()
            }, 10)
        }
    },
    sizefunc: function () {
        var h = this;
        var j = new Date().getTime();
        if (this.endtime >= j) {
            var i = (j - this.deftime) / this.time2;
            var f = (100 + this.egnum) * i / (2 * this.egnum * i + 100 - this.egnum);
            this.t = this.StartTop + (this.EndTop - this.StartTop) * f;
            var e = Math.floor(this.t) + this.px;
            this.r = this.StartRight + (this.EndRight - this.StartRight) * f;
            var g = Math.floor(this.r) + this.px;
            this.b = this.StartBottom + (this.EndBottom - this.StartBottom) * f;
            var a = Math.floor(this.b) + this.px;
            this.l = this.StartLeft + (this.EndLeft - this.StartLeft) * f;
            var d = Math.floor(this.l) + this.px;
            this.elmst.clip = "rect(" + e + " " + g + " " + a + " " + d + ")";
            this.interval = setTimeout(function () {
                h.sizefunc()
            }, 10)
        } else {
            this.elmst.clip = "rect(" + this.EndTop + "px " + this.EndRight + "px " + this.EndBottom + "px " + this.EndLeft + "px)";
            this.StartTop = this.t;
            this.StartRight = this.r;
            this.StartBottom = this.b;
            this.StartLeft = this.l;
            clearTimeout(this.interval);
            if (this.nextfunc) {
                setTimeout(function () {
                    h.nextfunc.call()
                }, this.funcdelay)
            }
        }
    }
};
ukk.inherit(ukk.Effect.Clip, ukk.Effect.Core);
ukk.Effect.Move = function (c, a, b) {
    this.initialize.apply(this, arguments)
};
ukk.Effect.Move.flg = false;
ukk.Effect.Move.elm = "";
ukk.Effect.Move.elmX = 0;
ukk.Effect.Move.elmY = 0;
ukk.Effect.Move.prototype = {
    initialize: function (elm, option, func) {
        var pre = this;
        this.elm = elm;
        this.elmst = elm.style;
        this.k = 0.95;
        ukk.Effect.Move.elm = elm;
        this.elmst.position = "absolute";
        this.interval = null;
       
        this.time = option[2];
        this.edging = option[3];
   
        if (func) {
            this.nextfunc = eval(func[0]);
            this.funcdelay = func[1]
        }
        this.interval = null;
        this.prop();
        
        this.egnum = this.edging * this.k;
        //if (!this.interval) {
        //    this.interval = setTimeout(function () {
      //          pre.movefunc()
      //      }, 10)
       // }
    },

startfunc:function(mx,my) {
var pre = this;
 this.EndX = mx;
      this.EndY = my;
this.deftime = new Date().getTime();
this.StartX = parseInt(this.elmst.left) || 0;
      this.StartY = parseInt(this.elmst.top) || 0;
      this.endtime = this.deftime + this.time;
      this.valueW = this.EndX - this.StartX;
      this.valueH = this.EndY - this.StartY;
     this.time2 = this.endtime - this.deftime;

clearTimeout(this.interval);
this.interval = null;
if (!this.interval) {
          this.interval = setTimeout(function () {
              pre.movefunc()
          }, 10)
     }
},

    movefunc: function () {
        var b = this;
        var e = new Date().getTime();
        if (this.endtime >= e) {
            var d = (e - this.deftime) / this.time2;
            var a = (100 + this.egnum) * d / (2 * this.egnum * d + 100 - this.egnum);
            if (this.EndX) {
                this.x = this.StartX + (this.EndX - this.StartX) * a;
                this.elmst.left = Math.floor(this.x) + this.px
            }
            if (this.EndY) {
                this.y = this.StartY + (this.EndY - this.StartY) * a;
                this.elmst.top = Math.floor(this.y) + this.px
            }
            this.interval = setTimeout(function () {
                b.movefunc()
            }, 10)
        } else {
            if (this.EndX) {
                this.elmst.left = this.EndX + this.px
            }
            if (this.EndY) {
                this.elmst.top = this.EndY + this.px
            }
            this.StartX = this.x;
            this.StartY = this.y;
            clearTimeout(this.interval);
            if (this.nextfunc) {
                setTimeout(function () {
                    b.nextfunc.call()
                }, this.funcdelay)
            }
        }
    },

prevStop :function(){
 clearTimeout(this.interval);
}
};
ukk.inherit(ukk.Effect.Move, ukk.Effect.Core);




/* Event */
ukk.Event= {
stopbubble : function (e){
if (e.target) { 
     e.stopPropagation(); 
}else if (window.event.srcElement) { 
     e.cancelBubble = true; 
   }  
},

stopevent : function (e){
if (e.target) { 
 e.preventDefault(); 
}else if (window.event.srcElement) { 
e.returnValue=false;
   }
}
}

