var CTA = Class.create();

CTA.prototype = {

initialize : function(element){
	
	this.element = $(element);
	this.alinks = $A(this.element.getElementsByTagName('a'));
	this.alinks.each(this.setupThumb.bind(this));
},
setupThumb : function(elm){
	Event.observe(elm,'mouseover',this.activate.bindAsEventListener(this),false);
	Event.observe(elm,'mouseout',this.activate.bindAsEventListener(this),false);
},

activate : function(ev){
	var elm = Event.findElement(ev,"a");
	var target = this.targetFunction(elm);
	  if($(target).hasClassName('current')){
	this.out(target);
	  } else {
		
	this.over(target);	  
	  }
	Event.stop(ev);
},

over : function(elm){
	
	$(elm).addClassName("current");
},
out : function(elm){
	$(elm).removeClassName("current");
},

targetFunction : function(elm) {
	
   // return $(elm).src.replace(/(.*)\.(jpg|gif|png)$/i, "$1_over.$2");
   	if($(elm).id.search(/link/) > -1){
	tab = $(elm).id.replace(/link/, "tab");
	} else {
	tab = $(elm).id.replace(/pic/, "tab");
	}
	return tab;
	
	
  }
}

