var comments = [{"date": "", "comment": "hi", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjXsgcM", "author": "hi"}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjNqgMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjMqgMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjLqgMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBicsgMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBibsgMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjKqgMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjsqQMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjrqQMM", "author": ""}, {"date": "", "comment": "", "approved": null, "key": "agtlYXN5Y29tbWVudHIPCxIHQ29tbWVudBjqqQMM", "author": ""}];
    if (typeof hcb_user == "undefined") hcb_user = {};
    var pagenum = 0;
    var host = 'www.macmemoryandmore.blogspot.com';
    var hcb = {
      rsp_cb:function(){
        if (!(hcb.rsp && hcb.rsp.success)) {alert("Failed to delete comment.");}
      },
      post:function (strURL,query) {
        var s=document.createElement("script");
        s.setAttribute("type","text/javascript");
        s.setAttribute("src", strURL + "?" + query);
        if (typeof s!="undefined") document.getElementsByTagName("head")[0].appendChild(s);
      },
      load_css: function(filename) {     
        var css = document.createElement('link');
        css.type = 'text/css';
        css.rel = 'stylesheet';
        css.href = filename;
        css.media = 'screen';
        document.getElementsByTagName("head")[0].appendChild(css);
      },
      approve: function(key) {
        comment = hcb.elem('comment_'+key);
        for (i=0; i<comment.childNodes.length;i++) {
          child = comment.childNodes[i];
          if (child && child.className && child.className.indexOf('approval-msg') != -1)
            comment.removeChild(child);
        }
        hcb.post('http://'+host+'/approve', 'key=' + key + '&refer='+window.location);
      },
      del: function(key) {
        hcb.elem('HCB_comment_box').removeChild(hcb.elem('comment_'+key));
        hcb.post('http://'+host+'/delete','key=' + key + '&refer='+window.location);
      },
      elem: function(id) {
        if (document.all) return document.all[id];
        else return document.getElementById(id);
      },
      make_comment_form: function() {
        var form = '<form action="http://'+host+'/post" method="get">';
        // :)
        form += '<p><b></b></p>';
        form += '<input type="hidden" name="page" value="'+window.location+'" />';
        form += '<input type="hidden" name="pf" value="0" /> <input type="hidden" name="mod" value="" />';
        form += '<div><label for="name">' + (hcb_user.name_label || 'Name') + '</label>&nbsp;<input class="text" name="name" type="text" value="" /></div>';
        form += '<div><textarea class="commentbox" name="content" id="HCB_textarea" rows="4" cols="60"></textarea></div>';
        form += '<div><input class="submit" type="submit" value="'+ (hcb_user.submit || 'comment') + '">&nbsp;';
        form += '<span class="home-desc">Powered By </span><a target="_blank" class="link-home" href="http://'+host+'">HTML Comment Box</a></div>';
        form += '</form>';
        form += '<style> a.link-home { font-size:80% !important; opacity:0.4 !important; color:blue !important; display:inline !important; visibility:visible !important;}</style>';
        hcb.elem("HCB_comment_form_box").innerHTML = form;
        
      },
      changepage:function(rel){
        s=document.createElement("script");
        s.setAttribute("type","text/javascript");
        s.setAttribute("src", "ooooooooooooooooooooooooooooooooooooooooooyourhtml"+(pagenum+rel));
        document.getElementsByTagName("head")[0].appendChild(s);
      },
      init:function(){
      
        var html = '<h3>' + (hcb_user.comments_header || 'Comments') + '</h3>';
        html += '<style>a.del{cursor:pointer;color:blue;}</style>';
    
    if (comments.length == 0) {
      html += '<p>No one has commented yet. Be the first!</p>';
    } else {
      for (i = 0;i < comments.length; i++) {
        html += '<div id="comment_' + comments[i].key + '">';
        if (false) html += '<a onclick="hcb.del(\'' + comments[i].key + '\')" class="del">[X]</a>&nbsp;';
        if (!comments[i].approved && 0) html += '<a onclick="hcb.approve(\'' + comments[i].key + '\')" class="del approval-msg">[OK]</a>&nbsp;';
        if (comments[i].date) html += '<span class="date">(' + comments[i].date + ') </span>';
        html += '<span class="author"><b>' + comments[i].author + '</b> said:</span>';
        html += '<blockquote style="overflow:hidden">' + comments[i].comment.replace(/(\S{30})/g,"$1 ") + '</blockquote>';
        if (!comments[i].approved && 0) html += '<p style="opacity:0.6" class="approval-msg">(this comment will not be published until you approve it)</p>';
        html += '</div>';
      }
      html += '<p>  (showing 0 to 9) <a href="#HCB_comment_box" onclick="hcb.changepage(1);">Next Page&gt;</a></p>'; // navigation.
    }
    html += '<div id="HCB_comment_form_box"><a href="javascript:hcb.make_comment_form()"><b>(+) Add your comment</b></a></div>';
        hcb.elem("HCB_comment_box").innerHTML = html;
      }
    };hcb.init();
var utl = {
    elem: function (id) {
        if (document.getElementById) {
            return document.getElementById(id);
        } else {
            return document.all[id];
        }
    },
    remove: function (node) {
        node.parentNode.removeChild(node);
    },

    addListener: function (element, type, expression) {
        if (window.addEventListener) { // Standard
            element.addEventListener(type, expression, true);
            return true;
        } else if (window.attachEvent) { // IE
            element.attachEvent('on' + type, expression);
            return true;
        } else return false;
    }
};

