Всё сам решил проблему... Кому интересно вот так:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<style>
img{
border: 0;
}
</style>
<script type="text/javascript" language="Javascript" src="main.js"></script>
<title>page</title>
</head>
<a href="#" class="imagelink"><img src="images/auction.png"></a>
<a href="#" class="imagelink"><img src="images/clickbank.png"></a>
<a href="#" class="imagelink"><img src="images/electronics.png"></a>
<a href="#" class="imagelink"><img src="images/magazines.png"></a>
<a href="#" class="imagelink"><img src="images/music.png"></a>
<a href="#" class="imagelink"><img src="images/news.png"></a>
<a href="#" class="imagelink"><img src="images/shopping.png"></a>
<a href="#" class="imagelink"><img src="images/video.png"></a>
<a href="#" class="imagelink"><img src="images/web-pages.png"></a>
</html>
main.js:
window.onload = getLinks;
var allTags = new Array();
function getLinks(){
var allTags = document.getElementsByTagName("*");
var classAr = new Array();
for(var i=0; i<allTags.length; i++){
if(allTags[i].className == 'imagelink'){
classAr.push(allTags[i]);
}
}
return rest(classAr)
}
function rest(arr){
var child = new Array();
for(var i = 0; i<arr.length; i++){
child.push(arr[i].childNodes[0].src);
var link = arr[i].childNodes[0].src;
arr[i].onclick = function(){
var link = this.childNodes[0].src;
for(var j=0; j<arr.length; j++){
var link2 = arr[j].childNodes[0].src;
if(link2.slice(link2.length - 5, link2.length - 4) == '2'){
var first = link2.slice(0, link2.length - 5);
var second = link2.slice(link2.length - 4);
arr[j].childNodes[0].src = first + second;
}
else{
if(link2 == link){
var type = link.slice(link.length - 4);
var elsee = link.slice(0, link.length - 4);
arr[j].childNodes[0].src = elsee + '2' + type;
}
}
}
return false;
}
}
return false;
}