/*
function embedVideo()
{
	if( $('previewvid') )
	{
		var flashvars = {
			file: includesPath + "/flv/video.flv", 
			image: includesPath + "/images/video-example.jpg", 
			autostart:"false",
			controlbar:"none",
			height: "203",
			width: "354",
		}
	
		var params = {
			allowfullscreen:"true", 
			allowscriptaccess:"always"
		}
	
		var attributes = {
			id:"previewvid",  
			name:"player1"
		}
	
		swfobject.embedSWF( includesPath + "/swf/mediaplayer.swf", "previewvid", "354", "203", "9.0.115", false, flashvars, params, attributes);
	
	}
}
*/
window.addEvent('domready', function()
{
	clientNav();
	
	clearSearch();
});

function clearSearch()
{
	if( $('search-box') ){
		$('search-box').addEvent('focus', function(event) {
			if( this.value == 'Search this site' )
			{
				this.value = '';	
			}
		});
		
		$('search-box').addEvent('blur', function(event) {
			if( this.value == '' )
			{
				this.value = 'Search this site';	
			}
		});
	}
}

function clientNav()
{
	if( $('nav-list') )
	{
		var tween = new Fx.Tween('client-inner');
		
		var els = $$('.client-wrapper .item');
		var count = els.length;
		
		for( i=0; i<count; i++ )
		{			
			var width = 370;
			var left = i*width;
			els[i].style.left = left+'px';
			els[i].style.position = 'absolute';
			els[i].style.width = width+'px';
		}
		
		if( count > 0 )
		{
			$('nav-1').addClass('active');	
		}
		
		tween.start('left', 0);
		
		$('client-inner').style.position = 'absolute';
		$('client-inner').style.top = '0px';
		
		$('nav-list').getElements('a').addEvent('click', function(event) {
			event.stop();
			var el = event.target;
			var id = el.id.replace('nav-', '');
			
			$('nav-list').getElements('a').removeClass('active');
			
			el.addClass('active');
			
			var moveAmount = -(id - 1) * width;
			
			tween.start('left', moveAmount);
		});
		
		$('next').addEvent('click', function(event) {
			event.stop();
			
			move( true, width, tween );
		});
		
		$('previous').addEvent('click', function(event) {
			event.stop();
			move( false, width, tween );
		});
			
	}
	
}

function move( isPositive, width, tween )
{
	var active = $('nav-list').getElements('a.active');
	
	if( isPositive )
	{
		var id = parseInt(active[0].id.replace('nav-', '')) + 1;
	}
	else{
		var id = parseInt(active[0].id.replace('nav-', '')) - 1;
	}
	
	if( id < 1 )
	{
		id = 4;
	}
	else if( id > 4 )
	{
		id = 1;
	}
	
	$('nav-list').getElements('a').removeClass('active');
	$('nav-'+id).addClass('active');
	
	var moveAmount = -(id - 1) * width;
	
	tween.start('left', moveAmount);
}