// JavaScript Document
	/*var gallery = new Array();
	var gallery_copy=new Array();
	load();
	function load(){
	gallery.push("images/gallery/1.jpg");
	gallery.push("images/gallery/2.jpg");
	gallery.push("images/gallery/3.jpg");
	gallery.push("images/gallery/4.jpg");
	gallery.push("images/gallery/5.jpg");	
	gallery.push("images/gallery/6.jpg");
	gallery.push("images/gallery/7.jpg");	
	
	gallery_copy.push("images/gallery/1.jpg");
	gallery_copy.push("images/gallery/2.jpg");
	gallery_copy.push("images/gallery/3.jpg");
	gallery_copy.push("images/gallery/4.jpg");
	gallery_copy.push("images/gallery/5.jpg");	
	gallery_copy.push("images/gallery/6.jpg");
	gallery_copy.push("images/gallery/7.jpg");	
	}*/
	function refreshImg(idimage){
		var elem;
	//	alert('image '+idimage);
	//	alert('GAALLENGHT '+gallery.length);
	//	alert('GAALcopylENGHT '+gallery_copy.length);
		elem=prendiElementoDaId(idimage);
		//alert(elem);
		opacity(idimage, 100, 0, 2000);
		setTimeout('refreshImgSub1("'+idimage+'")', 3000);
	}
	function refreshImgSub1(idimage, elem){
		var elem;
		var elem_a;
		elem=prendiElementoDaId(idimage);
		elem_a=prendiElementoDaId('a'+idimage);

		if(gallery.length<1)
		{
		gallery=gallery_copy.slice(0);
		gallery_links=gallery_copy_links.slice(0);
		//alert (gallery);
		}
		acaso=Math.floor(Math.random()*gallery.length);
		elem.src= gallery.splice(acaso,1);
		var prescelto=gallery_links.splice(acaso,1);
		
		if(prescelto!= ''){
			elem_a.href=prescelto;
           // elem_a.onclick = false;
            elem_a.onclick =  "";
            elem_a.target="_ope_gallery";
            elem_a.className = 'click';

			}
		else
            {
			elem_a.href="#";
			//elem_a.onclick = false;
            elem_a.onclick =  "javascript:void(0)";
            elem_a.target="_self";
            elem_a.className = 'null_click';
			}
		opacity(idimage, 0, 100, 2000);
		timerID = setTimeout("refreshImg('"+idimage+"')", 4000+(Math.floor(Math.random()*10000)));
	}
	
function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
   // var speed = Math.round(millisec / 800) + (millisec*7 / 800); 
    var speed = (millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

