﻿// GrowBag
//=========
// Copyright 2008 - Netalogue Technologies plc

    var x, y, tID, h, sx, sy
    var outer = ''
    var inner = ''
    var list = ''
       
    function growBag(i,o,l,d) {
        shrink()
        
        x = 0
        y = 0
        inner = i
        outer = o
        list = l
        
        obj = $get(outer)  
        obj.style.pixelLeft = $get(inner).offsetLeft
        h = $get(inner).offsetHeight
        w = $get(inner).offsetWidth
        sx = w / 10
        sy = h / 10
        obj.style.width = '0px'
        obj.style.height = '0px'        
        obj.style.visibility='visible'
        $get(inner).style.visibility='hidden'
        
        tID = setInterval('grow('+d.toString()+')', 20)
    }
    
    function grow(d) {
        x += sx
        y += sy
        
        if (y>=h) {
            clearInterval(tID)
            $get(outer).style.visibility='hidden'
            $get(inner).style.visibility='visible'
            $get(list).style.display=''
        } else {            
            obj = $get(outer)  
            obj.style.width = '' + x +'px'
            obj.style.height = '' + y +'px'
            
            if(d==-1) obj.style.top = '' + (0-y) +'px'
        }
    }
    
    function shrink() {
        clearInterval(tID)
        obj = $get(inner)
        if (obj) obj.style.visibility='hidden';
    }
    
    function waittwoseconds(){
        obj = $get(outer);
        obj.style.visibility='hidden';
        clearInterval(tID);
        tID = setInterval('shrink()', 500);
    }
