/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object   the table row
 * @param   string   the action calling this script (over, out or click)
 * @param   string   the default background color
 * @param   string   the color to use for mouseover
 * @param   string   the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */




	var rDiv = "";
	var rDiv1 = "";
	
	var fadeQueue = new Array(), RGB = new Array(256), k = 0, hex = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
	for (var i = 0; i < 16; i++) for (var j = 0; j < 16; j++) RGB[k++] = hex[i] + hex[j];
	
	function queueFade (tagid, direction, startRGB, endRGB, duration) {
	  if (fadeQueue.length == 0) fadeExtra(tagid, direction, 1);
	  for (var x = fadeQueue.length - 1; x >= 0; x--) {
		if (fadeQueue[x][0] == tagid) {
		  if (fadeQueue[x][1] != direction) {
			fadeQueue[fadeQueue.length] = [tagid, direction, startRGB, endRGB, duration];
			return false;
		  } else return false;
		}
	  }
	  fadeQueue[fadeQueue.length] = [tagid, direction, startRGB, endRGB, duration];
	  setTimeout("fade('" + tagid + "','" + startRGB + "'," + parseInt(startRGB.substr(1).substr(0, 2), 16) + "," + parseInt(startRGB.substr(1).substr(2, 2), 16) + "," + parseInt(startRGB.substr(1).substr(4, 2), 16) + ",'" + endRGB + "'," + (duration / 20) + ");", 100);
	}
	
	function queueCheck (tagid) {
	  var firstFade = true, firstKey = -1, secondFade = true, secondKey = 0, compileQueue = new Array();
	  for (var x = 0; x < fadeQueue.length; x++) {
		if (fadeQueue[x][0] == tagid) {
		  if (firstFade) {
			firstKey = x; firstFade = false;
		  } else if (secondFade) {
			secondKey = x; secondFade = false;
		  } else if (!secondFade) secondFade = true;
		} else compileQueue[compileQueue.length] = fadeQueue[x];
	  }
	  fadeExtra(tagid, fadeQueue[firstKey][1], 0);
	  if (!secondFade) {
		compileQueue[compileQueue.length] = fadeQueue[secondKey];
		fadeExtra(tagid, fadeQueue[secondKey][1], 1);
		setTimeout("fade('" + tagid + "','" + fadeQueue[secondKey][2] + "'," + parseInt(fadeQueue[secondKey][2].substr(1).substr(0, 2), 16) + "," + parseInt(fadeQueue[secondKey][2].substr(1).substr(2, 2), 16) + "," + parseInt(fadeQueue[secondKey][2].substr(1).substr(4, 2), 16) + ",'" + fadeQueue[secondKey][3] + "'," + (fadeQueue[secondKey][4] / 20) + ");", 0);
	  }
	  fadeQueue = compileQueue;
	}
	
	function fade(tagid, startRGB, r, g, b, endRGB, slices) {
	  incRGB = [r, g, b];
	  for (var x = 0; x < 3; x++) {
		var colRGB = parseInt(endRGB.substr(1).substr(x * 2, 2), 16);
		var incr = (colRGB - parseInt(startRGB.substr(1).substr(x * 2, 2), 16)) / slices;
		incRGB[x] = (incr < 0) ? Math.max(incRGB[x] + incr, colRGB) : Math.min(incRGB[x] + incr, colRGB);
	  }
	  if (incRGB[0] == parseInt(endRGB.substr(1).substr(0, 2), 16) &&
		  incRGB[1] == parseInt(endRGB.substr(1).substr(2, 2), 16) &&
		  incRGB[2] == parseInt(endRGB.substr(1).substr(4, 2), 16)) {
		document.getElementById(tagid).style.color = endRGB;
		setTimeout("queueCheck('" + tagid + "');", 0);
		return false;
	  }
	  document.getElementById(tagid).style.color = "#" + RGB[parseInt(incRGB[0])] + RGB[parseInt(incRGB[1])] + RGB[parseInt(incRGB[2])];
	  setTimeout("fade('" + tagid + "','" + startRGB + "'," + incRGB[0] + "," + incRGB[1] + "," + incRGB[2] + ",'" + endRGB + "'," + slices + ")", 20);
	}
	
	function fadeExtra(tagid, direction, af0_be1) {
		
	if(tagid =="fade_1"){  
	  if (direction == "in" && af0_be1 == 1) document.getElementById(tagid).innerHTML = rDiv;
	  if (direction == "out" && af0_be1 == 0) document.getElementById(tagid).innerHTML = "&nbsp;";
	}
	if(tagid =="fade_2"){  
	  if (direction == "in" && af0_be1 == 1) document.getElementById(tagid).innerHTML = rDiv1;
	  if (direction == "out" && af0_be1 == 0) document.getElementById(tagid).innerHTML = "&nbsp;";
	}
	
	}
	/* ***** End Functions ************************************************ */
	/* ******************************************************************** */
		
	
	
	var interval = "";
	var i = 5;
	var j = 0;
	var layerNumShowing=0;
	
	
	function init()
	{
		if (navigator.appName == "Netscape") {
			layerStyleRef="layer.";
			layerRef="document.layers";
			styleSwitch="";
		}else{
			layerStyleRef="layer.style.";
			layerRef="document.all";
			styleSwitch=".style";
		} 
	
	}
	
	/*function startInterval()
	{
		interval = window.setInterval("tTimer()",1000);
	} */
	function stopInterval()
	{
		window.clearInterval (interval);
		interval="";
	}
	
	function tTimer(conta)
	{
	   
		
		i--;
	   
		if (i == -1)
		{
				
			//alert ("TIME'S UP  " + j);
			stopInterval();
					i = 5;
					
					var rDivLink="";
					switch(j) {								 
					  case 0: {
						  user_fadeIn2(0, 'out');
						  user_fadeIn2(1, 'in');
						  if(conta == '1'){ j=0;}else{ j=1;}
						  
						  break;		    
					  }
					  case 1: {
						  
						  user_fadeIn2(0, 'out');
						  user_fadeIn2(2, 'in');
						  if(conta == '2'){ j=0;}else{ j=2;}
						 
						  break;				    
					  }
					  case 2: {
						  user_fadeIn2(0, 'out');
						  user_fadeIn2(3, 'in');
						  j=0;
						  break;				    
					  }
					}		
					
					
					/*if ( j==1){
						 //showLayerNumber(0);
						 //user_fadeIn1(0, 'out');
						 //user_fadeIn1(1, 'in');
						 user_fadeIn2(0, 'out');
						 user_fadeIn2(1, 'in');
						 		
						 layerNumShowing=0;	 	
						 j=0;
					}
					else {
						j=j+1;
						//showLayerNumber(1);
						//user_fadeIn1(0, 'out');
						//user_fadeIn1(2, 'in');
						user_fadeIn2(0, 'out');
						user_fadeIn2(2, 'in');
						
						layerNumShowing=1;
						
					}*/
					
				  startInterval();
		}
	}
	
	

			
				
				
				
				
				
				function divLinkFnc1(value) {
					var rDivLink="";
					switch(value) {								 
					  case 0: {
						  rDivLink = "#"; 
						  document.location.href= rDivLink;
						  break;		    
					  }
					  case 1: {
						  rDivLink = "#"; 
						  document.location= rDivLink;
						  break;				    
					  }
					}		
					return rDivLink;
				}
				
			
				function divLinkFnc2(value) {
					var rDivLink="";
					switch(value) {								 
					  case 0: {
						  rDivLink = "segn.php"; 
						  document.location.href= rDivLink;
						  break;		    
					  }
					  case 1: {
						  rDivLink = "segn.php"; 
						  document.location= rDivLink;
						  break;				    
					  }
					}		
					return rDivLink;
				}
            
				init();
				startInterval();
				



function scelta(numero,files)
{
   
    
    
   
    var the_idx_name = document.forms['mod'].elements[nome];
     document.forms['mod'].elements['files'].value=files;
     document.forms['mod'].submit();
   /* if(the_idx_name.options[0].selected){document.forms['mod'].elements['tabella'].value="Report";}
    if(the_idx_name.options[1].selected){document.forms['mod'].elements['tabella'].value="Movimenti";}
   
    alert(files);*/
} 