var expressive = {
   showScriptTagsInContainer: function() {
      var script_text = document.getElementById('container1').innerHTML;
      script_text = script_text.escapeHTML();
      script_text = script_text.replace(/\n/g,'<br/>');
      script_text = script_text.replace(/ /g,'&nbsp;');
      document.getElementById('container2').innerHTML = script_text;
   },
   
    showHideComments: function() {
        var display = (document.getElementById('showHideComments').checked) ? '' : 'none';
        //try {
        var collection = $$('.sh_javascript');
        for (var i=0; i<collection.length;i++) {
            collection[i].style.display = display;
        }
        
        var collection2 = $$('.sh_comment');
        for (var j=0; j<collection.length;j++) {
            collection2[j].style.display = display;
        }
        
    },
   
    showAllComments: function() {
        var comments = validanguage.getComments();
        for (var l=0;l<comments.length;l++){
            var commentText = comments[l].nodeValue;
            if (commentText.indexOf('validanguage')==-1) continue;
            commentText = '<!-- ' + commentText + ' -->';
            var origComment = commentText;
            commentText = commentText.escapeHTML();
            commentText = commentText.replace(/\n/g,'<br/>');
            commentText = commentText.replace(/ /g,'&nbsp;');
         
            //try/catch for IE
            try {
                if (comments[l].previousSibling.nodeName.toLowerCase() == 'div') {
                    comments[l].previousSibling.innerHTML = commentText;
                }
                else {
                    comments[l].previousSibling.nodeValue = origComment;
                }
            } 
            catch (e) { }
        }
        
        // Now hide them
        if (document.getElementById('showHideComments')) {
            document.getElementById('showHideComments').checked = false;
            expressive.showHideComments();
        }
        
    },
      
   getComments: function(el) {
   //fetches all comment nodes in the passed form node and returns them in a node list
    if (!el) el = document.documentElement;
    var comments = new Array();
    
    for (var c = 0; c < el.childNodes.length; c++) {
        if (el.childNodes[c].nodeType == 8)
            comments[comments.length] = el.childNodes[c];
        else if (el.childNodes[c].nodeType == 1)
            comments = comments.concat(this.getComments(el.childNodes[c]));
    }
    return comments;
   }
   
   
};


