
    var textAreaArray = new Array();

    $(document).ready(function($) {
        setInterval( doAutoSizeTextAreas, 300 );
    });
    
    function setAutoSize( textAreaId )
    {
        for( var i=0;i<textAreaArray.length;i++ )
        {
            if( textAreaArray[i] == textAreaId )
                return;
        }
        
        textAreaArray.push( textAreaId );
    }

    function doAutoSizeTextAreas()
    {
        for( var i=0;i<textAreaArray.length;i++ )
            autoSizeTextArea( textAreaArray[i] );
    }

    function autoSizeAllTextAreas()
    {
    	var tas = document.getElementsByTagName( 'textarea' );
    	
    	for( var i=0;i<tas.length;i++ )
    	{
    		autoSizeTextAreaElement( tas[i] );
    	}
    }

    function autoSizeTextAreaElement( ta )
    {
        if( ta == null )
            return;

        if( ta.value=='' || ta.scrollHeight == ta.clientHeight )
         	return;
        
        var count=0;
        
        while( ta.scrollHeight > ta.clientHeight && count < 30 )
        {
        	ta.rows = ta.rows + 1;
        	count++;
        }
        
        // ta.rows = countLines( ta.value, ta.cols, textAreaObj.defaultRows );
    }
    
    function autoSizeTextArea( textAreaId )
    {
        var a = document.getElementsByName( textAreaId );

        if( a.length == 0 )
            return;
        
        var ta = a[0];

        autoSizeTextAreaElement( ta );        
    }

    /*
    function countLines(strtocount, cols, defaultRows ) 
    {
        if( typeof strtocount == 'undefined' || strtocount==null )
            return defaultRows;
        
        var hard_lines = 1;
        var last = 0;
        while ( true ) 
        {
            last = strtocount.indexOf("\n", last+1);
            
            hard_lines ++;

            if ( last == -1 ) 
                break;
        }
        var soft_lines = Math.round(strtocount.length / (cols-1));
        var hard = eval("hard_lines  " + unescape("%3e") + "soft_lines;");
        if ( hard ) soft_lines = hard_lines;
        return soft_lines < defaultRows ? defaultRows : soft_lines;
    }
    */
