var previewWindow = null;
var previewElem = null;
function GCMGlobalOnload()
{
    initDHTMLAPI();
    if(top.location != self.location) top.location = self.location;
    GCMLocalOnload();
}
function GCMLocalOnload()
{
}
function GCMGlobalOnunload()
{
    GCMLocalOnunload();
}
function GCMLocalOnunload()
{
}
function Trim(str)
{
	if(str.replace(/\s+/i, "") == "")
	{
		return "";
	}
	else
	{
		var re = /^(\s*)([\W\w]*)(\b\s*$)/;
		if(re.test(str))
		{
			return str.replace(re, '$2');
		}
		else
		{
			return str;
		}
	}
}
function RoundNumber(num, dLen)
{
    return Math.round(num*Math.pow(10,dLen))/Math.pow(10,dLen);
}
function IsInt(val)
{
    if(isNaN(val)) return false;
    var re = /^\d+$/;
    return val.match(re);
}
function Preview(elemId)
{
    previewElem = getRawObject(elemId);
    previewWindow = window.open("./preview.aspx", "PreviewWindow");
    previewWindow.focus();
}
function DirectPreview(elemId)
{
    var elem = getRawObject(elemId);
    if(Trim(elem.value) == "")
    {
        alert("Please enter a value before attempting the preview.");
        elem.focus();
    }
    else
    {
        window.open(elem.value);
    }
}
function SwapImage(i)
{
    var re = /Rollover/;
    if(i.src.match(re))
    {
        i.src = i.src.replace(re, "");
    }
    else
    {
        i.src = i.src.replace(/\.gif/, "Rollover.gif");
    }
}
