/**
 * @author Mike Creighton
 */
function closeLightbox() {
	//$('lightbox').hide();
	//$('pageoverlay').hide();
/*---------------------------------------------------------------------*/
	//Remove the lightbox and video when played finished
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	//if ((browser=="Netscape"|| browser=="Microsoft Internet Explorer") && (version>=4))
	if ((browser=="Opera" || browser=="Microsoft Internet Explorer") && (version>=4))
	  {
		$('lightbox').hide();
		$('pageoverlay').hide();
		swfobject.removeSWF('simplevideoplayer_flash');
		//alert('Lighbox removed for IE');
	  }
	  else if ((browser=="Netscape"|| browser=="Crome"))
	  {
		$('lightbox').hide();
		$('pageoverlay').hide();
		swfobject.removeSWF('simplevideoplayer_flash');
		//alert('Lighbox removed for FF or other browsers');
	  }
	else
	  {
		//Remove the lightbox and video when played finished
		window.lightboxes.hide('VideoTrailer'); 
		//alert('Lighbox removed for Safari or other browsers');
	  }
/*---------------------------------------------------------------------*/	
	//Remove the SWF embedded above so we can update it
	//swfobject.removeSWF('simplevideoplayer_flash');
	
	//Readd our simplevideoplayer div that was removed during removeSWF() so we can re-emebed the movie player w/ the new movie
	$('VideoTrailer').insert("<div id=\"simplevideoplayer\"><p>Upgrade your flash player to see this content.</p></div>");
	
}

function displayDelayVideo(video,gameName, gameDate, externalUrl, requiresAgeGate)
{
	//alert("**********");
   if(document.getElementById("VideoTrailer")!=null){
      setTimeout( function() { displayVideo(video, gameName, gameDate, externalUrl, requiresAgeGate) });
   }
}

function displayVideo(video, gameName, gameDate, externalUrl, requiresAgeGate){
	//alert("inside displayVideo");
	document.getElementById('closeDiv').style.display='none';
	document.getElementById('imagePrev').style.display='none';
	document.getElementById('imageNext').style.display='none';
	document.getElementById('downloadble').style.display='none';
	
	
	
	window.lightboxes.show('VideoTrailer');
	 //setTimeout("window.lightboxes.show('VideoTrailer')",100);
	//alert("Video to be displayed: " + video + "\n" + gameName + "\n" + gameDate + "\n" + externalUrl + "\nAge Gate: " + requiresAgeGate);	
		
	
		var flashvars = {					
			videoURL:video,
			//videoURL: "http://fp.scea.com/csimg/psp/PSP_MM_PS_STORE_General.flv",
			gameName: gameName,
			gameDate: gameDate,
			externalUrl: externalUrl,
			requiresAgeGate: requiresAgeGate
			//keyColor : SysColor
	};

	swfobject.embedSWF('groups/public/documents/webasset/gow_simplevideoplayer_swf.swf', 'simplevideoplayer', '482', '272', '9.0.47', 'js/swfobject/expressinstall.swf', flashvars, {bgcolor: '#000000', menu: 'false', allowFullScreen:'true', quality:'best', saligh:'lt', allowScriptAccess:'always', wmode:'transparent'}, {id: 'simplevideoplayer_flash'});
	
	//Get and Register an event to our lightbox close button
	this.close = $('lightbox').select('div.close a').first();
	this.overlay = $('pageoverlay');
	
	/*this.overlay.observe('click', function(e){
	//alert('');
		Event.stop(e);
		$('lightbox').hide();
		$('pageoverlay').hide();
		
		//Remove the SWF embedded above so we can update it
		swfobject.removeSWF('simplevideoplayer_flash');
		
		//Readd our simplevideoplayer div that was removed during removeSWF() so we can re-emebed the movie player w/ the new movie
		if(!$('simplevideoplayer')){
			$('VideoTrailer').insert("<div id=\"simplevideoplayer\"><p>Upgrade your flash player to see this content.</p></div>");
		}
	
	
	});*/

	this.close.onclick = function(e){
	//alert('onclick');
		$('lightbox').hide();
		$('pageoverlay').hide();
		
		//Remove the SWF embedded above so we can update it
		swfobject.removeSWF('simplevideoplayer_flash');
		
		//Readd our simplevideoplayer div that was removed during removeSWF() so we can re-emebed the movie player w/ the new movie
	   $('VideoTrailer').insert("<div id=\"simplevideoplayer\">Upgrade your flash player to see this content.</div>");
	   return false;
	}
	
	// setTimeout("window.lightboxes.show('VideoTrailer')",1000);
	window.lightboxes.show('VideoTrailer');
		
}

function getFlashVersion(){ 
  // ie 
  try { 
    try { 
      // avoid fp6 minor version lookup issues 
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
      try { axo.AllowScriptAccess = 'always'; } 
      catch(e) { return '6,0,0'; } 
    } catch(e) {} 
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
  } catch(e) { 
    try { 
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
      } 
    } catch(e) {} 
  } 
  return '0,0,0'; 
} 
 
var version = getFlashVersion().split(',').shift(); 
if(version < 10){ 
  // flash is too old or we can't detect the plugin
	var alternateContent = 'In order to view this web site, you must have Adobe Flash Player installed and JavaScript enabled in your browser. <strong><a href="http://adobe.com/go/getflashplayer">Get the latest version of Adobe Flash Player</a></strong>';
	//document.write(alternateContent);
	//alert("Lower than 10");
}
