//###############################################################################
//##                                                                           ##
//##  (c) Think Big Publications, LLC ("Think Big"), August 2009.              ## 
//##                                                                           ##
//##  Duplication, selling, or transferring of this script is a violation of   ##
//##  the copyright and purchase agreement. Alteration of this script in any   ##
//##  way voids any responsibility Think Big has toward the functioning of     ##
//##  the script. Altering the script in an attempt to unlock other functions  ##
//##  of the program that have not been purchased is forbidden by Think Big    ##
//##  and is a violation of the purchase agreement. By modifying/running this  ##
//##  script, you agree to Think Big's terms and conditions located at         ##
//##  www.thinkbighq.com/software.html.                                        ##
//##                                                                           ##
//##  For support requests, bugs, suggestions or custom development, please    ##
//##  submit a ticket at www.thinkbigpublications.com/support.                 ##
//##                                                                           ##
//###############################################################################
//
// To use toggleSource(), simply put this line in your code after the BODY tag.   
// <script type="text/javascript" src="togglesource.js"></script>                 
//                                                                                
// The script clones the source DIV as a textarea in the destination DIV.         
//                                                                                
// toggleSource() parameters:                                                     
// divIn is a DIV containing the source HTML to clone as a textarea.              
// divOut is a DIV to hold the textarea HTML output.                              
                                                                                
function toggleSource(divIn,divOut)
{
if (!divIn || !divOut) return;
if (document.getElementById(divOut).innerHTML == "")
  document.getElementById(divOut).innerHTML="<textarea>" + replaceSpecialChars(document.getElementById(divIn).innerHTML) + "<\/textarea>";
else
  document.getElementById(divOut).innerHTML="";
}
function replaceSpecialChars(str)
{
    var out = "";
    for (i=0; i<str.length; i++)
    {
        switch (str[i])
        {
            case "©": out += "&amp;copy;"; break;
            default:  out += str[i]; break;
        }
    }
    return out;
}
