
function mpfFindObj(n, d)
{
	try {
        var p,i,x;
    	if(!d) {
    		d=document;
    	}
    
    	if((p=n.indexOf("?")) > 0 && parent.frames.length) {
    		d = parent.frames[n.substring(p+1)].document;
    		n = n.substring(0,p);
    	}
    
    	if(!(x = d[n]) && d.all) {
    		x = d.all[n];
    	}
    
    	/* ???for(i=0; !x && i < d.forms.length; i++) {
    		x = d.forms[i][n];
    	}*/
    
    	for(i = 0; !x && d.layers && i < d.layers.length; i++) {
    		x = mpfFindObj(n,d.layers[i].document);
    	}
    
    	if(!x && d.getElementById) {
    		x=d.getElementById(n);
    	}
    	
        return x;
    }
    catch(e) {
    
    }
    return null;
}

function mpfPostCommand(control, cmd, param, trg)
{
  
	if(control.form == null) {
		alert('nullss');
	}
	else {
		var formular = control.form;
		command = mpfFindObj("mpf_command", formular);
		if(cmd.length >0) {
			parameter = mpfFindObj("mpf_parameter", formular);
			if(parameter != null) {
                target = mpfFindObj("mpf_target", formular);
        		if(target != null) {
    				command.value = cmd;
    				parameter.value = param;
    				target.value = trg;
    				formular.submit();
                }
            }
		}
	}
}

function mpfPostCommand2(formular, cmd, param, trg)
{
	command = mpfFindObj("mpf_command", formular);
	if(command != null) {
		parameter = mpfFindObj("mpf_parameter", formular);
		if(parameter != null) {
            target = mpfFindObj("mpf_target", formular);
    		if(target != null) {
				command.value = cmd;
				parameter.value = param;
				target.value = trg;
				formular.submit();
            }
        }
	}
}

function mpfPostCommandCN(control_name, cmd, param, trg)
{

	control = mpfFindObj(control_name);
	if(control != null) {
        mpfPostCommand(control, cmd, param, trg);
	}
	else {
        alert('NULL');
	}
}

