function callMethod(target,method,formNM)
	{
	$('body').addClass("loading");

	if (formNM=="")
		{
		AjaxRequest.get(
		  {
		    'method':'POST'
		    ,'ab_target_id': target
		    ,'url': method
		    ,'generateUniqueUrl':true
		    ,'onSuccess':function(req)
					{
						document.getElementById(target).innerHTML = req.responseText;
						attachJS(req.responseText, target);
						$('body').removeClass("loading");
						bodyLoad();
					}
				,'onError':function(req)
					{
						document.getElementById(target).innerHTML = req.responseText;
					}
		  }
		);


		}
	else
		{
			originalFormAction = formNM.action;

			addField(formNM, "hidden", "ab_target_id", target);
			
			formNM.action = method;
	
			formNM.method = "POST";
		  var status = AjaxRequest.submit(
		    formNM
		    ,{
		      'onSuccess':function(req)
						{
						document.getElementById(target).innerHTML = req.responseText;
						attachJS(req.responseText, target);
						$('body').removeClass("loading");
						bodyLoad();
						}
		      ,'onError':function(req)
						{
							document.getElementById(target).innerHTML = req.responseText;
						}
		    }
			);

			formNM.action = originalFormAction;



		}

	}


function addField (form, fieldType, fieldName, fieldValue) {
  if (document.getElementById) {
    var input = document.createElement('INPUT');
      if (document.all) { // what follows should work 
                          // with NN6 but doesn't in M14
        input.type = fieldType;
        input.name = fieldName;
        input.value = fieldValue;
      }
      else if (document.getElementById) { // so here is the
                                          // NN6 workaround
        input.setAttribute('type', fieldType);
        input.setAttribute('name', fieldName);
        input.setAttribute('value', fieldValue);
      }

	    form.appendChild(input);
  }
}

function attachJS(src, target)
	{
    // Extract the SCRIPT elements from the sniplet.
		sniplet = src;
    sniplet = sniplet.replace(/[\n\r]/g," ");
    sniplet = sniplet.replace(/<\/script>/g,"<\/script>\n"); 
    var matches = sniplet.match(/<script>.*<\/script>/g); 

    // Execute the SCRIPT elements' contents.
		try
			{
	    for(var i = 0; i < matches.length; i++) 
	      {
	        var script = matches[i].replace(/<script>(.*)<\/script>/g,"$1"); 
	        try
	        	{
						eval(script);
						}
					catch(e)
						{
						alert(e+"\n"+e.description+"\n===============================\n"+src+"\n===============================\n"+target);
						} 
	      }
			}
		catch(e)
			{
			}

		try
			{
			document.getElementById(target).onLoad();
			}
		catch(e)
			{
//			alert("no onload action specified for "+target);
			}
		}
