

function initPeteVideo()
{
	var peteVideoButton = document.getElementById("peteVideoButton");
	var newA = document.createElement("a");
	newA.setAttribute("href", "#");
	newA.onclick = clickPeteVideoButton;
	peteVideoButton.parentNode.insertBefore(newA, peteVideoButton);
	newA.appendChild(peteVideoButton);
	
	return true;
}


function clickPeteVideoButton()
{
	var peteVideo = document.getElementById("peteVideo");
        peteVideo.style.zIndex= "99";
	peteVideo.style.left = "50%";
	peteVideo.style.marginLeft = -parseInt(peteVideo.offsetWidth / 2) + "px";
	peteVideo.style.top = getScrollingPosition()[1] + parseInt((getViewportSize()[1] - peteVideo.offsetHeight) / 2) + "px";
	
	setTimeout("GoFrameBeginFlashMovie();", 250);
	
	return false;
}


function GoFrameBeginFlashMovie()
{
	
	var flashMovie = getFlashMovieObject("peteVideoFlash");
//	flashMovie.GotoFrame(10);
//	flashMovie.GotoFrame();
	flashMovie.Play();
	return true;
}


function GoFrameHoldFlashMovie()
{
	var flashMovie = getFlashMovieObject("peteVideoFlash");
//	flashMovie.GotoFrame(5);
	flashMovie.Play();
	var peteVideo = document.getElementById("peteVideo");	
	peteVideo.style.left = "-9999px";
	peteVideo.style.top = "-9999px";
}


function getFlashMovieObject(movieName)
{
	if (window.document[movieName]) 
	{
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
		if (document.embeds && document.embeds[movieName])
		return document.embeds[movieName]; 
	}
	else
	{
		return document.getElementById(movieName);
	}
}


function getScrollingPosition()
{
	//array for X and Y scroll position
	var position = [0, 0];

	//if the window.pageYOffset property is supported
	if(typeof window.pageYOffset != 'undefined')
	{
		//store position values
		position = [
			window.pageXOffset,
			window.pageYOffset
			];
	}

	//if the documentElement.scrollTop property is supported
	//and the value is greater than zero
	if(typeof document.documentElement.scrollTop != 'undefined'
		&& document.documentElement.scrollTop > 0)
	{
		//store position values
		position = [
			document.documentElement.scrollLeft,
			document.documentElement.scrollTop
			];
	}

	//if the body.scrollTop property is supported
	else if(typeof document.body.scrollTop != 'undefined')
	{
		//store position values
		position = [
			document.body.scrollLeft,
			document.body.scrollTop
			];
	}

	//return the array
	return position;
};




function getViewportSize()
{
  var size = [0,0];
  
  if (typeof window.innerWidth != 'undefined')
  {
    size = [
        window.innerWidth,
        window.innerHeight
    ];
  }
  else if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth != 'undefined' 
      && document.documentElement.clientWidth != 0)
  {
    size = [
        document.documentElement.clientWidth, 
        document.documentElement.clientHeight
    ];
  }
  else
  {
    size = [
        document.getElementsByTagName('body')[0].clientWidth,
        document.getElementsByTagName('body')[0].clientHeight
    ];
  }
  
  return size;
};
