
function animateLayer(id, w, h, speed) {
  var layer = document.getElementById(id);
  layer.style.height = '200px';
  return;
  layer.w = 830;
  layer.h = 700;
  var dw = layer.w - w;
  var dh = layer.h - h;
  layer.step = parseInt(speed * dw);
  layer.stepw = - parseInt(dw / layer.step);
  layer.steph = - parseInt(dh / layer.step);
  animate(id);
};

function animate(id) {
  var obj = document.getElementById(id);
  if(obj.step > 0) {
    obj.w += obj.stepw;
    obj.h += obj.steph;
    obj.step --;
    update(obj);
    obj.animTimer = setInterval('animate("'+id+'")',50);
  }
  else
    clearInterval(obj.animTimer);
};
      
function update(obj) {
    obj.style.width = obj.w + 'px';
    obj.style.height = obj.h + 'px';
};

/*****************************************
 * menu animation
 *****************************************/

// var c_menuover = '#<xsl:value-of select="f:find_color(/*,'content-inner')"/>';
// var c_menu     = '#<xsl:value-of select="f:find_color(/*,'menu-inner')"/>';
// var c_menusel  = '#<xsl:value-of select="f:find_color(/*,'content-inner')"/>';
// var sections   = new Array(''<xsl:for-each select="/website/section">,"<xsl:value-of select="@name"/>"</xsl:for-each>);
// var buttons    = new Array(sections.length-1);
// for(var i=1; i < sections.length; i++) {
//  buttons[i] = document.getElementById('m_' + sections[i]);
// }

function reset_other_buttons(id) {
// for(var i=0;
}

function menu_over(id, issel) {
//  var obj = buttons[id];
//  if(obj.onlink)
// 	return;
//  if(obj.onlink_persist) {
// 	obj.onlink_persist = 0;
// 	return;
//  }
// // reset_other_buttons(id);
//  obj.steps = 0;
//  if(issel != 1) {
// 	obj.style.background = c_menuover;
// 	obj.animTimer = setInterval('animate_over("'+id+'")',20)
//  }
}

function animate_over(id) {
 var obj = buttons[id];
 if(obj.steps <= 40) {
	obj.style.width = (145 + obj.steps++) + 'px';
 }
 else {
	clearInterval(obj.animTimer);
 }
}

function animate_stop_if_needed(id) {
 var obj = buttons[id];
 if(obj.onlink != 1) {
	obj.style.background = c_menu;
	obj.style.width = '145px';
	clearInterval(obj.animTimer);
 }
 else {
	// "persistently" save, that the pointer was on link
	obj.onlink_persist = 1;
 }
 clearInterval(obj.animTimer2);
}

function menu_out(id,issel) {
 // var obj = buttons[id];
 // if(issel != 1 && !(obj.onlink_persist == 1)) {
 //        // stop animation only if we pointer really leaves the "button"
 //        obj.animTimer2 = setInterval('animate_stop_if_needed("'+id+'")',1);
 // }
}

function menu_link_over(id) {
 // var obj = buttons[id];
 // obj.onlink = 1;
}

function menu_link_out(id) {
 // var obj = buttons[id];
 // obj.onlink = 0;
}

/***********************************************
 * h1Setup()
 **********************************************/

var h1Arr=[];

function h1Setup(){
 h1Arr=document.getElementsByTagName('h2');
 for(var h=0; h < h1Arr.length; h++) {
	var h1=h1Arr[h],text=h1.firstChild.nodeValue;h1.removeChild(h1.firstChild);
	h1.animNodes=[];
	for(var i=0; i<text.length; i++) {
		var span=document.createElement('span');
		span.appendChild(document.createTextNode(text.substring(i,i+1)));
		h1.appendChild(span);
		h1.animNodes[h1.animNodes.length]=span
	}
	h1.animCount=0;
	h1.animTimer=setInterval('h1Anim('+h+')',50)
 }
};

function h1Anim(h){
 var h1=h1Arr[h],c=h1.animCount++,noAnim=1;
 for(var i=0; i<h1.animNodes.length; i++) {
	var s=h1.animNodes[i];
	var frac=Math.max(0,Math.min(1,(c-i)/10));
	if(s.animDone)
		continue;
	noAnim=0;
	s.style.color='rgb('+parseInt(255-frac) + 
		',' +
		parseInt(154-frac) +
		',0)'; // + parseInt(255-frac)+')';
	if(frac==1) {
		s.style.marginLeft='auto';
		s.animDone=1
	}
	else if(frac>0)
		s.style.marginLeft=0.6*(1-frac)+'em'
 }
 if(noAnim)clearInterval(h1.animTimer);
};


/*****************************
 * Layer animations
 *****************************/

function animateLayer(id, w, h, speed) {
  var layer = document.getElementById(id);
  layer.style.height = '200px';
  return;
  layer.w = 830;
  layer.h = 700;
  var dw = layer.w - w;
  var dh = layer.h - h;
  layer.step = parseInt(speed * dw);
  layer.stepw = - parseInt(dw / layer.step);
  layer.steph = - parseInt(dh / layer.step);
  obj.animTimer = setInterval('animate("'+id+'")',50);
};

function animate(id) {
  var obj = document.getElementById(id);
  if(obj.step > 0) {
    obj.w += obj.stepw;
    obj.h += obj.steph;
    obj.step -= 1;
    update(obj);
  }
  else
    clearInterval(obj.animTimer);
};
      
function update(obj) {
    obj.style.width = obj.w + 'px';
    obj.style.height = obj.h + 'px';
};