var editit_lite = function (textarea_id,opts) {
    var textarea = utl.elem(textarea_id);
    var iframe;
	opts = opts || {};
		
    function designOn() {
		
        // for compatibility reasons, need to be created this way
        iframe = document.createElement("iframe");
        iframe.frameBorder = 0;
        iframe.frameMargin = 0;
        iframe.framePadding = 0;
        
        iframe.className = textarea.className;
        iframe.id = textarea.id + '_iframe';
        iframe.title = textarea.name;
        textarea.parentNode.insertBefore(iframe, textarea);
        
        designPoll("<html><head><style>body{margin:0;width:100%;height:100%}</style></head><body>" + (textarea.innerHTML || '<br/>') + "</body></html>", function () {
            tb = utl.elem("toolbar_" + textarea.id);
            if (tb) utl.remove(tb);      
            textarea.parentNode.insertBefore(toolbar(), iframe);
            if(textarea.offsetWidth) iframe.style.width = textarea.offsetWidth+'px';
            ts = textarea.style;
            ts.display = 'none';
            iframe.style.borderWidth = ts.borderWidth || '1px';
            iframe.style.borderStyle = ts.borderStyle || 'outset';
            iframe.style.borderColor = ts.borderColor || 'black';
        });

    }
    function designPoll(doc, callback) {
        if (!iframe) {
            return false;
        }
        try {
            iframe.contentWindow.document.open();
            iframe.contentWindow.document.write(doc);
            iframe.contentWindow.document.close();
        } catch(error) {
            console.log(error);
        }
        if (document.contentEditable) {
            iframe.contentWindow.document.designMode = "On";
            callback();
            return true;
        }
        else if (document.designMode != null) {
            //try {
            iframe.contentWindow.document.designMode = "on";
            callback();
            return true;
            //} catch (error) {
            //	console.log(error);
            //}
        }
        setTimeout(function () {
            designPoll(doc, callback)
          },
          500);
        return false;
    }

    function designOff(submit) {
        var content = iframe.contentWindow.document.body.innerHTML;

        if (iframe.style.display != 'none') {
            textarea.innerHTML = content;
        }

        if (submit != true) {
            textarea.style.display = 'inline';
            iframe.style.display = 'none';
        }
    }

    function formatText(command, option) {
        iframe.contentWindow.focus();
        try {
            iframe.contentWindow.document.execCommand(command, false, option);
        } catch(e) {
            console.log(e);
        }
        iframe.contentWindow.focus();
    };

    function toolbar() {
        //return document.createElement("a");
        var tb = {
            bold: {},
            italic: {},
            underline: {},
            insertunorderedlist: {},
            insertorderedlist: {},
            removeformat: {}           
        };

		// if the extended editing options have been allowed...
        if (opts.extended) {
            tb.insertimage = {
                prompt: true
            };
            tb.fontsize = {
                values: ['1', '2', '3', '4', '5', '6']
            };
            tb.fontname = {
                values: ['arial', 'arial black', 'courier', 'courier new', 'comic sans ms', 'cursive', 'impact', 'georgia', 'helvetica', 'lucidia console', 'serif', 'sans-serif', 'monaco', 'monospace', 'palatino linotype', 'tahoma', 'times', 'trebuchet ms', 'verdana']
            };
            tb.forecolor = {
                values: ['black', 'grey', 'red', 'orange', 'yellow', 'green', 'blue', 'violet']
            };
            tb.justifyleft = {};
            tb.justifycenter = {};
            tb.justifyright = {};
		}

		// if links are allowed...
		if (opts.links) {
			tb.createlink = {
                prompt: true
            };
		}
		
        tools = document.createElement("div");
        tools.id = "toolbar_" + textarea.id;
        tools.className = "editit-tb";

        // render the toolbar
        html = "";
        for (k in tb) {
            if (tb[k].values) {
                select = "<select class='toolbar-select' id='sel_" + k + "'>";
                for (i = 0; i < tb[k].values.length; i++) {
                    item = tb[k].values[i];
                    select += "<option value='" + item + "'>" + item + "</option>"
                }
                select += "</select>";
                html += "<a>" + select + "</a>";
            } else {
                html += "<a class='icon' id='btn_" + k + "' title='"+k+"'></a>";
            }
        }
        html += "<br style='display:block;clear:both' />";
        tools.innerHTML = html;

        //TODO: remove remaining jQuery references.
        // toolbar event delegation
        utl.addListener(tools, "click", function (evt) {

            if (!evt.target.id.match(/btn_/)) return true;

            cmd = evt.target.id.replace("btn_", "");
            lastCommand = cmd;
            if (tb[cmd].cmd) { // custom command
                tb[cmd].cmd(evt.target);
            } else if (tb[cmd].prompt) { // command requiring prompt
                var p = prompt("URL:");
                if (p) formatText(cmd, p);
            } else formatText(cmd); // standard command
            return false;
        });

        //  make selection menus work.
        select_elements = tools.getElementsByTagName("select");
        for (i = 0; i < select_elements.length; i++) {
            utl.addListener(select_elements[i], "change", function (evt) {
                formatText(evt.target.id.replace("sel_", ""), evt.target.value);
            });
        }

        // disable design mode when we submit the form.
        form_elements = document.forms;
        for (i = 0; i < form_elements.length; i++) {
            utl.addListener(form_elements[i], "submit", function (evt) {
                designOff(true);
            });
        }

        return tools;
    };

    // enable design mode now
    designOn();

}; //editit_lite
hcb.load_css('your url link to the other url');
hcb.make_comment_form();