function object_exists(obj)
{
    return !(obj == null || typeof(obj) == 'undefined');
}


function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}


function urlwindow(url, title, width, height)
{
    var left = (screen.width - width) / 2;
    var top = (screen.height - height - 80) / 2;
    var win = window.open(url, title, 'width='+width+',height='+height+',resizable=0,scrollbars=1,menubar=0,status=0,location=0,left='+left+',top='+top+',screenX='+left+',screenY='+top );
	win.focus();
}

function FitPic() {
    var NS = (navigator.appName=="Netscape")?true:false;
    iWidth = (NS)?window.innerWidth:document.body.clientWidth;
    iHeight = (NS)?window.innerHeight:document.body.clientHeight;
    iWidth = document.images[0].width - iWidth;
    iHeight = document.images[0].height - iHeight;
    window.resizeBy(iWidth, iHeight);
    //document.getElementById('loading').style.visibility = "hidden";
    self.focus();
};


function submit_default_form()
{
    document.forms[0].submit();
}



function submit_form(name)
{
    document.forms[name].submit();
}



function setTRbackground(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    } else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    } else {
        return false;
    }

    var rowCellsCnt = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
}


function setTRclassName(theRow, className)
{
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    } else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    } else {
        return false;
    }

    var rowCellsCnt = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].className = className;
    }

    return true;
}
