function change_video(id)
	{
	
		if(!Browser.Engine.trident) 
		{
		toggle_loading(1);
		}
		
	update_url(stripslashes(work[id]['title']));
	document.getElementById('main').style.height = '392px';
	
	fade_out_thumb(id);

	var params = 'id='+id;

	var req = new Request.HTML({
		method: 'get',
		url: 'system/components/content/video-player.php',
		update: $('main'), 
		onComplete: function(){
		
		//setting title again to clean up after IE
		setTimeout(function(){confirm_title()},1000);
		
			if(!Browser.Engine.trident) 
			{
			toggle_loading(0);
			}
		
		}
	}).send(params);

	
	return false;
	}
	
	
function get_more_info()
	{


		if( (info['animating'] == false) )
		{
		update_status('animating', true);

		var div = document.getElementById('get-more-info');
		var div_container = document.getElementById('main');
	
	
	
			if(div.innerHTML == 'Less Info')
			{
//			var end_height = '392px';
//			226px
			var end_height = (get_height('player') + 35)+'px';
			
			slide_thumbs('263px', '39px');
			slide_info(end_height);
			div.innerHTML = 'Get More Info';
	
			} else {
			
				if(document.getElementById('video-description'))
				{
				var end_height = 400 + get_height('video-description');
				
				slide_thumbs('0px', '9px');
				slide_info(end_height);
				} else {
				
				
				var end_height = get_height('player')+get_height('main-content');
//				alert(end_height);
//				resize_main();
				slide_info(end_height);
				}
			
			div.innerHTML = 'Less Info';
			}
	
	
	
		return false;
		}
		
	}
	
	
	

current_page = 0;

function go_to_page(p, total, width)
	{
	
		if( (info['animating'] == false) )
		{
		update_status('animating', true);
		
			if(p == 'prev')
			{
			(current_page > 0) ? p=current_page-1 : p=0;
			} else if(p == 'next') {
			(current_page >= (total - 1)) ? p=current_page : p=current_page+1;
			}
		
		var n = 0;
		var offset = 0;
		var left = 0;
	
		load_thumbs(p);
		
			while(n < total)
			{
			var div = document.getElementById('thumbs'+n);
			
				if(n == p)
				{
				document.getElementById('page'+n).innerHTML = '<span class="selected">'+(n+1)+'</span>';
				} else {
				document.getElementById('page'+n).innerHTML = '<span>'+(n+1)+'</span>';
				}
			
			
				if(n < p)
				{
				offset = p - n;
				left = -(offset * width);
				} else {
				offset = n - p;
				left = offset * width;
				} 
	
	
			var fxStart = new Fx.Tween(div.id, {duration:500});
			fxStart.start('left', div.style.left, left+'px').chain(function() {
		
				update_status('animating', false);
		
				});

	
	//		div.style.left = left+'px';
			n++;
			}
		
		
		current_page = p;	
		return false;
		}
		
	}
	
	
	
	
	
	
	function loadVideo(image, flv, id)
	{
	var width = 640;
	var height = 360;

	var s1 = new SWFObject("system/swf/player.swf","ply",width,height,"8","#000000");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("flashvars","file="+flv+"&image="+image+"&controlbar=over&skin=system/swf/schoon.swf&fullscreen=true&shownavigation=false");
	s1.write(id);
	}
	
	
	
	
	
	

	
function slide_thumbs(end_height, pagination_end_height)
	{
	
		if(document.getElementById('thumbs-wrapper'))
		{
		var div = document.getElementById('thumbs-wrapper');
	
		var height;
		(div.style.height) ? height=div.style.height : height='226px';
	
		
		var fxStart = new Fx.Tween(div.id, {duration:500});
		fxStart.start('height', height, end_height);
		}


		if(document.getElementById('footer-top-pagination'))
		{
		var div_pagination = document.getElementById('footer-top-pagination');
	
		var pagination_height;
		(div_pagination.style.height) ? pagination_height=div_pagination.style.height : pagination_height='39px';

	
		var fxPagination = new Fx.Tween(div_pagination.id, {duration:500});
		fxPagination.start('height', pagination_height, pagination_end_height);
		}

//	div_pagination.style.height = pagination_end_height;	
	}
	
	
	
	
	
	
	
	
function slide_info(end_height)
	{
	
		if(end_height == 'auto')
		{
		end_height = 400 + get_height('video-description');
		}
	
	
	var div = document.getElementById('main');

	var height;
//	(div.style.height) ? height=div.style.height : height='392px';
	(div.style.height) ? height=div.style.height : height='400px';
	
	var fxStart = new Fx.Tween(div.id, {duration:500});
	fxStart.start('height', height, end_height).chain(function() {
			
			update_status('animating', false);

			});

	}
	
	
	
function show_thumb(id)
	{
	var div = document.getElementById(id);
	
	var fxStart = new Fx.Tween(div.id, {duration:1000});
	fxStart.set('opacity', '0');
	fxStart.set('visibility', 'visible');
	fxStart.start('opacity', '0', '1');
	}
	
	
function load_thumbs(page)
	{

		
		for ( keyVar in thumbs ) 
		{
			
			if(thumbs[keyVar]['id'])
			{
			var id = thumbs[keyVar]['id'];
			var thumb = thumbs[keyVar]['thumb'];
			var title = thumbs[keyVar]['title'];
			
			
				if( document.getElementById('thumb-'+page+'-'+id) )
				{
					if(!document.getElementById('thumb-'+page+'-'+id).innerHTML.length)
					{
					document.getElementById('thumb-'+page+'-'+id).innerHTML = '<img id="image-'+page+'-'+id+'" onload="show_thumb(\'image-'+page+'-'+id+'\')" style="visibility: hidden;" src="'+thumb+'" alt="'+title+'" width="156" height="88" />';
					}
				}
			
			}
			
		}
	
	}
	
	
	
	
	
	
	
function fade_out_thumb(id)
	{
	
		for ( keyVar in thumbs ) 
		{
			
			if(thumbs[keyVar]['id'])
			{
			var this_id = thumbs[keyVar]['id'];
			var thumb = thumbs[keyVar]['thumb'];
			var title = thumbs[keyVar]['title'];

				if(document.getElementById('thumb'+this_id))
				{
				var div = document.getElementById('thumb'+this_id);
	
				var opacity_end;
				(id == this_id) ? opacity_end=.5 : opacity_end=1;
				
				var opacity_start;
				(div.style.opacity) ? opacity_start=div.style.opacity : opacity_start=1;
	
					if((div.style.opacity && (div.style.opacity !== 1)) || (id == this_id))
					{			
					var fxStart = new Fx.Tween(div.id, {duration:1000});
					fxStart.start('opacity', opacity_start, opacity_end);
					}
				}
			
			}
			
		}
	
	}
	
	
	
	
	
function clear_player()
	{

		if(document.getElementById('flash-player'))
		{
		var div = document.getElementById('flash-player');
		div.innerHTML = '&nbsp;';
	 	}
	
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	