$( document ).ready
( 
	function() 
	{
	  init();
	}
);

var init = function () 
{
	setFiles(); // setFiles() in setFiles.js
	setExpand();
	setFlashPan(); //set up flash panorama viewer if we're on a gallery page...
	
	var directions = document.getElementById("directions");

	if ( directions )
	{
		var inputs = directions.getElementsByTagName("input");
				
		for ( var l = 0; l < inputs.length; l++ )
		{
			if ( inputs[l].id == "button" )
			{
				inputs[l].onclick = function()
				{
					to_y();
				}
			}
		}
	}
}

var setExpand = function ()
{
	var imageHeight;
	var collapseHeight;
	
	if( $.cookie( 'rodSImageExpand' ) == 'false' )
	{	
		$( 'span#expandText' ).text( 'Expand Image' );
		
		$( 'a#expand' ).show()
			.toggle(
				function () 
				{
					$( 'span#expandText' ).text( 'Collapse Image' );
					
					//$.cookie( 'rodSImageExpand', true, { expires: 365, path: '/', domain: 'rodservices.com' } );
					$.cookie( 'rodSImageExpand', true, { expires: 365, path: '/', domain: 'rodservices.systekproof.com' } );
					
					$( 'div#banner' ).animate(
						{
							height: imageHeight + 'px'
						}, 800
					);		
				},
				function () 
				{
					$( 'span#expandText' ).text( 'Expand Image' );
					
					$.cookie( 'rodSImageExpand', false, { expires: 365, path: '/', domain: 'rodservices.systekproof.com' } );
					
					$( 'div#banner' ).animate(
						{
							height: collapseHeight + 'px'
						}, 800
					);
				}
			);
	}
	else
	{	
		$( 'a#expand' ).show()
			.toggle 
			(
				function () 
				{
					$( 'span#expandText' ).text( 'Expand Image' );
					
					$.cookie( 'rodSImageExpand', false, { expires: 365, path: '/', domain: 'rodservices.systekproof.com' } );
					
					$( 'div#banner' ).animate(
						{
							height: collapseHeight + 'px'
						}, 800
					);
				},
				function () 
				{
					$( 'span#expandText' ).text( 'Collapse Image' );
					
					$.cookie( 'rodSImageExpand', true, { expires: 365, path: '/', domain: 'rodservices.systekproof.com' } );
					
					$( 'div#banner' ).animate(
						{
							height: imageHeight + 'px'
						}, 800
					);		
				}
			);
	}
	
	
	window.onload = function () 
	{
		imageHeight = $( '#banner > img' ).height();
		if( imageHeight == null ) // For IE6 only
		{
			imageHeight = $( '#banner > span' ).height();
		}
	
		collapseHeight = $( '#expand' ).height() + 60;
		
		if( $.cookie( 'rodSImageExpand' ) == 'false' )
		{
			$( 'div#banner' ).css(
				{
					height: collapseHeight + 'px'
				}
			);
		}
	}
}