var ids = ["view-faqs-btn", "view-faqs-link", "close_win"];

function fadeLayer(e) { 
	Effect.Fader('faq-container')
}

YAHOO.util.Event.addListener(ids, "click", fadeLayer);


document.observe("dom:loaded", function() {

	suppressInputHints();
	
	flowplayer("player", {src: gasolineProgramVideoPlayer, wmode: "transparent"}, {
		canvas: {
		},
		screen: {
			height:241,
			width:430,
			bottom:0
		},
		plugins:  {
			controls:  {
				url: gasolineProgramVideoPlayerControls,
				backgroundGradient: 'none',
				backgroundColor: 'transparent',
				all:false,
				buttonColor: '#73aa2f',
                buttonOverColor: '#648829',
                play:true,
           		volume:true,
               	mute:true,
                time:true,
                stop:true,
                fullscreen:true,
				scrubber:true
			}
		},
		clip: {
			autoPlay:false,
			onFinish: function() {
				$('endOfMovie').removeClassName('youcantseeme');
				showMovieOverlay();
				document.cookie = 'autoplay = false;';
			}
		}
	});

	if (readCookie('autoplay') == 'false')
	{
		showMovieOverlay();
	}
	else
	{
		flowplayer(0).play();
	}

	Event.observe('replay', 'click', function( event ) {
		event.preventDefault();
		hideMovieOverlay();
        flowplayer(0).play();
    });
	        
});

function readCookie(name)
{
	var cookies = name + "=";
	var ca = document.cookie.split(';');
	for(var i = 0 ; i < ca.length ; i++)
	{
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1,c.length);
		if (c.indexOf(cookies) == 0) return c.substring(cookies.length, c.length);
	}
	return null;
}

function showMovieOverlay()
{
	$('endOfMovie').removeClassName('youcantseeme');
}

function hideMovieOverlay()
{
	$('endOfMovie').addClassName('youcantseeme');
}

// Suppresses input hint boxes and displays the real input 
//   textboxes (or password boxes) if the real input textboxes (or password boxes) 
//   are already populated.  Useful for saved passwords or when the end user
//   hits the back button.
function suppressInputHints() {
	
	suppressInputHint( 'search' );
	
	// The user might already be logged in.  Make sure the login fields exist.
	if ( $( 'gl-username-display' ) != undefined ) {
		suppressInputHint( 'username' );
		suppressInputHint( 'password' );
	}
}

// Suppresses the specified input hint box and displays the real input 
//   textbox (or password box) if the real input textbox (or password box) 
//   is already populated.  Useful for saved passwords or when the end user
//   hits the back button.
function suppressInputHint( element ) {
	if ( $( 'gl-' + element + '-input' ).getValue() != '' ) {
		$('gl-' + element + '-display').hide();
		$('gl-' + element + '-input').show();
	}
}

function swapInputHint( element ) {
	$('gl-' + element + '-display').hide();
	$('gl-' + element + '-input').show();
	$('gl-' + element + '-input').focus();
}