/*********** ZOOM ****************/
function zoom(topic)
{
	var aZoomWin
	aPopUp= window.open('', 'Zoom', 'toobar=no, location=no, directories=no, status=no, scrollbar=yes, resizable=yes, copyhistory=no, width=900, height=7000')
	ndoc= aPopUp.document
	astr='<HTML><HEAD><BR><TITLE>' + topic + '</TITLE>'
	astr+= '</HEAD>'
	astr+= '<BODY>'
	astr+= '<center>'
	astr+= '<img src="' +topic+ '"alt=topic height="600" width="800">'
	astr+= '<BR><A HREF="topic">successiva</A>'	
	astr+= '</center>'
	astr+= '</BODY></HTML>'
	ndoc.write(astr)
	ndoc.close()
	self.aZoomWin = aPopUp
	aPopUp.window.focus()
}


/************ data ultima modifica ************/

function initArray() {

  this.length = initArray.arguments.length

  for (var i = 0; i < this.length; i++)

  this[i+1] = initArray.arguments[i]

}

var DOWArray = new initArray("Domenica","Lunedì","Martedì","Mercoledì",
			    "Giovedì","Venerdì","Sabato");

var MOYArray = new initArray("Gennaio","Febbraio","Marzo","Aprile",
			    "Maggio","Giugno","Luglio","Agosto","Settembre",
			    "Ottobre","Novembre","Dicembre");

var LastModDate = new Date(document.lastModified);



/************* immagini a caso *******************/

function rnd_image(){

   var now = new Date();


   var sec_divide = now.getSeconds();

   rnd_number = Math.floor(sec_divide/5); // /20=0, 1, 2  /10=0, 1, 2, 3, 4, 5  etc...

   return "<img src='img/pulse/robot_' + rnd_number +'.gif'>');"

}



