function find_object(sID){
    if (document.getElementById){
        return document.getElementById(sID);
    }
    else if (document.all){
        return document.all[sID];
    }
    else if (document.layers){
        return document.layers[sID];
    }
    else{
        return null;
    }
}

function ViewImage(imgname){
	var url = virtpath + '_images/get/'+imgname;
	openWindow(url, 'viewimage', 860, 660, "status=yes,toolbar=no,resizable=yes,scrollbars=yes,menubar=no");
}

function freeze_form(frm, buttonsonly){
    if(!frm) return;
    for (var j=0; j< frm.elements.length; j++){
        var el = frm.elements[j];
        if (buttonsonly || isMSIE5){
            if (el.type == 'button' || el.type == 'submit' || el.type == 'reset' || el.type == 'image')
                el.disabled = true;
        }
        else
            el.disabled = true;
    }
    return frm;
}

function formAction(frmForm, vValue){
    frmForm.Action.value = vValue;
    {frmForm.submit();freeze_form(frmForm);}
}
          
function show_hide(objname, vis, type){
    var obj = find_object(objname);
    if(!obj) return;
    if('visibility' == type)
        //alert(obj.style.visibility);
        obj.style.visibility = vis?'visible':'hidden';
    else
        obj.style.display = vis?'block':'none';
    
}

function openDlg(url, name, id, width, height) 
{
    if(isNaN(numID = parseInt(id, 10)))
        numID = id.substring(1, (id.length > 5)?5:id.length);
    // The dialog is resizable & has scrollbars for debug purposes
    return openWindow(url, name + numID, width, height, "status=yes,toolbar=no,resizable=yes,scrollbars=yes,menubar=no");
}

function openWindow(url, name, width, height, features) {
    var win;
    var top = 0;
    var left = 0;
    
    if (screen.width > width) left = (screen.width - width)/2;
    if (screen.height > height) top = (screen.height - height)/2;

    win = window.open(url, name, 'left='+left+',top='+top+', screenX='+left+',screenY='+top+',width='+width+',height='+ height + ((typeof(features) == "undefined")?'':(', ' + features))); 

    /*if (navigator.appName != 'Microsoft Internet Explorer')*/  { if ( window.focus )  win.focus()};
    return win;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


