// JavaScript Document

function dtCenterIt( obj ) {
              var w = getObjectWidth(obj);
			  var h = getObjectHeight(obj);
							
              var dw = getInsideWindowWidth()-w;
              var dh = getInsideWindowHeight()-h;
              var dx = 0;
              var dy = 0;
              
              if( dw > 0 ) {
                dx = dw/2;
              }

              if( dh > 0 ) {
                dy = dh/2;
              }
							
			 shiftTo( obj, dx, dy );
}

function dtCenterThem( mode ) {
              var w = 346;
			  var h = 100;
							
              var dw = getInsideWindowWidth()-w;
              var dh = getInsideWindowHeight()-h;
              var dx = 0;
              var dy = 0;
              
              if( dw > 0 ) {
                dx = dw/2;
              }

              if( dh > 0 ) {
                dy = dh/2-50;
								
			  if( dy < 20 )
				dy = 20
              }
     
              shiftTo( 'layerIntro', dx, dy );          
			   
              show( 'layerIntro' );			      
      }

function dtHideAllLayers() {
  hide( 'layerIntro' );  
}

function SetOpacity(elem, opacityAsInt)
{
	var opacityAsDecimal = opacityAsInt;
	
	if (opacityAsInt > 100)
		opacityAsInt = opacityAsDecimal = 100; 
	else if (opacityAsInt < 0)
		opacityAsInt = opacityAsDecimal = 0; 
	
	opacityAsDecimal /= 100;
	if (opacityAsInt < 1)
		opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
	
	elem.style.opacity = opacityAsDecimal;
	elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
}

function FadeOpacity(elemId, fromOpacity, toOpacity, time, fps)
{
	var steps = Math.ceil(fps * (time / 1000));
	var delta = (toOpacity - fromOpacity) / steps;
	
	FadeOpacityStep(elemId, 0, steps, fromOpacity, delta, (time / steps));
	
}

function FadeOpacityStep(elemId, stepNum, steps, fromOpacity, delta, timePerStep)
{
    SetOpacity(document.getElementById(elemId), Math.round(parseInt(fromOpacity) + (delta * stepNum)));

    if (stepNum < steps)
        setTimeout("FadeOpacityStep('" + elemId + "', " + (stepNum+1) + ", " + steps + ", " + fromOpacity + ", " + delta + ", " + timePerStep + ");", timePerStep);
		
}

