Firsly I would agree with Shyam and also install Firebug for Firefox; this will be a huge help for javascript debugging.
anyway, the line
xmlHttp.onreadystatechange = FetchComplete(layername);
will assign the result of FetchComplete(layername) to xmlHttp.onreadystatechange, which isn't what you want. It would need to be
xmlHttp.onreadystatechange = FetchComplete;
But then you have the problem of passing layername.
If you define the onreadystatechange as an anonymous inner function you can easily use variables defined outside it, so you could do something like this:
function GetAuctionData(pk) {
var xmlHttp=GetXmlHttpObject();
var layer = "Layer2";
if(xmlHttp==null) {
alert("Your browser is not supported?");
}
var url="get_auction.php?";
url=url+"cmd=GetAuctionData&pk="+pk;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById(layer).innerHTML=xmlHttp.responseText
} else if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading") {
document.getElementById(layer).innerHTML="loading"
}
};
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
layer is defined as a local variable in GetAuctionData() but is accessible in the anonymous function, because you are creating a Closure. Note that I haven't tested the above function, but it should work in principle.