﻿function anchorOver(anchor, stripID) {
    var strip = $get(stripID);
    var bounds = Sys.UI.DomElement.getBounds(anchor);
    var bounds2 = Sys.UI.DomElement.getBounds(strip);
    var tgetX = Math.max(0, bounds.x - 5);
    var tgetY = Math.max(0, bounds.y + bounds.height / 2 - bounds2.height / 2);
    strip.style.top = String.format("{0}px", tgetY);
    if (anchor["tween"]){
        anchor["tween"].stop();
        anchor["tween"].dispose();
    }
    if (anchor["tween2"]){
        anchor["tween2"].stop();
        anchor["tween2"].dispose();
    }
    anchor["tween"] = $create(
                    Pacem.UI.Tween, // type
                    {'isCssProperty': true, 'type': Pacem.UI.TweenType.int, 'easingFunc': Pacem.UI.Easing.Sine.easeOut, 'property': 'width', 'unit': Pacem.UI.Unit.pixels, 'start': 0, 'finish': tgetX, 'duration': .25} // properties
                    , { 'motionChanged': tween_motionChanged} // events
                    , null, strip
                    );
    anchor["tween2"] = $create(
                    Pacem.UI.Tween, // type
                    {'isCssProperty': true, 'type': Pacem.UI.TweenType.color, 'easingFunc': Pacem.UI.Easing.Linear.easeNone, 'property': 'color', 'start': 0x6c91a9, 'finish': 0x99d4ff, 'duration': .25} // properties
                    , null, null, anchor.childNodes[1]);
}
function anchorOut(anchor, stripID) {
    var strip = $get(stripID);
    var actualBounds = Sys.UI.DomElement.getBounds(strip);
    if (anchor["tween"]) {
        anchor["tween"].stop();
        anchor["tween"].dispose();
    }
    if (anchor["tween2"]) {
        anchor["tween2"].stop();
        anchor["tween2"].dispose();
    }
    anchor["tween"] = $create(Pacem.UI.Tween, { 'isCssProperty': true, 'type': Pacem.UI.TweenType.int, 'easingFunc': Pacem.UI.Easing.Sine.easeIn, 'property': 'width', 'unit': Pacem.UI.Unit.pixels, 'start': actualBounds.width, 'finish': 0, 'duration': .5, 'delay': .0 }, null, null, strip);
    anchor["tween2"] = $create(Pacem.UI.Tween, { 'isCssProperty': true, 'type': Pacem.UI.TweenType.color, 'easingFunc': Pacem.UI.Easing.Linear.easeNone, 'property': 'color', 'start': 0x99d4ff, 'finish': 0x6c91a9, 'duration': .5, 'delay': .0 }, null, null, anchor.childNodes[1]);
}
function tween_motionChanged(sender, args) {
    // not implemented...
}