// $Id: main.js 69 2008-04-29 11:51:52Z mstillwell $

// onLoad functions
function init() {
	externalLinks();
	doSifr();
}

// opens links in new window with rel="external" to validate xhtml strict
function externalLinks() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
 	for (var i=0; i<anchors.length; i++) { 
   			var anchor = anchors[i]; 
 			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external"){
 				anchor.target = "_blank"; 
       		} else if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "thiswindow")anchor.target = "_top";
 	} 
}

function FlvPlayer (videourl) {
  this.videourl = 'videourl=' + videourl;
  this.width = 568;
  this.height = 377;
  this.dh; // drag handle
  
  this.build = function() {
    // Build html such as
    // <div id="modaldialog">
    //   <div id="flv_player">
    //     <div id="flv_player_horizon">
    //       <div id="flv_player_content">
    //         {flv player}
    //          <a id="flv_player_close" href="..."></a>
    //       </div>
    //     </div>
    //   </div>
    //  </div>
    var close = new Element('a', { 'id': 'flv_player_close', 'href': 'javascript:fp.hide()' });
    var content = new Element('div', { 'id': 'flv_player_content'});
    var horizon = new Element('div', { 'id': 'flv_player_horizon'});
    var player = new Element('div', { 'id': 'flv_player'});
    var dialog = new Element('div', { 'id': 'modaldialog', 'style':'display: none;'});
    
    body = $$('body');
    
    // This is a call to a modified version of AC_FL_RunContent - it returns the generated html
    // 
    content.innerHTML =  AC_FL_RunContent("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0",
                   "width", "488",
				   "height", "300",
				   "src", "/swf/synergy-videoplayer",
				   "quality", "high",
				   "pluginspage", "http://www.macromedia.com/go/getflashplayer",
				   "align", "middle",
				   "play", "true",
				   "loop", "true",
				   "scale", "showall",
				   "wmode", "window",
				   "devicefont", "false",
				   "id", "synergy-videoplayer",
				   "bgcolor", "#ffffff",
				   "name", "/swf/synergy-videoplayer",
				   "menu", "true",
				   "allowFullScreen", "false",
				   "allowScriptAccess","sameDomain",
				   "movie", "/swf/synergy-videoplayer",
				   "FlashVars", this.videourl,
				   "salign", ""
				   ); //end AC code
				       
    horizon.insert(content);
    player.insert(horizon);
    player.insert(close);
    dialog.insert(player);
    body[0].insert( { top: dialog });
  }
  
  this.show = function() {
    body = $$('body');
    offset = body[0].cumulativeScrollOffset();
    $('flv_player').style.top = (offset[1] + (document.viewport.getHeight() - this.height)/2) + "px";
    $('flv_player').style.left = (document.viewport.getWidth() - this.width)/2 + "px";
    $('modaldialog').show();
    this.dh = new Draggable('flv_player');
  }
  
  this.hide = function() {
    this.dh.destroy();
    $('modaldialog').hide();
  }
}

function StaffBio() {
  this.width = 568;
  this.height = 377;
  this.dh; 
  
  // Build html like
  // <div id="modaldialog">
  //   <div id="staffBio">
  //     <a id="staffBioClose"></a>
  //     <div id="StaffBioContent">
  //      { content }
  //     </div>
  //   </div>
  // </div>
  this.build = function() {
    var close = new Element('a', { 'id': 'staffBioClose', 'href': 'javascript:staffbio.hide()' });
    var content = new Element('div', { 'id': 'staffBioContent' });
    var container = new Element('div', { 'id': 'staffBio' });
    var dialog = new Element('div', { 'id': 'modaldialog', 'style':'display: none;'});
    
    body = $$('body');

    container.insert(close);
    container.insert(content);
    dialog.insert(container);
    body[0].insert( { top: dialog });
  }
  
  this.show = function(html) {
    body = $$('body');
    offset = body[0].cumulativeScrollOffset();
    $('staffBio').style.top = (offset[1] + (document.viewport.getHeight() - this.height)/2) + "px";
    $('staffBio').style.left = (document.viewport.getWidth() - this.width)/2 + "px";
    $('staffBioContent').innerHTML = html;
    $('modaldialog').show();
    this.dh = new Draggable('staffBio');
  }
  
  this.hide = function() {
    this.dh.destroy();
    $('modaldialog').hide();
  }
}
