

//Integrated to Walter Zorn html library



// Uses WZ dhtml library to make timed transformations of dhtml,
// so minimizing, maximizing layers can be rather "smoot" for user,
// simulating windows os.

//Function transformLayer
//x,y = Position. Top left corner coordinates
//id = id of the Div (i.e.: id="myLayer", then, use "myLayer", WITH quotes!)
//duration = Duration, in miliseconds
//steps = Transition intervals



function transformLayer (x,y,id,duration,steps) {
  
  //duration is in seconds
  stepDuration = Math.round(duration/steps) ; // Value is in miliseconds.

  obj = dd.elements[id];
  

  // Get original values: x,y = top left corner;  w,h = width height   
  
  x1 = obj.x;  
  y1 = obj.y;  
  

  // If values not set, or zero, we do not modify them, and take original as final as well
  x = (x)?x:x1;
  y = (y)?y:y1;
  
  // how much do we need to modify our values for each step?
  // The WZ library moveBy and resizeBy takes the diff with inverted sign as from original ce script:
  difX = (x - x1)/steps;  
  difY = (y - y1)/steps;  
  
  
  
  if(top.debug==true)  window.alert('x1:'+x1+', y1:'+y1+',<br>x:'+x+', y:'+y+', w:'+w+', h:'+h+', <br>difX:'+difX+', difY:'+difY+', difW:'+difW+', difH:'+difH+',<br>duration:'+duration+', <br>steps:'+steps+',<br>stepDuration:'+stepDuration+'');
 
  obj.moveBy(difX,difY);
  //updatecell(obj.name);

  //We take out the amount of time used, and a step already being executed
  duration = (duration - stepDuration);
  steps --;

	//If there is any step left, we execute again
	if(steps>=0){
	 setTimeout('transformLayer('+x+','+y+',"'+id+'",'+duration+','+steps+')',stepDuration);
	} else {
		
		fade_text()
	}
  //If Return... we could set some api here as to call a function to be evaluated by the javascript,if set, on return
  //for example to call the function that has to populate the div with content
  //but WZ has already thought on it :-)
  return;

}



function fadeLayer (x,y,id,duration,steps,curopacity) {
  
  //duration is in seconds
  stepDuration = Math.round(duration/steps) ; // Value is in miliseconds.

  obj = dd.elements[id];
  if(!curopacity)
  	curopacity = x;
  
  // Get original values: x,y = top left corner;  w,h = width height   
  
  x1 = obj.x;  
  y1 = obj.y;  
  
  

  // If values not set, or zero, we do not modify them, and take original as final as well
  //x = (x)?x:x1;
  //y = (y)?y:y1;
  

  // how much do we need to modify our values for each step?
  // The WZ library moveBy and resizeBy takes the diff with inverted sign as from original ce script:
  //difX = (x - x1)/steps;  
  //difY = (y - y1)/steps;  
  dif = (y - x)/steps; 
  Math.round(dif * 100)/100
  //newOpacity = dif * curstep;
  curopacity = curopacity + dif
  //curstep++;
  
  if(curopacity > 1)
  	curopacity = 1
  if(curopacity < 0)
  	curopacity = 0
  	
  	
 //if(curopacity < y)
 // 	curopacity = y
  obj.setOpacity(curopacity)
  
  //if(top.debug==true)  
  //	window.alert('id:'+id+',x:'+x+', y:'+y+', dif:'+dif+',duration:'+duration+', steps:'+steps+',stepDuration:'+stepDuration+',curopacity:'+curopacity);
 
 
 // alert(dif)
  //obj.moveBy(difX,difY);
  //updatecell(obj.name);

  //We take out the amount of time used, and a step already being executed
  duration = duration - stepDuration;
  //steps --;

	//If there is any step left, we execute again
	//if(steps>=0)
	if(curopacity != y)
	{
	 setTimeout('fadeLayer('+x+','+y+',"'+id+'",'+duration+','+steps+','+curopacity+')',stepDuration);
	} else {
		switch_text()
		fading = false
		moving = false
	}
	
  //If Return... we could set some api here as to call a function to be evaluated by the javascript,if set, on return
  //for example to call the function that has to populate the div with content
  //but WZ has already thought on it :-)
  return;

}