// JavaScript Document
var theEle = null;
var flashInfo = getFlashVersion();
function getMyStyle(element, styleProperty){
  var computedStyle = null;

  if (typeof element.currentStyle != "undefined"){
    computedStyle = element.currentStyle;
  }
  else {
    computedStyle = document.defaultView.getComputedStyle(element, null);
  }
  return computedStyle[styleProperty];
}

function getFlashVersion() {
  var flashVersion = new Array();

  flashVersion["major"] = 0;
  flashVersion["build"] = 0;

  if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
    var description = navigator.plugins["Shockwave Flash"].description;

    if (description != null) {
      var versionString = description.replace(/^.*\s+(\S+\s+\S+$)/, "$1");

      flashVersion["major"] = parseInt(versionString.replace(/^(.*)\..*$/, "$1"));
      flashVersion["build"] = parseInt(versionString.replace(/^.*r(.*)$/, "$1"));
    }
  }
  else if (typeof window.ActiveXObject != "undefined") {
    try {
      var flashObject = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      var description = flashObject.GetVariable("$version");

      if (description != null) {
        var versionNumbers = description.replace(/^\S+\s+(.*)$/, "$1").split(",");
        flashVersion["major"] = parseInt(versionNumbers[0]);
        flashVersion["build"] = parseInt(versionNumbers[2]);
      }
    }
    catch(error) {
    }
  }

  return flashVersion;
}

function animateResize (who,whatSize) {
	theEle = document.getElementById (who);
	clearInterval(theEle.animationTimer);
	document.getElementById(who).animationTimer = setInterval('resizeObject('+whatSize+')', 10);
}

function animateWidth (who,whatSize) {
		theEle = document.getElementById (who);
	clearInterval(theEle.animationTimer);
	  document.getElementById(who).animationTimer = setInterval('resizeWidth('+whatSize+')', 10);
}

function resizeWidth (destinationwidth) {
		target = theEle;
	var maxSpeed = 100;
	var currentwidth = parseInt(getMyStyle(target, "width"));
//  var currentTop = parseInt(getMyStyle(target, "top"));

  if (isNaN(currentwidth)){
    currentwidth = 100;
  }
  if (typeof target.floatingPointwidth == "undefined") {
    target.floatingPointwidth = currentwidth;
  }

  var deceleratewidth = 1 + Math.abs(destinationwidth - target.floatingPointwidth) / 2;

  if (deceleratewidth > maxSpeed) {
    deceleratewidth = maxSpeed;
  }

/*  if (decelerateTop > maxSpeed)
  {
    decelerateTop = maxSpeed;
  }*/

  if (target.floatingPointwidth < destinationwidth) {
    target.floatingPointwidth += deceleratewidth;

    if (target.floatingPointwidth > destinationwidth) {
      target.floatingPointwidth = destinationwidth;
    }
  }
  else {
    target.floatingPointwidth -= deceleratewidth;

    if (target.floatingPointwidth < destinationwidth) {
      target.floatingPointwidth = destinationwidth;
    }
  }

  target.style.width = parseInt(target.floatingPointwidth) + "px";

  if (target.floatingPointwidth == destinationwidth){
    clearInterval(target.animationTimer);
	if (callBack.length > 1) {
		  this[callBack]();
		  callBack = "";
	  }

  }
}

function resizeObject(destinationHeight){
	target = theEle;
	var maxSpeed = 20;
	var currentHeight = parseInt(getMyStyle(target, "height"));
//  var currentTop = parseInt(getMyStyle(target, "top"));

  if (isNaN(currentHeight)){
    currentHeight = 100;
  }

/*  if (isNaN(currentTop))
  {
    currentTop = 0;
  }*/

  if (typeof target.floatingPointHeight == "undefined")
  {
    target.floatingPointHeight = currentHeight;
//    target.floatingPointTop = currentTop;
  }

  var decelerateHeight = 1 + Math.abs(destinationHeight - target.floatingPointHeight) / 5;
//  var decelerateTop = 1 + Math.abs(destinationTop - target.floatingPointTop) / 10;

  if (decelerateHeight > maxSpeed)
  {
    decelerateHeight = maxSpeed;
  }

/*  if (decelerateTop > maxSpeed)
  {
    decelerateTop = maxSpeed;
  }*/

  if (target.floatingPointHeight < destinationHeight){
    target.floatingPointHeight += decelerateHeight;

    if (target.floatingPointHeight > destinationHeight){
      target.floatingPointHeight = destinationHeight;
    }
  }
  else
  {
    target.floatingPointHeight -= decelerateHeight;

    if (target.floatingPointHeight < destinationHeight)
    {
      target.floatingPointHeight = destinationHeight;
    }
  }

/*  if (target.floatingPointTop < destinationTop)
  {
    target.floatingPointTop += decelerateTop;

    if (target.floatingPointTop > destinationTop)
    {
      target.floatingPointTop = destinationTop;
    }
  }
  else
  {
    target.floatingPointTop -= decelerateTop;

    if (target.floatingPointTop < destinationTop)
    {
      target.floatingPointTop = destinationTop;
    }
  }
*/
  target.style.height = parseInt(target.floatingPointHeight) + "px";
//  target.style.top = parseInt(target.floatingPointTop) + "px";

  if (target.floatingPointHeight == destinationHeight){
    clearInterval(target.animationTimer);
  }
}


function eventListener(fn,containerID) {
	if (containerID == null) {
		container = "stationhighlight";
	}
	var container = document.getElementById(containerID);
  if (typeof window.addEventListener != 'undefined') {
    container.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined') {
    container.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined') {
    container.attachEvent('onload', fn);
  }
  else {
    var oldfn = window.onload;
    if (typeof window.onload != 'function') {
      container.onload = fn;
    }
    else {
      container.onload = function(){
        oldfn();
        fn();
      };
    }
  }
}


