function getObj( name ){
    var el = new Object;
    if ( document.getElementById){
        el.obj      = document.getElementById( name );
        el.style    = document.getElementById( name ).style;
    }else if( document.all ){
        el.obj      = document.all[name];
        el.style    = document.all[name].style;
    }else if( document.layers ){
        el.obj      = document.layers[name];
        el.style    = document.layers[name];
    }
    return el;
}

/**
*   Simple function for several browsers
*   to get y axis offset
*/
function getScrollXY() {
    var scrOfY = 0;
    if ( typeof( window.pageYOffset ) == 'number' ){
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    }else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ){
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    }else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ){
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    return scrOfY;
}

/**
*   Function to set position for sliding element
*   @param string element id 
*	@param additional_height
*   @param int delay in milliseconds of function calling
*/
function setPosition( element_id, additional_height, delay ){

    var obj = getObj( element_id );
    var sh  = getScrollXY( );
    var dh  = document.getElementById( element_id ).offsetHeight+additional_height;
    
    sh <= dh ? ch = 0 : ch = (sh - dh);
    
    var oldch = parseInt( obj.style.top );
	
    obj.style.position = 'relative';
	//alert(obj.style.left);
	
    
    if( ch != oldch ){
        if( ch > oldch ){
            oldch = oldch + Math.round( ( ch - oldch ) / 2 );
        }else if( ch < oldch ){
            oldch = oldch - Math.round( ( oldch - ch ) / 2 );
        }
        
        if( Math.abs( ch - oldch ) <= 1 ){
            oldch = ch;
        }
        obj.style.top = oldch+"px";
        setTimeout( "setPosition('"+element_id+"', "+additional_height+",  '"+delay+"')", delay);
    }else{
        setTimeout( "setPosition('"+element_id+"', "+additional_height+", '"+delay+"')", delay);
    }
}

/**
 * Function to perform banner sliding from top to bottom
 * @param container id -  container
 * @param banner div id -  banner
 * @param int additional_height
 * @param int delay
 */
function slideBanner( container, banner, additional_height, delay ){
    if( !document.getElementById )  return false;
    var container_div = document.getElementById( container );
    var banner_div = document.getElementById( banner );
    if( container_div && banner_div ){
        banner_div.style.top = "0px";
        banner_div.style.height = container_div.offsetHeight+"px";
        setPosition( banner, additional_height, delay );
    }
}
