var SwapImage = Class.create({
 initialize: function(element,new_src){
   old_img=$("top_img");
   new_img = new Element('a',{href:'#'+new_src.url,id:'new_top_img',style:"position:absolute;z-index:2;"});
   new_img.insert(new Element('img',{src:new_src.img,alt:'header image',title:'header image'}));
   new_img.setOpacity(0.001);
   this.swap_image(old_img,new_img);
 },
 swap_image: function(old_img,new_img){
   $('head_img_span').insert(new_img);
   new_img.clonePosition(old_img);
   new_img.fade({from:.001,to:1,afterFinish:function(){
     old_img.select("img")[0].src=new_img.select("img")[0].src;
     old_img.href=new_img.href;
     new_img.remove();
               }.bind(this)});
 }
});
img_num=0;
document.observe('dom:loaded', function() {
	var p=new PeriodicalExecuter(function(p){
	  img_num++;
	  img_num = img_num == head_imgs.length ? 0 : img_num;
	  img_swap=new SwapImage("top_img",head_imgs[img_num]);
	}, 6);
});