Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
Prototype.Browser.IE7 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7;
Prototype.Browser.IE8 = Prototype.Browser.IE && !Prototype.Browser.IE6 && !Prototype.Browser.IE7;

function ToggleVisibility(id)
{
    var element = document.getElementById(id);
    if (element)
    {
        if (element.style.display == 'none')
        {
            element.style.display = '';
        }
        else
        {
            element.style.display = 'none';
        }
    }
}


function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function popup(sURL, iWidth, iHeight, iX, iY, scrollBars) {

    if (!scrollBars)
    {
        scrollBars = "0";
    }
    var mywindow = window.open ("" + sURL + "", "mywindow","menubar=1,location=1,status=1,scrollbars=" + scrollBars + ", width=" + iWidth + ",height=" + iHeight + "");
    mywindow.moveTo(iX,iY);
    mywindow.focus();
} 

function popupClone(sURL, iWidth, iHeight, iX, iY, scrollBars) {

    if (!scrollBars)
    {
        scrollBars = "0";
    }
    var myCloneWindow = window.open ("" + sURL + "", "mywindow","resizable=1,menubar=1,location=1,status=1,scrollbars=" + scrollBars + ", width=" + iWidth + ",height=" + iHeight + "");
    myCloneWindow.moveTo(iX,iY);
    myCloneWindow.focus();
} 

function copyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
	else
	{
		// You have to sign the code to enable this or allow the action in about:config by changing
		// user_pref("signed.applets.codebase_principal_support", true);
		// netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

		var clip = Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		// create a transferable
		var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		// specify the data we wish to handle. Plaintext in this case.
		trans.addDataFlavor('text/unicode');

		// To get the data from the transferable we need two new objects
		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=meintext;

		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);	   
	}
}
