function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Non è stato possibile impostare un gestore di eventi");
  }
}
//addEvent(window,'load',function (){swapMenu.init()},false);
addEvent(window,'load',initGall,false);

function initGall(){
		if (document.getElementById('prod-spalla')) {
		var apics=document.getElementById('prod-spalla').getElementsByTagName('a');
		for (i=0;i<apics.length;i++){
			apics[i].id="gd-"+i;
			//apics[i].onclick=new Function( "drawGall('" + apics[i].id + "');return false;");
			
		}
		$("#prod-spalla a").click( function() {
			drawGall(this.id);
			return false;
		} );
	}
}

function drawGall(id){
var cpic=document.getElementById("ctesto-2");
var thepics=cpic.getElementsByTagName("img");
var thepic=thepics[0];
thepic.setAttribute("id","pic-change");
if(thepic.src!=document.getElementById(id).href){
	$("#pic-change").fadeTo("slow", 0, function(){ 
	  thepic.onload=function(){$("#pic-change").fadeTo("slow", 1);}
	  thepic.src=document.getElementById(id).href;
	  	});
}
else{return false}
}