/**
 * Scroll To from Flash 2009
 *
 */

window.addEvent( 'domready', function(){

	aryLenses = getLenses();
	aryLensSceneDirectories = getLensSceneDirectories();
	objSmoothScroll = new SmoothScroll({ duration: 1000 });

	// Start a lens widget
	objLensTints = new LensTints( aryLenses, aryLensSceneDirectories );

	// Attach the lensChange event so we can update the lens puck
	$( 'lens_tint' ).addEvent( 'lensChange', lensChangedHandler );

	// Since the lens puck didnt have a chance to update on
	//	objLensTints.initialize(), we're going to tell it to
	//	change again to the default lens
	objLensTints.defaultLens();

});

function lensChangedHandler( objEvent )
{

	// Create a new image
	objNewPuck	= new Element( "img" );

	// Add the image source
	objNewPuck.setProperty( 'src', '/images/brochure/visionaries/icon_lens_large_' + objLensTints.objLensToUse.strImageName + '.png' );

	// Replace the old element
	$( 'lens_puck' ).replaceWith( objNewPuck );

	// Add the ID of the new element
	objNewPuck.setProperty( 'id', 'lens_puck' );

	// Ugh @ IE detections... but we need to run pngfix() for IE
	aryVersion	= navigator.appVersion.split( "MSIE" );
	intVersion	= parseFloat( aryVersion[1] );
	if( intVersion >= 5.5 )
	{ 
		pngfix();
	}

	// Default lens scenes
	if( objLensTints.objLensToUse.intLensId == 58 )
	{
		objLensTints.strCurrentLensEnvironment	= "golf_green";
		objLensTints.changeScene();
	}

	if( objLensTints.objLensToUse.intLensId == 126 )
	{
		objLensTints.strCurrentLensEnvironment	= "water_ocean";
		objLensTints.changeScene();
	}

	if( objLensTints.objLensToUse.intLensId == 127 )
	{
		objLensTints.strCurrentLensEnvironment	= "water_shallow";
		objLensTints.changeScene();
	}

	if( objLensTints.objLensToUse.intLensId == 140 )
	{
		objLensTints.strCurrentLensEnvironment	= "road_flatland";
		objLensTints.changeScene();
	}

	if( objLensTints.objLensToUse.intLensId == 2 )
	{
		objLensTints.strCurrentLensEnvironment	= "trail_desert";
		objLensTints.changeScene();
	}

	if( objLensTints.objLensToUse.intLensId == 19 )
	{
		objLensTints.strCurrentLensEnvironment	= "water_shallow";
		objLensTints.changeScene();
	}

	if( objLensTints.objLensToUse.intLensId == 65 )
	{
		objLensTints.strCurrentLensEnvironment	= "field";
		objLensTints.changeScene();
	}
	if( objLensTints.objLensToUse.intLensId == 95 )
	{
		objLensTints.strCurrentLensEnvironment	= "snow_half_pipe";
		objLensTints.changeScene();
	}
	
	
}

function scrollToFeatured()
{
	objScroll 	= new Fx.Scroll( window );

	objScroll.toElement( 'featured' );
}

function scrollToPortfolio()
{
	objScroll 	= new Fx.Scroll( window );

	objScroll.toElement( 'portfolio' );
}

