

function $(el)
{

    if(typeof(el) == "string")      
         return document.getElementById(el);
    else
        return el;
}
  
var repositionDiv = {
    div : null,
    obj : null,
    btnOffset : null,
    init : function (obj,div)
    {
   
       this.div = $(div);
       this.obj = $(obj);
       this.btnOffset = getOffset(this.obj);
       this.width = this.obj.clientWidth;
       this.height = this.obj.clientHeight;
       this.proccess();
  
    },
    proccess : function()
    {
    
        this.div.style.display = "block";
        this.div.style.top =  this.btnOffset["y"] + this.height  + "px";
        this.div.style.left = this.btnOffset["x"] + "px";
        var Height = this.div.clientHeight;
       
        var start = new Array;
        start[0] = this.btnOffset["y"] + this.height - 10;
        start[1] = 0;
        start[2] = 0;
        var end = new Array;
        end[0] = this.btnOffset["y"] + this.height;
        end[1] = Height;
        end[2] = 100;
        this.div.style.overflow = "hidden";
        
        //animEffect.animInit(start,end,this.div,this.callback,.3,this.callbackEnd);
        //this.div.style.top = this.btnOffset["y"] + this.height + "px";
        //this.div.style.left = this.btnOffset["x"] + this.width + "px";
        
        //animEffect
    },
    open:function()
    {
    },
    close:function()
    {
    },
    callback : function(obj,v)
    {
        obj.style.top = v[0] + "px";
        obj.style.height = v[1] + "px";
        obj.style.opacity = v[2]/100;
        obj.style.filter = "alpha(opacity ="+v[2]+")";

    },
    callbackEnd : function(obj)
    {
        obj.style.height = "auto";
        obj.style.overflow = "visible";
    }
}

function getOffset(el)
{
 var x;
 var y ;
    el = $(el);
    if (el.offsetParent && el) 
    {
         x = el.offsetLeft;
        
         y = el.offsetTop;
        while (el.offsetParent) 
        {
            el = el.offsetParent;
            x += el.offsetLeft;
            y += el.offsetTop;            
        }
    }
    else
    {
        x = el.offsetLeft;
        y = el.offsetTop;      
    } 
    
    var returnOffset = new Array();
    returnOffset['x'] = x;
    returnOffset['y'] = y;
    return returnOffset;
}
function dragme(div,event,mask)
{
    var _dragDiv = null;
    var _mask = $(mask);
    var ie=document.all;
    var nn6=document.getElementById&&!document.all;
    var x,y;
    dragStart();
    function dragStart()
    {
         _dragDiv = $(div); 
         
        if (event == null) event = window.event       
            var target = event.target != null ? event.target : event.srcElement;  
      
        //slide has begun!        
        tx = parseInt(_dragDiv.style.left);
        ty = parseInt(_dragDiv.style.top);
        x = event.clientX;
        y = event.clientY;  
        
        document.onmousemove = mousemove;     
        
        document.body.focus();  
        //firefox image drag fix thingie
        if(event.preventDefault)
         {
          event.preventDefault();
         }
        document.onselectstart = function () { return false; };       
        target.ondragstart = function() { return false; }; 
        return false;        
    }
    
    function mousemove(event)
    {
        if (event == null) event = window.event;
         var target = event.target != null ? event.target : event.srcElement;  
        if(_mask)
        {
            var locusX = tx + event.clientX - x;       
            var locusY = ty + event.clientY - y ;  
            _dragDiv.style.left = locusX  + "px";
            _dragDiv.style.top  = locusY  + "px"; 
            if(target != mask && mask.className == "zoomIn2")
                QViewPopUp.HidePopUp();     
        }
        else
        {
            var locusX = tx + event.clientX - x;       
            var locusY = ty + event.clientY - y ;  
            _dragDiv.style.left = locusX  + "px";
            _dragDiv.style.top  = locusY  + "px"; 
        } 
    }
    
    document.onmouseup = function()
    {
        if(_dragDiv)
        { 
            _dragDiv.style.cursor = "";
            document.onmousemove = null;
            _dragDiv.ondragstart = null; 
            _dragDiv = null;
            document.onselectstart = null;  
        };
    }

}
function cleardrag()
{
    document.onmousemove = null;
}

//animation function
var animConst = function() {};
animConst.prototype =   {
    fps : 33,
    z : null,
    interval : null,
    a : null,
    delta : null,
    t : null,
    obj : null,            
    animInit: function(start,end,obj,callback,t,callbackEnd)
    {    
        this.t = Math.round(t * this.fps);
        this.interval = 0;
        this.delta = new Array;
        this.a = 100/(this.t*this.t);        
        this.start = start;
        this.end = end;
        this.obj = obj;
        this.callback = callback;
        this.callbackEnd = callbackEnd;
        var startLength = this.start.length;
        for(var i =0;i < startLength;i++)
        {   
            this.delta[i] = end[i] - start[i];
        }
        var animObj = this;  
        this.z = window.setInterval(function(){animObj.doCalc()}, animObj.fps);
    },
    doCalc : function()
    {
        var returnValue = new Array;
        this.interval += 1;
        var ratio = this.a * this.interval * this.interval;
        var start = this.start;
        var delta = this.delta;
        
        var startLength = this.start.length;    
         
        for(var i =0;i < startLength;i++)
        {
            returnValue[i] = start[i] + Math.round(ratio * delta[i]/100);
        }       
         
        this.callback(this.obj,returnValue);         
        if(this.interval >= this.t)
        {        
            if(this.callbackEnd)
                this.callbackEnd(this.obj);
            this.clear();
            return false;
        }
    },
    callback : function(){},
    callbackEnd : function(){},
    clear : function()
    {      
        if(this.z)
        {   
            this.interval = null,
            window.clearInterval(this.z);
            this.z = null;     
        }
        return false;
    },
    destroy : function()
    {
        delete this;
    }
};
var animEffect = new animConst();
var pizza = {
    
}
