function unsafe_value( input )
{
	input = replace( input, '&amp;', '&' );
	input = replace( input, '&gt;', '>' );
	input = replace( input, '&lt;', '<' );
	input = replace( input, '&quot;', '"' );
	input = replace( input, '&#036;', '$' );
	input = replace( input, '&#33;', '!' );
	input = replace( input, '&#39;', "'" );
	input = replace( input, '<BR>', "\n" );
	input = replace( input, '<BR/>', "\n" );

	return input;
}

function safe_value( input )
{
	input = replace( input, '&', '&amp;' );
	input = replace( input, '>', '&gt;' );
	input = replace( input, '<', '&lt;' );
	input = replace( input, '"', '&quot;' );
	input = replace( input, '$', '&#036;' );
	input = replace( input, '!', '&#33;' );
	input = replace( input, "'", '&#39;' );
	input = replace( input, "\n", '<BR/>' );

	return input;
}

function replace (inString,oldText,newText)
{
	return (inString.split(oldText).join(newText));
}

// http://www.krikkit.net/howto_javascript_copy_clipboard.html
function clipboard( txt, auto )
{
	if ( window.clipboardData )  {
		window.clipboardData.setData('Text', txt);
		return true;
	} else if ( window.netscape ) {
		try {
			netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		}
		catch( e ) {
			return false;
		}

		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		trans.addDataFlavor('text/unicode');

		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=txt;

		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*2);

		var clipid=Components.interfaces.nsIClipboard;

		if (! clip ) return false;

		clip.setData(trans,null,clipid.kGlobalClipboard);
		return true;
	}

	return false;
}

/* COOKIES */

/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=05 Jan 2010 00:00:00 GMT" : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function addBookmark(title,url)
{ 
	if (window.sidebar) { 
	window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
	window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
	return true;
	}
}