﻿var step = 0;
var titles = new Array(". . . . . . . .","Request for Date");
var titleOrg = document.title;
//var iInvitationTitleTimerID;
//var iGuestTitleTimerID;
var iTitleTimerID = 0;
var displayingInvitation = false;
var displayingGuest = false;

function DisplayTitles()
{
	document.title = titles[step++ % 2];
}

function StartDisplayingInvitationTitles() 
{
	displayingInvitation = true;
	if (iTitleTimerID == 0)
	{
		TriggerAudioAlert();
		//StartAudioAlert();
		iTitleTimerID = setInterval("DisplayTitles()", 1500);
	}
		
}

function StopDisplayingInvitationTitles()
{
	StopAudioAlert();
	displayingInvitation = false;
	if (displayingGuest == false && iTitleTimerID != 0)
	{
		clearInterval(iTitleTimerID);
		document.title = titleOrg;
		iTitleTimerID = 0;
	}
}

function StartDisplayingGuestTitles() 
{
	displayingGuest = true;
	if (iTitleTimerID == 0)
	{
		//alert("StartDisplayingGuestTitles: Timer started");
		iTitleTimerID = setInterval("DisplayTitles()", 2000);
	}
}

function StopDisplayingGuestTitles()
{
	displayingGuest = false;
	if (displayingInvitation == false && iTitleTimerID != 0)
	{
		//alert("StopDisplayingGuestTitles: Timer stopped");
		clearInterval(iTitleTimerID);
		document.title = titleOrg;
		iTitleTimerID = 0;
	}
}

    
function CancelEventBubbling(evnt)
{ 		
	var e;
	if (window.event)
		e = window.event;
	else
		e = evnt;
		
	e.cancelBubble = true;
}

function ChangeCheckBoxState(id, checkState)
{
	var cb = document.getElementById(id);
	if (cb != null)
		cb.checked = checkState;
}

function ChangeAllCheckBoxStates(checkState)
{
	// Toggles through all of the checkboxes defined in the CheckBoxIDs array
	// and updates their value to the checkState input parameter
	if (CheckBoxIDs != null)
	{
	 for (var i = 0; i < CheckBoxIDs.length; i++)
		ChangeCheckBoxState(CheckBoxIDs[i], checkState);
	}
}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var audioTimer;

function StartAudioAlert()
{
	clearInterval(audioTimer); // assumes this function is called from TriggerAudioAlert()
	var MovieObj = (InternetExplorer) ? Movie2 : document.Movie2[1];
	MovieObj.SetVariable('alert', 1);
}

function StopAudioAlert()
{
	var MovieObj = (InternetExplorer) ? Movie2 : document.Movie2[1];
	MovieObj.SetVariable('alert', 0);
}
        
function TriggerAudioAlert()
{
	// need a timer delay to work under firefox... not sure why.
	audioTimer = setInterval("StartAudioAlert()",500);
}
/*
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function() {
		oldonload();
		func();
		}
	}
}
*/

function OpenNewWindow(pictureUrl, width, height)
{
	newwindow = window.open(pictureUrl, 'pictureViewer', 'location=no, directories=no, fullscreen=no, menubar=no, status=no, toolbar=no, width=' + width + ', height=' + height + ', scrollbars=no');
	if (window.focus)
	{
		newwindow.focus()
	}
	return false;
}

/*
var flashInfo = getFlashVersion();

alert("This browser has Flash version: " + flashInfo["major"] +
    "." + flashInfo["build"]);

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 show(id)
{
	document.getElementById(id).style.display = '';
}

function hide(id)
{
	document.getElementById(id).style.display = 'none';
}					 

function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}
			func();
		}
	}
}
