﻿/// <reference path="../jsframe.js" />
function MovingEffect(selector)
{
    var parm={curWidth:0,curHeight:0, maxHeight:100,maxWidth:50, increment:5,delay:1,interval:null}      //默认设置
    for(var key in arguments[1]) parm[key]=arguments[1][key];
    var node=$(selector);
    node._parm=parm;
    //垂直方向Maxing
    node.VerMaxing=function()
    {
        var parm=node._parm;
        if(!parm.content) parm.content=node.subElem(".content")[0];
        parm.curHeight+=parm.increment;
        if(parm.curHeight>=parm.maxHeight)
        {
            clearInterval(parm.interval);
            parm.curHeight=parm.maxHeight;
        }
        parm.content.style.height=parm.curHeight+"px";
    }
    //垂直Mining
    node.VerMining=function()
    {
        var parm=node._parm;
        if(!parm.content) parm.content=node.subElem(".content")[0];
        parm.curHeight-=parm.increment;
        if(parm.curHeight<=0)
        {
            clearInterval(parm.interval);
            parm.curHeight=0;
        }
        parm.content.style.height=parm.curHeight+"px";
    }
    
    //水平方向Maxing
    node.HorMaxing=function()
    {
        var parm=node._parm;
        if(!parm.content) parm.content=node.subElem(".content")[0];
        parm.curWidth+=parm.increment;
        if(parm.curWidth>=parm.maxWidth)
        {
            clearInterval(parm.interval);
            parm.curWidth=parm.maxWidth;
        }
        parm.content.style.width=parm.curWidth+"px";
    }
    //水平方向Mining
    node.HorMining=function()
    {
        var parm=node._parm;
        if(!parm.content) parm.content=node.subElem(".content")[0];
        parm.curWidth-=parm.increment;
        if(parm.curWidth<=0)
        {
            clearInterval(parm.interval);
            parm.curWidth=0;
        }
        parm.content.style.width=parm.curWidth+"px";
    }
    
    //水平局中
    node.HorCenter=function()
    {
        var rect=GS.getClientRect();
        var left=(rect.width-node.offsetWidth)/2+document.documentElement.scrollLeft;
        this.style.left=left+"px";
    }
    //垂直局中
    node.VerCenter=function()
    {
        var rect=GS.getClientRect();
        var top=(rect.height-node.offsetHeight)/2+document.documentElement.scrollTop;
        this.style.top=top+"px";
    }
    return node;
}