﻿
$(function() {

    $.extend({
        copyHTML: function(a, b) {
            $(b).html($(a).html());
        },  //  Copy HTML from {a} to {b}
        switchVal: function(a, b) {
            var av = $(a).val(); var bv = $(b).val();
            $(b).val(av); $(a).val(bv);
        },   // Switch A with B
        decodeHTML: function(html) {
            return html.replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;nbsp;/g, " ").replace(/\%22/g, " ");
        },
        hasCache: function(key) {
            return $('#cache_' + key).size() > 0;
        },
        setCache: function(key, value) {
            if (!$.hasCache(key)) {
                $('body').append('<textarea id="cache_' + key + '" class="Cache" style="display: none;"></textarea>');
            }
            $('#cache_' + key).val(value);
        },
        getCache: function(key) {
            if ($.hasCache(key)) {
                return $('#cache_' + key).val();
            }   return null;
        },
        removeCache: function(key) {
            if ($.hasCache(key)) {
                $('#cache_' + key).remove();
                return true;
            }   return false;
        }
    });

});

jQuery.copy=function(data){return jQuery.fn.copy.call({},data);};jQuery.fn.copy=function(delimiter){var me=this,flashcopier=(function(fid){return document.getElementById(fid)||(function(){var divnode=document.createElement('div');divnode.id=fid;document.body.appendChild(divnode);return divnode;})();})('_flash_copier'),data=jQuery.map(me,function(bit){return typeof bit==='object'? bit.value||bit.innerHTML.replace(/<.+>/g,''):'';}).join(delimiter||'').replace(/^\s+|\s+$/g,'')||delimiter,divinfo='<embed src="jquery.copy.swf"FlashVars="clipboard='+encodeURIComponent(data)+'"width="0"height="0"'+'type="application/x-shockwave-flash"></embed>';flashcopier.innerHTML=divinfo;return this;};