
//
// ---------- FUNCTIONS ----------
//

/*
addEvent function found at http://www.scottandrew.com/weblog/articles/cbs-events
*/
function addEvent(obj, evType, fn) {
  if (obj.addEventListener) {
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent) {
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    return false;
  }
}

// trim whitespace at beginning and end of string
function trim(st){
  return st.replace(/^\s*(.*\S)?\s*$/, '$1');
}

// Clear the default input of an input text field when it receives focus. Save the original input in this.orgValue.
function defaultInputFocus(me){
  if(me.orgValue==undefined)  me.orgValue=me.value;
  if(me.value==me.orgValue)  me.value='';
}
// Restore the original value of an input text field when it looses focus and nothing has been entered.
function defaultInputBlur(me){
  if(trim(me.value)=='')  me.value=me.orgValue;
}

function InsertFlash(flashURL, w, h, version){
  if(version=='')  version='6,0,0,0';
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+w+'" height="'+h+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+'">');
  document.write('<param name="allowScriptAccess" value="sameDomain" />');
  document.write('<param name=movie value="'+flashURL+'" />');
  document.write('<param name="quality" value="high" />');
  document.write('<param name="wmode" value="opaque" />');  // this allows DHTML elements in front of Flash and prevents screenreaders (like JAWS) from getting stuck of Flash
  document.write('<embed src="'+flashURL+'" type="application/x-shockwave-flash" quality="high" width="'+w+'" height="'+h+'" wmode="opaque" allowScriptAccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
  document.write('</object>');
}



function hoverInfoOver(obj){
  hinfRootObj = obj.parentNode;
  hinfDiv0Obj = hinfRootObj.getElementsByTagName('div')[0];
  hinfDiv1Obj = hinfRootObj.getElementsByTagName('div')[1];
  uniqueScopeName = 'scope' + hinfRootObj.style.top.toString() + hinfRootObj.style.left.toString();

  hinfDiv0Obj.style.display = 'block';

  new Effect.Appear($(hinfDiv1Obj), { from: 0, to: 1.0, duration: 0.6, queue: { position: 'end', scope: uniqueScopeName } });
}

function hoverInfoOut(obj){
  hinfRootObj = obj.parentNode;
  hinfDiv0Obj = hinfRootObj.getElementsByTagName('div')[0];
  hinfDiv1Obj = hinfRootObj.getElementsByTagName('div')[1];
  uniqueScopeName = 'scope' + hinfRootObj.style.top.toString() + hinfRootObj.style.left.toString();

  hinfDiv0Obj.style.display = 'none';

  new Effect.Fade($(hinfDiv1Obj), { from: 1.0, to: 0, duration: 0.1, queue: { position: 'end', scope: uniqueScopeName } });
}


var gFlowPlayerRevealed = false;
function revealFlowPlayer(idSlide, idCanvas){
  if(!gFlowPlayerRevealed){
    new Effect.SlideDown(idSlide, { duration: 2.0, afterFinish:function(){startFlowPlayer(idCanvas)} });
    gFlowPlayerRevealed = true;
  }else{
    startFlowPlayer(idCanvas);
  }
}

function startFlowPlayer(idCanvas){
  $f( idCanvas, "/swf/flowplayer/flowplayer-3.0.5.swf", 
      {
        clip: {
          autoPlay: true
        },
        canvas: {
          //backgroundColor: '#004186',
          backgroundGradient: 'none'
        },
        plugins: {
          controls: {
            backgroundColor: '#2d3e46',
            backgroundGradient: 'low',
          
            timeColor: '#D0DBF2',
            progressColor: '#004186',
            bufferColor: '#899CC9'
          }
        }
      }
  );
}

