
// calculate the current window width //
function pageWidth() 
{
  return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

// calculate the current window height //
function pageHeight() 
{
  return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() 
{
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() 
{
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}

// hide the dialog box //
function hideDialog() 
{
  var dialog = document.getElementById('dialog');
  document.getElementById('dialog-mask').style.visibility = "hidden";
  document.getElementById('dialog').style.visibility = "hidden";
  document.getElementById('popupvideo').style.visibility = "hidden";
  
  //document.getElementById('MenloPlayer').style.display = "none";
  //document.getElementById('MenloPlayer').style.visibility = "hidden";
  
  document.getElementById('popvideo').style.visibility = "hidden";
  document.getElementById('popvideo').innerHTML = "";
  clearInterval(dialog.timer);
}

function recieveMp3(mp3Path)
{
	activeFlash(mp3Path);
}

function getFlash(movieName) 
{
    if (navigator.appName.indexOf("Microsoft") != -1) 
	{
        return window[movieName];
    } 
	else 
	{
        return document[movieName];
    }
}

function activeFlash(value) 
{
	/*
	 * does not actualy do an alert but calls a call
	 * back function from the flash object to play the movie.
	 */
  getFlash("MenloPlayer").alert(value);
}

// build/show the dialog box, populate the data and call the fadeDialog function //
function showDialog(type,autohide) 
{

  var dialog;
  var dialogheader;
  var dialogclose;
  var dialogtitle;
  var dialogcontent;
  var dialogmask;
  var title = "Burgess Gym Project";
  var idx = type.selectedIndex;
  // get the value of the selected option 
  var which = type.options[idx].value; 
	
	 var input = "<span><h2 class='label'>Gym Project as of "+which+"</h2></span>";
	     input += "<div id='popupvideo'>";
	 	 input += "<img src='http://www.menlopark.org/miscam/"+which+"/mov/"+which+".jpg' style='height:315px;width:525px;  margin-top:5px' alt='' />";
	 
	 /*input += "<span>Time Lapse of the Gym Project</span>";
	 input += "<div id='popvideo'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' id='MenloPlayer' width='100%' height='100%' align='middle' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=9,0,18,0' style='visibility:visible'>";
	 input += "<param value='true' name='allowFullScreen'/><param value='always' name='allowScriptAccess'/>";
	 input += "<param name='movie' value='http://www.menlopark.org/gymproject/Other/FXVideo_Example.swf' />";
	 input += "<param value='' name='flashVars'/>";
	 input += "<param name='quality' value='high'/>";
	 input += "<param value='transparent' name='wmode'/>"; 
	 input += "<param name='bgcolor' value='#444444' />";
	 input += "<embed id='MenloPlayer' height='100%' width='100%' align='middle' type='application/x-shockwave-flash' flashvars='' pluginspage='http://www.adobe.com/go/getflashplayer' allowscriptaccess='always' name='MenloPlayer' wmode='transparent'  bgcolor='#444444' quality='high' allowfullscreen='true' src='http://www.menlopark.org/gymproject/Other/FXVideo_Example.swf'/>";
	 input += "</object></div>";*/
	 
	 input +="</div>";
	 input +="<div id='bottomstmp'> <h2 class='label' style='float:right;'>City of Menlo Park</h2><img style='height:25px; width:25px; float:right; margin:3px;' src='http://www.menlopark.org/gymproject/Images/cmp2.gif'/></div>";
  
  if(!document.getElementById('dialog')) 
  {
    dialog = document.createElement('div');
    dialog.id = 'dialog';
    dialogheader = document.createElement('div');
    dialogheader.id = 'dialog-header';
    dialogtitle = document.createElement('div');
    dialogtitle.id = 'dialog-title';
    dialogclose = document.createElement('div');
    dialogclose.id = 'dialog-close';
    dialogcontent = document.createElement('div');
    dialogcontent.id = 'dialog-content';
    dialogmask = document.createElement('div');
    dialogmask.id = 'dialog-mask';
    document.body.appendChild(dialogmask);
    document.body.appendChild(dialog);
    dialog.appendChild(dialogheader);
    dialogheader.appendChild(dialogtitle);
    dialogheader.appendChild(dialogclose);
    dialog.appendChild(dialogcontent);;
    dialogclose.setAttribute('onclick','hideDialog()');
    dialogclose.onclick = hideDialog;
  } 
  else 
  {
    dialog = document.getElementById('dialog');
    dialogheader = document.getElementById('dialog-header');
    dialogtitle = document.getElementById('dialog-title');
    dialogclose = document.getElementById('dialog-close');
    dialogcontent = document.getElementById('dialog-content');
    dialogmask = document.getElementById('dialog-mask');
    dialogmask.style.visibility = "visible";
    dialog.style.visibility = "visible";
  }
  
  var width = pageWidth();
  var height = pageHeight();
  var left = leftPosition();
  var top = topPosition();
  var dialogwidth = dialog.offsetWidth;
  var dialogheight = dialog.offsetHeight;
  var topposition = top + (height / 3) - (dialogheight / 2);
  var leftposition = left + (width / 2) - (dialogwidth / 2);
  dialog.style.left = "271px";
  dialog.style.top = "50px";
  dialogheader.className = "success" + "header";
  dialogtitle.innerHTML = title;
  dialogcontent.className = "videopres";
  dialogcontent.innerHTML = input;
  
  //recieveMp3("http://www.menlopark.org/miscam/January10/mov/January10.flv");
  //window.getElementById('MenloPlayer').alert('http://www.menlopark.org/miscam/January10/mov/January10.flv');
  
}
