//Global variable for now playing text
var global_nowplaying_text;
var ada_player;

//functionality to swap transcript text and transcript area.  This also swaps between ada and non-ada players.  The player always resets to the first item upon clicking View Transcript or Close Transcript
function viewTranscript(view_text,close_text,locale,base_flash_path,now_playing_text,transcript_height,no_flash_image,no_flash_alt_text){
	var ie7_bottom_height = parseInt(transcript_height) + 150;
	var transcript = $('view_transcripts').getElement('a');
	var tr_container = $('video_transcript_container');
	if(transcript.get('html') == view_text){
		tr_container.setStyle('display', 'block');
		tr_container.setStyle('height', transcript_height + 'px');
		if ( ('bottom') != null ){
			if (Browser.Engine.trident5 == true) {
				$('bottom').setStyle('height', ie7_bottom_height + 'px');
			} else {
				$('bottom').setStyle('height', transcript_height + 'px');
			}
		}
		transcript.set('html', close_text);
		ada_player = true;
		$('video_holder').setStyle('height', '340px');
		$('video_holder').empty();
		$('video_holder').set('html', '<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"480\" height=\"340\" id=\"videoPlayer\">\<param name=\"movie\" value=\"/' + locale + '/flash/pomeVideoPlayer.swf\" />\<param name=\"flashvars\" value=\"xml=' + base_flash_path + 'xml/config_ADA.xml&amp;defaultVideo=0\" />\<param name=\"wmode\" value=\"transparent\" />\<param name=\"allowfullscreen\" value=\"true\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"/' + locale + '/flash/pomeVideoPlayer.swf\" width=\"480\" height=\"340\"><param name=\"flashvars\" value=\"xml=' + base_flash_path + 'xml/config_ADA.xml&amp;defaultVideo=0\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowfullscreen\" value=\"true\" /><!--<![endif]--><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"' + no_flash_image + '\" alt=\"' + no_flash_alt_text + '\" /></a><!--[if !IE]>--></object><!--<![endif]--></object>');
		/*$('video_transcript_container').setStyle('height', transcript_height + 'px');
		$('bottom').setStyle('height', transcript_height + 'px');*/
	}
	else{
		tr_container.setStyle('display', 'none');
		transcript.set('html', view_text);
		ada_player = false;
		$('video_holder').setStyle('height', '310px');
		$('video_holder').empty();
		$('video_holder').set('html', '<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"480\" height=\"310\" id=\"videoPlayer\">\<param name=\"movie\" value=\"/' + locale + '/flash/pomeVideoPlayer.swf\" />\<param name=\"flashvars\" value=\"xml=' + base_flash_path + 'xml/config_nonADA.xml&amp;defaultVideo=0\" />\<param name=\"wmode\" value=\"transparent\" /><param name=\"allowfullscreen\" value=\"true\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"/' + locale + '/flash/pomeVideoPlayer.swf\" width=\"480\" height=\"310\"><param name=\"flashvars\" value=\"xml=' + base_flash_path + 'xml/config_nonADA.xml&amp;defaultVideo=0\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowfullscreen\" value=\"true\" /><!--<![endif]--><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"' + no_flash_image + '\" alt=\"' + no_flash_alt_text + '\" /></a><!--[if !IE]>--></object><!--<![endif]--></object>');
		$('video_transcript_container').setStyle('height', '423px');
		$('bottom').setStyle('height', '423px');
	}
	removeNowPlaying();
	var first_lc_li = $('video_area_lc').getElement('li');
	var first_now_playing_span = first_lc_li.getElement('span');
	first_lc_li.addClass('current_vid');
	first_now_playing_span.set('html', '&nbsp;<strong>' + now_playing_text + '</strong>');
}

function videoView(video_number,locale,now_playing_text,base_flash_path,no_flash_image,no_flash_alt_text) {
	//Functionality to swap in and out videos
	//Check to see if ada player or non-ada player should be loaded
	if (ada_player == true){
		$('video_holder').empty();
		$('video_holder').set('html', '<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"480\" height=\"340\" id=\"videoPlayer\">\<param name=\"movie\" value=\"/' + locale + '/flash/pomeVideoPlayer.swf\" />\<param name=\"flashvars\" value=\"xml='  + base_flash_path + 'xml/config_ADA.xml&amp;defaultVideo=' + video_number + '\" />\<param name=\"wmode\" value=\"transparent\" /><param name=\"allowfullscreen\" value=\"true\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"/' + locale + '/flash/pomeVideoPlayer.swf\" width=\"480\" height=\"340\"><param name=\"flashvars\" value=\"xml=' + base_flash_path + 'xml/config_ADA.xml&amp;defaultVideo=' + video_number + '\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowfullscreen\" value=\"true\" /><!--<![endif]--><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"' + no_flash_image + '\" alt=\"' + no_flash_alt_text + '\" /></a><!--[if !IE]>--></object><!--<![endif]--></object>');
	}
	else {
		$('video_holder').empty();
		$('video_holder').set('html', '<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"480\" height=\"310\" id=\"videoPlayer\">\<param name=\"movie\" value=\"/' + locale + '/flash/pomeVideoPlayer.swf\" />\<param name=\"flashvars\" value=\"xml='  + base_flash_path + 'xml/config_nonADA.xml&amp;defaultVideo=' + video_number + '\" />\<param name=\"wmode\" value=\"transparent\" /><param name=\"allowfullscreen\" value=\"true\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"/' + locale + '/flash/pomeVideoPlayer.swf\" width=\"480\" height=\"310\"><param name=\"flashvars\" value=\"xml=' + base_flash_path + 'xml/config_nonADA.xml&amp;defaultVideo=' + video_number + '\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"allowfullscreen\" value=\"true\" /><!--<![endif]--><a href=\"http://www.adobe.com/go/getflashplayer\"><img src=\"' + no_flash_image + '\" alt=\"' + no_flash_alt_text + '\" /></a><!--[if !IE]>--></object><!--<![endif]--></object>');
	}
	removeNowPlaying();
	global_nowplaying_text = now_playing_text;
}

//functionality to swap now playing text and styles
function removeNowPlaying(){
	//remove now playing style and empty out each span with now playing
	$('video_area_lc').getElements('li').each(function(el){
		el.removeClass('current_vid');
	});
	$('video_area_lc').getElements('span').each(function(el){
		el.empty();
	});
}

window.addEvent('load', function() {
//add now playing text and style
	var lc_links = $('video_area_lc').getElements('a').each(function(el){
		el.addEvent('click', function(){
			var parent_li = el.getParent();
			var now_playing_span = parent_li.getElement('span');
			parent_li.addClass('current_vid');
			now_playing_span.set('html', '&nbsp;<strong>' + global_nowplaying_text + '</strong>');
		});
	});
});