/************* SIGNAL *******************/


    var w3c=(document.getElementById)? true: false;
    var ie5=(w3c && document.all)? true : false;
    var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;
	var steps = 80;
	var left = steps;

	function subBox(x,y,w,h,bgc,id){
	  var v=document.createElement('div');
	  v.setAttribute('id',id);
	  v.style.position='absolute';
	  v.style.left=x+'px';
	  v.style.top=y+'px';
	  v.style.width=w+'px';
	  v.style.height=h+'px';
	  v.style.backgroundColor=bgc;
	  v.style.visibility='hidden';
	  v.style.padding='0px 0px 0px 0px';
      
      rnd_number = Math.floor(Math.random()*11);
      v.innerHTML= '<img src="img/pulse/robot_' + rnd_number +'.gif">';
	  //v.innerHTML= '<img src="img/pulse/guardian_32.gif">';
	  return v;
	}

	function selectPath() {
	  var el = document.getElementsByTagName("div");
	  var i, j = 0, k = 0;
	  var pts = {};

	  for (i = 0; i < el.length; i++) {
	    if (i % 3 == 0) pts[j] = {};
	    pts[j][k++] = { x: el[i].offsetLeft, y: el[i].offsetTop };
	    if ((i + 1) % 3 == 0) { j++; k = 0; }
	  }
	  pts.rows = j;
	  pts.cols = 3;

	  // Add an additional row
	  pts[pts.rows] = {};
	  for (i = 0; i < pts.cols; i++) {
	    var e = el[el.length - 3 + i];
	    pts[pts.rows][i] = { x: e.offsetLeft, y: e.offsetTop + e.offsetHeight - 10 };
	  }
	  pts.rows++;

	  // Add an additional column
	  for (i = 0; i < pts.rows; i++)
	    pts[i][3] = { x: pts[i][2].x + el[2].offsetWidth - 10, y: pts[i][2].y };
	  pts.cols++;

	  s = "";
//	  alert(el[0].offsetHeight);
//	  alert(el[0].offsetWidth);

	  // Select a path
	  var path = { length: 0 };
	  for (i = 0; i < pts.rows; i++)
	    path[path.length++] = pts[i][Math.floor(Math.random() * pts.cols)];

	  // Debug
//	  for (i = 0; i < path.length; i++) {
//	    b = subBox(path[i].x - 10, path[i].y - 10, 20, 20, 'Transparent', "sp_"+i);
//	    b.style.visibility='visible';
//	    document.body.appendChild(b);
//	  }

	  return path;
	}

	var signals = { length: 0 };

	function signal() {
	  this.idx = signals.length;
	  signals[signals.length++] = this;
	  this.path = null;
	  this.layer = subBox(0, 0, 20, 20, 'Transparent', "sp");
	  document.body.appendChild(this.layer);
	  this.stepsPerPath = 20;
	  this.speed = 50;
	  this.curStep = 0;
	  this.curPoint = 0;
	  // 0: next point, 1: gox1, 2: goy1, 3: gox2, 4: goy2
	  this.state = 0;
	  this.start = function () {
	    this.state = 0;
	    this.curPoint = 0;
	    this.layer.style.left = (this.path[0].x - 10) + 'px';
	    this.layer.style.top = (this.path[0].y - 10) + 'px';
	    this.layer.style.visibility='visible';
	    setTimeout("thread(" + this.idx + ")", this.speed);
	  }
	  this.doStep = function() {
	    var b, e, p;
	    switch (this.state) {
	    case 0:
	      if (this.curPoint == this.path.length - 1) return false;
	      this.curStep = 0;
	      this.state = Math.random() > 0.5 ? 1 : 4;
	      break;
	    case 1:
	    case 3:
	      b = this.path[this.curPoint].x * 1.0;
	      e = this.path[this.curPoint + 1].x * 1.0;
	      p = (1.0 * this.curStep) / this.stepsPerPath;

	      this.layer.style.left =(b + Math.floor((e - b) * p) - 10) + 'px';
	      this.layer.style.top = (this.path[this.curPoint + (this.state == 1 ? 0 : 1)].y - 10) + 'px';
	      if (++this.curStep == this.stepsPerPath) {
	        if (this.state == 1) {
	          this.state = 2;
		  this.curStep = 0;
		} else { // state == 3
		  this.state = 0;
		  this.curStep = 0;
		  this.curPoint++;
		}
	      }
	      break;
	    case 2:
	    case 4:
	      b = this.path[this.curPoint].y * 1.0;
	      e = this.path[this.curPoint + 1].y * 1.0;
	      p = (1.0 * this.curStep) / this.stepsPerPath;

	      this.layer.style.left = (this.path[this.curPoint + (this.state == 2 ? 1 : 0)].x - 10) + 'px';
	      this.layer.style.top =(b + Math.floor((e - b) * p) - 10) + 'px';
	      if (++this.curStep == this.stepsPerPath) {
	        if (this.state == 2) {
	          this.state = 0;
		  this.curStep = 0;
		  this.curPoint++;
		} else { // state == 4
		  this.state = 3;
		  this.curStep = 0;
		}
	      }
	      break;
	    }
	    return true;
	  }
	  this.doStop = function () {
	    this.layer.style.visibility = 'hidden';
	    fire(this.idx);
	  }
	}

	function thread(idx) {
	  if (signals[idx].doStep())
	    setTimeout("thread("+idx+")", signals[idx].speed);
	  else
	    signals[idx].doStop();
	}

	function fire(idx) {
	  var s = signals[idx];
	  s.path = selectPath();
	  s.start();
	}

	function animate(n) {
	  --n;
	  fire((new signal()).idx);
	  if (n) setTimeout("animate("+n+")", 5000);
	}

	var links = {
	  people: { width: 119, height:  20 },
	  apps:   { width:  88, height:  19 },
	  links:  { width:  92, height:  19 },
	  src:    { width:  96, height:  28 },
	  xmpl:   { width:  42, height: 134 },
	  doc:    { width:  36, height:  98 },
	  info:   { width: 109, height:  27 },
	  quick:  { width:  99, height:  19 },
	  mail:   { width:  86, height:  27 },
	  about:  { width: 112, height:  20 }
	};

	var order = { 0: 'src', 1: 'doc', 2: 'info', 3: 'xmpl',
	  4: 'apps', 5: 'people', 6: 'links', 7: 'mail', 8: 'about',
	  9: 'quick', length: 10 };

	function show() {
	  var iw = 844;
	  var ih = 104;
      left = -1;
	  if (left) {
        document.images.Logo.width = Math.floor(iw * ((steps - left) * 1.0/steps));
        document.images.Logo.height = Math.floor(ih * ((steps - left) * 1.0/steps));
	    left--;
	    setTimeout(show, 100);
	  }
	  else { document.images.Logo.width = iw; document.images.Logo.height = ih; }
	}

	function showLink(n) {
	  if (n < order.length) {
	    if (n >= 0) document.images[order[n]].style.visibility = 'visible';
	    setTimeout("showLink("+(n + 1)+")", 900);
	  }
	}

	var stretch = { 1: 1, 2: 0.9, 3: 0.8, 4: 0.7, 5: 0.8, 6: 0.9 }
	var magnifying = false;
	function magnify(n, v) {
	  if (!v && magnifying) return;
	  magnifying = true;
	  if (!v) v = 6;
	  if (ie5) document.images[n].style.filter = "alpha(opacity="+(stretch[v] * 100)+")";
	  else document.images[n].style.MozOpacity = stretch[v];
	  // FIXME: Fix this on mozilla
	  if (v > 1) setTimeout("magnify('"+n+"', "+(v - 1)+")", 100);
	  else magnifying = false;
	}



function hide(id){
    Effect.toggle(id, 'slide' );
    /*
	if(document.getElementById(id).style.display == "none"){
        document.getElementById(id).style.display = "";
        new Effect.SlideUp(document.getElementById(id));
	}else{
        document.getElementById(id).style.display = "none";
        new Effect.SlideDown(document.getElementById(id));
	}*/
}