I'm not sure if I understand, so take this with a pinch of salt
But basically the swapimage function allows lots of arguments to be passed at once and tries to swap all the srcs of the images.
findObj seems to go through browser checks and tries to find the object and then returns it to the swapImage function
Code:
function MM_swapImage() { //v3.0
var i, j=0, x, //Initiating variables (Making them available for this function only as initiated with var)
a=MM_swapImage.arguments; //Even the the brackets () are empty, arguments can still be passed to this function. they are stored in variable a.
document.MM_sr=new Array; //create new array named MM_sr (As a child of the document)
for(i=0;i<(a.length-2);i+=3) //for all arguments passed -2,
if ((x=MM_findObj(a[i]))!=null) //if the object exists
{
document.MM_sr[j++]=x; //add it to the array
if(!x.oSrc) x.oSrc=x.src; //if the object doesn't have an attribute oSrc, make oSrc = the current src
x.src=a[i+2]; //the source = array element [i+2]
}
}
which calls
function MM_findObj(n, d) { //v4.01
var p,i,x; //Local variables
if(!d) d=document; //store document in the varible d, if not already there
if((p=n.indexOf("?"))>0&&parent.frames.length) { //If ? is there (I'm guessing query string) and frames
d=parent.frames[n.substring(p+1)].document; //d = this frames document?
n=n.substring(0,p);} // n = the string up to p
if(!(x=d[n])&&d.all) x=d.all[n];//if not x is an object and the document allows document.all (Old IE versions), x = the object
for (i=0;!x&&i<d.forms.length;i++) // when x is not found and i is then than the number of forms
x=d.forms[i][n]; //x = the forms object
for(i=0;!x&&d.layers&&i<d.layers.length;i++)// for all layers (Netscape browsers) x=MM_findObj(n,d.layers[i].document); //find x in layers
if(!x && d.getElementById) x=d.getElementById(n);// if get element by id, get x (New browsers)
return x; //obvious
}
Bookmarks