/*
    JavaScript file with added functionality for dwr.
    
    Created : 21-3-2006, M. Schot
    Updated : $Author: indi $ $Date: 2010/03/09 16:11:59 $
    URL     : $HeadURL: svn://217.77.141.251/workstationContext/Trunk/web/js/dwr_utils.js $
    Revision: $Revision: 1.1.6.3 $
    ID      : $Id: dwr_utils.js,v 1.1.6.3 2010/03/09 16:11:59 indi Exp $
    
    Changes :
    -
*/

function objectEval(text)  {
    // eval() breaks when we use it to get an object using the { a:42, b:'x' }
    // syntax because it thinks that { and } surround a block and not an object
    // So we wrap it in an array and extract the first element to get around
    // this.
    // The regex = [start of line][whitespace]{[stuff]}[whitespace][end of line]
    text = text.replace(/\n/g, ' ');
    text = text.replace(/\r/g, ' ');
    if (text.match(/^\s*\{.*\}\s*$/))
    {
      text = '[' + text + '][0]';
    }
    return eval(text);
}
    
function toggleVisibility(theElem){        
    if(theElem!=undefined && theElem!=null){
        try{
            var visible = theElem.style.display!='none';                
            if(visible){
                if(theElem.display!=undefined){
                    theElem.originalDisplay = theElem.style.display;
                }
                theElem.style.display='none';                    
            }else{
                if(theElem.originalDisplay==undefined){
                    theElem.originalDisplay='block';
                }                    
                theElem.style.display=theElem.originalDisplay;
            }
        }catch(e){alert(e);}
    }
}